Use this file to discover all available pages before exploring further.
Trading in the SportsX SDK uses two services. STXOrderService handles order placement, cancellation, and order history. STXTradeService handles fills (trades). Both services support real-time counterparts via WebSocket channels for latency-sensitive workflows.
If you pass cancelOnDisconnect: true without having joined STXActiveOrdersChannel, the call throws STXCancelOnDisconnectNotEnabledException. For a market-maker workflow, join the channel before placing any orders:
var activeOrders = serviceProvider.GetRequiredService<STXActiveOrdersChannel>();await activeOrders.ConnectAsync();// Now cancelOnDisconnect: true is safe to usevar order = await orders.ConfirmOrderAsync( price: 45, quantity: 5, marketId: "mkt_abc", action: STXOrderAction.sell, orderType: STXOrderType.limit, cancelOnDisconnect: true);
If you only want a resting order that survives disconnects, pass cancelOnDisconnect: false.
Each matched order generates one or more trade records. Resolve STXTradeService to query them:
var trades = serviceProvider.GetRequiredService<STXTradeService>();// All fills, most recent firstvar allFills = await trades.GetMyTradesAsync( limit: 50, sortBy: STXTradesSortByField.time, sortOrder: STXSortOrder.desc);// Fills for a specific ordervar orderFills = await trades.GetMyTradesForOrderAsync(orderId);
The pattern below is adapted from cssdk-console’s STXWorker.cs. It shows the full lifecycle: connect channels, subscribe to price ticks, and requote on each tick:
// 1. Authenticate and connect channelsawait _login.LoginAsync(email, password, keepSessionAlive: true);await _ordersChannel.ConnectAsync();await _tradesChannel.ConnectAsync();await _portfolioChannel.ConnectAsync();// 2. Subscribe to market price ticks_marketChannel.OnPriceUpdate += OnPriceTick;await _marketChannel.ConnectAsync();await _marketChannel.SubscribeAsync("mkt_abc");// 3. Requote on each tickasync void OnPriceTick(STXMarketInfoChannelData tick){ // Cancel stale quotes and place fresh ones in one batch await _orderService.CancelAllOrdersAsync(); await _orderService.ConfirmOrdersAsync(BuildQuotes(tick));}
Cancel-on-disconnect, automatic JWT refresh, and portfolio-balance tracking are all handled by the registered SDK services — the loop above is the core of the app.