-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses Indicator Window in Timeseries Examples
- Loading branch information
1 parent
6fe917c
commit b310bc4
Showing
7 changed files
with
173 additions
and
307 deletions.
There are no files selected for viewing
120 changes: 0 additions & 120 deletions
120
...ch Environment/06 Indicators/02 Data Point Indicators/04 Create Indicator Timeseries.html
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
...rch Environment/06 Indicators/02 Data Point Indicators/04 Create Indicator Timeseries.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<p>You need to <a href="/docs/v2/research-environment/indicators/data-point-indicators#03-Create-Subscriptions">subscribe to some market data</a> and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period 2-standard-deviation <code>BollingerBands</code> indicator.</p> | ||
<div class="section-example-container"> | ||
<pre class="csharp">var bb = new BollingerBands(20, 2);</pre> | ||
<pre class="python">bb = BollingerBands(20, 2)</pre> | ||
</div> | ||
|
||
<? | ||
$variableName='bb'; | ||
$pythonImage='<img class="python docs-image" src="https://cdn.quantconnect.com/i/tu/indicator-datapoint-py-helper-bb.png" alt="Historical bollinger band data">'; | ||
|
||
$setWindowSizeExampleContainer=' | ||
<div class="section-example-container"> | ||
<pre class="csharp">// 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;</pre> | ||
<pre class="python"># 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</pre> | ||
</div>'; | ||
|
||
$dataDisplayStep = ' | ||
<li class="csharp">Display the data.</li> | ||
<div class="csharp section-example-container"> | ||
<pre class="csharp">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}"); | ||
}</pre> | ||
</div> | ||
<img class="csharp docs-image" src="https://cdn.quantconnect.com/i/tu/indicator-datapoint-cs-classic-bb.png" alt="Historical bollinger band data"> | ||
<li class="python">Populate a <code>DataFrame</code> with the data in the <code>Indicator</code> object.</li> | ||
<div class="python section-example-container"> | ||
<pre class="python">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()</pre> | ||
</div> | ||
<img class="python docs-image" src="https://cdn.quantconnect.com/i/tu/indicator-datapoint-py-classic-bb.png" alt="Historical bollinger band data"'; | ||
include(DOCS_RESOURCES."/indicators/create-indicator-timeseries.php"); | ||
?> |
96 changes: 0 additions & 96 deletions
96
04 Research Environment/06 Indicators/03 Bar Indicators/04 Create Indicator Timeseries.html
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
04 Research Environment/06 Indicators/03 Bar Indicators/04 Create Indicator Timeseries.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<p>You need to <a href="/docs/v2/research-environment/indicators/bar-indicators#03-Create-Subscriptions">subscribe to some market data</a> and create an indicator in order to calculate a timeseries of indicator values. In this example, use a 20-period <code>AverageTrueRange</code> indicator.</p> | ||
<div class="section-example-container"> | ||
<pre class="csharp">var atr = new AverageTrueRange(20);</pre> | ||
<pre class="python">atr = AverageTrueRange(20)</pre> | ||
</div> | ||
|
||
<? | ||
$variableName='atr'; | ||
$pythonImage='<img class="python docs-image" src="https://cdn.quantconnect.com/i/tu/indicator-bar-py-helper-atr.png" alt="Historical average true range data">'; | ||
|
||
$setWindowSizeExampleContainer=' | ||
<div class="section-example-container"> | ||
<pre class="csharp">// Set the window.size to the desired timeseries length | ||
atr.Window.Size = 50; | ||
atr.TrueRange.Window.Size = 50;</pre> | ||
<pre class="python"># Set the window.size to the desired timeseries length | ||
atr.window.size = 50 | ||
atr.true_range.window.size = 50</pre> | ||
</div>'; | ||
|
||
$dataDisplayStep = ' | ||
<li class="csharp">Display the data.</li> | ||
<div class="csharp section-example-container"> | ||
<pre class="csharp">foreach (var i in Enumerable.Range(0, 5).Reverse()) | ||
{ | ||
Console.WriteLine($"{atr[i].EndTime:yyyyMMdd} {atr[i].Value:f4} {atr.TrueRange[i].Value:f4}"); | ||
}</pre> | ||
</div> | ||
<img class="csharp docs-image" src="https://cdn.quantconnect.com/i/tu/indicator-bar-cs-classic-atr.png" alt="Historical average true range data"> | ||
<li class="python">Populate a <code>DataFrame</code> with the data in the <code>Indicator</code> object.</li> | ||
<div class="python section-example-container"> | ||
<pre class="python">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()</pre> | ||
</div> | ||
<img class="python docs-image" src="https://cdn.quantconnect.com/i/tu/indicator-bar-py-classic-atr.png" alt="Historical average true range data">'; | ||
include(DOCS_RESOURCES."/indicators/create-indicator-timeseries.php"); | ||
?> |
Oops, something went wrong.