Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
False signal generated on stock split

Hi, I am new to Quantopian,

I am working on a strategy that goes long TQQQ when his EMA 2 is crossing above his EMA 5 (weekly) and goes with AGG if his EMA 2 is crossing below his EMA 5 (weekly) or if the price hits his trailing stop(daily) 10%.

Everything seems to be working fine but when there is a stock split, the trailing stop triggers, having the stock to sell without real signal on an adjusted split basis. (See in the algo the TQQQ split of 05/24/2018).

What am I doing wrong, what can I do to get the right signal?

Thank you very much for your help!

3 responses

I'm sure there's better way to do this but it works now.
The cost_basis and amount in portfolio.positions are split adjusted.
Also, you do not need to schedule the trailing stop every minutes, it will automatically trigger if you schedule the order at market open.
If you comment out the two lines below, you will get the sames results as the algo you posted. Good luck.

We don't really expect the backtester to change our stored variables, do we? Personally I would find that totally irritating...
A good practice to account for splits when using stops or take profits is to always multiply price by the number of shares. If splits are implemented correctly you will have the same position size and ratio if the price doesn't really move.

@ Tentor
Thank you so much, really helpful , I have been looking so hard!