Skip to content

Commit

Permalink
Inline PEP8: Handling Data > TradeBar | QuoteBar | Tick
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCatarino committed Apr 23, 2024
1 parent fe37e04 commit aa29842
Show file tree
Hide file tree
Showing 44 changed files with 82 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<? include(DOCS_RESOURCES."/datasets/data-normalization.php"); ?>

<p>To set the data normalization mode for a security, pass a <code>dataNormalizationMode</code> argument to the <code class="csharp">AddEquity</code><code class="python">add_equity</code> method.</p>
<p>To set the data normalization mode for a security, pass a <code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code> argument to the <code class="csharp">AddEquity</code><code class="python">add_equity</code> method.</p>

<div class="section-example-container">
<pre class="csharp">_symbol = AddEquity("SPY", dataNormalizationMode: DataNormalizationMode.Raw).Symbol;</pre>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tradebar.php");
?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/quotebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tick.php");
?>

<p>If <a href='/docs/v2/cloud-platform/datasets/quantconnect/us-equities#05-Suspicious-Ticks'>we detect a tick that may be suspicious</a>, we set its <code>Suspicious</code> flag to true.</p>
<p>If <a href='/docs/v2/cloud-platform/datasets/quantconnect/us-equities#05-Suspicious-Ticks'>we detect a tick that may be suspicious</a>, we set its <code class="csharp">Suspicious</code><code class="python">suspicious</code> flag to true.</p>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<? include(DOCS_RESOURCES."/datasets/data-normalization.php"); ?>

<p>To set the data normalization mode for a security, pass a <code>dataNormalizationMode</code> argument to the <code class="csharp">AddEquity</code><code class="python">add_equity</code> method..</p>
<p>To set the data normalization mode for a security, pass a <code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code> argument to the <code class="csharp">AddEquity</code><code class="python">add_equity</code> method..</p>

<div class="section-example-container">
<pre class="csharp">_symbol = AddEquity("YESBANK", market: Market.India, dataNormalizationMode: DataNormalizationMode.Raw).Symbol;</pre>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tradebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "contract";
$pythonVariable = "self.contract_symbol";
$cSharpVariable = "_contractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "contract";
$pythonVariable = "self.contract_symbol";
$cSharpVariable = "_contractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tradebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/quotebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tick.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tradebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/quotebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "security";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tick.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "Forex pair";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/quotebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "Forex pair";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tick.php");
?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "contract";
$pythonVariable = "self.contract_symbol";
$cSharpVariable = "_contractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "contract";
$pythonVariable = "self.contract_symbol";
$cSharpVariable = "_contractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "contract";
$pythonVariable = "self.contract_symbol";
$cSharpVariable = "_contractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "Option contract";
$pythonVariable = "self.option_contract_symbol";
$cSharpVariable = "_optionContractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "Option contract";
$pythonVariable = "self.option_contract_symbol";
$cSharpVariable = "_optionContractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p><code>Tick</code> objects represent a price for the Index at a moment in time. <code>Tick</code> objects have the following properties:</p>
<div data-tree='QuantConnect.Data.Market.Tick'></div>

<p>Index ticks have a non-zero value for the <code>Price</code> property, but they have a zero value for the <code>BidPrice</code>, <code>BidSize</code>, <code>AskPrice</code>, and <code>AskSize</code> properties.</p>
<p>Index ticks have a non-zero value for the <code class="csharp">Price</code><code class="python">price</code> property, but they have a zero value for the <code class="csharp">BidPrice</code><code class="python">bid_price</code>, <code class="csharp">BidSize</code><code class="python">bid_size</code>, <code class="csharp">AskPrice</code><code class="python">ask_price</code>, and <code class="csharp">AskSize</code><code class="python">ask_size</code> properties.</p>

<p>In backtests, LEAN groups ticks into one millisecond buckets. In live trading, LEAN groups ticks into ~70-millisecond buckets. To get the <code>Tick</code> objects in the <code>Slice</code>, index the <code>Ticks</code> property of the <code>Slice</code> with a <code>Symbol</code>. The <code>Slice</code> may not contain data for your <code>Symbol</code> at every time step. To avoid issues, check if the <code>Slice</code> contains data for your Index before you index the <code>Slice</code> with the Index <code>Symbol</code>.</p>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "contract";
$pythonVariable = "self.contract_symbol";
$cSharpVariable = "_contractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?
$securityName = "contract";
$pythonVariable = "self.contract_symbol";
$cSharpVariable = "_contractSymbol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "CFD";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/quotebar.php");
?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?
$securityName = "CFD";
$pythonVariable = "self.symbol";
$pythonVariable = "self._symbol";
$cSharpVariable = "_symbol";
include(DOCS_RESOURCES."/securities/tick.php");
?>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<h4>Futures</h4>
<p>In the case of Futures, the data normalization mode affects how historical data of two contracts is stitched together to form the <a href='/docs/v2/writing-algorithms/universes/futures#12-Continous-Contracts'>continuous contract</a>. To view all the available options, see <a href='/docs/v2/writing-algorithms/securities/asset-classes/futures/requesting-data#09-Data-Normalization'>Data Normalization</a>. The default value is <code>DataNormalizationMode.Adjusted</code>. To change the data normalization mode, in the <a href='/docs/v2/writing-algorithms/initialization'>Initialize</a> method, pass a <code>dataNormalizationMode</code> argument to the <code class="csharp">AddFuture</code><code class="python">add_future</code> method.</p>
<p>In the case of Futures, the data normalization mode affects how historical data of two contracts is stitched together to form the <a href='/docs/v2/writing-algorithms/universes/futures#12-Continous-Contracts'>continuous contract</a>. To view all the available options, see <a href='/docs/v2/writing-algorithms/securities/asset-classes/futures/requesting-data#09-Data-Normalization'>Data Normalization</a>. The default value is <code>DataNormalizationMode.Adjusted</code>. To change the data normalization mode, in the <a href='/docs/v2/writing-algorithms/initialization'>Initialize</a> method, pass a <code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code> argument to the <code class="csharp">AddFuture</code><code class="python">add_future</code> method.</p>
<div class="section-example-container">
<pre class="csharp">AddFuture(Futures.Currencies.BTC, dataNormalizationMode: DataNormalizationMode.BackwardsRatio);</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</tbody>
</table>

<p>If you already have a subscription to the underlying Equity but it's not <code>Raw</code> data normalization, LEAN automatically changes it to <code>Raw</code>.</p>
<p>If you already have a subscription to the underlying Equity but it's not <code class="csharp">Raw</code><code class="python">RAW</code> data normalization, LEAN automatically changes it to <code class="csharp">Raw</code><code class="python">RAW</code>.</p>

<p>To override the default <a href="/docs/v2/writing-algorithms/reality-modeling/options-models/pricing">pricing model</a> of the Option, <a href='https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/options-models/pricing#04-Set-Models'>set a pricing model</a>.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h4>Argument: <span><code>dataMappingMode</code></span></h4>
</tr>
<tr>
<td>
<h4>Argument: <span><code>dataNormalizationMode</code></span></h4>
<h4>Argument: <span><code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code></span></h4>
<p class='property-description'>The price scaling mode to use for the continuous future contract</p>
<p>Data Type: <span><code class='csharp'>DataNormalizationMode?</code><code class='python'>DataNormalizationMode/NoneType</code></span><span class='pipe-separator'> | </span> Default Value: <span><code class='python'>None</code><code class='csharp'>null</code></span></p>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>


<p>To configure how LEAN identifies the current Future contract in the continuous series and how it forms the adjusted price between each contract, provide <code>dataMappingMode</code>, <code>dataNormalizationMode</code>, and <code>contractDepthOffset</code> arguments to the <code class="csharp">AddFuture</code><code class="python">add_future</code> method. The <code>Future</code> object that the <code class="csharp">AddFuture</code><code class="python">add_future</code> method returns contains a <code>Mapped</code> property that references the current contract in the continuous contract series. As the contracts roll over, the <code>Mapped</code> property references the next contract in the series and you receive a <code>SymbolChangedEvent</code> object in the <code class="csharp">OnData</code><code class="python">on_data</code> method. The <code>SymbolChangedEvent</code> references the old contract <code>Symbol</code> and the new contract <code>Symbol</code>. You can use <code>SymbolChangedEvents</code> to roll over contracts.</p>
<p>To configure how LEAN identifies the current Future contract in the continuous series and how it forms the adjusted price between each contract, provide <code>dataMappingMode</code>, <code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code>, and <code>contractDepthOffset</code> arguments to the <code class="csharp">AddFuture</code><code class="python">add_future</code> method. The <code>Future</code> object that the <code class="csharp">AddFuture</code><code class="python">add_future</code> method returns contains a <code>Mapped</code> property that references the current contract in the continuous contract series. As the contracts roll over, the <code>Mapped</code> property references the next contract in the series and you receive a <code>SymbolChangedEvent</code> object in the <code class="csharp">OnData</code><code class="python">on_data</code> method. The <code>SymbolChangedEvent</code> references the old contract <code>Symbol</code> and the new contract <code>Symbol</code>. You can use <code>SymbolChangedEvents</code> to roll over contracts.</p>

<div class="section-example-container">
<pre class="csharp">public override void OnData(Slice slice)
Expand Down Expand Up @@ -47,7 +47,7 @@
<p>In backtesting, the <code>SymbolChangedEvent</code> occurs at midnight Eastern Time (ET). In live trading, the live data for continuous contract mapping arrives at 6/7 AM ET, so that's when it occurs.</p>
<h4>Data Normalization Modes</h4>
<p>The <code>dataNormalizationMode</code> argument defines how the price series of two contracts are stitched together when the contract rollovers occur. The following <code>DataNormalizatoinMode</code> enumeration members are available for continuous contracts:</p>
<p>The <code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code> argument defines how the price series of two contracts are stitched together when the contract rollovers occur. The following <code>DataNormalizatoinMode</code> enumeration members are available for continuous contracts:</p>
<div data-tree='QuantConnect.DataNormalizationMode' data-fields='ForwardPanamaCanal,BackwardsPanamaCanal,BackwardsRatio,FORWARD_PANAMA_CANAL,BACKWARDS_PANAMA_CANAL,BACKWARDS_RATIO,'></div>
<p>We use the entire Futures history to adjust historical prices. This process ensures you get the same adjusted prices, regardless of the backtest end date.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
If you are live trading Equities or backtesting Equities without the adjusted <a href="/docs/v2/writing-algorithms/securities/asset-classes/us-equity/requesting-data#11-Data-Normalization">data normalization mode</a>,
reset your indicators when <a href="/docs/v2/writing-algorithms/securities/asset-classes/us-equity/corporate-actions#02-Splits">splits</a> and <a href="/docs/v2/writing-algorithms/securities/asset-classes/us-equity/corporate-actions#03-Dividends">dividends</a> occur.
If a split or dividend occurs, the data in your indicators becomes invalid because it doesn't account for the price adjustments that the split or dividend causes.
To replace your indicator history with the newly-adjusted prices, call the <code>Reset</code> method and then warm up the indicator with <code>ScaledRaw</code> data from a <a href='/docs/v2/writing-algorithms/historical-data/history-requests'>history request</a>.
To replace your indicator history with the newly-adjusted prices, call the <code>Reset</code> method and then warm up the indicator with <code class="csharp">ScaledRaw</code><code class="python">SCALED_RAW</code> data from a <a href='/docs/v2/writing-algorithms/historical-data/history-requests'>history request</a>.
</p>

<div class="section-example-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h4>Create Insights</h4>
var insight = Insight.Price("IBM", Resolution.Minute, 20, InsightDirection.Up);</pre>
</div>

<p>In the <code>Price</code> method, the <code>period</code> argument can be a <code class="python">timedelta</code><code class="csharp">TimeSpan</code> object, a <code class="csharp">DateTime</code><code class="python">datetime</code> object, or a function that receives a <code class="csharp">DateTime</code><code class="python">datetime</code> object and returns the expiry <code class="csharp">DateTime</code><code class="python">datetime</code>.</p>
<p>In the <code class="csharp">Price</code><code class="python">price</code> method, the <code>period</code> argument can be a <code class="python">timedelta</code><code class="csharp">TimeSpan</code> object, a <code class="csharp">DateTime</code><code class="python">datetime</code> object, or a function that receives a <code class="csharp">DateTime</code><code class="python">datetime</code> object and returns the expiry <code class="csharp">DateTime</code><code class="python">datetime</code>.</p>

<h4>Group Insights</h4>
<p>Sometimes an algorithm's performance relies on multiple insights being traded together, like in pairs trading and options straddles. These types insights should be grouped. Insight groups signal to the Execution model that the insights need to be acted on as a single unit to maximize the alpha created.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
include(DOCS_RESOURCES."/securities/data-normalization.php");
?>

<p>When you request historical data, the <code class="csharp">History</code><code class="python">history</code> method uses the data normalization of your security subscription. To get historical data with a different data normalization, pass a <code>dataNormalizationMode</code> argument to the <code class="csharp">History</code><code class="python">history</code> method.</p>
<p>When you request historical data, the <code class="csharp">History</code><code class="python">history</code> method uses the data normalization of your security subscription. To get historical data with a different data normalization, pass a <code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code> argument to the <code class="csharp">History</code><code class="python">history</code> method.</p>
<div class="section-example-container">
<pre class="csharp">var history = qb.History(qb.Securities.Keys, qb.Time-TimeSpan.FromDays(10), qb.Time, dataNormalizationMode: DataNormalizationMode.SplitAdjusted);</pre>
<pre class="python">history = qb.history(qb.securities.keys, qb.time-timedelta(days=10), qb.time, dataNormalizationMode=DataNormalizationMode.SPLIT_ADJUSTED)</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<td><code class="csharp">Resolution.Minute</code><code class="python">Resolution.MINUTE</code></td>
</tr>
<tr>
<td><code>dataNormalizationMode</code></td>
<td><code class="csharp">dataNormalizationMode</code><code class="python">data_normalization_mode</code></td>
<td><code>DataNormalizationMode.Adjusted</code></td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion 07 Meta/01 Change Log/02 Documentation Updates.html
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ <h4>2023-10-09</h4>
<h4>2023-10-06</h4>
<ul>
<li>Added <a href='/docs/v2/cloud-platform/projects/files#09-Encrypt-Files'>Cloud Platform > Projects > Files > Encrypt Files</a></li>
<li>Updated <a href='/docs/v2/writing-algorithms/indicators/key-concepts#10-Reset-Indicators'>Writing Algorithms > Indicators > Key Conecpts > Reset Indicators</a> to include an example of using <code>ScaledRaw</code> data</li>
<li>Updated <a href='/docs/v2/writing-algorithms/indicators/key-concepts#10-Reset-Indicators'>Writing Algorithms > Indicators > Key Conecpts > Reset Indicators</a> to include an example of using <code class="csharp">ScaledRaw</code><code class="python">SCALED_RAW</code> data</li>
<li>Added the following pages/sections for short availability:</li>
<ul>
<li><a href='/docs/v2/writing-algorithms/reality-modeling/short-availability/key-concepts'>Writing Algorithms > Reality Modeling > Short Availability > Key Concepts</a></li>
Expand Down
Loading

0 comments on commit aa29842

Please sign in to comment.