Could anyone out there please help me to understand why I’m getting order rejection errors from IB on certain days?
As background, my algo is set up to trade once per day, one minute after market open. The relevant order execution code looks like this:
(Various criteria in code to determine what value is stored in variable name ‘buy_mode’, which determines whether I will place an order for asset1 or sell my holdings in asset1 and switch to asset2 or vice versa.)
if buy_mode == 3:
if buy_mode == 2:
When I receive the error in my live trading dashboard, for example, it shows that I sold all of the shares of asset2 successfully, but that my order of 100% of my portfolio value for asset1 securities was rejected. It says that, "Your order is not accepted because your Equity with Loan Value of [8631 USD] is insufficient to cover the Initial Margin requirement of [11062 USD]."
This order rejection error keeps on happening every few days and I have to restart the algo. I called IB and they basically just told me that because it is a market order, they don’t know what price I would get filled at ultimately, so I need to have more cash in my account. So, needless to say, this explanation doesn’t really help me if I want to be able to place orders for 100% of my portfolio value. Note that I have also run into this issue at order_target_percent levels less than 1.0 (e.g., at 0.9, 0.8, 0.7). I’m pretty sure the orders would sail through every day with no problem if I set the order_target_percent at 0.5...maybe? However, I don’t particularly want to leave half of my portfolio in cash every day…
By the way, my algo trades fine in backtests with no issues whatsoever, and it worked fine for a few days of live-trading at a time, so I'm trying to understand how I can resolve this issue.
Has anyone else encountered this kind of problem?