Connections: accounts & balances
Accounts & balances
How accounts are identified across providers and modes, and how a trading provider reports cash (futures) versus per-asset wallets (crypto).
Identifying an account
Accounts come from many providers and exist in several modes, so the platform identifies each one with
a composite key, AccountId. It has three parts, and all three participate in equality and
hashing so the trading service can index accounts with no ambiguity — the same broker account
number used in both live and paper does not alias, because the mode differs.
contractpublic readonly record struct AccountId(
string ProviderKey, // which provider hosts it: "rithmic", "binance", "sim"
string ProviderAccountId, // the provider's own id (account number, sub-account, slot)
AccountMode Mode); // Live / Paper / Sim
The ProviderKey ties an account back to the connection that hosts it — it matches the
provider's ProviderKey and the connection's key. Every order operation takes an
AccountId, which is how PlaceAsync
routes a request to the right provider. AccountId renders to a stable
"providerKey/accountId/mode" string (with a matching TryParse) so a chart's
selected account survives a workspace save and restart.
The Account snapshot
An Account is the financial snapshot a provider streams through
AccountSnapshotEvent. It carries the figures a trader and a risk system need, and exposes
a couple of derived conveniences.
Accountpublic sealed record Account(
AccountId Id, string DisplayName, string Currency,
decimal CashValue, decimal RealizedPnL, decimal UnrealizedPnL,
decimal MarginUsed, decimal BuyingPower, DateTime UpdatedUtc)
{
public AccountMode Mode => Id.Mode;
public decimal Equity => CashValue + UnrealizedPnL;
}
Per-asset balances (crypto)
A futures account has a single cash figure, captured by Account.CashValue. A crypto-spot
account instead holds many assets at once — BTC, ETH, USDT — so cash alone cannot describe it.
Providers that declare the AssetBalances capability stream a
BalanceSnapshotEvent carrying the full set of non-zero balances, each an
AccountBalance. Futures providers simply never declare that capability and never emit it.
AccountBalancepublic sealed record AccountBalance // build via AccountBalance.Create(asset, total, available)
{
public string Asset { get; } // upper-cased: "BTC", "USDT"
public decimal Total { get; } // available + reserved
public decimal Available { get; } // free to spend now
public decimal Reserved => Total - Available; // locked in working orders (derived)
}
Reserved is always derived as Total − Available rather than set
independently, so the three figures can never drift apart. Use the Create factory, which
trims and upper-cases the asset symbol and validates that none of the figures is negative and that
available never exceeds total.
Account modes
AccountMode distinguishes Live, Paper and Sim. It is
part of the identity (see above) and is surfaced on Account.Mode, so the UI can badge an
account and a risk system can apply different limits to live versus simulated trading.
Account, AccountId,
AccountBalance and the order/position records all live in the
TradeStrike.Pipeline.Trading namespace and are catalogued in the
Trading reference. The strategy API consumes the same types from the
other side — see Strategies → Bars & position state.
End of the connections chapter
That covers a connection end to end: discovery, the data provider (backfill, ticks, depth, metadata) and the trading provider (orders, fills, positions, accounts and balances, all via one event stream). For the exact signatures of every type, continue to the reference.