Account NLV is 53k, but is holding 68k (15k margin). Long-only.
Hypothesis: Rounding inside order_stubs_to_orders
is causing this.
All tickers hold excess positions, but example given is AAPL.
AAPL held via blotter & broker: 29 shares
. Moonshot calculations say it should hold ~20 shares
.
There are no pending/cancelled/submitted orders.
Calculation:
Account NLV: 53k
Target Weight: 0.055556
Algo allocation: 1.0
Trade Value: NLV * Weight: 53k * 0.055555 = $2944.44444
Price of Security: $142.00
Target Quantity: $2944.44444 / 142.00 = 20.73 shares
You can see in a moonshot dev the target-weights check out; 18 signals ~ 0.055556.
.
Positions just copy target weights: positions = target_weights.copy()
Based on the position size of 29, reverse engineering would say the target weight given by order_stubs_to_orders is:
29 shares * $142 = $4118.
$4118/53k = 0.0777 target weight.
Are there rounding functions being applied inside order_stubs_to_orders
causing this?
I've had this algo dip margin minimally in the past, +-4% in order to maintain an equal-weighted portfolio self.allocate_equal_weights()
, but 30% margin is excessive.