Has anyone else seen their API paper orders canceled? Does it have something to do with my orders being submitted overnight? Not having limit or stop prices?
PS I’m using the python library and the example from here:
It worked great creating the orders but canceled them this morning.
def submitOrder(self, qty, stock, side, resp):
if(qty > 0):
try:
self.alpaca.submit_order(stock, qty, side, "market", "day")
print("Market order of | " + str(qty) + " " + stock + " " + side + " | completed.")
resp.append(True)
except:
print("Order of | " + str(qty) + " " + stock + " " + side + " | did not go through.")
resp.append(False)
else:
print("Quantity is 0, order of | " + str(qty) + " " + stock + " " + side + " | not completed.")
resp.append(True)
Timestamps are so close that it looks like a batch cancel from your code maybe? If you’re using the code you linked to then lines 37 - 41 cancels all open orders.
Interesting thought. I do call cancel all open orders before I run the buying loop though. Is it possible that the cancel all orders is waiting for orders to cancel since there weren’t any in there?
Tonight I’ll add a check for open orders before calling the cancel all open orders.
Thanks for the thought.
I just checked and self.alpaca.cancel_order(order.id) uses the order id. So that can’t be it. It must have something to do with the market opening.
PPS I submitted the orders via the python library at 10:02 PM PT. According to the documentation, since the orders came in after 8 PM they should have been queued for the next day. However, the orders were canceled at 5:51 AM PT. This is strange.