Hi everyone,
New here, been loving it so far. I've been working on implementing a trailing stop loss algorithm with sentiment data leading to purchase signals. I will soon post my algorithm for the community to check, and also, to have a concrete trailing stop loss algorithm implementation as an example.
But for the time being I have a question regarding stop orders in the paper trading system. In the following code, this is how I call my buy orders:
if buy_condition:
stop_price = price*context.stop_pct_initial
order(sid, qty, style=StopOrder(stop_price))
where context.stop_pct_initial = 0.995.
I am currently looking at today's paper trading performance, and I notice that my algorithm purchased 5 shares of VXX at an average cost of $18.49 which should have had a stop price set on it of $18.4075 as seen in the logs:
2016-04-06 08:31 handle_data:76 INFO BUY: Equity(38054 [VXX]), price = 18.5, stop = 18.4075
yet the current price is $17.38, well below the stop loss, as seen in todays performance of VXX:
VXX performance April 6th 2016
So I am wondering why the stop never executed and turned my 5 shares into a market order.
Please let me know if you all would like more information.
Thanks!
Richard