Is CalculateOrderQuantity supposed to work with futures contracts? I've tried using it:

quantity = self.CalculateOrderQuantity(sym, pos_pct)

self.MarketOrder(sym, quantity)

But I consistently see errors like:

r: 2020-03-25 00:00:00
Order Error: id: 32, Insufficient buying power to complete order (Value:42777.7), Reason: Id: 32, Initial Margin: 42777.7, Free Margin: 42000.94

What causes the discrepancy? Or is this API even meant to be used with futures contracts?

 

Author