Summary
updateAccountValue() stores account values keyed only by the tag name, ignoring the currency argument. IBKR sends many account-value tags (TotalCashValue, NetLiquidation, BuyingPower, …) once per currency plus a consolidated BASE line. Because the handler does values.set(key, val) without the currency, each currency's value for a given key overwrites the previous one — only the last-received currency survives. For multi-currency accounts this stores a non-base value for keys consumed as base-currency totals → incorrect account figures.
Location
services/uta/src/domain/trading/brokers/ibkr/request-bridge.ts:
override updateAccountValue(key: string, val: string, _currency: string, _accountName: string): void {
this.accountCachePending_?.values.set(key, val) // currency ignored → same-key overwrite
}
(accountSummary() likewise leaves _currency unused.) Then IbkrBroker.getAccount() reads values.get('TotalCashValue') / get('NetLiquidation') etc. as if they were base-currency totals.
Impact
- Accounts holding more than one currency (e.g. USD + HKD for HK equities) get an incorrect
totalCashValue and a derived netLiquidation that depends on IBKR's per-currency send order.
- USD-only accounts are unaffected (USD == BASE), so the bug stays hidden until a non-base currency appears.
Suggested fix
- Key account values by
(key, currency), or capture the BASE line specifically for consolidated totals (keep per-currency where needed).
getAccount() should read the BASE value for account-level totals.
Note
Found while debugging account balances on a USD-only IBKR paper account; not reproduced there by design (USD == BASE). Flagging the code path as currency-unsafe — it will bite any account that holds a non-base currency (e.g. HKD for HK stocks).
Summary
updateAccountValue()stores account values keyed only by the tag name, ignoring thecurrencyargument. IBKR sends many account-value tags (TotalCashValue,NetLiquidation,BuyingPower, …) once per currency plus a consolidatedBASEline. Because the handler doesvalues.set(key, val)without the currency, each currency's value for a given key overwrites the previous one — only the last-received currency survives. For multi-currency accounts this stores a non-base value for keys consumed as base-currency totals → incorrect account figures.Location
services/uta/src/domain/trading/brokers/ibkr/request-bridge.ts:(
accountSummary()likewise leaves_currencyunused.) ThenIbkrBroker.getAccount()readsvalues.get('TotalCashValue')/get('NetLiquidation')etc. as if they were base-currency totals.Impact
totalCashValueand a derivednetLiquidationthat depends on IBKR's per-currency send order.Suggested fix
(key, currency), or capture theBASEline specifically for consolidated totals (keep per-currency where needed).getAccount()should read theBASEvalue for account-level totals.Note
Found while debugging account balances on a USD-only IBKR paper account; not reproduced there by design (USD == BASE). Flagging the code path as currency-unsafe — it will bite any account that holds a non-base currency (e.g. HKD for HK stocks).