Back

Security object shows $0.67, history shows $12

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

Update Backtest








stocksplit

check documentation:

https://www.quantconnect.com/docs/algorithm-reference/initializing-algorithms#Initializing-Algorithms-Selecting-Asset-Data

 

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. The DataNormalizationMode 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.

0

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.

0


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)

https://www.quantconnect.com/docs/algorithm-reference/handling-data#Handling-Data-Time-Slices

class Slice:
TradeBars Bars;
QuoteBars QuoteBars;
Ticks Ticks;
OptionChains OptionChains;
FuturesChains FuturesChains;
Splits Splits;
Dividends Dividends;
Delistings Delistings;
SymbolChangedEvents SymbolChangedEvents;

0

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.

0

small example using splits basic python split example

0

small delistings example when talking about splits:

delistings example

0

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.

0

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.

0

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. 

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed