Hey guys, looking for advice on how best to handle splits during live trading?
Off tops, here's my current thinking:
- Reference split data from a third party source such as Nasdaq's Split Calendar which has a really simple public API that will return splits for a given day in JSON i.e. https://api.nasdaq.com/api/calendar/splits?date=2020-11-13
- Refresh history nightly, assuming splits are updated same day (is this the case?)
- Make a history call during the day once an entry signal is triggered. i.e. Right before making an actual trade. However, not sure how soon splits are made available by the data vendor.
Charles Naccio
While waiting for feedback from the community, I came up with the following solution which uses Yahoo Finance as a backup source for splits data which works well enough, and should help in situations where split data is not available in QuantConnect or during live trading. Hope this helps!
Note that _algo and symbol are local member variables declared in my class.
/// <summary> /// Indicates whether or not this symbol has /// a stock split planned for today. /// </summary> /// <param name="data">Slice object keyed by symbol containing stock data</param> /// <returns>True if split is planned for today.</returns> public Boolean IsSplitting(Slice data = null) { var isSplitting = false; // Check local data first if (data != null) isSplitting = data.Splits.ContainsKey(symbol); // If splits not found locally, double check via public source if (!isSplitting) { var splitDay = $"{_algo.Time : yyyy-MM-dd}"; var splits = _algo.Download( $"https://finance.yahoo.com/calendar/splits?day={splitDay}" ); isSplitting = splits.Contains($"/quote/{symbol.Value}?p={symbol.Value}"); } // Return results return isSplitting; }
Charles Naccio
Please note there's a bug in my code above on line 15; there's an accidential space being added to the formatted date. Change line 15 as below.
var splitDay = $"{_algo.Time:yyyy-MM-dd}";
Shile Wen
Hi Charles,
The Slice has a Splits, which provides split information to OnData when split information comes through.
Best,
Shile Wen
Charles Naccio
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!