Thank you for your response. I have been able to capture more data that will hopefully shed more light on the issue.
Below is the csv of all orders saved as a csv from the strategy file itself. As mentioned previously, this is coming directly from the dataframe passed to order_stubs_to_orders.It is my understand, that with limit_position_sizes() configured the way that it is, Quantrocket should only order in quantities of 100 and only ever allow 100 positions per stock
It is clear that two unexpected behaviors are happening:
- There are sometimes multiple orders happening for the same stock on the same minute candle (which I didn't know was possible). See orange and yellow rows.
- When the double orders on the same candle happen, the closing order for that position can sometimes be the matching quantity (look at index 16 and 17) or there can be multiple close orders on a single candle (see index 10-13).
It appears to be possible for these two behaviors to happen at the same time, creating index 16-17.
Validation of Issue:
I took a moment to consider what could cause the behavior we're seeing. The first thing that came to mind was "Maybe the orders aren't being filled for a minute or two."
I pulled all our orders from blotter, threw the csv in excel and cross sectioned the data to find the orders from previous image.
This provides the information needed to prove that quantrocket is sending multiple orders to the broker when the strange behavior takes place and that our orders are being filled when this multiple order behavior happens. The index column matches the index column from the previous image.
Recap:
The above behaviors shouldn't be possible what I understand about the features we're using. Quantrocket shouldn't be able to place multiple orders in one candle for the same stock and it shouldn't open continue to open/add to positions after 100 shares have been acquired (index 6-9).
I believe if we were able to get the above behaviors sorted, the order quantities being above 100 would resolve itself.
Please, correct my understanding if I am off base here. I am still not seeing any evidence of this being an issue within the strategy file itself.
Open to ideas!