Skip to content

Create markets

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

An app that STX has granted the markets.write scope can create player-prop markets on scheduled events, from an address on its IP allow-list. Creating markets covers the setup and the full list of outcomes; this page shows the SDK calls. Where the exchange does not offer it yet, Markets.Create, Markets.Types and Events.Players return an error matching stx.ErrNotAvailable; see What you can do.

The calls run as your app, on an app token from the oauth package:

package main
import (
"context"
"fmt"
"log"
"os"
stx "github.com/stxapp/stx-go"
"github.com/stxapp/stx-go/oauth"
)
func main() {
ctx := context.Background()
app, err := oauth.New(oauth.Config{
BaseURL: "demo.stxapp.io",
ClientID: os.Getenv("STX_OAUTH_CLIENT_ID"),
ClientSecret: os.Getenv("STX_OAUTH_CLIENT_SECRET"),
})
if err != nil {
log.Fatal(err)
}
client, err := app.AppClient([]string{oauth.ScopeEvents, oauth.ScopeMarketsWrite})
if err != nil {
log.Fatal(err)
}
eventID := "24636b3d-f566-4dd3-8c8b-c1a6c2747789"
roster, err := client.Events.Players(ctx, eventID)
if err != nil {
log.Fatal(err)
}
player := roster.Teams[0].Players[0]
fmt.Println(player.PlayerID, player.Name, player.Jersey, player.Position)
// 3895074 Connor McDavid 97 C
markets := []stx.NewMarket{{PlayerID: player.PlayerID, Stat: "GOAL_SO", Line: 3.5}}
// Check first: every check runs on STX and nothing is created.
checked, err := client.Markets.Create(ctx, eventID, markets, &stx.CreateMarketsOptions{DryRun: true})
if err != nil {
log.Fatal(err)
}
for _, r := range checked {
if r.Status != stx.MarketValid && r.Status != stx.MarketExists {
log.Fatalf("market %d: %s", r.Index, r.Reason)
}
}
results, err := client.Markets.Create(ctx, eventID, markets, nil)
if err != nil {
log.Fatal(err)
}
for _, r := range results {
fmt.Println(r.Status, r.MarketID)
}
// created 2a473aeb-10de-47e4-a7ce-dbb771094d84
}
  • Lines must be positive and end in .5: 3.5 is accepted; 3, 3.25 and 0 come back rejected with invalid_line (stx.RejectInvalidLine).
  • Stats: an event accepts the stats Events.Players lists in Stats.
  • Results come back one per market, in order: stx.MarketCreated, stx.MarketExists (already listed, same MarketID), stx.MarketValid (with DryRun) or stx.MarketRejected with a Reason. Index is the market’s position in your list, and Market is the market as you asked for it. Resending is safe.
  • DryRun: true runs every check on STX and creates nothing.
  • Validate: true checks players, stats and lines before sending, and returns failures as rejected without a request. It reads the event’s players, so the token also needs events.
  • Up to stx.MaxMarketsPerRequest (25) markets per call.

Markets.Types lists every market type the exchange has, keyed by rule. A type with PartnerCreate set can be created with Markets.Create, and lists the fields an entry takes and the stats each event type offers. It changes only when STX adds a rule or a stat, so read it once.

types, err := client.Markets.Types(ctx)
if err != nil {
log.Fatal(err)
}
psl := types[stx.RulePlayerStatLine]
fmt.Println(len(types), psl.PartnerCreate, len(psl.EventTypes))
// 57 true 4

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