Why this discrepancy and any suggestions on how to avoid it?
2017-12-21 00:00:00 ZSAN VXLELNXHWMSL: $0.67 ZSAN VXLELNXHWMSL close high low open volume
symbol time
ZSAN VXLELNXHWMSL 2017-12-20 15:56:00 12.800 12.820 12.800 12.820 700.0
2017-12-20 15:57:00 12.800 12.820 12.800 12.820 700.0
2017-12-20 15:58:00 12.800 12.820 12.800 12.820 700.0
2017-12-20 15:59:00 12.934 12.934 12.934 12.934 64.0
2017-12-20 16:00:00 12.800 12.800 12.800 12.800 15.0
Michael Manus
stocksplit
check documentation:
By default equity data in QuantConnect is Split and Dividend adjusted backwards in time to give smooth continuous prices. This allows easy use for indicators. Some algorithms need raw or partially adjusted price data. You can control this with the
SetDataNormalizationMode()
method. TheDataNormalizationMode
enum has the values Adjusted (default), Raw, SplitAdjusted, and TotalReturn. When data is set to Raw mode the dividends are paid as cash into your algorithm and the splits are directly applied to your holding quantity.Garyha
Essentially I want history and all prices to pretend they are looking at data at that date and time, and never with any knowledge of the future. What needs to be done?
How would one go about making this limit price relevant to its sub-$1 price (at that time) vs the $12+ in Securities[s].Price? The $12+ evidently reflects the 1/20 Jan reverse split about a month after this time frame.
In this example, the stock makes it thru the price filter between 60 and 70 cents but then this code decides its price is 12.92 and places a limit order at 12.27. It needs to be entirely unaware of the upcoming stock split. I'd prefer that all of my code never ever have any chance of any knowledge of the future at all.
And how would SetDataNormalizationMode() be implemented in CoarseSelection() or for all stocks that show up? Since one would probably want consistency for all stocks, could you consider adding an option of making it apply to all stocks once from Initialize?
Please see logging at the bottom of this code. Thanks.
Michael Manus
you would need to adapt the values in the indicators and other stuff you are using when a split occured:
(new system new rules :D)
class Slice:
TradeBars Bars;
QuoteBars QuoteBars;
Ticks Ticks;
OptionChains OptionChains;
FuturesChains FuturesChains;
Splits Splits;
Dividends Dividends;
Delistings Delistings;
SymbolChangedEvents SymbolChangedEvents;
Garyha
I'm asking how to keep knowledge of the future out of an algorithm. Seems a rudimentary question that others have surely solved.
Took a look at the link and surrounding pages. Tried pasting that code, syntax error. My lack of book-learning maybe.
Could someone clone my code above and attach with needed modifications?
There are five output lines showing ZSAN with prices above 12 that should change to below $1.
If I had to guess, I think I can confidently estimate with 100% certainty that I'm clueless on what to do next. I'm coming from 4+ years on Quantopian and 4091 algorithms that I've worked on solely counting just the ones saved locally. I post tools to help others, always wanting to go an extra mile to try to be sure they won't just wind up feeling frustrated. Regarding the image below, they are unheard-of numbers (one year 240% profit with alpha 1.2, sharpe 64, 0% drawdown) and if I could implement this to some degree on QuantConnect, then I think my experience would wind up helping others here too but I'm blocked by this issue.
Can someone clone my backtest code from the previous message and attach modifications that prevent knowing about the future? Thanks if so.
Michael Manus
small example using splits basic python split example
Michael Manus
small delistings example when talking about splits:
delistings example
Garyha
That's a single security, "MSFT" being set in Initialize.
Many folks would surely be rounding up securities dynamically with a price filter in the Coarse filter like mine.
What we'll need here is for someone to look at my code, specifically the logging output that I placed in comments at the bottom of it, then make changes to my code so that the 12 dollar prices are no longer happening, and then attach their new backtest to illustrate how to solve it in a dynamic universe. That would be great.
Garyha
My comment was in response to the split example, didn't see the other in time. Although OnSecuritiesChanged() and other callbacks (I think they're called?) are really useful. Want to focus on ... the 12 dollar prices no longer happening, thanks.
Jared Broad
Welcome @Garyha -- the right way to do coarse universe selection and request raw pricing is to use the SecurityInitializer class (example).
Adjusted pricing is best for indicators which require smooth pricing. Security price on the coarse object is the raw price; if your code is making decisions based on the absolute asset price then yes you could have different results in raw and adjusted modes. Most people don't use absolute price and are working with log returns to normalize the data; investing percentages.
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.
Stephen Hyer
Hi guys,
I'm very curious if there was a common solution found to this problem. @Garyha Jared Broad
I'm having a near identical problem with TVIX right now. I want my algorithm to ignore all future price data until that point in time is reached- including stock splits. I also want all stock splits to register. Right now on Aug 30, 2013 my algorithm is collapsing because it doesn't recognize the reverse split. This happens over and over throughout the TVIX data stream at different dates. These dates almost always coincide with reverse splits.
Using raw data is also influencing my moving average and RSI indicators for the worse. I want my indicators to use smoothed, adjusted data for seamless transition but I want my buy/sell orders to accurately reflect the day's share price and my correctly adjusted held QTY.
I've been combing Quantconnect's forums for days now looking for an answer and this post seems to be on the money. Was this problem resolved, and if so how?
Thank you,
Stephen
JayJayD
Stephen Hyer , the TVIX issue is already reported. It has to do with errors in the factor file.
Sadly that kind of error is present in our vendor's raw data and there is not much we can do before they fix their side.
Garyha
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!