stake

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package stake provides an idiomatic Go HTTP client for Stake's unofficial API.

Create a client with a session token or credentials, then use the typed NYSE and ASX service groups:

client, err := stake.NewClient(stake.WithSessionToken(token))
positions, err := client.NYSE.Equities.List(ctx)
orders, err := client.ASX.Orders.List(ctx)

Methods accept context.Context, use net/http, and return typed values plus errors.

Index

Constants

View Source
const StakeURL = "https://api2.prd.hellostake.com/"

Variables

View Source
var (
	NYSE = NYSEEndpoints{
		StakeURL:            StakeURL,
		AccountBalance:      "https://api2.prd.hellostake.com/api/cma/getAccountBalance",
		AccountTransactions: "https://api2.prd.hellostake.com/api/users/accounts/accountTransactions",
		Brokerage:           "https://api2.prd.hellostake.com/api/orders/brokerage?orderAmount={orderAmount}",
		CancelOrder:         "https://api2.prd.hellostake.com/api/orders/cancelOrder/{orderId}",
		CashAvailable:       "https://api2.prd.hellostake.com/api/users/accounts/cashAvailableForWithdrawal",
		CreateSession:       "https://api2.prd.hellostake.com/api/sessions/v2/createSession",
		EquityPositions:     "https://api2.prd.hellostake.com/api/users/accounts/v2/equityPositions",
		FundDetails:         "https://api2.prd.hellostake.com/api/fund/details",
		MarketDataQuote:     "https://api.prd.hellostake.com/us/pricing/quotes/marketData",
		MarketStatus:        "https://api2.prd.hellostake.com/api/utils/marketStatus",
		Orders:              "https://api2.prd.hellostake.com/api/users/accounts/v2/orders",
		ProductsSuggestions: "https://api2.prd.hellostake.com/api/products/getProductSuggestions/{keyword}",
		QuickBuy:            "https://api2.prd.hellostake.com/api/purchaseorders/v2/quickBuy",
		Quotes:              "https://api2.prd.hellostake.com/api/quotes/marketData/{symbols}",
		Rate:                "https://api2.prd.hellostake.com/api/wallet/rate",
		Ratings:             "https://api2.prd.hellostake.com/api/data/calendar/ratings?tickers={symbols}&pageSize={limit}",
		SellOrders:          "https://api2.prd.hellostake.com/api/sellorders",
		Symbol:              "https://api2.prd.hellostake.com/api/products/searchProduct?symbol={symbol}&page=1&max=1",
		TransactionHistory:  "https://api2.prd.hellostake.com/api/users/accounts/transactionHistory",
		TransactionDetails:  "https://api2.prd.hellostake.com/api/users/accounts/transactionDetails?reference={reference}&referenceType={reference_type}",
		Transactions:        "https://api2.prd.hellostake.com/api/users/accounts/transactions",
		Users:               "https://api2.prd.hellostake.com/api/user",
		Watchlists:          "https://api2.prd.hellostake.com/us/instrument/watchlists",
		CreateWatchlist:     "https://api2.prd.hellostake.com/us/instrument/watchlist",
		ReadWatchlist:       "https://api2.prd.hellostake.com/us/instrument/watchlist/{watchlist_id}",
		UpdateWatchlist:     "https://api2.prd.hellostake.com/us/instrument/watchlist/{watchlist_id}/items",
		Statement:           "https://api2.prd.hellostake.com/api/data/fundamentals/{symbol}/statements?startDate={date}",
	}

	ASX = ASXEndpoints{
		StakeURL:             StakeURL,
		Brokerage:            "https://api2.prd.hellostake.com/api/asx/orders/brokerage?orderAmount={orderAmount}",
		CashAvailable:        "https://api2.prd.hellostake.com/api/asx/cash",
		CancelOrder:          "https://api2.prd.hellostake.com/api/asx/orders/{orderId}/cancel",
		EquityPositions:      "https://api2.prd.hellostake.com/api/asx/instrument/equityPositions",
		MarketStatus:         "https://api2.prd.hellostake.com/api/asx/instrument/quoteTwo/ASX",
		AggregatedDepth:      "https://api2.prd.hellostake.com/api/asx/instrument/aggregatedDepth/{symbol}?type=EQUITY",
		CourseOfSales:        "https://api2.prd.hellostake.com/api/asx/instrument/courseOfSales/{symbol}",
		Orders:               "https://api2.prd.hellostake.com/api/asx/orders",
		ProductsSuggestions:  "https://api2.prd.hellostake.com/api/asx/instrument/search?searchKey={keyword}",
		Symbol:               "https://api2.prd.hellostake.com/api/asx/instrument/singleQuote/{symbol}",
		TradeActivity:        "https://api2.prd.hellostake.com/api/asx/orders/tradeActivity",
		Watchlists:           "https://api2.prd.hellostake.com/api/asx/instrument/v2/watchlists",
		CreateWatchlist:      "https://api2.prd.hellostake.com/api/asx/instrument/v2/watchlist",
		ReadWatchlist:        "https://api2.prd.hellostake.com/api/asx/instrument/v2/watchlist/{watchlist_id}",
		UpdateWatchlist:      "https://api2.prd.hellostake.com/api/asx/instrument/v2/watchlist/{watchlist_id}/items",
		InstrumentFromSymbol: "https://api2.prd.hellostake.com/api/asx/instrument/view/{symbol}",
		Transactions:         "https://api2.prd.hellostake.com/api/asx/transactions",
		Users:                "https://api2.prd.hellostake.com/api/user",
	}
)
View Source
var (
	// ErrInvalidLogin is returned when credentials or a session token are rejected.
	ErrInvalidLogin = errors.New("stake: invalid login")
	// ErrMissingSessionToken is returned when token-based login has no token.
	ErrMissingSessionToken = errors.New("stake: missing session token")
	// ErrUnsupportedExchange is returned when an operation is unavailable for an exchange.
	ErrUnsupportedExchange = errors.New("stake: unsupported exchange")
	// ErrNotFound is returned when a requested local API object cannot be found.
	ErrNotFound = errors.New("stake: not found")
	// ErrTradeFailed is returned when Stake accepts a trade request that later fails.
	ErrTradeFailed = errors.New("stake: trade failed")
)

Functions

func FormatEndpoint

func FormatEndpoint(template string, values map[string]string) (string, error)

FormatEndpoint replaces Python-style endpoint placeholders without URL encoding.

Types

type APIError

type APIError struct {
	StatusCode int
	Method     string
	URL        string
	Body       []byte
}

APIError describes a non-2xx response from the Stake API.

func (*APIError) Error

func (e *APIError) Error() string

type ASXBuyRequest

type ASXBuyRequest interface {
	// contains filtered or unexported methods
}

ASXBuyRequest is implemented by Australian-market buy requests.

type ASXCashAvailable

type ASXCashAvailable struct {
	BuyingPower                    *FlexibleFloat64 `json:"buyingPower,omitempty"`
	CashAvailableForTransfer       *FlexibleFloat64 `json:"cashAvailableForTransfer,omitempty"`
	CashAvailableForWithdrawalHold *FlexibleFloat64 `json:"cashAvailableForWithdrawalHold,omitempty"`
	CashAvailableForWithdrawal     *FlexibleFloat64 `json:"cashAvailableForWithdrawal,omitempty"`
	ClearingCash                   *FlexibleFloat64 `json:"clearingCash,omitempty"`
	PendingBuys                    *FlexibleInt     `json:"pendingBuys,omitempty"`
	PendingWithdrawals             *FlexibleInt     `json:"pendingWithdrawals,omitempty"`
	SettledCash                    *FlexibleFloat64 `json:"settledCash,omitempty"`
	SettlementHold                 *FlexibleInt     `json:"settlementHold,omitempty"`
	TradeSettlement                *FlexibleInt     `json:"tradeSettlement,omitempty"`
}

ASXCashAvailable holds Australian-market cash availability.

type ASXCourseOfSale

type ASXCourseOfSale struct {
	ID                  string           `json:"id,omitempty"`
	InstrumentCodeID    string           `json:"instrumentCodeId,omitempty"`
	ExchangeMarket      string           `json:"exchangeMarket,omitempty"`
	Price               *FlexibleFloat64 `json:"price,omitempty"`
	Volume              *FlexibleInt     `json:"volume,omitempty"`
	Value               *FlexibleFloat64 `json:"value,omitempty"`
	TradeTimeMillis     *int64           `json:"tradeTimeMillis,omitempty"`
	CancelledTimeMillis *int64           `json:"cancelledTimeMillis,omitempty"`
	BuyOrderNumber      string           `json:"buyOrderNumber,omitempty"`
	SellOrderNumber     string           `json:"sellOrderNumber,omitempty"`
}

ASXCourseOfSale is an ASX course-of-sales record.

type ASXDepthLevel

type ASXDepthLevel struct {
	ID             string           `json:"id,omitempty"`
	Price          *FlexibleFloat64 `json:"price,omitempty"`
	Volume         *FlexibleInt     `json:"volume,omitempty"`
	NumberOfOrders *FlexibleInt     `json:"numberOfOrders,omitempty"`
	Value          *FlexibleFloat64 `json:"value,omitempty"`
	Orders         []ASXDepthOrder  `json:"orders,omitempty"`
}

ASXDepthLevel is an ASX market-depth level.

type ASXDepthOrder

type ASXDepthOrder struct {
	ID          string           `json:"id,omitempty"`
	Exchange    string           `json:"exchange,omitempty"`
	Volume      *FlexibleInt     `json:"volume,omitempty"`
	Value       *FlexibleFloat64 `json:"value,omitempty"`
	Undisclosed *bool            `json:"undisclosed,omitempty"`
}

ASXDepthOrder is an individual order inside an ASX depth level.

type ASXEndpoints

type ASXEndpoints struct {
	StakeURL             string
	Brokerage            string
	CashAvailable        string
	CancelOrder          string
	EquityPositions      string
	MarketStatus         string
	AggregatedDepth      string
	CourseOfSales        string
	Orders               string
	ProductsSuggestions  string
	Symbol               string
	TradeActivity        string
	Watchlists           string
	CreateWatchlist      string
	ReadWatchlist        string
	UpdateWatchlist      string
	InstrumentFromSymbol string
	Transactions         string
	Users                string
}

ASXEndpoints contains all known Stake ASX API endpoints.

type ASXEquitiesService

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

ASXEquitiesService reads Australian-market equity positions.

func (*ASXEquitiesService) List

List returns the user's Australian-market portfolio positions.

type ASXEquityPosition

type ASXEquityPosition struct {
	AvailableForTradingQty *int     `json:"availableForTradingQty,omitempty"`
	AveragePrice           string   `json:"averagePrice,omitempty"`
	InstrumentID           string   `json:"instrumentId,omitempty"`
	MarketValue            string   `json:"marketValue,omitempty"`
	MarketPrice            string   `json:"mktPrice,omitempty"`
	Name                   string   `json:"name,omitempty"`
	OpenQty                *int     `json:"openQty,omitempty"`
	PriorClose             string   `json:"priorClose,omitempty"`
	RecentAnnouncement     *bool    `json:"recentAnnouncement,omitempty"`
	Sensitive              *bool    `json:"sensitive,omitempty"`
	Symbol                 string   `json:"symbol,omitempty"`
	UnrealizedDayPLPercent *float64 `json:"unrealizedDayPLPercent,omitempty"`
	UnrealizedDayPL        *float64 `json:"unrealizedDayPL,omitempty"`
	UnrealizedPLPercent    *float64 `json:"unrealizedPLPercent,omitempty"`
	UnrealizedPL           *float64 `json:"unrealizedPL,omitempty"`
}

ASXEquityPosition is one Australian-market portfolio position.

type ASXEquityPositions

type ASXEquityPositions struct {
	PageNum         *int                `json:"pageNum,omitempty"`
	HasNext         *bool               `json:"hasNext,omitempty"`
	EquityPositions []ASXEquityPosition `json:"equityPositions,omitempty"`
}

ASXEquityPositions is the user's Australian-market portfolio.

type ASXExpiryDate

type ASXExpiryDate string

ASXExpiryDate controls ASX order validity.

const (
	ASXExpiryOneDay     ASXExpiryDate = "GFD"
	ASXExpiryThirtyDays ASXExpiryDate = "GTC"
)

type ASXFundingAction

type ASXFundingAction string

ASXFundingAction is an ASX funding action filter/value.

const (
	ASXFundingActionDeposit         ASXFundingAction = "DEPOSIT"
	ASXFundingActionDividendDeposit ASXFundingAction = "DIVIDEND_DEPOSIT"
	ASXFundingActionSettlement      ASXFundingAction = "SETTLEMENT"
	ASXFundingActionTransfer        ASXFundingAction = "TRANSFER"
	ASXFundingActionWithdrawal      ASXFundingAction = "WITHDRAWAL"
	ASXFundingActionAdjustment      ASXFundingAction = "ADJUSTMENT"
)

type ASXFundingCurrency

type ASXFundingCurrency string

ASXFundingCurrency is an ASX funding currency.

const ASXFundingCurrencyAUD ASXFundingCurrency = "AUD"

type ASXFundingRecord

type ASXFundingRecord struct {
	Action      ASXFundingAction   `json:"action,omitempty"`
	Amount      *FlexibleFloat64   `json:"amount,omitempty"`
	ApprovedBy  string             `json:"approvedBy,omitempty"`
	Currency    ASXFundingCurrency `json:"currency,omitempty"`
	CustomerFee *FlexibleFloat64   `json:"customerFee,omitempty"`
	ID          string             `json:"id,omitempty"`
	InsertedAt  *FlexibleTime      `json:"insertedAt,omitempty"`
	Reference   string             `json:"reference,omitempty"`
	Side        ASXFundingSide     `json:"side,omitempty"`
	Status      ASXFundingStatus   `json:"status,omitempty"`
	UpdatedAt   *FlexibleTime      `json:"updatedAt,omitempty"`
	UserID      string             `json:"userId,omitempty"`
}

ASXFundingRecord is an Australian-market funding transaction.

type ASXFundingRequest

type ASXFundingRequest struct {
	Statuses []ASXFundingStatus
	Sort     []ASXSort
	Actions  []ASXFundingAction
	Limit    int
	Offset   int
}

ASXFundingRequest filters ASX funding transactions.

type ASXFundingSide

type ASXFundingSide string

ASXFundingSide is an ASX funding ledger side.

const (
	ASXFundingSideCredit ASXFundingSide = "CREDIT"
	ASXFundingSideDebit  ASXFundingSide = "DEBIT"
)

type ASXFundingStatus

type ASXFundingStatus string

ASXFundingStatus is an ASX funding status.

const (
	ASXFundingStatusAwaitingApproval ASXFundingStatus = "AWAITING_APPROVAL"
	ASXFundingStatusPending          ASXFundingStatus = "PENDING"
	ASXFundingStatusReconciled       ASXFundingStatus = "RECONCILED"
)

type ASXFundings

type ASXFundings struct {
	Fundings   []ASXFundingRecord `json:"items,omitempty"`
	HasNext    *bool              `json:"hasNext,omitempty"`
	Page       *FlexibleInt       `json:"page,omitempty"`
	TotalItems *FlexibleInt       `json:"totalItems,omitempty"`
}

ASXFundings is a paginated ASX funding response.

type ASXFundingsService

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

ASXFundingsService reads Australian-market funding data.

func (*ASXFundingsService) CashAvailable

func (s *ASXFundingsService) CashAvailable(ctx context.Context) (*ASXCashAvailable, error)

CashAvailable returns Australian-market cash availability.

func (*ASXFundingsService) InFlight

func (s *ASXFundingsService) InFlight(ctx context.Context) (*ASXFundings, error)

InFlight returns ASX pending or awaiting-approval funding transactions.

func (*ASXFundingsService) List

List returns ASX funding transactions matching the request.

type ASXInstrument

type ASXInstrument struct {
	InstrumentID       string `json:"instrumentId"`
	Symbol             string `json:"symbol"`
	Name               string `json:"name,omitempty"`
	Type               string `json:"type"`
	RecentAnnouncement *bool  `json:"recentAnnouncement,omitempty"`
	Sensitive          *bool  `json:"sensitive,omitempty"`
}

ASXInstrument is an Australian-market instrument suggestion.

type ASXLimitBuyRequest

type ASXLimitBuyRequest struct {
	Symbol         string
	InstrumentCode string
	Units          int
	Validity       ASXExpiryDate
	ValidityDate   *time.Time
	Price          float64
}

ASXLimitBuyRequest buys ASX units at a limit price.

type ASXLimitSellRequest

type ASXLimitSellRequest struct {
	Symbol         string
	InstrumentCode string
	Units          int
	Validity       ASXExpiryDate
	ValidityDate   *time.Time
	Price          float64
}

ASXLimitSellRequest sells ASX units at a limit price.

type ASXMarketBuyRequest

type ASXMarketBuyRequest struct {
	Symbol         string
	InstrumentCode string
	Units          int
	Validity       ASXExpiryDate
	ValidityDate   *time.Time
	Price          *float64
}

ASXMarketBuyRequest buys ASX units using market-to-limit pricing.

type ASXMarketSellRequest

type ASXMarketSellRequest struct {
	Symbol         string
	InstrumentCode string
	Units          int
	Validity       ASXExpiryDate
	ValidityDate   *time.Time
	Price          *float64
}

ASXMarketSellRequest sells ASX units using market-to-limit pricing.

type ASXMarketService

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

ASXMarketService reads Australian-market status.

func (*ASXMarketService) Get

Get returns the current Australian-market status.

func (*ASXMarketService) IsOpen

func (s *ASXMarketService) IsOpen(ctx context.Context) (bool, error)

IsOpen reports whether the Australian market is open.

type ASXMarketStatus

type ASXMarketStatus struct {
	LastTradingDate *FlexibleTime        `json:"lastTradingDate,omitempty"`
	Status          ASXMarketStatusValue `json:"status"`
}

ASXMarketStatus is Stake's Australian-market status response.

type ASXMarketStatusValue

type ASXMarketStatusValue struct {
	Current string `json:"current"`
}

ASXMarketStatusValue is an Australian-market status payload.

type ASXOrder

type ASXOrder struct {
	AveragePrice          *FlexibleFloat64 `json:"averagePrice,omitempty"`
	Broker                string           `json:"broker,omitempty"`
	CompletedTimestamp    *FlexibleTime    `json:"completedTimestamp,omitempty"`
	EstimatedBrokerage    *FlexibleFloat64 `json:"estimatedBrokerage,omitempty"`
	EstimatedExchangeFees *FlexibleFloat64 `json:"estimatedExchangeFees,omitempty"`
	ExpiresAt             *FlexibleTime    `json:"expiresAt,omitempty"`
	FilledUnits           *FlexibleFloat64 `json:"filledUnits,omitempty"`
	InstrumentCode        string           `json:"instrumentCode"`
	InstrumentID          string           `json:"instrumentId,omitempty"`
	LimitPrice            *FlexibleFloat64 `json:"limitPrice,omitempty"`
	OrderCompletionType   string           `json:"orderCompletionType,omitempty"`
	OrderID               string           `json:"id"`
	OrderStatus           string           `json:"orderStatus,omitempty"`
	PlacedTimestamp       FlexibleTime     `json:"placedTimestamp"`
	Side                  ASXSide          `json:"side"`
	Type                  ASXTradeType     `json:"type"`
	UnitsRemaining        *FlexibleInt     `json:"unitsRemaining,omitempty"`
	ValidityDate          string           `json:"validityDate,omitempty"`
	Validity              string           `json:"validity,omitempty"`
}

ASXOrder is an Australian-market order.

type ASXOrdersService

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

ASXOrdersService manages Australian-market pending orders.

func (*ASXOrdersService) Brokerage

func (s *ASXOrdersService) Brokerage(ctx context.Context, orderAmount float64) (*Brokerage, error)

Brokerage returns the Australian-market brokerage estimate for an order amount.

func (*ASXOrdersService) Cancel

func (s *ASXOrdersService) Cancel(ctx context.Context, request CancelOrderRequest) error

Cancel cancels an Australian-market pending order.

func (*ASXOrdersService) List

func (s *ASXOrdersService) List(ctx context.Context) ([]ASXOrder, error)

List returns Australian-market pending orders.

type ASXProduct

type ASXProduct struct {
	Symbol              string           `json:"symbol,omitempty"`
	OutOfMarketQuantity *FlexibleInt     `json:"outOfMarketQuantity,omitempty"`
	OutOfMarketSurplus  *FlexibleInt     `json:"outOfMarketSurplus,omitempty"`
	MarketStatus        string           `json:"marketStatus,omitempty"`
	LastTradedExchange  string           `json:"lastTradedExchange,omitempty"`
	LastTradedTimestamp *int64           `json:"lastTradedTimestamp,omitempty"`
	LastTrade           string           `json:"lastTrade,omitempty"`
	Bid                 *FlexibleFloat64 `json:"bid,omitempty"`
	Ask                 *FlexibleFloat64 `json:"ask,omitempty"`
	PriorClose          *FlexibleFloat64 `json:"priorClose,omitempty"`
	Open                *FlexibleFloat64 `json:"open,omitempty"`
	High                *FlexibleFloat64 `json:"high,omitempty"`
	Low                 *FlexibleFloat64 `json:"low,omitempty"`
	PointsChange        *FlexibleFloat64 `json:"pointsChange,omitempty"`
	PercentageChange    *FlexibleFloat64 `json:"percentageChange,omitempty"`
	OutOfMarketPrice    *FlexibleFloat64 `json:"outOfMarketPrice,omitempty"`
}

ASXProduct is an Australian-market quote/product response.

type ASXProductAggregatedDepth

type ASXProductAggregatedDepth struct {
	ID              string          `json:"id,omitempty"`
	Ticker          string          `json:"ticker,omitempty"`
	TotalBuyCount   *FlexibleInt    `json:"totalBuyCount,omitempty"`
	TotalSellCount  *FlexibleInt    `json:"totalSellCount,omitempty"`
	TotalBuyVolume  *FlexibleInt    `json:"totalBuyVolume,omitempty"`
	TotalSellVolume *FlexibleInt    `json:"totalSellVolume,omitempty"`
	BuyOrders       []ASXDepthLevel `json:"buyOrders,omitempty"`
	SellOrders      []ASXDepthLevel `json:"sellOrders,omitempty"`
}

ASXProductAggregatedDepth is ASX aggregated market depth.

type ASXProductCourseOfSales

type ASXProductCourseOfSales struct {
	Ticker        string            `json:"ticker,omitempty"`
	TotalVolume   *FlexibleInt      `json:"totalVolume,omitempty"`
	TotalTrades   *FlexibleInt      `json:"totalTrades,omitempty"`
	TotalValue    *FlexibleFloat64  `json:"totalValue,omitempty"`
	CourseOfSales []ASXCourseOfSale `json:"courseOfSales,omitempty"`
}

ASXProductCourseOfSales is ASX course-of-sales data.

type ASXProductsService

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

ASXProductsService reads Australian-market products and instruments.

func (*ASXProductsService) CourseOfSales

func (s *ASXProductsService) CourseOfSales(ctx context.Context, symbol string) (*ASXProductCourseOfSales, error)

CourseOfSales returns ASX course-of-sales data for a symbol.

func (*ASXProductsService) Depth

Depth returns ASX aggregated market depth for a symbol.

func (*ASXProductsService) Get

func (s *ASXProductsService) Get(ctx context.Context, symbol string) (*ASXProduct, error)

Get returns an Australian-market product/quote for a symbol.

func (*ASXProductsService) ProductFromInstrument

func (s *ASXProductsService) ProductFromInstrument(ctx context.Context, instrument ASXInstrument) (*ASXProduct, error)

ProductFromInstrument returns the product for an Australian-market instrument suggestion.

func (*ASXProductsService) Search

Search returns Australian-market instrument suggestions for a keyword.

type ASXSellRequest

type ASXSellRequest interface {
	// contains filtered or unexported methods
}

ASXSellRequest is implemented by Australian-market sell requests.

type ASXServices

type ASXServices struct {
	Equities     *ASXEquitiesService
	Fundings     *ASXFundingsService
	Market       *ASXMarketService
	Orders       *ASXOrdersService
	Products     *ASXProductsService
	Trades       *ASXTradesService
	Transactions *ASXTransactionsService
	Watchlists   *WatchlistService
}

ASXServices groups services backed by Stake's Australian market endpoints.

type ASXSide

type ASXSide string

ASXSide is an ASX trade/order side.

const (
	ASXSideBuy  ASXSide = "BUY"
	ASXSideSell ASXSide = "SELL"
)

type ASXSort

type ASXSort struct {
	Attribute string           `json:"attribute"`
	Direction ASXSortDirection `json:"direction"`
}

ASXSort is a sort expression for ASX endpoints.

type ASXSortDirection

type ASXSortDirection string

ASXSortDirection controls ASX pagination sort direction.

const (
	ASXSortAscending  ASXSortDirection = "asc"
	ASXSortDescending ASXSortDirection = "desc"
)

type ASXTradeType

type ASXTradeType string

ASXTradeType is the Australian-market order type used by trade requests.

const (
	ASXTradeTypeMarket ASXTradeType = "MARKET_TO_LIMIT"
	ASXTradeTypeLimit  ASXTradeType = "LIMIT"
	ASXTradeTypeStop   ASXTradeType = "STOP"
)

type ASXTradesService

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

ASXTradesService submits Australian-market trades.

func (*ASXTradesService) Buy

func (s *ASXTradesService) Buy(ctx context.Context, request ASXBuyRequest) (*ASXOrder, error)

Buy submits an Australian-market buy request.

func (*ASXTradesService) Sell

func (s *ASXTradesService) Sell(ctx context.Context, request ASXSellRequest) (*ASXOrder, error)

Sell submits an Australian-market sell request.

type ASXTransaction

type ASXTransaction struct {
	AveragePrice         *FlexibleFloat64 `json:"averagePrice,omitempty"`
	BrokerOrderID        *FlexibleInt     `json:"brokerOrderId,omitempty"`
	CompletedTimestamp   *FlexibleTime    `json:"completedTimestamp,omitempty"`
	Consideration        *FlexibleFloat64 `json:"consideration,omitempty"`
	ContractNoteNumber   *FlexibleInt     `json:"contractNoteNumber,omitempty"`
	ContractNoteNumbers  []int            `json:"contractNoteNumbers,omitempty"`
	ContractNoteReceived *bool            `json:"contractNoteReceived,omitempty"`
	EffectivePrice       *FlexibleFloat64 `json:"effectivePrice,omitempty"`
	ExecutionDate        *FlexibleTime    `json:"executionDate,omitempty"`
	InstrumentID         string           `json:"instrumentCode,omitempty"`
	LimitPrice           *FlexibleFloat64 `json:"limitPrice,omitempty"`
	OrderCompletionType  string           `json:"orderCompletionType,omitempty"`
	OrderStatus          string           `json:"orderStatus,omitempty"`
	PlacedTimestamp      *FlexibleTime    `json:"placedTimestamp,omitempty"`
	Side                 ASXSide          `json:"side,omitempty"`
	Type                 string           `json:"type,omitempty"`
	Units                *FlexibleFloat64 `json:"units,omitempty"`
	UserBrokerageFees    *FlexibleFloat64 `json:"userBrokerageFees,omitempty"`
}

ASXTransaction is a trade activity record from the Australian market.

type ASXTransactionRecordRequest

type ASXTransactionRecordRequest struct {
	Sort   []ASXSort
	Limit  int
	Offset int
}

ASXTransactionRecordRequest filters ASX trade activity.

type ASXTransactions

type ASXTransactions struct {
	Transactions []ASXTransaction `json:"items,omitempty"`
	HasNext      *bool            `json:"hasNext,omitempty"`
	Page         *FlexibleInt     `json:"page,omitempty"`
	TotalItems   *FlexibleInt     `json:"totalItems,omitempty"`
}

ASXTransactions is a paginated ASX transaction response.

type ASXTransactionsService

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

ASXTransactionsService lists ASX trade activity.

func (*ASXTransactionsService) List

List returns ASX trade activity matching the request.

type Brokerage

type Brokerage struct {
	BrokerageFee          *FlexibleFloat64 `json:"brokerageFee,omitempty"`
	BrokerageDiscount     *FlexibleFloat64 `json:"brokerageDiscount,omitempty"`
	FixedFee              *FlexibleFloat64 `json:"fixedFee,omitempty"`
	VariableFeePercentage *FlexibleFloat64 `json:"variableFeePercentage,omitempty"`
	VariableLimit         *FlexibleInt     `json:"variableLimit,omitempty"`
}

Brokerage is a brokerage estimate.

type CancelOrderRequest

type CancelOrderRequest struct {
	OrderID string `json:"orderId"`
}

CancelOrderRequest identifies an order to cancel.

type Client

type Client struct {

	// User is populated after Login succeeds. It is an exported field for
	// convenience, but callers performing concurrent Login calls should prefer
	// the value returned by Login; reading User directly while Login is in
	// progress is not safe.
	User *User

	// NYSE exposes typed services for Stake's US market endpoints.
	NYSE *NYSEServices
	// ASX exposes typed services for Stake's Australian market endpoints.
	ASX *ASXServices
	// contains filtered or unexported fields
}

Client is an HTTP client for Stake's API.

func NewClient

func NewClient(options ...Option) (*Client, error)

NewClient constructs a Stake API client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, endpoint string, in any, out any) error

Delete performs a DELETE request against a Stake endpoint and decodes JSON into out.

func (*Client) Exchange

func (c *Client) Exchange() Exchange

Exchange returns the client's selected exchange.

func (*Client) Get

func (c *Client) Get(ctx context.Context, endpoint string, out any) error

Get performs a GET request against a Stake endpoint and decodes JSON into out.

func (*Client) Login

func (c *Client) Login(ctx context.Context) (*User, error)

Login authenticates with Stake and retrieves the current user.

func (*Client) Post

func (c *Client) Post(ctx context.Context, endpoint string, in any, out any) error

Post performs a POST request against a Stake endpoint and decodes JSON into out.

func (*Client) SessionToken

func (c *Client) SessionToken() string

SessionToken returns the current Stake session token.

func (*Client) SetExchange

func (c *Client) SetExchange(exchange Exchange) error

SetExchange changes the client's selected exchange.

type CreateWatchlistRequest

type CreateWatchlistRequest struct {
	Name    string   `json:"name"`
	Tickers []string `json:"tickers,omitempty"`
}

CreateWatchlistRequest creates a watchlist, optionally with initial tickers.

type CredentialsLoginRequest

type CredentialsLoginRequest struct {
	Username       string  `json:"username"`
	Password       string  `json:"password"`
	OTP            *string `json:"otp,omitempty"`
	RememberMeDays int     `json:"rememberMeDays"`
	PlatformType   string  `json:"platformType"`
}

CredentialsLoginRequest authenticates with username/password credentials.

type Currency

type Currency string

Currency is a currency code used by Stake's FX endpoint.

const (
	CurrencyAUD Currency = "AUD"
	CurrencyUSD Currency = "USD"
)

type DeleteWatchlistRequest

type DeleteWatchlistRequest struct {
	ID string `json:"id"`
}

DeleteWatchlistRequest deletes a watchlist by ID.

type EquityCategory

type EquityCategory string

EquityCategory is a NYSE equity category.

const (
	EquityCategoryETF   EquityCategory = "ETF"
	EquityCategoryStock EquityCategory = "Stock"
)

type Exchange

type Exchange string

Exchange identifies a Stake market supported by the client.

const (
	// ExchangeNYSE selects Stake's US market endpoints.
	ExchangeNYSE Exchange = "nyse"
	// ExchangeASX selects Stake's Australian market endpoints.
	ExchangeASX Exchange = "asx"
)

type FXConversion

type FXConversion struct {
	FromCurrency Currency `json:"fromCurrency"`
	ToCurrency   Currency `json:"toCurrency"`
	FromAmount   float64  `json:"fromAmount"`
	ToAmount     float64  `json:"toAmount"`
	Rate         float64  `json:"rate"`
	Quote        string   `json:"quote"`
}

FXConversion is a Stake currency conversion quote.

type FXConversionRequest

type FXConversionRequest struct {
	FromCurrency Currency `json:"fromCurrency"`
	ToCurrency   Currency `json:"toCurrency"`
	FromAmount   float64  `json:"fromAmount"`
}

FXConversionRequest requests a currency conversion quote.

type FXService

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

FXService converts currencies through Stake's US-market wallet endpoint.

func (*FXService) Convert

func (s *FXService) Convert(ctx context.Context, request FXConversionRequest) (*FXConversion, error)

Convert returns an FX conversion quote.

type FlexibleFloat64

type FlexibleFloat64 float64

FlexibleFloat64 decodes JSON numbers or numeric strings.

func (FlexibleFloat64) Float64

func (f FlexibleFloat64) Float64() float64

Float64 returns the value as a float64.

func (FlexibleFloat64) MarshalJSON

func (f FlexibleFloat64) MarshalJSON() ([]byte, error)

MarshalJSON encodes the value as a JSON number.

func (*FlexibleFloat64) UnmarshalJSON

func (f *FlexibleFloat64) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes numbers, quoted numbers, empty strings, and null.

type FlexibleInt

type FlexibleInt int

FlexibleInt decodes JSON integers, integer-like floats, or numeric strings.

func (FlexibleInt) Int

func (i FlexibleInt) Int() int

Int returns the value as an int.

func (FlexibleInt) MarshalJSON

func (i FlexibleInt) MarshalJSON() ([]byte, error)

MarshalJSON encodes the value as a JSON integer.

func (*FlexibleInt) UnmarshalJSON

func (i *FlexibleInt) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes numbers, quoted numbers, empty strings, and null.

type FlexibleString

type FlexibleString string

FlexibleString decodes JSON strings or primitive values into a string.

func (FlexibleString) String

func (s FlexibleString) String() string

String returns the value as a string.

func (*FlexibleString) UnmarshalJSON

func (s *FlexibleString) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes strings, numbers, booleans, empty strings, and null.

type FlexibleTime

type FlexibleTime struct {
	time.Time
}

FlexibleTime decodes RFC3339 timestamps, timezone-less Stake timestamps, date-only strings, and Unix second/millisecond timestamps.

func (FlexibleTime) MarshalJSON

func (t FlexibleTime) MarshalJSON() ([]byte, error)

MarshalJSON encodes the value as RFC3339Nano or null when zero.

func (*FlexibleTime) UnmarshalJSON

func (t *FlexibleTime) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes common Stake timestamp encodings.

type GetWatchlistRequest

type GetWatchlistRequest struct {
	ID string `json:"id"`
}

GetWatchlistRequest retrieves a watchlist by ID.

type NYSEBuyRequest

type NYSEBuyRequest interface {
	// contains filtered or unexported methods
}

NYSEBuyRequest is implemented by US-market buy requests.

type NYSECashAvailable

type NYSECashAvailable struct {
	CardHoldAmount               float64              `json:"cardHoldAmount"`
	CashAvailableForTrade        float64              `json:"cashAvailableForTrade"`
	CashAvailableForWithdrawal   float64              `json:"cashAvailableForWithdrawal"`
	CashBalance                  float64              `json:"cashBalance"`
	CashSettlement               []NYSECashSettlement `json:"cashSettlement"`
	DWCashAvailableForWithdrawal float64              `json:"dwCashAvailableForWithdrawal"`
	PendingOrdersAmount          float64              `json:"pendingOrdersAmount"`
	PendingPOLIAmount            float64              `json:"pendingPoliAmount"`
	PendingWithdrawals           float64              `json:"pendingWithdrawals"`
	ReservedCash                 float64              `json:"reservedCash"`
}

NYSECashAvailable holds US-market cash availability.

type NYSECashSettlement

type NYSECashSettlement struct {
	UTCTime FlexibleTime `json:"utcTime"`
	Cash    float64      `json:"cash"`
}

NYSECashSettlement is a pending cash settlement line.

type NYSEEndpoints

type NYSEEndpoints struct {
	StakeURL            string
	AccountBalance      string
	AccountTransactions string
	Brokerage           string
	CancelOrder         string
	CashAvailable       string
	CreateSession       string
	EquityPositions     string
	FundDetails         string
	MarketDataQuote     string
	MarketStatus        string
	Orders              string
	ProductsSuggestions string
	QuickBuy            string
	Quotes              string
	Rate                string
	Ratings             string
	SellOrders          string
	Symbol              string
	TransactionHistory  string
	TransactionDetails  string
	Transactions        string
	Users               string
	Watchlists          string
	CreateWatchlist     string
	ReadWatchlist       string
	UpdateWatchlist     string
	Statement           string
}

NYSEEndpoints contains all known Stake NYSE API endpoints.

type NYSEEquitiesService

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

NYSEEquitiesService reads US-market equity positions.

func (*NYSEEquitiesService) List

List returns the user's US-market portfolio positions.

type NYSEEquityPosition

type NYSEEquityPosition struct {
	AskPrice               *float64       `json:"askPrice,omitempty"`
	AvailableForTradingQty float64        `json:"availableForTradingQty"`
	AveragePrice           float64        `json:"avgPrice"`
	BidPrice               *float64       `json:"bidPrice,omitempty"`
	Category               EquityCategory `json:"category,omitempty"`
	CostBasis              float64        `json:"costBasis"`
	DailyReturnValue       float64        `json:"dailyReturnValue"`
	EncodedName            string         `json:"encodedName"`
	InstrumentID           string         `json:"instrumentID"`
	LastTrade              float64        `json:"lastTrade"`
	MarketPrice            float64        `json:"mktPrice"`
	MarketValue            float64        `json:"marketValue"`
	Name                   string         `json:"name"`
	OpenQty                float64        `json:"openQty"`
	Period                 string         `json:"period"`
	PriorClose             float64        `json:"priorClose"`
	ReturnOnStock          *float64       `json:"returnOnStock,omitempty"`
	Side                   Side           `json:"side"`
	Symbol                 string         `json:"symbol"`
	UnrealizedDayPLPercent float64        `json:"unrealizedDayPLPercent"`
	UnrealizedDayPL        float64        `json:"unrealizedDayPL"`
	UnrealizedPL           float64        `json:"unrealizedPL"`
	URLImage               string         `json:"urlImage"`
	YearlyReturnPercentage *float64       `json:"yearlyReturnPercentage,omitempty"`
	YearlyReturnValue      *float64       `json:"yearlyReturnValue,omitempty"`
}

NYSEEquityPosition is one US-market portfolio position.

func (*NYSEEquityPosition) UnmarshalJSON

func (p *NYSEEquityPosition) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts Stake's mixed numeric encodings while preserving the public float64 fields.

type NYSEEquityPositions

type NYSEEquityPositions struct {
	EquityPositions []NYSEEquityPosition `json:"equityPositions"`
	EquityValue     float64              `json:"equityValue"`
	PricesOnly      bool                 `json:"pricesOnly"`
}

NYSEEquityPositions is the user's US-market portfolio.

func (*NYSEEquityPositions) UnmarshalJSON

func (p *NYSEEquityPositions) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts Stake's mixed numeric encodings while preserving the public float64 fields.

type NYSEFunding

type NYSEFunding struct {
	IOF           string           `json:"iof,omitempty"`
	VET           string           `json:"vet,omitempty"`
	BSB           string           `json:"bsb,omitempty"`
	AccountNumber string           `json:"accountNumber,omitempty"`
	InsertDate    *FlexibleTime    `json:"insertDate,omitempty"`
	Channel       string           `json:"channel,omitempty"`
	AmountTo      *FlexibleFloat64 `json:"amountTo,omitempty"`
	AmountFrom    *FlexibleFloat64 `json:"amountFrom,omitempty"`
	Status        string           `json:"status,omitempty"`
	Speed         string           `json:"speed,omitempty"`
	FXFee         *FlexibleFloat64 `json:"fxFee,omitempty"`
	ExpressFee    *FlexibleInt     `json:"expressFee,omitempty"`
	TotalFee      *FlexibleFloat64 `json:"totalFee,omitempty"`
	SpotRate      *FlexibleFloat64 `json:"spotRate,omitempty"`
	Reference     string           `json:"reference,omitempty"`
	W8Fee         *FlexibleInt     `json:"w8Fee,omitempty"`
	CurrencyFrom  string           `json:"currencyFrom,omitempty"`
	CurrencyTo    string           `json:"currencyTo,omitempty"`
}

NYSEFunding is a detailed US-market funding transaction.

type NYSEFundingsService

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

NYSEFundingsService reads US-market funding data.

func (*NYSEFundingsService) CashAvailable

func (s *NYSEFundingsService) CashAvailable(ctx context.Context) (*NYSECashAvailable, error)

CashAvailable returns US-market cash availability.

func (*NYSEFundingsService) InFlight

InFlight returns US-market funds currently in flight.

func (*NYSEFundingsService) List

List returns US-market funding transactions by expanding transaction-history details.

type NYSEFundsInFlight

type NYSEFundsInFlight struct {
	Type                   string  `json:"type"`
	InsertDateTime         string  `json:"insertDateTime"`
	EstimatedArrivalTime   string  `json:"estimatedArrivalTime"`
	EstimatedArrivalTimeUS string  `json:"estimatedArrivalTimeUS"`
	TransactionType        string  `json:"transactionType"`
	ToAmount               float64 `json:"toAmount"`
	FromAmount             float64 `json:"fromAmount"`
}

NYSEFundsInFlight is a US-market pending funding transfer.

type NYSEInstrument

type NYSEInstrument struct {
	EncodedName  string `json:"encodedName,omitempty"`
	ImageURL     string `json:"imageUrl,omitempty"`
	InstrumentID string `json:"instrumentId"`
	Name         string `json:"name"`
	Symbol       string `json:"symbol"`
}

NYSEInstrument is a US-market instrument suggestion.

type NYSELimitBuyRequest

type NYSELimitBuyRequest struct {
	Symbol     string
	LimitPrice float64
	Quantity   int
	Comments   string
}

NYSELimitBuyRequest buys a quantity at a limit price.

type NYSELimitSellRequest

type NYSELimitSellRequest struct {
	Symbol     string
	LimitPrice float64
	Quantity   int
	Comments   string
}

NYSELimitSellRequest sells a quantity at a limit price.

type NYSEMarketBuyRequest

type NYSEMarketBuyRequest struct {
	Symbol     string
	AmountCash float64
	Comments   string
}

NYSEMarketBuyRequest buys by cash amount at market price.

type NYSEMarketDataQuote

type NYSEMarketDataQuote struct {
	Open                               *FlexibleFloat64 `json:"open,omitempty"`
	High                               *FlexibleFloat64 `json:"high,omitempty"`
	Low                                *FlexibleFloat64 `json:"low,omitempty"`
	PriorClose                         *FlexibleFloat64 `json:"priorClose,omitempty"`
	Close                              *FlexibleFloat64 `json:"close,omitempty"`
	Bid                                *FlexibleFloat64 `json:"bid,omitempty"`
	Ask                                *FlexibleFloat64 `json:"ask,omitempty"`
	CloseBid                           *FlexibleFloat64 `json:"closeBid,omitempty"`
	CloseAsk                           *FlexibleFloat64 `json:"closeAsk,omitempty"`
	LastTrade                          *FlexibleFloat64 `json:"lastTrade,omitempty"`
	PrePostMarketLastTrade             *FlexibleFloat64 `json:"prePostMarketLastTrade,omitempty"`
	DailyReturnQuote                   *FlexibleFloat64 `json:"dailyReturnQuote,omitempty"`
	DailyReturnPercentageQuote         *FlexibleFloat64 `json:"dailyReturnPercentageQuote,omitempty"`
	PrePostMarketDailyReturn           *FlexibleFloat64 `json:"prePostMarketDailyReturn,omitempty"`
	PrePostMarketDailyReturnPercentage *FlexibleFloat64 `json:"prePostMarketDailyReturnPercentage,omitempty"`
	TradingStatus                      string           `json:"tradingStatus,omitempty"`
	MarketStatus                       string           `json:"marketStatus,omitempty"`
	TradeTimestamp                     *FlexibleTime    `json:"tradeTimestamp,omitempty"`
	Volume                             *FlexibleInt     `json:"volume,omitempty"`
	StakeInstrumentID                  string           `json:"stakeInstrumentId,omitempty"`
	Symbol                             string           `json:"symbol,omitempty"`
}

NYSEMarketDataQuote is a real-time US-market price snapshot.

type NYSEMarketSellRequest

type NYSEMarketSellRequest struct {
	Symbol   string
	Quantity float64
	Comments string
}

NYSEMarketSellRequest sells a quantity at market price.

type NYSEMarketService

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

NYSEMarketService reads US-market status.

func (*NYSEMarketService) Get

Get returns the current US-market status.

func (*NYSEMarketService) IsOpen

func (s *NYSEMarketService) IsOpen(ctx context.Context) (bool, error)

IsOpen reports whether the US market is open.

type NYSEMarketStatus

type NYSEMarketStatus struct {
	Status NYSEMarketStatusValue `json:"status"`
}

NYSEMarketStatus is Stake's US-market status response.

type NYSEMarketStatusValue

type NYSEMarketStatusValue struct {
	ChangeAt string `json:"change_at,omitempty"`
	Next     string `json:"next,omitempty"`
	Current  string `json:"current"`
}

NYSEMarketStatusValue is a US-market status payload.

type NYSEOrder

type NYSEOrder struct {
	OrderNumber      string       `json:"orderNo"`
	OrderID          string       `json:"orderID"`
	OrderCashAmount  int          `json:"orderCashAmt"`
	Symbol           string       `json:"symbol"`
	StopPrice        float64      `json:"stopPrice"`
	Side             Side         `json:"side"`
	OrderType        OrderType    `json:"orderType"`
	CumulativeQty    string       `json:"cumQty"`
	LimitPrice       float64      `json:"limitPrice"`
	CreatedWhen      FlexibleTime `json:"createdWhen"`
	OrderStatus      int          `json:"orderStatus"`
	OrderQty         float64      `json:"orderQty"`
	Description      string       `json:"description"`
	InstrumentID     string       `json:"instrumentID"`
	ImageURL         string       `json:"imageUrl"`
	InstrumentSymbol string       `json:"instrumentSymbol"`
	InstrumentName   string       `json:"instrumentName"`
	EncodedName      string       `json:"encodedName"`
}

NYSEOrder is a US-market pending order.

type NYSEOrdersService

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

NYSEOrdersService manages US-market pending orders.

func (*NYSEOrdersService) Brokerage

func (s *NYSEOrdersService) Brokerage(ctx context.Context, orderAmount float64) (*Brokerage, error)

Brokerage returns the US-market brokerage estimate for an order amount.

func (*NYSEOrdersService) Cancel

func (s *NYSEOrdersService) Cancel(ctx context.Context, request CancelOrderRequest) error

Cancel cancels a US-market pending order.

func (*NYSEOrdersService) List

func (s *NYSEOrdersService) List(ctx context.Context) ([]NYSEOrder, error)

List returns US-market pending orders.

type NYSEProduct

type NYSEProduct struct {
	ID                     string           `json:"id"`
	InstrumentTypeID       string           `json:"instrumentTypeID,omitempty"`
	Symbol                 string           `json:"symbol"`
	Description            string           `json:"description"`
	Category               string           `json:"category,omitempty"`
	CurrencyID             string           `json:"currencyID,omitempty"`
	URLImage               string           `json:"urlImage"`
	Sector                 string           `json:"sector,omitempty"`
	ParentID               string           `json:"parentID,omitempty"`
	Name                   string           `json:"name"`
	DailyReturn            float64          `json:"dailyReturn"`
	DailyReturnPercentage  float64          `json:"dailyReturnPercentage"`
	LastTraded             float64          `json:"lastTraded"`
	MonthlyReturn          float64          `json:"monthlyReturn"`
	YearlyReturnPercentage *FlexibleFloat64 `json:"yearlyReturnPercentage,omitempty"`
	YearlyReturnValue      *FlexibleFloat64 `json:"yearlyReturnValue,omitempty"`
	Popularity             FlexibleInt      `json:"popularity"`
	Watched                FlexibleInt      `json:"watched"`
	News                   FlexibleInt      `json:"news"`
	Bought                 FlexibleInt      `json:"bought"`
	Viewed                 FlexibleInt      `json:"viewed"`
	ProductType            string           `json:"productType"`
	TradeStatus            *FlexibleInt     `json:"tradeStatus,omitempty"`
	EncodedName            string           `json:"encodedName"`
	Period                 string           `json:"period"`
	InceptionDate          FlexibleString   `json:"inceptionDate,omitempty"`
	InstrumentTags         []any            `json:"instrumentTags"`
	ChildInstruments       []NYSEInstrument `json:"childInstruments"`
}

NYSEProduct is a US-market product.

type NYSEProductWithQuote

type NYSEProductWithQuote struct {
	NYSEProduct
	MarketDataQuote NYSEMarketDataQuote `json:"marketDataQuote"`
}

NYSEProductWithQuote merges product metadata with live market data.

type NYSEProductsService

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

NYSEProductsService reads US-market products and instruments.

func (*NYSEProductsService) Get

func (s *NYSEProductsService) Get(ctx context.Context, symbol string) (*NYSEProduct, error)

Get returns a US-market product for a symbol. A nil product means Stake returned no match.

func (*NYSEProductsService) GetMarketDataQuote

func (s *NYSEProductsService) GetMarketDataQuote(ctx context.Context, symbol string) (*NYSEMarketDataQuote, error)

GetMarketDataQuote returns a real-time US-market price snapshot for a symbol.

func (*NYSEProductsService) GetWithQuote

func (s *NYSEProductsService) GetWithQuote(ctx context.Context, symbol string) (*NYSEProductWithQuote, error)

GetWithQuote returns a US-market product enriched with live market data.

func (*NYSEProductsService) ProductFromInstrument

func (s *NYSEProductsService) ProductFromInstrument(ctx context.Context, instrument NYSEInstrument) (*NYSEProduct, error)

ProductFromInstrument returns the product for a US-market instrument suggestion.

func (*NYSEProductsService) Search

Search returns US-market instrument suggestions for a keyword.

type NYSESellRequest

type NYSESellRequest interface {
	// contains filtered or unexported methods
}

NYSESellRequest is implemented by US-market sell requests.

type NYSEServices

type NYSEServices struct {
	Equities     *NYSEEquitiesService
	Fundings     *NYSEFundingsService
	FX           *FXService
	Market       *NYSEMarketService
	Orders       *NYSEOrdersService
	Products     *NYSEProductsService
	Ratings      *RatingsService
	Statements   *StatementService
	Trades       *NYSETradesService
	Transactions *NYSETransactionsService
	Watchlists   *WatchlistService
}

NYSEServices groups services backed by Stake's US market endpoints.

type NYSEStopBuyRequest

type NYSEStopBuyRequest struct {
	Symbol     string
	AmountCash float64
	Price      float64
	Comments   string
}

NYSEStopBuyRequest buys by cash amount when the stop price is reached.

type NYSEStopSellRequest

type NYSEStopSellRequest struct {
	Symbol    string
	Quantity  float64
	StopPrice float64
	Comments  string
}

NYSEStopSellRequest sells a quantity when the stop price is reached.

type NYSETradeResponse

type NYSETradeResponse struct {
	AmountCash        *FlexibleFloat64 `json:"amountCash,omitempty"`
	Category          string           `json:"category"`
	Commission        *FlexibleFloat64 `json:"commission,omitempty"`
	Description       string           `json:"description,omitempty"`
	DWOrderID         string           `json:"dwOrderId"`
	EffectivePrice    *FlexibleFloat64 `json:"effectivePrice,omitempty"`
	EncodedName       string           `json:"encodedName"`
	ID                string           `json:"id"`
	ImageURL          string           `json:"imageURL"`
	InsertedDate      FlexibleTime     `json:"insertedDate"`
	ItemID            string           `json:"itemId"`
	LimitPrice        *FlexibleFloat64 `json:"limitPrice,omitempty"`
	Name              string           `json:"name"`
	OrderRejectReason string           `json:"orderRejectReason,omitempty"`
	Quantity          *FlexibleFloat64 `json:"quantity,omitempty"`
	Side              string           `json:"side"`
	Status            *FlexibleInt     `json:"status,omitempty"`
	StopPrice         *FlexibleFloat64 `json:"stopPrice,omitempty"`
	Symbol            string           `json:"symbol"`
	UpdatedDate       FlexibleTime     `json:"updatedDate"`
}

NYSETradeResponse is Stake's US-market trade response.

type NYSETradeType

type NYSETradeType string

NYSETradeType is the US-market order type used by trade requests.

const (
	NYSETradeTypeMarket NYSETradeType = "market"
	NYSETradeTypeLimit  NYSETradeType = "limit"
	NYSETradeTypeStop   NYSETradeType = "stop"
)

type NYSETradesService

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

NYSETradesService submits US-market trades.

func (*NYSETradesService) Buy

Buy submits a US-market buy request.

func (*NYSETradesService) Sell

Sell submits a US-market sell request.

type NYSETransaction

type NYSETransaction struct {
	AccountAmount                 float64                    `json:"accountAmount"`
	AccountBalance                float64                    `json:"accountBalance"`
	AccountType                   string                     `json:"accountType"`
	Comment                       string                     `json:"comment"`
	DividendTax                   map[string]any             `json:"dividendTax,omitempty"`
	Dividend                      map[string]any             `json:"dividend,omitempty"`
	DNB                           bool                       `json:"dnb"`
	FeeBase                       int                        `json:"feeBase"`
	FeeExchange                   int                        `json:"feeExchange"`
	FeeSEC                        float64                    `json:"feeSec"`
	FeeTAF                        float64                    `json:"feeTaf"`
	FeeXtraShares                 int                        `json:"feeXtraShares"`
	FillPrice                     float64                    `json:"fillPx"`
	FillQuantity                  float64                    `json:"fillQty"`
	FinancialTransactionID        string                     `json:"finTranID"`
	FinancialTransactionTypeID    string                     `json:"finTranTypeID"`
	Instrument                    *NYSETransactionInstrument `json:"instrument,omitempty"`
	MergerAcquisition             map[string]any             `json:"mergerAcquisition,omitempty"`
	OrderID                       string                     `json:"orderID,omitempty"`
	OrderNumber                   string                     `json:"orderNo,omitempty"`
	PositionDelta                 *FlexibleFloat64           `json:"positionDelta,omitempty"`
	SendCommissionToInteliclear   bool                       `json:"sendCommissionToInteliclear"`
	Symbol                        string                     `json:"symbol,omitempty"`
	SystemAmount                  int                        `json:"systemAmount"`
	TransactionAmount             float64                    `json:"tranAmount"`
	TransactionSource             string                     `json:"tranSource"`
	TransactionWhen               FlexibleTime               `json:"tranWhen"`
	UpdatedReason                 string                     `json:"updatedReason,omitempty"`
	WLPAmount                     int                        `json:"wlpAmount"`
	WLPFinancialTransactionTypeID string                     `json:"wlpFinTranTypeID,omitempty"`
}

NYSETransaction is an account transaction from the US market.

type NYSETransactionHistoryType

type NYSETransactionHistoryType string

NYSETransactionHistoryType is Stake's NYSE transaction-history category.

const (
	NYSETransactionHistoryBuy             NYSETransactionHistoryType = "Buy"
	NYSETransactionHistoryCorporateAction NYSETransactionHistoryType = "Corporate Action"
	NYSETransactionHistoryDividend        NYSETransactionHistoryType = "Dividend"
	NYSETransactionHistoryDividendTax     NYSETransactionHistoryType = "Dividend Tax"
	NYSETransactionHistoryFunding         NYSETransactionHistoryType = "Funding"
	NYSETransactionHistorySell            NYSETransactionHistoryType = "Sell"
)

type NYSETransactionInstrument

type NYSETransactionInstrument struct {
	ID     string `json:"id"`
	Symbol string `json:"symbol"`
	Name   string `json:"name"`
}

NYSETransactionInstrument is the instrument nested on NYSE transactions.

type NYSETransactionRecordRequest

type NYSETransactionRecordRequest struct {
	To        time.Time            `json:"to"`
	From      time.Time            `json:"from"`
	Limit     int                  `json:"limit"`
	Offset    *time.Time           `json:"offset,omitempty"`
	Direction TransactionDirection `json:"direction"`
}

NYSETransactionRecordRequest filters NYSE account transactions.

func NewNYSETransactionRecordRequest

func NewNYSETransactionRecordRequest() NYSETransactionRecordRequest

NewNYSETransactionRecordRequest returns the same defaults used by stake-python.

type NYSETransactionsService

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

NYSETransactionsService lists NYSE account transactions.

func (*NYSETransactionsService) List

List returns transactions matching the request.

type Option

type Option func(*Client) error

Option configures a Client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL rewrites absolute Stake endpoints to the provided base URL. It is primarily useful with httptest.Server.

func WithCredentials

func WithCredentials(username, password string) Option

WithCredentials configures username/password authentication.

func WithCredentialsRequest

func WithCredentialsRequest(request CredentialsLoginRequest) Option

WithCredentialsRequest configures username/password authentication with all request fields.

func WithExchange

func WithExchange(exchange Exchange) Option

WithExchange selects the exchange used by Login when retrieving the user record.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets the HTTP client used for requests.

func WithSessionToken

func WithSessionToken(token string) Option

WithSessionToken configures token-based authentication.

func WithSessionTokenFromEnv

func WithSessionTokenFromEnv(name string) Option

WithSessionTokenFromEnv configures token-based authentication from an environment variable. If name is empty, STAKE_TOKEN is used.

type OrderType

type OrderType int

OrderType is a NYSE pending-order type.

const (
	OrderTypeMarket OrderType = 1
	OrderTypeLimit  OrderType = 2
	OrderTypeStop   OrderType = 3
)

type ProductSearchByName

type ProductSearchByName struct {
	Keyword string `json:"keyword"`
}

ProductSearchByName searches products by name, description, or symbol-like keyword.

type Rating

type Rating struct {
	ID            string     `json:"id,omitempty"`
	Symbol        string     `json:"ticker,omitempty"`
	Exchange      string     `json:"exchange,omitempty"`
	Name          string     `json:"name,omitempty"`
	Analyst       string     `json:"analyst,omitempty"`
	Currency      string     `json:"currency,omitempty"`
	URL           string     `json:"url,omitempty"`
	Importance    *int       `json:"importance,omitempty"`
	Notes         string     `json:"notes,omitempty"`
	Updated       *time.Time `json:"updated,omitempty"`
	ActionPT      string     `json:"action_pt,omitempty"`
	ActionCompany string     `json:"action_company,omitempty"`
	RatingCurrent *string    `json:"rating_current,omitempty"`
	PTCurrent     *float64   `json:"pt_current,omitempty"`
	RatingPrior   *string    `json:"rating_prior,omitempty"`
	PTPrior       *float64   `json:"pt_prior,omitempty"`
	URLCalendar   string     `json:"url_calendar,omitempty"`
	URLNews       string     `json:"url_news,omitempty"`
	AnalystName   string     `json:"analyst_name,omitempty"`
}

Rating is an analyst rating entry.

func (*Rating) UnmarshalJSON

func (r *Rating) UnmarshalJSON(data []byte) error

UnmarshalJSON maps blank rating/price-target fields to nil, matching stake-python.

type RatingsRequest

type RatingsRequest struct {
	Symbols []string
	Limit   int
}

RatingsRequest requests analyst ratings for one or more symbols.

type RatingsService

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

RatingsService lists US-market analyst ratings.

func (*RatingsService) List

func (s *RatingsService) List(ctx context.Context, request RatingsRequest) ([]Rating, error)

List returns analyst ratings for the requested symbols.

type SessionTokenLoginRequest

type SessionTokenLoginRequest struct {
	Token string `json:"token"`
}

SessionTokenLoginRequest authenticates with an existing Stake session token.

type Side

type Side string

Side is a NYSE trade/order side.

const (
	SideBuy  Side = "B"
	SideSell Side = "S"
)

type Statement

type Statement struct {
	Date          string        `json:"date"`
	Quarter       int           `json:"quarter"`
	Year          int           `json:"year"`
	StatementData StatementData `json:"statementData"`
}

Statement is one fundamentals statement period.

type StatementData

type StatementData struct {
	BalanceSheet    []StatementValue `json:"balanceSheet"`
	IncomeStatement []StatementValue `json:"incomeStatement"`
	CashFlow        []StatementValue `json:"cashFlow"`
	Overview        []StatementValue `json:"overview"`
}

StatementData groups fundamentals data categories.

type StatementRequest

type StatementRequest struct {
	Symbol    string
	StartDate time.Time
}

StatementRequest requests fundamentals statements for a symbol.

type StatementService

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

StatementService lists US-market fundamentals statements.

func (*StatementService) List

func (s *StatementService) List(ctx context.Context, request StatementRequest) ([]Statement, error)

List returns fundamentals statements for a symbol.

type StatementValue

type StatementValue struct {
	DataCode string  `json:"dataCode"`
	Value    float64 `json:"value"`
}

StatementValue is one fundamentals data point.

type TransactionDirection

type TransactionDirection string

TransactionDirection controls NYSE transaction pagination direction.

const (
	TransactionDirectionPrevious TransactionDirection = "prev"
	TransactionDirectionNext     TransactionDirection = "next"
)

type UpdateWatchlistRequest

type UpdateWatchlistRequest struct {
	ID      string   `json:"id"`
	Tickers []string `json:"tickers"`
}

UpdateWatchlistRequest adds or removes tickers from a watchlist.

type User

type User struct {
	ID                       string `json:"userId"`
	FirstName                string `json:"firstName"`
	LastName                 string `json:"lastName"`
	EmailAddress             string `json:"emailAddress"`
	MACStatus                string `json:"macStatus"`
	AccountType              string `json:"accountType"`
	RegionIdentifier         string `json:"regionIdentifier"`
	DWAccountNumber          string `json:"dw_AccountNumber,omitempty"`
	CanTradeOnUnsettledFunds *bool  `json:"canTradeOnUnsettledFunds,omitempty"`
	Username                 string `json:"username,omitempty"`
}

User is the authenticated Stake user.

type Watchlist

type Watchlist struct {
	WatchlistID string                `json:"watchlistId"`
	Name        string                `json:"name,omitempty"`
	Count       *FlexibleInt          `json:"count,omitempty"`
	TimeCreated *FlexibleTime         `json:"timeCreated,omitempty"`
	Instruments []WatchlistInstrument `json:"instruments,omitempty"`
}

Watchlist is a Stake watchlist.

type WatchlistInstrument

type WatchlistInstrument struct {
	EncodedName        string `json:"encodedName,omitempty"`
	ImageURL           string `json:"imageUrl,omitempty"`
	InstrumentID       string `json:"instrumentId,omitempty"`
	Name               string `json:"name,omitempty"`
	Symbol             string `json:"symbol,omitempty"`
	Type               string `json:"type,omitempty"`
	RecentAnnouncement *bool  `json:"recentAnnouncement,omitempty"`
	Sensitive          *bool  `json:"sensitive,omitempty"`
}

WatchlistInstrument is the common instrument shape returned inside watchlists.

type WatchlistService

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

WatchlistService manages watchlists for one exchange.

func (*WatchlistService) Add

Add adds tickers to a watchlist, ignoring tickers already present.

func (*WatchlistService) Create

Create creates a watchlist. Duplicate local names return an error before the POST.

func (*WatchlistService) Delete

func (s *WatchlistService) Delete(ctx context.Context, request DeleteWatchlistRequest) (bool, error)

Delete deletes a watchlist. It returns true when the deleted ID is absent from the response.

func (*WatchlistService) Get

Get returns a watchlist by ID.

func (*WatchlistService) List

func (s *WatchlistService) List(ctx context.Context) ([]Watchlist, error)

List returns all watchlists for the service exchange.

func (*WatchlistService) Remove

Remove removes tickers from a watchlist, ignoring tickers not present.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL