Live accounts vs. Paper account: Margin concerns

If you have a 4x margin account with IB and have your algorithm set to utilize only 2x margin can you effectively use 2x your initial capital without an error?  My paper trade account doesn't seem to have the capacity for margin as my order was invalid after trying to use 1.1x account value.  I'm concerned this will happen in live trading as well despite the copious margin I've been provided. 

On the side, is my logic correct that I will never use the entire amount of margin provided by setting the algorithm to use a maximum margin amount of 2x when in reality I have 4x? (essentially I never want to use the entirety of the margin allowed, but do wish to utilize up to 2x under special cirumstances)

Thank you for your assistance. 

Update Backtest

The default margin model is SecurityMarginModel with the default leverage 2X for equity. 

We also provide the PatternDayTradingMarginModel to model intraday pattern day trading for US equities which provides 4x intraday leverage and 2x overnight leverage. Please see the documentation[symbol].MarginModel = PatternDayTradingMarginModel()

You can also set the leverage in your algorithm manually for example


Thank you for the fast response.  I've set my universe leverage to 2 using the following syntax in my initialize:


    def Initialize(self):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
        # Chart - Master Container for the Chart:
        stockPlot = Chart("Trade Plot")
        self.UniverseSettings.Resolution = Resolution.Daily
        self.UniverseSettings.Leverage = 2


This works fine when backtesting and I don't receive any order execution errors over the multiyear backtest.  However, I'm connected to live trade against my IB paper account and today an order was invalid due to not having enough equity.  Among all positions the account would have been invested at 1.1x leverage.  Is this a problem caused by the paper account being a "cash" account and not a "margin" account? And so the algorithm is functioning with the rule that it is allowed 2x initial investment but the paper account doesn't actually allow that? 


You should have a margin paper account to trade the assets with leverage in paper live trading. If you have a cash account, you need to set the brokerage model with the cash account type in the algorithm

self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Cash)

Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed