Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
IB Live Trading - All orders getting rejected

I recently started Live Trading with my IB account and so far all of my open orders have been almost immediately rejected with the following error message:

"Cash available (settled cash):[my available cash];Cash needed for this order and other pending orders: [a number greater than my available cash, different for each rejected order]"

I have no idea why this is happening, as everything ran smoothly when I used the same algorithm with my IB Paper Trading account. My algorithm goes through rounds of 10 candidates and opens limit orders for each. After a certain amount of time, the open orders that have yet to be filled are cancelled and new ones are created (I haven't gotten to this stage in live trading because all of the ones from the first round are rejected so quickly. None have been filled so far). Even if all of the open orders were filled at once (extraordinarily unlikely), I'd still have ~30% of my portfolio available as cash.

Any help would be greatly appreciated.
~Sam

4 responses

record(Settled = context.account.settled_cash) for the real account, that value will only be relevant in real trading. (Maybe always the same as context.portfolio.cash in backtest and paper). Try order_value against settled_cash.

Do you have a Cash acocunt or a Margin account and what type of margin? If you have a cash account you have to want 3 days (T+3). I solve that with statements like this:


    for i in range(2, 21, 5):  
        schedule_function(define_weights, date_rules.month_start(i), time_rules.market_open(minutes=64))  
        schedule_function(trade_sell, date_rules.month_start(i), time_rules.market_open(minutes=65))  
        schedule_function(define_weights, date_rules.month_start(i+3), time_rules.market_open(minutes=65))  
        schedule_function(trade_buy, date_rules.month_start(i+3), time_rules.market_open(minutes=66)) 

Hi Blue,
Right now I'm using context.account.settled_cash to track cash, but I think I'll try switching over to order_value (I'm using the standard order method now) and see if that changes anything.

Hi Peter,
I have a cash account, but I was under the impression that using settled_cash took care of the potential T+3 issue. Has your experience shown otherwise?

The first round of orders today were all rejected with the same error message, but after that everything worked properly. I have no idea what happened (I didn't stop the algorithm and redeploy or anything), but I appreciate the advice nonetheless.