diff --git a/04 Research Environment/06 Indicators/02 Data Point Indicators/04 Create Indicator Timeseries.html b/04 Research Environment/06 Indicators/02 Data Point Indicators/04 Create Indicator Timeseries.html deleted file mode 100644 index a7df26787e..0000000000 --- a/04 Research Environment/06 Indicators/02 Data Point Indicators/04 Create Indicator Timeseries.html +++ /dev/null @@ -1,120 +0,0 @@ -
You need to subscribe to some market data and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period 2-standard-deviation BollingerBands
indicator.
var bb = new BollingerBands(20, 2);-
bb = BollingerBands(20, 2)-
You can create the indicator timeseries with the Indicator
helper method or you can manually create the timeseries.
To create an indicator timeseries with the helper method, call the Indicator
method.
// Create a dataframe with a date index, and columns are indicator values. -var bbIndicator = qb.Indicator(bb, symbol, 50, Resolution.Daily);-
# Create a dataframe with a date index, and columns are indicator values. -bb_dataframe = qb.indicator(bb, symbol, 50, Resolution.DAILY)-
Follow these steps to manually create the indicator timeseries:
- -// Request historical trading data with the daily resolution. -var history = qb.History(symbol, 70, Resolution.Daily);-
# Request historical trading data with the daily resolution. -history = qb.history[TradeBar](symbol, 70, Resolution.DAILY)-
RollingWindow
for each attribute of the indicator to hold their values.// Create a window dictionary to store RollingWindow objects. -var window = new Dictionary<string, RollingWindow<decimal>>(); -// Store the RollingWindow objects, index by key is the property of the indicator. -var time = new RollingWindow<DateTime>(50); -window["bollingerbands"] = new RollingWindow<decimal>(50); -window["lowerband"] = new RollingWindow<decimal>(50); -window["middleband"] = new RollingWindow<decimal>(50); -window["upperband"] = new RollingWindow<decimal>(50); -window["bandwidth"] = new RollingWindow<decimal>(50); -window["percentb"] = new RollingWindow<decimal>(50); -window["standarddeviation"] = new RollingWindow<decimal>(50); -window["price"] = new RollingWindow<decimal>(50); --
# Create a window dictionary to store RollingWindow objects. -window = {} -# Store the RollingWindow objects, index by key is the property of the indicator. -window['time'] = RollingWindow[DateTime](50) -window["bollingerbands"] = RollingWindow[float](50) -window["lowerband"] = RollingWindow[float](50) -window["middleband"] = RollingWindow[float](50) -window["upperband"] = RollingWindow[float](50) -window["bandwidth"] = RollingWindow[float](50) -window["percentb"] = RollingWindow[float](50) -window["standarddeviation"] = RollingWindow[float](50) -window["price"] = RollingWindow[float](50) --
RollingWindow
objects.// Define an update function to add the indicator values to the RollingWindow object. -bb.Updated += (sender, updated) => -{ - var indicator = (BollingerBands)sender; - time.Add(updated.EndTime); - window["bollingerbands"].Add(updated); - window["lowerband"].Add(indicator.LowerBand); - window["middleband"].Add(indicator.MiddleBand); - window["upperband"].Add(indicator.UpperBand); - window["bandwidth"].Add(indicator.BandWidth); - window["percentb"].Add(indicator.PercentB); - window["standarddeviation"].Add(indicator.StandardDeviation); - window["price"].Add(indicator.Price); -};-
# Define an update function to add the indicator values to the RollingWindow object. -def update_bollinger_band_window(sender: object, updated: IndicatorDataPoint) -> None: - indicator = sender - window['time'].add(updated.end_time) - window["bollingerbands"].add(updated.value) - window["lowerband"].add(indicator.lower_band.current.value) - window["middleband"].add(indicator.middle_band.current.value) - window["upperband"].add(indicator.upper_band.current.value) - window["bandwidth"].add(indicator.band_width.current.value) - window["percentb"].add(indicator.percent_b.current.value) - window["standarddeviation"].add(indicator.standard_deviation.current.value) - window["price"].add(indicator.price.current.value) - -bb.updated += UpdateBollingerBandWindow-
When the indicator receives new data, the preceding handler method adds the new IndicatorDataPoint
values into the respective RollingWindow
.
foreach(var bar in history) -{ - bb.Update(bar.EndTime, bar.Close); -}-
for bar in history: - bb.update(bar.end_time, bar.close)-
Console.WriteLine($"time,{string.Join(',', window.Select(kvp => kvp.Key))}"); -foreach (var i in Enumerable.Range(0, 5).Reverse()) -{ - var data = string.Join(", ", window.Select(kvp => Math.Round(kvp.Value[i],6))); - Console.WriteLine($"{time[i]:yyyyMMdd}, {data}"); -}-
DataFrame
with the data in the RollingWindow
objects.bb_dataframe = pd.DataFrame(window).set_index('time')-
You need to subscribe to some market data and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period 2-standard-deviation BollingerBands
indicator.
var bb = new BollingerBands(20, 2);+
bb = BollingerBands(20, 2)+
// Set the window.size to the desired timeseries length +bb.Window.Size=50; +bb.LowerBand.Window.Size=50; +bb.MiddleBand.Window.Size=50; +bb.UpperBand.Window.Size=50; +bb.BandWidth.Window.Size=50; +bb.PercentB.Window.Size=50; +bb.StandardDeviation.Window.Size=50; +bb.Price.Window.Size=50;+
# Set the window.size to the desired timeseries length +bb.window.size=50 +bb.lower_band.window.size=50 +bb.middle_band.window.size=50 +bb.upper_band.window.size=50 +bb.band_width.window.size=50 +bb.percent_b.window.size=50 +bb.standard_deviation.window.size=50 +bb.price.window.size=50+
foreach (var i in Enumerable.Range(0, 5).Reverse()) +{ + Console.WriteLine($"{bb[i].EndTime:yyyyMMdd} {bb[i].Value:f4} {bb.LowerBand[i].Value:f4} {bb.MiddleBand[i].Value:f4} {bb.UpperBand[i].Value:f4} {bb.BandWidth[i].Value:f4} {bb.PercentB[i].Value:f4} {bb.StandardDeviation[i].Value:f4} {bb.Price[i].Value:f4}"); +}+
DataFrame
with the data in the Indicator
object.bb_dataframe = pd.DataFrame({ + "current": pd.Series({x.end_time: x.value for x in bb}), + "lower_band": pd.Series({x.end_time: x.value for x in bb.lower_band}), + "middle_band": pd.Series({x.end_time: x.value for x in bb.middle_band}), + "upper_band": pd.Series({x.end_time: x.value for x in bb.upper_band}), + "band_width": pd.Series({x.end_time: x.value for x in bb.band_width}), + "percent_b": pd.Series({x.end_time: x.value for x in bb.percent_b}), + "standard_deviation": pd.Series({x.end_time: x.value for x in bb.standard_deviation}), + "price": pd.Series({x.end_time: x.value for x in bb.price}) +}).sort_index()+
You need to subscribe to some market data and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period AverageTrueRange
indicator.
var atr = new AverageTrueRange(20);-
atr = AverageTrueRange(20)-
You can create the indicator timeseries with the Indicator
helper method or you can manually create the timeseries.
To create an indicator timeseries with the helper method, call the Indicator
method.
// Create a dataframe with a date index, and columns are ATR indicator values. -var atrIndicator = qb.Indicator(atr, symbol, 50, Resolution.Daily);-
# Create a dataframe with a date index, and columns are ATR indicator values. -atr_dataframe = qb.indicator(atr, symbol, 50, Resolution.DAILY)-
Follow these steps to manually create the indicator timeseries:
- -// Request historical trading data with the daily resolution. -var history = qb.History(symbol, 70, Resolution.Daily);-
# Request historical trading data with the daily resolution. -history = qb.history[TradeBar](symbol, 70, Resolution.DAILY)-
RollingWindow
for each attribute of the indicator to hold their values.// Create a window dictionary to store RollingWindow objects. -var window = new Dictionary<string, RollingWindow<decimal>>(); -// Store the RollingWindow objects, index by key is the property of the indicator. -var time = new RollingWindow<DateTime>(50); -window["averagetruerange"] = new RollingWindow<decimal>(50); -window["truerange"] = new RollingWindow<decimal>(50); --
# Create a window dictionary to store RollingWindow objects. -window = {} -# Store the RollingWindow objects, index by key is the property of the indicator. -window['time'] = RollingWindow[DateTime](50) -window['averagetruerange'] = RollingWindow[float](50) -window["truerange"] = RollingWindow[float](50) --
RollingWindow
objects.// Define an update function to add the indicator values to the RollingWindow object. -atr.Updated += (sender, updated) => -{ - var indicator = (AverageTrueRange)sender; - time.Add(updated.EndTime); - window["averagetruerange"].Add(updated); - window["truerange"].Add(indicator.TrueRange); -};-
# Define an update function to add the indicator values to the RollingWindow object. -def update_average_true_range_window(sender: object, updated: IndicatorDataPoint) -> None: - indicator = sender - window['time'].add(updated.end_time) - window["averagetruerange"].add(updated.value) - window["truerange"].add(indicator.true_range.current.value) - -atr.updated += UpdateAverageTrueRangeWindow-
When the indicator receives new data, the preceding handler method adds the new IndicatorDataPoint
values into the respective RollingWindow
.
foreach(var bar in history){ - // Update the indicators with the whole bar. - atr.Update(bar); -}-
for bar in history: - atr.update(bar)-
Console.WriteLine($"time,{string.Join(',', window.Select(kvp => kvp.Key))}"); -foreach (var i in Enumerable.Range(0, 5).Reverse()) -{ - var data = string.Join(", ", window.Select(kvp => Math.Round(kvp.Value[i],6))); - Console.WriteLine($"{time[i]:yyyyMMdd}, {data}"); -}-
DataFrame
with the data in the RollingWindow
objects.atr_dataframe = pd.DataFrame(window).set_index('time')-
You need to subscribe to some market data and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period AverageTrueRange
indicator.
var atr = new AverageTrueRange(20);+
atr = AverageTrueRange(20)+
// Set the window.size to the desired timeseries length +atr.Window.Size = 50; +atr.TrueRange.Window.Size = 50;+
# Set the window.size to the desired timeseries length +atr.window.size = 50 +atr.true_range.window.size = 50+
foreach (var i in Enumerable.Range(0, 5).Reverse()) +{ + Console.WriteLine($"{atr[i].EndTime:yyyyMMdd} {atr[i].Value:f4} {atr.TrueRange[i].Value:f4}"); +}+
DataFrame
with the data in the Indicator
object.atr_dataframe = pd.DataFrame({ + "current": pd.Series({x.end_time: x.value for x in atr}), + "truerange": pd.Series({x.end_time: x.value for x in atr.true_range}) +}).sort_index()+
You need to subscribe to some market data and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period VolumeWeightedAveragePriceIndicator
indicator.
var vwap = new VolumeWeightedAveragePriceIndicator(20);-
vwap = VolumeWeightedAveragePriceIndicator(20)-
You can create the indicator timeseries with the Indicator
helper method or you can manually create the timeseries.
To create an indicator timeseries with the helper method, call the Indicator
method.
// Create a dataframe with a date index, and columns are indicator values. -var vwapIndicator = qb.Indicator(vwap, symbol, 50, Resolution.Daily);-
# Create a dataframe with a date index, and columns are indicator values. -vwap_dataframe = qb.indicator(vwap, symbol, 50, Resolution.DAILY)-
Follow these steps to create an indicator timeseries:
- -// Request historical trading data with the daily resolution. -var history = qb.History(symbol, 70, Resolution.Daily);-
# Request historical trading data with the daily resolution. -history = qb.history[TradeBar](symbol, 70, Resolution.DAILY)-
RollingWindow
for each attribute of the indicator to hold their values.// Create a window dictionary to store RollingWindow objects. -var window = new Dictionary<string, RollingWindow<decimal>>(); -// Store the RollingWindow objects, index by key is the property of the indicator. -var time = new RollingWindow<DateTime>(50); -window["volumeweightedaveragepriceindicator"] = new RollingWindow<decimal>(50); --
# Create a window dictionary to store RollingWindow objects. -window = {} -# Store the RollingWindow objects, index by key is the property of the indicator. -window['time'] = RollingWindow[DateTime](50) -window['volumeweightedaveragepriceindicator'] = RollingWindow[float](50) --
RollingWindow
objects.// Define an update function to add the indicator values to the RollingWindow object. -vwap.Updated += (sender, updated) => -{ - time.Add(updated.EndTime); - window["volumeweightedaveragepriceindicator"].Add(updated); -};-
# Define an update function to add the indicator values to the RollingWindow object. -def update_vwap_window(sender: object, updated: IndicatorDataPoint) -> None: - window['time'].add(updated.end_time) - window["volumeweightedaveragepriceindicator"].add(updated.value) - -vwap.updated += UpdateVWAPWindow-
When the indicator receives new data, the preceding handler method adds the new IndicatorDataPoint
values into the respective RollingWindow
.
foreach(var bar in history){ - // Update the indicators with the whole TradeBar. - vwap.Update(bar); -}-
for bar in history: - vwap.update(bar)-
Console.WriteLine($"time,{string.Join(',', window.Select(kvp => kvp.Key))}"); -foreach (var i in Enumerable.Range(0, 5).Reverse()) -{ - var data = string.Join(", ", window.Select(kvp => Math.Round(kvp.Value[i],6))); - Console.WriteLine($"{time[i]:yyyyMMdd}, {data}"); -}-
DataFrame
with the data in the RollingWindow
objects.vwap_dataframe = pd.DataFrame(window).set_index('time')-
You need to subscribe to some market data and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period VolumeWeightedAveragePriceIndicator
indicator.
var vwap = new VolumeWeightedAveragePriceIndicator(20);+
vwap = VolumeWeightedAveragePriceIndicator(20)+
// Set the window.size to the desired timeseries length +vwap.Window.Size = 50;+
# Set the window.size to the desired timeseries length +vwap.window.size = 50+
foreach (var i in Enumerable.Range(0, 5).Reverse()) +{ + Console.WriteLine($"{vwap[i].EndTime:yyyyMMdd} {vwap[i].Value:f4}"); +}+
DataFrame
with the data in the Indicator
object.vwap_dataframe = pd.DataFrame({ + "current": pd.Series({x.end_time: x.value for x in vwap})) +}).sort_index()+
You can create the indicator timeseries with the Indicator
helper method or you can manually create the timeseries.
To create an indicator timeseries with the helper method, call the Indicator
method.
// Create a dataframe with a date index, and columns are indicator values. +var =$variableName?>Indicator = qb.Indicator(=$variableName?>, symbol, 50, Resolution.Daily);+
# Create a dataframe with a date index, and columns are indicator values. +=$variableName?>_dataframe = qb.indicator(=$variableName?>, symbol, 50, Resolution.DAILY)+
Follow these steps to manually create the indicator timeseries:
+ +// Request historical trading data with the daily resolution. +var history = qb.History(symbol, 70, Resolution.Daily);+
# Request historical trading data with the daily resolution. +history = qb.history[TradeBar](symbol, 70, Resolution.DAILY)+
Window.Size
window.size
for each attribute of the indicator to hold their values.foreach (var bar in history) +{ + =$variableName?>.Update(=strcmp($variableName, 'bb') !== 0 ? "bar": "bar.EndTime, bar.Close" ?>); +}+
for bar in history: + =$variableName?>.update(=strcmp($variableName, 'bb') !== 0 ? "bar" : "bar.end_time, bar.close"?>)+