We're happy to announce a new feature in QuantConnect -- custom split and dividend handling! Currently all the dividend and splits are factored into the asset price. Starting today you can control how the algorithm models reality!
E.g. Do you want raw asset prices, with dividends paid as cash and splits adjusting the quantity of your holdings? This is the closest possible to reality, and can be achieved with the new setting: DataNormalizationMode.Raw
Would you prefer splits adjusted into the price, but dividends paid in cash? This is ideal for charting since the price is continuous, but the dividends are still paid in cash. You can use this mode with: DataNormalizationMode.SplitAdjusted
How about Total Return charting? Where dividends are added into the price of the asset, so the total asset price includes the sum of dividends? This is a popular technique to account for the receipt and reinvestment of dividends. You can access this mode with: DataNormalizationMode.TotalReturn
The current, default behavior of QuantConnect is to fully adjust for splits and dividends, giving you an adjusted price which always equals today's price. This is ideal for easy charting and simplified portfolio modeling. We kept this as the default since the stock plots rely on adjusted pricing.
To get started with customized price normalization, set the mode on the security during the Initialize() method: e.g.
Securities["MSFT"].SetDataNormalizationMode(DataNormalizationMode.TotalReturn);
You can also bind to Dividends and Splits events:
public void OnData(Splits split) {
split["MSFT"].SplitFactor
}
public void OnData(Dividends dividends) {
dividends["MSFT"].Distribution
}
Check out the QC University algorithm below as an example of how to get started!
Sameer Allidina
Hi Jared, wondering if this is done differently in the algorithm framework model -- I use ManualUniverseSelectionModel, and after this I check the Securities dictionary, and it has a count of 0 (there is 1 security in my ManualUniverseSelectionModel for which I want raw dividend mode).
Sameer Allidina
I may have an answer to this for anyone with the same question:
it appears that you can do this by setting a custom security initializer via:
SetSecurityInitializer(mySecurityInitializer)
Then, in your custom security initializer (mySecurityInitializer), you will receive a callback for each security in your universe, and can call security.SetDataNormalizationMode(...)
Levi Freedman
How do I access raw prices in Research?
Shile Wen
Hi Levi,
Since History requests are based on the Data Normalization of the security, we can simply set the Data Normalization to raw before retrieving data with security.SetDataNormalizationMode(DataNormalizationMode.Raw). I've shown this in notebook of the attached backtest.
Best,
Shile Wen
Levi Freedman
Perfect, thanks.
Alexandre Catarino
Hi David Thielen ,
Splits and Dividends were incorporated into the Slice object.
However, they are still accessible via OnData(Splits) and OnData(Dividends), since we haven't deprecated those overloads.
Sachin Kholamkar
How does DataNormalizationMode.TotalReturn mode handle splits? With quantity or price?
Kevin Wheeler
“The current, default behavior of QuantConnect is to fully adjust for splits and dividends, giving you an adjusted price which always equals today's price. This is ideal for easy charting and simplified portfolio modeling. We kept this as the default since the stock plots rely on adjusted pricing.”
Is this equal to DataNormalizationMode.TotalReturn? Otherwise what does it mean to “fully adjust for splits and dividends"?
Jared Broad
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!