MOC orders not working
Hi everyone,
I run a single day backtest and exit all my open positions using MOC orders at the end of the day. But after the backtest is done, I have a lot of open positions. Anyone has the same problem?
Tagged:
Comments
*** Update.***
I looked into those open positions. Most of them have nan in md.L1.closing_trade. Myabe that is because those symbols do not have closing print
That's correct - no closing print on the exchange of the MOC then no fill. md.L1.closing_trade will be NaN until there's a print. Reminder, large NYSE/AMEX closing prints can be delayed up to half hour after the close, but a majority fill close to the time of the closing bell. Also, you might want to run your back until 17:00 to catch all late prints if doing NYSE/AMEX on close orders
New to CQ... I put in the following round turn:
order_id = order.algo_buy(self.symbol, "market", intent="init", order_quantity=qty)
order_id = order.algo_sell(self.symbol, "28bfb89c-93f9-45b1-b414-f79aa16865c5", intent='exit') # in on_fill... I guess I'm not to supply qty?
Console shows both orders being generated:
SITO 2017-06-05 10:01:05.005000 order number: 0000000000000001
SITO 2017-06-05 10:01:05.006700 order number: 0000000000000002
Tried tweaking the end time of the sim but I'm still not getting any MOC fill. Also, saw this in the docs:
My goal is to have some existing algo manage the details of MOC... just get me out! For any symbol. Tips?
jm801551 -
Without seeing some sample code, my guess is that those orders are being placed back-to-back. If so, the "exit" is being rejected because you aren't in the trade (and there is nothing to exit) when the order is being placed. Does that make sense?
-Shayne