QuantRocket

Calculating order quantity vs. currently held positions


#1

Hi, is this true that:

(1) the function target_weights_to_positions should output the % of the allocated portfolio the strategy should be held, and

(2) QuantRocket automatically calculates the required order quantity by substracting current positions from this target quantity?

The user guide says so, but I am not sure if this applies to intraday strategies, as, when I review the blotter orders, all my intraday strategies place orders equal to the target quantity, on top of the existing position (i.e. not substracting the current position).


#2

(1) signals_to_target_weights should allocate the desired position weights as a percentage of allocated capital. (target_weights_to_positions only runs in backtests, to simulate fills; in live trading, target weights are used to create orders which are sent to the broker and thereby become positions.)

(2) Correct. In addition to existing positions, Moonshot also takes account of any open orders. So, target quantity - existing position quantity - existing order quantity = order quantity.

This applies to end of day and intraday strategies alike. The relevant Moonshot code is here.


#3

Great, thank you.
So QuantRocket adjusts target quantities based on both existing positions and open orders? The code seems to indicate this.
My intraday strategy places an order every 10mins and there were some unfilled open orders (due to IB unable to locate borrow) when the next order was placed.
I suspected this might have caused the issue, but it seems the relevant Moonshot code may already take this into account, so wanted to double confirm.


#4

Yes, that’s correct.