@huskly/ibkr-client 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,6 +59,9 @@ Optional environment variables:
59
59
 
60
60
  ## Version 2 migration
61
61
 
62
+ Version 2.1.1 makes the four top-level `getAccountBalances()` amounts nullable. Missing, invalid, and
63
+ non-finite broker values are `null`, not a financial zero. Numeric zero remains `0`.
64
+
62
65
  Version 2.0.0 makes session and write safety evidence explicit:
63
66
 
64
67
  - Use `initializeBrokerageSession(...)` and the other explicit lifecycle methods instead of `init()`.
@@ -81,9 +84,11 @@ validated at runtime. Its broker-neutral account API includes:
81
84
  session's broker contract ID for exact follow-up reads. Account balances include typed
82
85
  `margin.total`, `margin.securities`, and `margin.commodities` snapshots with IBKR's available
83
86
  funds, buying power, excess liquidity, cushion, SMA, equity-with-loan, Reg-T, initial- and
84
- maintenance-margin, full, look-ahead, and leverage values. The client removes comma separators
85
- from numeric provider strings, such as day P/L field `78` and account summary amounts. Margin
86
- values are `null` when IBKR omits or returns an invalid value; numeric zero remains `0`.
87
+ maintenance-margin, full, look-ahead, and leverage values. The client removes valid comma
88
+ separators from numeric provider strings, such as day P/L field `78` and account summary amounts.
89
+ The top-level net liquidation, available funds, buying power, and cash balance values and all
90
+ margin values are `null` when IBKR omits or returns an invalid or non-finite value. Numeric zero
91
+ remains `0`.
87
92
  - `getAccountSettlementEvidence()` for one settled-cash observation of the account. It reads the
88
93
  same account summary endpoint as `getAccountBalances()` and returns the account id, one
89
94
  client-minted `observedAtEpochMillis`, and the `settledCash`, `availableFunds`, `totalCashValue`,
@@ -93,7 +98,7 @@ validated at runtime. Its broker-neutral account API includes:
93
98
  client never infers a currency and never defaults one to `"USD"`, and one missing field never
94
99
  makes the read throw. `presentSummaryFieldNames` lists the sorted key NAMES present in the
95
100
  summary response, names only and never values, so an operator can confirm the live schema
96
- without seeing amounts. This method is additive: `getAccountBalances()` is unchanged.
101
+ without seeing amounts. This method remains a separate read from `getAccountBalances()`.
97
102
  - `getQuotes()` and `searchInstruments()` for equity/ETF discovery and quotes. Quote requests accept
98
103
  a symbol and an optional broker ID. A broker ID reads that exact contract without symbol
99
104
  discovery. A request without one can also resolve a complete OSI option symbol without loading
@@ -1611,7 +1611,7 @@ export class IbkrClient {
1611
1611
  const summary = await this.req({
1612
1612
  path: `portfolio/${accountId}/summary`,
1613
1613
  });
1614
- const amount = (key) => toNumber(summary[key]?.amount);
1614
+ const amount = (key) => toNullableNumber(summary[key]?.amount);
1615
1615
  const marginSnapshot = (suffix) => ({
1616
1616
  equityWithLoanValue: toNullableNumber(summary[`equitywithloanvalue${suffix}`]?.amount),
1617
1617
  regTEquity: toNullableNumber(summary[`regtequity${suffix}`]?.amount),