diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/11 Data Normalization.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/11 Data Normalization.php index ff0be7bd4f..f442915f01 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/11 Data Normalization.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/11 Data Normalization.php @@ -4,7 +4,7 @@ include(DOCS_RESOURCES."/datasets/data-normalization.php"); ?> -
To set the data normalization mode for a security, pass a dataNormalizationMode
argument to the AddEquity
add_equity
method.
To set the data normalization mode for a security, pass a dataNormalizationMode
data_normalization_mode
argument to the AddEquity
add_equity
method.
_symbol = AddEquity("SPY", dataNormalizationMode: DataNormalizationMode.Raw).Symbol;diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/03 Trades.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/03 Trades.php index 189ac2a321..b042aa583f 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/03 Trades.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/03 Trades.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/04 Quotes.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/04 Quotes.php index 93b3dab182..666557a64e 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/04 Quotes.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/04 Quotes.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/05 Ticks.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/05 Ticks.php index b10d5d3f84..a806ba1574 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/05 Ticks.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/02 Handling Data/05 Ticks.php @@ -1,8 +1,8 @@ - -
If we detect a tick that may be suspicious, we set its Suspicious
flag to true.
If we detect a tick that may be suspicious, we set its Suspicious
suspicious
flag to true.
To set the data normalization mode for a security, pass a dataNormalizationMode
argument to the AddEquity
add_equity
method..
To set the data normalization mode for a security, pass a dataNormalizationMode
data_normalization_mode
argument to the AddEquity
add_equity
method..
_symbol = AddEquity("YESBANK", market: Market.India, dataNormalizationMode: DataNormalizationMode.Raw).Symbol;diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/02 India Equity/02 Handling Data/02 Trades.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/02 India Equity/02 Handling Data/02 Trades.php index 463b186243..bb4d771a89 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/02 India Equity/02 Handling Data/02 Trades.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/02 India Equity/02 Handling Data/02 Trades.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/03 Equity Options/02 Handling Data/02 Trades.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/03 Equity Options/02 Handling Data/02 Trades.php index 7773ac7281..fcc18f8cfd 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/03 Equity Options/02 Handling Data/02 Trades.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/03 Equity Options/02 Handling Data/02 Trades.php @@ -1,4 +1,4 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/04 Quotes.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/04 Quotes.php index 93b3dab182..2e33e917e5 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/04 Quotes.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/04 Quotes.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/05 Ticks.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/05 Ticks.php index 0595f8a481..fdc6307f66 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/05 Ticks.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/04 Crypto/02 Handling Data/05 Ticks.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/03 Trades.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/03 Trades.php index 463b186243..bb4d771a89 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/03 Trades.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/03 Trades.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/04 Quotes.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/04 Quotes.php index 93b3dab182..2e33e917e5 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/04 Quotes.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/04 Quotes.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/05 Ticks.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/05 Ticks.php index 0595f8a481..fdc6307f66 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/05 Ticks.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/05 Crypto Futures/02 Handling Data/05 Ticks.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/02 Quotes.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/02 Quotes.php index 61f87f4a81..e09a71be8a 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/02 Quotes.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/02 Quotes.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/03 Ticks.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/03 Ticks.php index a19ed9e28b..12eca6b287 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/03 Ticks.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Forex/02 Handling Data/03 Ticks.php @@ -1,6 +1,6 @@ - diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/07 Futures/02 Handling Data/02 Trades.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/07 Futures/02 Handling Data/02 Trades.php index 7773ac7281..fcc18f8cfd 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/07 Futures/02 Handling Data/02 Trades.php +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/07 Futures/02 Handling Data/02 Trades.php @@ -1,4 +1,4 @@ -
Tick
objects represent a price for the Index at a moment in time. Tick
objects have the following properties:
-Index ticks have a non-zero value for the Price
property, but they have a zero value for the BidPrice
, BidSize
, AskPrice
, and AskSize
properties.
Index ticks have a non-zero value for the Price
price
property, but they have a zero value for the BidPrice
bid_price
, BidSize
bid_size
, AskPrice
ask_price
, and AskSize
ask_size
properties.
In backtests, LEAN groups ticks into one millisecond buckets. In live trading, LEAN groups ticks into ~70-millisecond buckets. To get the Tick
objects in the Slice
, index the Ticks
property of the Slice
with a Symbol
. The Slice
may not contain data for your Symbol
at every time step. To avoid issues, check if the Slice
contains data for your Index before you index the Slice
with the Index Symbol
.
In the case of Futures, the data normalization mode affects how historical data of two contracts is stitched together to form the continuous contract. To view all the available options, see Data Normalization. The default value is DataNormalizationMode.Adjusted
. To change the data normalization mode, in the Initialize method, pass a dataNormalizationMode
argument to the AddFuture
add_future
method.
In the case of Futures, the data normalization mode affects how historical data of two contracts is stitched together to form the continuous contract. To view all the available options, see Data Normalization. The default value is DataNormalizationMode.Adjusted
. To change the data normalization mode, in the Initialize method, pass a dataNormalizationMode
data_normalization_mode
argument to the AddFuture
add_future
method.
AddFuture(Futures.Currencies.BTC, dataNormalizationMode: DataNormalizationMode.BackwardsRatio);diff --git a/03 Writing Algorithms/12 Universes/04 Equity Options/02 Create Universes.php b/03 Writing Algorithms/12 Universes/04 Equity Options/02 Create Universes.php index c41859c7f9..ca0c53b7a1 100644 --- a/03 Writing Algorithms/12 Universes/04 Equity Options/02 Create Universes.php +++ b/03 Writing Algorithms/12 Universes/04 Equity Options/02 Create Universes.php @@ -89,7 +89,7 @@ -
If you already have a subscription to the underlying Equity but it's not Raw
data normalization, LEAN automatically changes it to Raw
.
If you already have a subscription to the underlying Equity but it's not Raw
RAW
data normalization, LEAN automatically changes it to Raw
RAW
.
To override the default pricing model of the Option, set a pricing model.
diff --git a/03 Writing Algorithms/12 Universes/06 Futures/11 Create Universes.html b/03 Writing Algorithms/12 Universes/06 Futures/11 Create Universes.html index 3f9e7228a1..8cd78eae74 100644 --- a/03 Writing Algorithms/12 Universes/06 Futures/11 Create Universes.html +++ b/03 Writing Algorithms/12 Universes/06 Futures/11 Create Universes.html @@ -63,7 +63,7 @@dataMappingMode
dataNormalizationMode
dataNormalizationMode
data_normalization_mode
The price scaling mode to use for the continuous future contract
Data Type: DataNormalizationMode?
DataNormalizationMode/NoneType
| Default Value: None
null
To configure how LEAN identifies the current Future contract in the continuous series and how it forms the adjusted price between each contract, provide dataMappingMode
, dataNormalizationMode
, and contractDepthOffset
arguments to the AddFuture
add_future
method. The Future
object that the AddFuture
add_future
method returns contains a Mapped
property that references the current contract in the continuous contract series. As the contracts roll over, the Mapped
property references the next contract in the series and you receive a SymbolChangedEvent
object in the OnData
on_data
method. The SymbolChangedEvent
references the old contract Symbol
and the new contract Symbol
. You can use SymbolChangedEvents
to roll over contracts.
To configure how LEAN identifies the current Future contract in the continuous series and how it forms the adjusted price between each contract, provide dataMappingMode
, dataNormalizationMode
data_normalization_mode
, and contractDepthOffset
arguments to the AddFuture
add_future
method. The Future
object that the AddFuture
add_future
method returns contains a Mapped
property that references the current contract in the continuous contract series. As the contracts roll over, the Mapped
property references the next contract in the series and you receive a SymbolChangedEvent
object in the OnData
on_data
method. The SymbolChangedEvent
references the old contract Symbol
and the new contract Symbol
. You can use SymbolChangedEvents
to roll over contracts.
public override void OnData(Slice slice) @@ -47,7 +47,7 @@In backtesting, the
SymbolChangedEvent
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.Data Normalization Modes
-The
+dataNormalizationMode
argument defines how the price series of two contracts are stitched together when the contract rollovers occur. The followingDataNormalizatoinMode
enumeration members are available for continuous contracts:The
dataNormalizationMode
data_normalization_mode
argument defines how the price series of two contracts are stitched together when the contract rollovers occur. The followingDataNormalizatoinMode
enumeration members are available for continuous contracts: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.
diff --git a/03 Writing Algorithms/28 Indicators/02 Key Concepts/10 Reset Indicators.html b/03 Writing Algorithms/28 Indicators/02 Key Concepts/10 Reset Indicators.html index 66fbbfdd1f..347b0cae96 100644 --- a/03 Writing Algorithms/28 Indicators/02 Key Concepts/10 Reset Indicators.html +++ b/03 Writing Algorithms/28 Indicators/02 Key Concepts/10 Reset Indicators.html @@ -11,7 +11,7 @@ If you are live trading Equities or backtesting Equities without the adjusted data normalization mode, reset your indicators when splits and dividends 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 theReset
method and then warm up the indicator withScaledRaw
data from a history request. + To replace your indicator history with the newly-adjusted prices, call theReset
method and then warm up the indicator withScaledRaw
SCALED_RAW
data from a history request.diff --git a/03 Writing Algorithms/34 Algorithm Framework/03 Alpha/01 Key Concepts/06 Insights.html b/03 Writing Algorithms/34 Algorithm Framework/03 Alpha/01 Key Concepts/06 Insights.html index fbc9cd5002..f27cfebf49 100644 --- a/03 Writing Algorithms/34 Algorithm Framework/03 Alpha/01 Key Concepts/06 Insights.html +++ b/03 Writing Algorithms/34 Algorithm Framework/03 Alpha/01 Key Concepts/06 Insights.html @@ -33,7 +33,7 @@-Create Insights
var insight = Insight.Price("IBM", Resolution.Minute, 20, InsightDirection.Up);In the
+Price
method, theperiod
argument can be atimedelta
TimeSpan
object, aDateTime
datetime
object, or a function that receives aDateTime
datetime
object and returns the expiryDateTime
datetime
.In the
Price
price
method, theperiod
argument can be atimedelta
TimeSpan
object, aDateTime
datetime
object, or a function that receives aDateTime
datetime
object and returns the expiryDateTime
datetime
.Group Insights
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.
diff --git a/04 Research Environment/03 Datasets/04 US Equity/07 Data Normalization.php b/04 Research Environment/03 Datasets/04 US Equity/07 Data Normalization.php index 106d5e5359..03642d7038 100644 --- a/04 Research Environment/03 Datasets/04 US Equity/07 Data Normalization.php +++ b/04 Research Environment/03 Datasets/04 US Equity/07 Data Normalization.php @@ -5,7 +5,7 @@ include(DOCS_RESOURCES."/securities/data-normalization.php"); ?> -When you request historical data, the
+History
history
method uses the data normalization of your security subscription. To get historical data with a different data normalization, pass adataNormalizationMode
argument to theHistory
history
method.When you request historical data, the
History
history
method uses the data normalization of your security subscription. To get historical data with a different data normalization, pass adataNormalizationMode
data_normalization_mode
argument to theHistory
history
method.var history = qb.History(qb.Securities.Keys, qb.Time-TimeSpan.FromDays(10), qb.Time, dataNormalizationMode: DataNormalizationMode.SplitAdjusted);history = qb.history(qb.securities.keys, qb.time-timedelta(days=10), qb.time, dataNormalizationMode=DataNormalizationMode.SPLIT_ADJUSTED)diff --git a/04 Research Environment/03 Datasets/12 Futures/03 Create Subscriptions.php b/04 Research Environment/03 Datasets/12 Futures/03 Create Subscriptions.php index f11d4c6685..3b4e31e078 100644 --- a/04 Research Environment/03 Datasets/12 Futures/03 Create Subscriptions.php +++ b/04 Research Environment/03 Datasets/12 Futures/03 Create Subscriptions.php @@ -37,7 +37,7 @@Resolution.Minute
Resolution.MINUTE
dataNormalizationMode
dataNormalizationMode
data_normalization_mode
DataNormalizationMode.Adjusted
ScaledRaw
dataScaledRaw
SCALED_RAW
dataIf you use Adjusted
, SplitAdjusted
, or TotalReturn
, we use the entire split and dividend history to adjust historical prices. This process ensures you get the same adjusted prices, regardless of the
+
If you use Adjusted
ADJUSTED
, SplitAdjusted
SPLIT_ADJUSTED
, or TotalReturn
TOTAL_RETURN
, we use the entire split and dividend history to adjust historical prices. This process ensures you get the same adjusted prices, regardless of the
if($writingAlgorithms) { ?>
- backtest end date. The ScaledRaw
data normalization is only for history requests. When you use ScaledRaw
, we use the split and dividend history before the algorithm's current time to adjust historical prices. The ScaledRaw
data normalization model enables you to warm up indicators with adjusted data when you subscribe to Raw
security data.
ScaledRaw
SCALED_RAW
data normalization is only for history requests. When you use ScaledRaw
SCALED_RAW
, we use the split and dividend history before the algorithm's current time to adjust historical prices. The ScaledRaw
SCALED_RAW
data normalization model enables you to warm up indicators with adjusted data when you subscribe to Raw
RAW
security data.
} else { ?>
- QuantBook
time. If you use ScaledRaw
, we use the split and dividend history before the QuantBook
's EndDate
to adjust historical prices.
+ QuantBook
time. If you use ScaledRaw
SCALED_RAW
, we use the split and dividend history before the QuantBook
's EndDate
to adjust historical prices.
} ?>
\ No newline at end of file
diff --git a/Resources/datasets/request-data.php b/Resources/datasets/request-data.php
index 02ab402ecc..0ed9e7b394 100644
--- a/Resources/datasets/request-data.php
+++ b/Resources/datasets/request-data.php
@@ -406,7 +406,7 @@
null
None
dataNormalizationMode
dataNormalizationMode
data_normalization_mode
DataNormalizationMode?
DataNormalizationMode/NoneType
null
None
A dividend is a payment that a company gives to shareholders to distribute profits. When a dividend payment occurs for an Equity in your algorithm, LEAN sends a Dividend
object to the OnData
on_data
method. Dividend
objects have the following properties:
If you backtest with the Adjusted
or TotalReturn
data normalization mode, the dividends are factored into the price. If you backtest with the other data normalization modes or trade live, when a dividend payment occurs, LEAN automatically adds the payment amount to your cashbook. If you have indicators in your algorithm, reset and warm-up your indicators with ScaledRaw data when dividend payments occur so that the data in your indicators account for the price adjustments that the dividend causes.
If you backtest with the Adjusted
ADJUSTED
or TotalReturn
TOTAL_RETURN
data normalization mode, the dividends are factored into the price. If you backtest with the other data normalization modes or trade live, when a dividend payment occurs, LEAN automatically adds the payment amount to your cashbook. If you have indicators in your algorithm, reset and warm-up your indicators with ScaledRaw data when dividend payments occur so that the data in your indicators account for the price adjustments that the dividend causes.
To get the Dividend
objects, index the Dividends
object with the security Symbol
. The Dividends
object may not contain data for your Symbol
. To avoid issues, check if the Dividends
object contains data for your security before you index it with the security Symbol
.
You receive Split
objects when a split is in the near future and when it occurs. To know if the split occurs in the near future or now, check the Type
property.
If you backtest without the Raw
data normalization mode, the splits are factored into the price and volume. If you backtest with the Raw
data normalization mode or trade live, when a split occurs, LEAN automatically adjusts your positions based on the SplitFactor
. If the post-split quantity isn't a valid lot size, LEAN credits the remaining value to your cashbook in your account currency. If you have indicators in your algorithm, reset and warm-up your indicators with ScaledRaw data when splits occur so that the data in your indicators account for the price adjustments that the splits cause.
If you backtest without the Raw
RAW
data normalization mode, the splits are factored into the price and volume. If you backtest with the Raw
RAW
data normalization mode or trade live, when a split occurs, LEAN automatically adjusts your positions based on the SplitFactor
. If the post-split quantity isn't a valid lot size, LEAN credits the remaining value to your cashbook in your account currency. If you have indicators in your algorithm, reset and warm-up your indicators with ScaledRaw data when splits occur so that the data in your indicators account for the price adjustments that the splits cause.
To get the Split
objects, index the Splits
object with the security Symbol
. The Splits
object may not contain data for your Symbol
. To avoid issues, check if the Splits
object contains data for your security before you index it with the security Symbol
.
To set the data normalization mode for a security, pass a dataNormalizationMode
argument to the AddEquity
add_equity
method.
To set the data normalization mode for a security, pass a dataNormalizationMode
data_normalization_mode
argument to the AddEquity
add_equity
method.
var =$cSharpVariableName?> = =$writingAlgorithms ? "" : "qb." ?>AddEquity("=$ticker?>", dataNormalizationMode: DataNormalizationMode.Raw).Symbol;diff --git a/Resources/securities/quotebar.php b/Resources/securities/quotebar.php index f99e7d6dd4..11facb2ad5 100644 --- a/Resources/securities/quotebar.php +++ b/Resources/securities/quotebar.php @@ -1,11 +1,11 @@ -
QuoteBar
objects are bars that consolidate NBBO quotes from the exchanges. They contain the open, high, low, and close prices of the bid and ask. The Open
, High
, Low
, and Close
properties of the QuoteBar
object are the mean of the respective bid and ask prices. If the bid or ask portion of the QuoteBar
has no data, the Open
, High
, Low
, and Close
properties of the QuoteBar
copy the values of either the Bid
or Ask
instead of taking their mean.
QuoteBar
objects are bars that consolidate NBBO quotes from the exchanges. They contain the open, high, low, and close prices of the bid and ask. The Open
open
, High
high
, Low
low
, and Close
close
properties of the QuoteBar
object are the mean of the respective bid and ask prices. If the bid or ask portion of the QuoteBar
has no data, the Open
open
, High
high
, Low
low
, and Close
close
properties of the QuoteBar
copy the values of either the Bid
bid
or ask
ask
instead of taking their mean.
QuoteBar
objects have the following properties:
To get the QuoteBar
objects in the Slice
, index the QuoteBars
property of the Slice
with the =$securityName?> Symbol
. If the =$securityName?> doesn't actively get quotes or you are in the same time step as when you added the =$securityName?> subscription, the Slice
may not contain data for your Symbol
. To avoid issues, check if the Slice
contains data for your =$securityName?> before you index the Slice
with the =$securityName?> Symbol
.
To get the QuoteBar
objects in the Slice
, index the QuoteBars
property of the Slice
with the =$securityName?> Symbol
symbol
. If the =$securityName?> doesn't actively get quotes or you are in the same time step as when you added the =$securityName?> subscription, the Slice
may not contain data for your Symbol
symbol
. To avoid issues, check if the Slice
contains data for your =$securityName?> before you index the Slice
with the =$securityName?> Symbol
symbol
.
public override void OnData(Slice slice) @@ -16,9 +16,9 @@ } }-
def OnData(self, slice: Slice) -> None: - if =$pythonVariable?> in slice.QuoteBars: - quote_bar = slice.QuoteBars[=$pythonVariable?>]+
def on_data(self, slice: Slice) -> None: + if =$pythonVariable?> in slice.quote_bars: + quote_bar = slice.quote_bars[=$pythonVariable?>]
You can also iterate through the QuoteBars
dictionary. The keys of the dictionary are the Symbol
objects and the values are the QuoteBar
objects.
def OnData(self, slice: Slice) -> None: - for symbol, quote_bar in slice.QuoteBars.items(): - ask_price = quote_bar.Ask.Close+
def on_data(self, slice: Slice) -> None: + for symbol, quote_bar in slice.quote_bars.items(): + ask_price = quote_bar.ask.close
QuoteBar
objects let LEAN incorporate spread costs into your simulated trade fills to make backtest results more realistic.
QuoteBar
objects let LEAN incorporate spread costs into your simulated trade fills to make backtest results more realistic.
Tick
objects represent a single trade or quote at a moment in time. A trade tick is a record of a transaction for the =$securityName?>. A quote tick is an offer to buy or sell the =$securityName?> at a specific price. Tick
objects have the following properties:
Trade ticks have a non-zero value for the Quantity
and Price
properties, but they have a zero value for the BidPrice
, BidSize
, AskPrice
, and AskSize
properties. Quote ticks have non-zero values for BidPrice
and BidSize
properties or have non-zero values for AskPrice
and AskSize
properties. To check if a tick is a trade or a quote, use the TickType
property.
Trade ticks have a non-zero value for the Quantity
quantity
and Price
price
properties, but they have a zero value for the BidPrice
bid_price
, BidSize
bid_size
, AskPrice
ask_price
, and AskSize
ask_size
properties. Quote ticks have non-zero values for BidPrice
bid_price
and BidSize
bid_size
properties or have non-zero values for AskPrice
ask_price
and AskSize
ask_size
properties. To check if a tick is a trade or a quote, use the TickType
ticktype
property.
In backtests, LEAN groups ticks into one millisecond buckets. In live trading, LEAN groups ticks into ~70-millisecond buckets. To get the Tick
objects in the Slice
, index the Ticks
property of the Slice
with a Symbol
. If the =$securityName?> doesn't actively trade or you are in the same time step as when you added the =$securityName?> subscription, the Slice
may not contain data for your Symbol
. To avoid issues, check if the Slice
contains data for your =$securityName?> before you index the Slice
with the =$securityName?> Symbol
.
In backtests, LEAN groups ticks into one millisecond buckets. In live trading, LEAN groups ticks into ~70-millisecond buckets. To get the Tick
objects in the Slice
, index the Ticks
property of the Slice
with a Symbol
symbol
. If the =$securityName?> doesn't actively trade or you are in the same time step as when you added the =$securityName?> subscription, the Slice
may not contain data for your Symbol
symbol
. To avoid issues, check if the Slice
contains data for your =$securityName?> before you index the Slice
with the =$securityName?> Symbol
symbol
.
public override void OnData(Slice slice) @@ -18,11 +18,11 @@ } }-
def OnData(self, slice: Slice) -> None: - if =$pythonVariable?> in slice.Ticks: - ticks = slice.Ticks[=$pythonVariable?>] +def on_data(self, slice: Slice) -> None: + if =$pythonVariable?> in slice.ticks: + ticks = slice.ticks[=$pythonVariable?>] for tick in ticks: - price = tick.Price+ price = tick.price
You can also iterate through the Ticks
dictionary. The keys of the dictionary are the Symbol
objects and the values are the List<Tick>
list[Tick]
objects.
def OnData(self, slice: Slice) -> None: - for symbol, ticks in slice.Ticks.items(): +def on_data(self, slice: Slice) -> None: + for symbol, ticks in slice.ticks.items(): for tick in ticks: - price = tick.Price+ price = tick.price
Tick data is raw and unfiltered, so it can contain bad ticks that skew your trade results. For example, some ticks come from dark pools, which aren't tradable. We recommend you only use tick data if you understand the risks and are able to perform your own online tick filtering.
\ No newline at end of file diff --git a/Resources/securities/tradebar.php b/Resources/securities/tradebar.php index e334db04ae..afe630898b 100644 --- a/Resources/securities/tradebar.php +++ b/Resources/securities/tradebar.php @@ -2,7 +2,7 @@TradeBar
objects have the following properties:
To get the TradeBar
objects in the Slice
, index the Slice
or index the Bars
bars
property of the Slice
with the =$securityName?> Symbol
. If the =$securityName?> doesn't actively trade or you are in the same time step as when you added the =$securityName?> subscription, the Slice
may not contain data for your Symbol
. To avoid issues, check if the Slice
contains data for your =$securityName?> before you index the Slice
with the =$securityName?> Symbol
.
To get the TradeBar
objects in the Slice
, index the Slice
or index the Bars
bars
property of the Slice
with the =$securityName?> Symbol
symbol
. If the =$securityName?> doesn't actively trade or you are in the same time step as when you added the =$securityName?> subscription, the Slice
may not contain data for your Symbol
symbol
. To avoid issues, check if the Slice
contains data for your =$securityName?> before you index the Slice
with the =$securityName?> Symbol
symbol
.
public override void OnData(Slice slice) @@ -13,9 +13,8 @@ } }-
def OnData(self, slice: Slice) -> None: - if =$pythonVariable?> in slice.Bars: - trade_bar = slice.Bars[=$pythonVariable?>]+
def on_data(self, slice: Slice) -> None: + trade_bar = slice.bars.get(=$pythonVariable?>) # None if not found
def OnData(self, slice: Slice) -> None: - for symbol, trade_bar in slice.Bars.items(): - close_price = trade_bar.Close+ for symbol, trade_bar in slice.bars.items(): + close_price = trade_bar.close \ No newline at end of file diff --git a/code-generators/enum-table-generator.py b/code-generators/enum-table-generator.py index 826cb4610c..779e35e83c 100644 --- a/code-generators/enum-table-generator.py +++ b/code-generators/enum-table-generator.py @@ -186,9 +186,8 @@ def HtmlGeneration(obj_name, sorted_obj, extra=''): items = [y[0] for y in market if y[1] == x] items = [y[0] for y in market_data if y[0].lower() in items] items = [y for y in items if y.lower() not in ["ftx", "ftxus", "fxcm", "gdax"]] - + items = set(items + [x for x in items]) with open(f"{destination}/market-{x}.html", "w", encoding="utf-8") as file: x = "Futures" if x == "future" else x file.write(f"""
The following Market
enumeration members are available for {x.title().replace("Option", "Options").replace("option", " Options").replace("Index", "Indices").replace("Indices Options", "Index Options")}: