I’m trying to use half of my remaining margin to buy securities with a 2x leverage margin setup. My live account also provides 2x leverage, but both the simulation and live brokerage are returning incorrect values for remaining margin and buying power. I’m using an Alpaca margin account.

For example, with an initial cash balance of $100K, the remaining margin and buying power should be $200K. However, both self.portfolio.get_buying_power(s.symbol, OrderDirection.BUY) and self.portfolio.margin_remaining return only $100K.

Am I missing something here? I’ve attached sample code to verify the margin calculation. Thank you for your help.