Skip to content

Combos

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

type CombosService struct {
// contains filtered or unexported fields
}

CombosService trades combos: requests for quote as a player (taker), and quotes as a maker. Use it through Client.Combos. Its Player and Maker open a stream of their own; to share one socket with other subscriptions, use Stream.ComboPlayer and Stream.ComboMaker.

Where an exchange does not offer combos, joining returns an error matching ErrNotAvailable.

func (s *CombosService) Available(ctx context.Context) (bool, error)

Available reports whether this exchange offers combos, by joining a player topic nobody owns: the exchange answers “unmatched topic” where it has no combos, and refuses the join for another reason where it does. Nothing is created.

func (s *CombosService) Maker(ctx context.Context, opts ...StreamOption) (*ComboMaker, error)

Maker opens a stream and joins the maker topic. Closing the maker closes that stream.

func (s *CombosService) Player(ctx context.Context, opts ...StreamOption) (*ComboPlayer, error)

Player opens a stream and joins the player topic. Closing the player closes that stream.

type ComboBestQuote struct {
QuoteID string `json:"quote_id"`
Amount Decimal `json:"amount"`
ExpiresAt int64 `json:"expires_at"`
}

ComboBestQuote is the best live quote. Every field is empty when nothing is live. ExpiresAt is in Unix microseconds.

type ComboBestQuoteEvent struct {
RFQID string `json:"rfq_id"`
MarketID string `json:"market_id"`
ComboBestQuote
}

ComboBestQuoteEvent is “best_quote” to the player: the best quote changed.

type ComboCashOut struct {
RFQID string `json:"rfq_id"`
// MarketID is the combination being sold.
MarketID string `json:"market_id"`
// Quantity is set by the exchange: what you hold less your resting sells.
Quantity Decimal `json:"quantity"`
}

ComboCashOut is the reply to ComboPlayer.CashOut.

type ComboEvent struct {
// Event is the event name, for example "best_quote" or "rfq_opened".
Event string
// RFQID is the request it is about; QuoteID the quote, on maker events
// that name one.
RFQID string
QuoteID string
Payload json.RawMessage
// Data is the typed payload. To the player: *ComboBestQuoteEvent,
// *ComboPlacedEvent or *ComboRequestClosedEvent. To the maker:
// *ComboRFQOpenedEvent, *ComboRFQClosedEvent, *ComboQuoteAcceptedEvent,
// *ComboMakerPlacedEvent or *ComboQuoteClosedEvent.
Data any
}

ComboEvent is one push on a combo topic.

type ComboLeg struct {
MarketID string `json:"market_id"`
Outcome ComboOutcome `json:"outcome"`
}

ComboLeg is one leg of a quote request: an open, ordinary market and the outcome the combination needs of it.

type ComboMaker struct {
// contains filtered or unexported fields
}

ComboMaker is the maker’s side of combos, on combo_quote:<user_id>. Get one with Stream.ComboMaker. Joining subscribes to every request opened from then on (“rfq_opened”); earlier requests are not replayed.

A quote belongs to this topic: closing it or a dropped socket withdraws it. Every refusal is a *ComboRefusedError with the exchange’s reason in Code.

func (m *ComboMaker) Close() error

Close leaves the topic, which withdraws every quote placed on it.

func (m *ComboMaker) Done() <-chan struct{}

Done is closed when the maker ends.

func (m *ComboMaker) Err() error

Err returns why the maker ended, like Subscription.Err.

func (m *ComboMaker) Events() <-chan ComboEvent

Events returns the channel typed events arrive on, closed when the maker ends.

func (m *ComboMaker) ExternalID() string

ExternalID returns your pseudonym. Makers’ pseudonyms are shown to no one.

func (m *ComboMaker) History() []ComboEvent

History returns the events received so far (the latest 1000), oldest first.

func (m *ComboMaker) Quote(ctx context.Context, q ComboQuoteRequest) (ComboQuote, error)

Quote offers an amount on a request. Price it against the request’s MaxPrice and TickSize.

func (m *ComboMaker) Topic() string

Topic returns the wire topic.

func (m *ComboMaker) WaitFor(ctx context.Context, w ComboWait) (ComboEvent, error)

WaitFor returns the first event that matches w, looking first at the events already received. It takes nothing from ComboMaker.Events.

func (m *ComboMaker) WithdrawQuote(ctx context.Context, rfqID, quoteID string) error

WithdrawQuote removes one of your quotes.

type ComboMakerPlacedEvent struct {
RFQID string `json:"rfq_id"`
MarketID string `json:"market_id"`
ExternalID string `json:"external_id"`
QuoteID string `json:"quote_id"`
OrderID string `json:"order_id"`
Quantity Decimal `json:"quantity"`
Price Decimal `json:"price"`
}

ComboMakerPlacedEvent is “placed” to the maker: the quote bound and your order was placed, at the same size and price as the player’s.

type ComboOutcome string

ComboOutcome is what the combination needs of a leg: “won” or “lost”.

const (
ComboWon ComboOutcome = "won"
ComboLost ComboOutcome = "lost"
)

The outcomes of a leg.

type ComboPlacedEvent struct {
RFQID string `json:"rfq_id"`
ComboPlacement
}

ComboPlacedEvent is “placed” to the player: the bind placed your order.

type ComboPlacement struct {
MarketID string `json:"market_id"`
OrderID string `json:"order_id"`
Quantity Decimal `json:"quantity"`
Price Decimal `json:"price"`
}

ComboPlacement is what an accept placed for you: your order on the combination’s market. Its fills arrive on the fills channel.

type ComboPlayer struct {
// contains filtered or unexported fields
}

ComboPlayer is the player’s side of combos, on rfq:<user_id>. Get one with Stream.ComboPlayer.

A request belongs to this topic: closing it or a dropped socket ends the request “cancelled”, and the stream’s rejoin does not bring it back. Every refusal is a *ComboRefusedError with the exchange’s reason in Code.

Example

Ask for quotes on a combination and accept the best one.

ctx := context.Background()
client, err := stx.New(stx.WithProfile("us-demo"))
if err != nil {
log.Fatal(err)
}
player, err := client.Combos.Player(ctx)
if err != nil {
log.Fatal(err)
}
defer player.Close()
req, err := player.RequestQuote(ctx, []stx.ComboLeg{
{MarketID: "71692895-2991-440b-923d-7dfb6783cb17", Outcome: stx.ComboWon},
{MarketID: "e00651a3-10cb-4bc1-9e1f-c5ea1796c83b", Outcome: stx.ComboWon},
}, "250.00")
if err != nil {
log.Fatal(err)
}
ev, err := player.WaitFor(ctx, stx.ComboWait{Events: []string{"best_quote"}, RFQID: req.RFQID})
if err != nil {
log.Fatal(err)
}
best := ev.Data.(*stx.ComboBestQuoteEvent)
placed, err := player.Accept(ctx, req.RFQID, best.QuoteID, best.Amount)
if err != nil {
log.Fatal(err)
}
fmt.Println(placed.MarketID, placed.Quantity, placed.Price)
func (p *ComboPlayer) Accept(ctx context.Context, rfqID, quoteID string, amount Decimal) (ComboPlacement, error)

Accept binds the request at amount or better, normally the amount “best_quote” showed; the best live quote binds, so the placement can be better than amount. It waits up to 35 seconds unless ctx ends first.

When nothing at least as good is live it returns a *ComboRefusedError matching ErrComboPriceMoved, with the live quote in Best; the request stays open and you can accept again. The reply says what was placed; fills arrive on the fills channel.

func (p *ComboPlayer) Cancel(ctx context.Context, rfqID string) error

Cancel ends the request and drops every quote on it.

func (p *ComboPlayer) CashOut(ctx context.Context, marketID string) (ComboCashOut, error)

CashOut asks makers to quote for what you hold of a combination, by the market id from “placed”. The exchange sets the size.

func (p *ComboPlayer) Close() error

Close leaves the topic. Every request still open on it ends “cancelled”. To see each request’s own close first, cancel it and wait for its “negotiation_closed” before closing.

func (p *ComboPlayer) Done() <-chan struct{}

Done is closed when the player ends.

func (p *ComboPlayer) Err() error

Err returns why the player ended, like Subscription.Err.

func (p *ComboPlayer) Events() <-chan ComboEvent

Events returns the channel typed events arrive on, closed when the player ends.

func (p *ComboPlayer) ExternalID() string

ExternalID returns your pseudonym, which makers see on your requests.

func (p *ComboPlayer) History() []ComboEvent

History returns the events received so far (the latest 1000), oldest first.

func (p *ComboPlayer) RequestQuote(ctx context.Context, legs []ComboLeg, amount Decimal) (ComboRequest, error)

RequestQuote asks makers to quote on these legs for a stake in dollars, such as “250.00” (whole cents). Makers quote what you win; quotes arrive as “best_quote” events.

func (p *ComboPlayer) Snapshot(ctx context.Context, rfqID string) (ComboSnapshot, error)

Snapshot returns the request now, with the live best quote.

func (p *ComboPlayer) Topic() string

Topic returns the wire topic.

func (p *ComboPlayer) WaitFor(ctx context.Context, w ComboWait) (ComboEvent, error)

WaitFor returns the first event that matches w, looking first at the events already received. It takes nothing from ComboPlayer.Events.

type ComboQuote struct {
QuoteID string `json:"quote_id"`
Amount Decimal `json:"amount"`
// ExternalID is the player's pseudonym.
ExternalID string `json:"external_id"`
}

ComboQuote is the reply to ComboMaker.Quote. It carries no price or size: the bind sets those.

type ComboQuoteAcceptedEvent struct {
RFQID string `json:"rfq_id"`
MarketID string `json:"market_id"`
ExternalID string `json:"external_id"`
QuoteID string `json:"quote_id"`
}

ComboQuoteAcceptedEvent is “quote_accepted” to the maker: this quote is about to be bound.

type ComboQuoteClosedEvent struct {
RFQID string `json:"rfq_id"`
MarketID string `json:"market_id"`
ExternalID string `json:"external_id"`
QuoteID string `json:"quote_id"`
Reason string `json:"reason"`
}

ComboQuoteClosedEvent is “negotiation_closed” to the maker: this quote stopped standing. Reason is “placed_elsewhere”, “maker_refused”, “cancelled”, “expired”, “leg_not_quotable”, “unknown_leg” or “player_refused”.

type ComboQuoteRequest struct {
// RFQID is the request, from "rfq_opened".
RFQID string
// Amount, in dollars: on a buy what the player wins, on a cash out what
// you pay for the whole size.
Amount Decimal
// ExpiresIn is how long the quote stands, counted from receipt, in whole
// milliseconds. The quote ends no later than its request.
ExpiresIn time.Duration
// ClientOrderID (at most 255 bytes) is copied onto your order if the
// quote binds.
ClientOrderID string
}

ComboQuoteRequest is a maker’s quote.

type ComboRFQClosedEvent struct {
RFQID string `json:"rfq_id"`
MarketID string `json:"market_id"`
Reason string `json:"reason"`
}

ComboRFQClosedEvent is “rfq_closed” to makers: a request ended. Reason is “placed”, “cancelled”, “expired”, “leg_not_quotable”, “unknown_leg”, “player_refused”, “maker_refused” or “ended”.

type ComboRFQLeg struct {
MarketID string `json:"market_id"`
Outcome ComboOutcome `json:"outcome"`
ShortName string `json:"short_name"`
}

ComboRFQLeg is one leg as makers see it. ShortName is the leg market’s display name, when the exchange has one.

type ComboRFQOpenedEvent struct {
RFQID string `json:"rfq_id"`
// MarketID is empty on a buy and the combination on a cash out.
MarketID string `json:"market_id"`
// ExternalID is the player's pseudonym.
ExternalID string `json:"external_id"`
// Side is the player's side; you take the other.
Side string `json:"side"`
Amount Decimal `json:"amount"`
Quantity Decimal `json:"quantity"`
MaxPrice Decimal `json:"max_price"`
TickSize Decimal `json:"tick_size"`
ExpiresAt int64 `json:"expires_at"`
Legs []ComboRFQLeg `json:"legs"`
}

ComboRFQOpenedEvent is “rfq_opened” to makers: a player opened a request. Price it against MaxPrice and TickSize, not constants.

type ComboRequest struct {
RFQID string `json:"rfq_id"`
}

ComboRequest is the reply to ComboPlayer.RequestQuote.

type ComboRequestClosedEvent struct {
RFQID string `json:"rfq_id"`
MarketID string `json:"market_id"`
Reason string `json:"reason"`
}

ComboRequestClosedEvent is “negotiation_closed” to the player: the request ended without placing. Reason is “cancelled”, “expired”, “leg_not_quotable”, “unknown_leg”, “player_refused” or “maker_refused”.

type ComboSnapshot struct {
RFQID string `json:"rfq_id"`
// MarketID is empty on a buy until a bind places, and the combination on
// a cash out.
MarketID string `json:"market_id"`
// Status is "open", or "binding" while an acceptance waits for its next
// bind attempt.
Status string `json:"status"`
// Side is "buy" for a request, "sell" for a cash out.
Side string `json:"side"`
// Amount is the stake on a buy; Quantity the size on a cash out.
Amount Decimal `json:"amount"`
Quantity Decimal `json:"quantity"`
ExpiresAt int64 `json:"expires_at"`
BestQuote ComboBestQuote `json:"best_quote"`
}

ComboSnapshot is the reply to ComboPlayer.Snapshot: the request now.

type ComboWait struct {
// Events are the event names to match, for example "best_quote".
Events []string
RFQID string
QuoteID string
}

ComboWait selects the event ComboPlayer.WaitFor and ComboMaker.WaitFor wait for. Empty fields match anything.

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