Brokerage & trade history
Brokerage
The low-level brokerage gateway surface — a connect-once gateway that exposes optional data, trading and account sub-gateways — plus the broker DTOs and the trade-history store and backfill seam.
On this page
Gateways — TradeStrike.Pipeline.Brokerage
A broker plugin implements IBrokerageGateway and an IBrokerageGatewayFactory.
The gateway connects with BrokerCredentials and an AccountMode, advertises
BrokerCapabilities, and exposes whichever of the three sub-gateways it supports (the others are
null). The host adapts these DTOs into the higher-level trading
model.
| Type | Members |
|---|---|
IBrokerageGateway : IDisposable
|
string BrokerKey, BrokerCapabilities Capabilities, nullable IBrokerageDataGateway? Data, IBrokerageTradingGateway? Trading, IBrokerageAccountGateway? Account, BrokerConnectionStatus Status; event Action<BrokerConnectionStatus>? ConnectionStatusChanged; Task ConnectAsync(BrokerCredentials credentials, AccountMode mode, ct), Task DisconnectAsync(). |
IBrokerageGatewayFactory |
IBrokerageGateway Create(). |
IBrokerageDataGateway |
Task<IReadOnlyList<BrokerBar>> GetBarsAsync(string symbol, TimeSpan barInterval, DateTime fromUtc, DateTime toUtcExclusive, ct), IDisposable? SubscribeTrades(string symbol, Action<BrokerTrade> onTrade), Task<IReadOnlyList<BrokerInstrument>> GetInstrumentsAsync(ct), Task<string?> GetAdjustmentVersionAsync(string symbol, ct). |
IBrokerageTradingGateway |
Task<BrokerOrderAck> PlaceOrderAsync(BrokerOrderSpec, ct), Task<BrokerCancelAck> CancelOrderAsync(string accountId, string symbol, string venueOrderId, ct), Task<BrokerModifyAck> ModifyOrderAsync(BrokerModifySpec, ct), Task<bool> FlattenAsync(string accountId, string? symbol, ct), Task<BrokerSymbolRules?> GetSymbolRulesAsync(string symbol, ct), event Action<BrokerOrderUpdate>? OrderUpdated, event Action? StreamsReconnected, Task StartStreamsAsync(ct), Task StopStreamsAsync(), Task<IReadOnlyList<BrokerOrderUpdate>> GetOpenOrdersAsync(ct). |
IBrokerageAccountGateway |
Task<IReadOnlyList<BrokerAccount>> GetAccountsAsync(ct), Task<IReadOnlyList<BrokerPosition>> GetPositionsAsync(ct), Task<IReadOnlyList<AccountBalance>> GetBalancesAsync(string accountId, ct), event Action<BrokerAccount>? AccountUpdated, event Action<BrokerPosition>? PositionUpdated, event Action<string, IReadOnlyList<AccountBalance>>? BalancesUpdated. |
BrokerCapabilities |
[Flags] enum: None, HistoricalBars, LiveTrades, Instruments, PlaceOrders, CancelOrders, ModifyOrders, FlattenPositions, Brackets, Positions, Balances. |
BrokerConnectionStatus |
enum: Disconnected, Connecting, Connected, ConnectionLost. |
BrokerCredentials |
BrokerCredentials(IReadOnlyDictionary<string,string> values); static Empty, string? Get(string key), string Require(string key), bool Has(string key). |
Broker DTOs
| Type | Members |
|---|---|
BrokerAccount |
record: AccountId(string), DisplayName, Currency, CashValue, RealizedPnL, UnrealizedPnL, MarginUsed, BuyingPower, AccountMetrics? Metrics = null. |
BrokerPosition |
record: AccountId, Symbol, Quantity, AverageEntryPrice, LastPrice, UnrealizedPnL, Multiplier = 1m. |
BrokerInstrument |
record: Symbol, Description, TickSize, double? PointValue, QuantityUnit, LotSize?, QuantityStep?, MinQuantity?, QuoteCurrency?, AdjustmentVersion?, InstrumentCategory? Category. |
BrokerSymbolRules |
record: decimal? PriceStep, QuantityStep, MinQuantity, MaxQuantity, MinNotional; static None. |
BrokerTrade |
readonly record struct: string Symbol, double Price, double Size, DateTime TimestampUtc. |
BrokerBar |
readonly record struct: DateTime StartUtc, double Open/High/Low/Close, double Volume. |
Order specs & acks
Order verbs use venue-agnostic specs and return typed acks (success + venue order id / reject reason).
Order lifecycle is reported through BrokerOrderUpdate on the trading gateway's
OrderUpdated event.
| Type | Members |
|---|---|
BrokerOrderSpec |
record: AccountId, Symbol, OrderSide Side, OrderType Type, decimal Quantity, decimal? LimitPrice, decimal? StopPrice, TimeInForce, BracketSpec? Bracket, string ClientOrderId. |
BrokerOrderAck |
record: bool Success, string? VenueOrderId, string? RejectReason; static Accepted(venueOrderId), Rejected(reason). |
BrokerOrderUpdate |
record: AccountId, ClientOrderId, VenueOrderId, BrokerOrderStatus Status, FilledQuantity, AverageFillPrice, LastFillQuantity?, LastFillPrice?, LastFillCommission, RejectReason?, DateTime TimestampUtc. |
BrokerOrderStatus |
enum: Working, Filled, Cancelled, Rejected, Expired, Unknown. |
BrokerModifySpec |
record: AccountId, VenueOrderId, Symbol, decimal? NewQuantity, NewLimitPrice, NewStopPrice, TimeInForce? NewTimeInForce. |
BrokerModifyAck |
record: bool Success, string? FailureReason; static Ok, Failed(reason). |
BrokerCancelAck |
record: bool Success, string? FailureReason; static Ok, Failed(reason). |
Registration
Advertise a broker to the host with a BrokerRegistration — its display name, capabilities,
credential fields and the factory that builds the gateway.
| Type | Members |
|---|---|
BrokerRegistration |
record: string TypeId, string DisplayName, BrokerCapabilities Capabilities, bool SupportsPaper, bool HasOwnMarketData, bool ReportsCommission, IReadOnlyList<ProviderCredentialField> Credentials, IBrokerageGatewayFactory GatewayFactory. |
Trade history — TradeStrike.Pipeline.TradeHistory
A durable fill ledger. The host appends PersistedFills and queries them with a
TradeHistoryQuery; a broker may also implement ITradeHistoryBackfillSource to
import historical fills from the venue.
| Type | Members |
|---|---|
ITradeHistoryStore : IDisposable
|
void Append(PersistedFill fill), IReadOnlyList<PersistedFill> QueryFills(TradeHistoryQuery query), decimal RecordedQuantityForOrder(string orderId), IReadOnlyList<AccountId> KnownAccounts(), IReadOnlyList<string> KnownInstruments(), event Action? FillsChanged. |
ITradeHistoryBackfillSource |
Task BackfillAsync(AccountId account, DateTime sinceUtc, CancellationToken ct = default). |
PersistedFill |
record: AccountId Account, string Instrument, OrderSide Side, decimal Quantity, decimal Price, decimal Commission, DateTime TimestampUtc, string OrderId, string? BrokerOrderId, long Sequence, init Tag, FeeCurrency; string FillKey, void Validate(). |
TradeHistoryQuery |
record: DateTime? FromUtc, DateTime? ToUtc, IReadOnlyCollection<AccountId> Accounts, IReadOnlyCollection<string> Instruments; static All. |