Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Buying power (Interactive Brokers)

Hi there, I am having trouble controlling leverage in the backtest and live trading since
context.account.buying_power (IB: BuyingPower) for IB Margin Account = Available Funds * 4. But the backtest value buying_power is set to infinity.
I have been trying something like this:

    net_liquid=context.portfolio.portfolio_value  
    buying_power=context.account.available_funds*4  
    leverage= (buying_power/(net_liquid))  
    order_target_percent(sec, leverage)

But the result is different. I am wondering if anyone has any suggestions?

1 response

I think this is firstly due to what type of margin account you have. Do you have a portfolio margin account or a regular T margin?
Secondly, IB usually have different standards for different account types, for instance they will treat a proprietary group differently from and individual investor.
Third and last. I think you are required to exceed a certain set amount in net liquidity before you are eligible for using their full margin perks. If I remember correctly they set out something like a 100,000.00$ but I'm not entirely sure.
I hope something in this post is of value to you.

Best,
Carl