Skip to content

Combos

Describes github.com/stxapp/stx-go v0.3.1, the current release.

A combination is one market over two or more legs. As a player you ask for quotes on a set of legs and a stake; makers quote what you win; you accept, and the exchange places one ordinary order for each side on the combination’s market. Combos explains the product and Combo negotiation documents every command, push and refusal at the wire level. This page shows the SDK calls.

Both sides run on the socket, with an API key that has write access. client.Combos.Player and client.Combos.Maker each open a stream of their own; to share one socket with other subscriptions, call stream.ComboPlayer or stream.ComboMaker on a stream instead. Where the exchange does not offer combos, joining returns an error matching stx.ErrNotAvailable, and client.Combos.Available tells you before you try.

The values below were captured on US demo. The legs are two pre-match soccer markets, each to win: 29396ce5-a4f3-4d81-b980-2f637ab3a660 (GAL @ LILL, GAL in regulation) and 663ebfe6-26d5-45e0-a0ac-6859f7087832 (MAN @ COMO, MAN in regulation).

player, err := client.Combos.Player(ctx)
if err != nil {
log.Fatal(err)
}
defer player.Close()
fmt.Println(player.ExternalID()) // 9c87ec1c-588e-4512-9b91-d71653e41458
legs := []stx.ComboLeg{
{MarketID: "29396ce5-a4f3-4d81-b980-2f637ab3a660", Outcome: stx.ComboWon}, // GAL @ LILL: GAL
{MarketID: "663ebfe6-26d5-45e0-a0ac-6859f7087832", Outcome: stx.ComboWon}, // MAN @ COMO: MAN
}
req, err := player.RequestQuote(ctx, legs, stx.MustDecimal("5.00"))
if err != nil {
log.Fatal(err)
}
fmt.Println(req.RFQID) // 190058b7-ae66-4f6f-a30b-dc8951960d98

ExternalID is your pseudonym, which makers see on requests and quotes. Nobody sees a maker’s. The amount is your stake in dollars. A request lives 5 minutes, and it belongs to this player session: closing it, or a dropped socket, ends the request as canceled.

rfqID := "190058b7-ae66-4f6f-a30b-dc8951960d98" // req.RFQID, from RequestQuote
ev, err := player.WaitFor(ctx, stx.ComboWait{Events: []string{"best_quote"}, RFQID: rfqID})
if err != nil {
log.Fatal(err)
}
best := ev.Data.(*stx.ComboBestQuoteEvent)
fmt.Println(best.QuoteID, best.Amount) // 05308411-acfa-4b81-af8c-c390ad41a254 10.0000
placed, err := player.Accept(ctx, rfqID, best.QuoteID, best.Amount)
if err != nil {
log.Fatal(err)
}
fmt.Println(placed.MarketID, placed.Quantity, placed.Price, placed.OrderID)
// c5cde34a-d13c-4849-8135-8ed0baf70ccd 14.00 0.3334 fba8fd62-3389-4d3d-ac09-a0b383f6c11e

You only ever see the best amount, never who quoted it. Accept takes the least you will take, and binds the best live quote at that amount or more, whoever made it. The bind created the combination market c5cde34a-d13c-4849-8135-8ed0baf70ccd: the price is max_price × stake / (stake + win) = 5 / 15, rounded up to the tick, and the size is whole contracts, floor(5 / 0.3334) = 14. The reply says what was placed, not what filled; follow fills and positions on the account channels.

WaitFor also looks at events already received, so an event that arrived before you asked is not missed. player.Events() delivers every push as it arrives, and player.Snapshot(ctx, rfqID) reads a request’s live state at any moment.

Asking for more than anything live is refused with stx.ErrComboPriceMoved, and the request stays open. The error carries the live best quote, ready to accept again:

_, err := player.Accept(ctx, "190058b7-ae66-4f6f-a30b-dc8951960d98", "05308411-acfa-4b81-af8c-c390ad41a254", stx.MustDecimal("25.00"))
var refused *stx.ComboRefusedError
if errors.Is(err, stx.ErrComboPriceMoved) && errors.As(err, &refused) && refused.Best != nil {
fmt.Println(refused.Code, refused.Best.QuoteID, refused.Best.Amount)
// price_moved 05308411-acfa-4b81-af8c-c390ad41a254 10.0000
}
out, err := player.CashOut(ctx, "c5cde34a-d13c-4849-8135-8ed0baf70ccd")
if err != nil {
log.Fatal(err)
}
fmt.Println(out.RFQID, out.Quantity) // 7422de30-8cab-478e-b42c-612eeada2170 14.00
if err := player.Cancel(ctx, out.RFQID); err != nil {
log.Fatal(err)
}

A cash out is a new request with its own id. The exchange sets the size: what you hold less your resting sells. Makers quote what they pay for the whole size, and you accept the same way. A fill reaches your position a moment after the trade, so a cash out sent straight after buying can be refused with Code nothing_to_sell; retry it.

A maker session receives every request opened after it joins (rfq_opened) and quotes what the player wins:

maker, err := client.Combos.Maker(ctx)
if err != nil {
log.Fatal(err)
}
defer maker.Close()
for ev := range maker.Events() {
opened, ok := ev.Data.(*stx.ComboRFQOpenedEvent)
if !ok || opened.Side != "buy" {
continue
}
fmt.Println(opened.RFQID, opened.Amount, len(opened.Legs), opened.MaxPrice, opened.TickSize)
// 190058b7-ae66-4f6f-a30b-dc8951960d98 5.0000 2 1.0000 0.0001000
q, err := maker.Quote(ctx, stx.ComboQuoteRequest{
RFQID: opened.RFQID,
Amount: stx.MustDecimal("10.00"),
ExpiresIn: time.Minute,
ClientOrderID: "combo-quote-0001",
})
if err != nil {
log.Println("quote refused:", err)
continue
}
fmt.Println(q.QuoteID) // 05308411-acfa-4b81-af8c-c390ad41a254
}

On a buy Amount is the stake and MarketID is empty, because no combination market exists yet; on a cash out (Side sell) MarketID is the combination and Quantity the size. Price against MaxPrice and TickSize, never a constant. ClientOrderID is copied onto your order if the quote binds. maker.WithdrawQuote(ctx, rfqID, quoteID) takes a quote back; closing the session or losing the socket withdraws every quote it holds.

When your quote binds you get quote_accepted (*stx.ComboQuoteAcceptedEvent), then placed with your own order (*stx.ComboMakerPlacedEvent). A quote that loses gets negotiation_closed (*stx.ComboQuoteClosedEvent) with a reason such as placed_elsewhere, and every maker session gets rfq_closed when a request ends. A quote_accepted is not a promise: if the player’s order is refused, negotiation_closed follows instead of placed. A complete maker that quotes until stopped is in the example programs.

Every refusal is a *stx.ComboRefusedError with the command, the exchange’s reason in Code (such as not_found, unknown_quote, leg_not_quotable or price_moved) and, for a refused order, the order’s reason in Detail (for example player_refused with nothing_to_sell or insufficient_assets). The full list is in Combo negotiation.

STX is operated by XV Exchange, LLC, a Designated Contract Market regulated by the U.S. Commodity Futures Trading Commission (CFTC). Contracts traded on STX are cleared by XV Clearing, LLC, a CFTC-registered Derivatives Clearing Organization. Trading involves substantial risk of loss and may not be appropriate for everyone. Members risk losing the cost to enter any transaction, including fees. Consider whether trading is appropriate for you in light of your experience and financial resources. Nothing on this site is investment advice or a recommendation to trade. Past performance is not indicative of future results.

© 2026 STX. All rights reserved.llms.txtllms-full.txtView as Markdown
Docs version v1.10.5