Lean.Brokerages.InteractiveBrokers
Lean.Brokerages.InteractiveBrokers copied to clipboard
Incorrect Cash Balance when Account is enrolled for Insured Bank Deposit Sweep Program
In the documentation, it's mentioned that IB accounts enrolled in the Insured Bank Deposit Sweep Program (IBDSP) are not supported.
Quote:
"Insured Bank Deposit Sweep Program LEAN doesn't support IB accounts in the Insured Bank Deposit Sweep Program because when LEAN reads your account balances, it includes cash that's in the FDIC Sweep Account Cash, which isn't tradable. For example, if your account has $150K USD of cash, only $100K may be available to trade if $50K is in FDIC Sweep Account Cash. To opt out of the program, see Insured Bank Deposit Sweep Program."
However, the issue isn't that the amount reserved for the IBDSP isn't available for trading. IB treats it internally equivalent to cash. Only withdrawals may take an extra business day. So it shouldn't affect the cash balances in LEAN.
The real issue is that LEAN double counts this amount, which results in an inflated value shown in the CashBook.
I noticed that the value displayed in LEAN's CashBook matches the actual IB cash balance plus the amount reserved for IBDSP on the previous day. The latter is already included in the IB cash amount, so LEAN ends up counting it twice.
It seems this might be related to the timing of when certain account data gets updated and when LEAN performs the cash sync, which causes these inconsistencies.
As a result, position sizes end up being about 10-15% larger than they should be.
I also have a few data extracts that could be helpful, but I can't share them publicly here. I'll send them to the QC support team directly.
I'd really appreciate it if you could look into this issue and fix the bug. Thanks!
We've recently check this and IB is reporting double the amount of cash, that's why we've documented users are required to opt out of the program. We did review the account data that IB is providing and it didn't seem possible to recover the correct balance
Hi @Martin-Molinero, I've received the following response from IB:
Apparently, there are other account value keys (like SettledCash and TotalCashValue) that provide a more accurate representation of cash/NLV and enables a better handling of IBDSP activity.
Could you please consider them and check whether it helps to solve this issue?