I have some custom data that needs to be dealt with splits and dividends. just wondering if Lean can help that. I notice there's FactorFileGenerator.cs in toolbox.
QUANTCONNECT COMMUNITY
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.
Mia Alissi
To handle custom data with splits and dividends in Lean, you can utilize several components and methods provided by QuantConnect. Here's a guide to help you manage these corporate actions effectively:
FactorFileGenerator.cs: This is a tool in the QuantConnect Toolbox that helps generate factor files, which are essential for handling splits and dividends. Factor files contain historical data about corporate actions for a given symbol.
AlgorithmManager Class: This class provides methods like
handle_dividends
andhandle_splits
to apply dividends and splits to your algorithm instance. These methods can be used to manage corporate actions within your custom data.Data Normalization Mode: Ensure your custom data is set with the appropriate data normalization mode (e.g.,
Raw
,Adjusted
). This setting determines how dividends and splits are applied to your data. For example, setting it toRaw
will pay dividends as cash directly into your portfolio.Handling Corporate Actions in OnData: Use the
OnData
method to processDividend
andSplit
objects when they occur. You can adjust your portfolio and cashbook accordingly. Here's an example of how to access splits and dividends in your algorithm:SecurityPortfolioManager: Use methods like
apply_dividend
andapply_split
to adjust your portfolio for dividends and splits. These methods help ensure that your portfolio reflects the changes due to corporate actions.Testing with Backtesting: Run backtests with your custom data to ensure that splits and dividends are handled as expected. Make adjustments to your algorithm as needed to ensure accuracy.
By following these steps, you can effectively manage splits and dividends in your custom data using Lean. If you have any specific questions or need further assistance, feel free to ask!
Sources: Corporate Actions - QuantConnect.com, Corporate Actions - QuantConnect.com, Dividend Algorithm, Factor Optimization Framework on SPY Constituents, Sector Rotation Based On News Sentiment
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.
Andy Hu
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!