okx

package module
v0.20260723.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 13 Imported by: 0

README

go-okx

Go Reference

A Go SDK for the OKX v5 API.

OKX v5 is a single unified account API: spot, margin, perpetual swaps, futures, options, funding, sub-accounts, earn and copy-trading are all served from one domain under the /api/v5/* path namespace and signed with one HMAC-SHA256 scheme. This SDK wraps the complete REST surface plus the v5 WebSocket streams.

API Aligned to
/api/v5 REST + v5 WebSocket (public / private / business) 2026-07-23

Response structs are reconciled against the live API (not just the docs), so endpoints stay in sync with the date above: every public endpoint and every private read endpoint is tested against production and the real JSON keys are diffed against the typed structs.

Install

go get github.com/UnipayFI/go-okx@latest

Highlights

  • One signing/transport core for the whole v5 API; a single okx.Client.
  • Fluent per-endpoint API: NewXxxService(...).SetFoo(...).Do(ctx).
  • Amounts as decimal.Decimal, ms timestamps as time.Time — OKX's string-encoded numbers and ""/"0"/"-1" "not set" sentinels are decoded for you (no per-field format tags).
  • OKX's always-an-array data envelope handled by typed helpers (DoList/DoOne/DoObject); batch order results expose per-item sCode.
  • WebSocket: typed subscribe services over the public/private/business gateways, automatic login + ping/pong keepalive, and order entry over a persistent connection.

Quick start

package main

import (
	"context"
	"fmt"

	"github.com/UnipayFI/go-okx"
	"github.com/UnipayFI/go-okx/client"
	"github.com/shopspring/decimal"
)

func main() {
	ctx := context.Background()

	c := okx.NewClient(
		client.WithAuth("apiKey", "apiSecret", "passphrase"),
		// client.WithProxy("socks5://127.0.0.1:7890"),
		// client.WithDemoTrading(true),
	)
	_ = c.SyncServerTime(ctx) // align clock to avoid signature drift

	// Public market data (no auth).
	tickers, _ := c.NewGetTickersService(okx.InstTypeSpot).Do(ctx)
	fmt.Println(len(tickers), "spot tickers")

	// Private account data.
	bal, _ := c.NewGetBalanceService().Do(ctx)
	fmt.Println("total equity:", bal.TotalEq)

	// Place a limit order.
	ref, err := c.NewPlaceOrderService("BTC-USDT", okx.TdModeCash, okx.SideBuy,
		okx.OrdTypeLimit, decimal.RequireFromString("0.0001")).
		SetPx(decimal.RequireFromString("30000")).
		Do(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Println("ordId:", ref.OrdId, "sCode:", ref.SCode)
}

Authentication

Pass credentials from the OKX API-management page (the passphrase is the one set when the key was created):

c := okx.NewClient(client.WithAuth(apiKey, apiSecret, passphrase))

Requests are signed with HMAC-SHA256 over timestamp + method + requestPath(+ "?" + query) + body, base64-encoded into the OK-ACCESS-SIGN header, with an ISO-8601 millisecond UTC OK-ACCESS-TIMESTAMP. For an RSA key or external signer, pass client.WithSignFn(fn).

Other options: WithProxy (http/https/socks5), WithBaseURL, WithDemoTrading (routes to OKX's paper-trading via the x-simulated-trading header), WithTimeOffset, WithLogger, WithHTTPClient.

Response envelope

OKX always returns {"code":"0","msg":"","data":[ ... ]} with data as an array. Service methods return the natural Go shape:

  • list endpoints → ([]T, error)
  • single-object endpoints (balance, config, place-order ack, …) → (*T, error)
  • batch order place/cancel/amend → ([]T, error) whose items carry sCode/sMsg

WebSocket

ws := okx.NewWebSocketClient(
	client.WithWebSocketAuth(apiKey, apiSecret, passphrase), // private/business channels
)

// Public ticker (public gateway, no login).
done, _, _ := ws.NewSubscribeTickersService("BTC-USDT").
	Do(ctx, func(p *request.WsPush[[]okx.WsTicker], err error) {
		if err != nil {
			return
		}
		fmt.Println(p.Arg.InstID, p.Data[0].Last)
	})
close(done) // unsubscribe + close

// Private account (auto login).
ws.NewSubscribeAccountService().Do(ctx, func(p *request.WsPush[[]okx.WsAccount], err error) {
	// p.Data[0].TotalEq, ...
})

Each Do returns (done chan<- struct{}, stop <-chan struct{}, err error): close done to unsubscribe; stop closes when the reader exits. Ping/pong keepalive is automatic.

Orders can also be placed over a persistent, logged-in connection — a low-latency alternative to the REST trade endpoints:

tc, _ := ws.DialTrade(ctx) // connect + login
defer tc.Close()
ack, _ := tc.PlaceOrder(ctx, okx.OrderArg{
	InstId: "BTC-USDT", TdMode: okx.TdModeCash, Side: okx.SideBuy,
	OrdType: okx.OrdTypeLimit, Sz: decimal.RequireFromString("0.0001"),
	Px: decimal.RequireFromString("30000"),
})
// tc.AmendOrder / tc.CancelOrder / tc.BatchPlaceOrders / ...

Packages

Area Files
Public / market data public_data.go market.go market_index.go rubik.go status.go
Trading account account.go account_bills.go account_borrow.go account_config.go
Trade trade_order.go trade_fills.go trade_convert.go
Algo / Grid / Recurring algo.go grid.go recurring.go
Funding / Convert / Sub-account asset.go convert.go subaccount.go
Financial (earn) finance_savings.go finance_staking.go finance_loan.go
Copy / Block (RFQ) / Spread / Affiliate copytrading.go rfq.go sprd.go affiliate.go
WebSocket ws_public.go ws_business.go ws_private.go ws_trade.go
Package Scope
okx the unified-account REST + WebSocket client (root package)
client/ request/ REST client, options, HMAC signer, envelope decode, WS subscribe/login
common/ constants, global time.Time + decimal.Decimal JSON codec
cmd/okxraw/ dev tool: sign + dump any endpoint's raw response

Testing

Tests hit the live API and read credentials from the environment, skipping when unset:

export OKX_API_KEY=...  OKX_API_SECRET=...  OKX_PASSPHRASE=...
export OKX_PROXY=socks5://127.0.0.1:7890   # optional
export OKX_DEMO=1                            # optional: paper trading

go test ./... -run TestAccount -v                 # one module at a time
OKX_TEST_WRITE=1 go test . -run TestOrderLifecycle # live order test (tiny, reversible)
  • Run per module (-run TestXxx) — OKX rate-limits per endpoint, so the full suite can trip 50011 Too Many Requests (the test helpers auto-retry it).
  • Capability-gated reads (copy-trading, spread, RFQ, fixed-loan, sub-account) are tolerated when the account lacks the capability — signing is still exercised.
  • State-changing endpoints are implemented but never executed by the suite, except the gated TestOrderLifecycle (a tiny far-below-market post_only order on a large-cap pair that is immediately cancelled). Withdrawal is implemented but never tested.

The cmd/okxraw helper dumps any endpoint's raw signed response:

go run ./cmd/okxraw GET /api/v5/account/config
go run ./cmd/okxraw GET /api/v5/account/bills "instType=SPOT&limit=5"

Changelog

  • 2026-06-24 — Initial release. Full OKX v5 REST coverage (trading account, order-book/algo/grid/recurring trading, funding, convert, sub-account, financial products, copy-trading, block (RFQ) & spread trading, public/market data, trading statistics, status) plus the v5 WebSocket streams (public, private and business gateways + WebSocket order entry). Aligned to the OKX v5 docs as of 2026-06-24.

License

MIT

Documentation

Overview

Package okx is a Go SDK for the OKX v5 API.

OKX v5 is a single unified-account API: spot, margin, perpetual swaps, futures, options, funding, sub-accounts, earn and copy-trading are all served from one domain (https://www.okx.com) under the /api/v5/* path namespace and signed with one HMAC-SHA256 scheme. This package exposes every REST endpoint (and, in the ws_*.go files, the v5 WebSocket streams) through a fluent, per-endpoint Service API.

Install: go get github.com/UnipayFI/go-okx Import: import "github.com/UnipayFI/go-okx"

Authentication uses the OK-ACCESS-KEY / OK-ACCESS-SIGN / OK-ACCESS-TIMESTAMP / OK-ACCESS-PASSPHRASE headers; the sign is base64(HMAC-SHA256(secret, prehash)) over timestamp + method + requestPath + body, with an ISO-8601 millisecond UTC timestamp.

Quick start:

c := okx.NewClient(client.WithAuth(apiKey, apiSecret, passphrase))
if err := c.SyncServerTime(ctx); err != nil { /* ... */ }

// Public market data (no auth).
tickers, err := c.NewGetTickersService(okx.InstTypeSpot).Do(ctx)

// Private account data.
bal, err := c.NewGetBalanceService().Do(ctx)

Index

Constants

View Source
const MaxBatchOrders = 20

MaxBatchOrders is the maximum number of orders OKX accepts in a single batch-orders / cancel-batch-orders / amend-batch-orders request (REST) and in the WS batch-* ops. Larger batches are rejected; callers should chunk by this.

View Source
const MaxClOrdIDLen = 32

MaxClOrdIDLen is the maximum length OKX accepts for a client order id (clOrdId). Longer ids are rejected with code 51000 ("Parameter clOrdId error"). OKX also requires the id to be alphanumeric (letters and digits only); see ValidateClOrdID.

Variables

This section is empty.

Functions

func ValidateClOrdID added in v0.20260623.1

func ValidateClOrdID(clOrdId string) error

ValidateClOrdID reports whether clOrdId satisfies OKX's client-order-id rule: at most MaxClOrdIDLen characters, letters and digits only (case-sensitive). It lets callers fail fast instead of round-tripping to a 51000 rejection. An empty clOrdId is allowed (the field is optional) and reported valid.

Types

type AccountConfig

type AccountConfig struct {
	UID                   string   `json:"uid"`
	MainUID               string   `json:"mainUid"`
	AccountLevel          string   `json:"acctLv"`
	AccountSTPMode        string   `json:"acctStpMode"`
	PositionMode          string   `json:"posMode"`
	AutoLoan              bool     `json:"autoLoan"`
	GreeksType            string   `json:"greeksType"`
	Level                 string   `json:"level"`
	LevelTemporary        string   `json:"levelTmp"`
	ContractIsolatedMode  string   `json:"ctIsoMode"`
	MarginIsolatedMode    string   `json:"mgnIsoMode"`
	SpotOffsetType        string   `json:"spotOffsetType"`
	RoleType              string   `json:"roleType"`
	TraderInstruments     []string `json:"traderInsts"`
	SpotTraderInstruments []string `json:"spotTraderInsts"`
	OpAuth                string   `json:"opAuth"`
	KYCLevel              string   `json:"kycLv"`
	Label                 string   `json:"label"`
	IP                    string   `json:"ip"`
	Perm                  string   `json:"perm"`
	LiquidationGear       string   `json:"liquidationGear"`
	EnableSpotBorrow      bool     `json:"enableSpotBorrow"`
	SpotBorrowAutoRepay   bool     `json:"spotBorrowAutoRepay"`
	Type                  string   `json:"type"`
	SpotRoleType          string   `json:"spotRoleType"`
	StrategyType          string   `json:"stgyType"`
	SettleCurrency        string   `json:"settleCcy"`
	SettleCurrencyList    []string `json:"settleCcyList"`
	FeeType               string   `json:"feeType"`
}

AccountConfig is the account's configuration.

type AccountLevelSetting

type AccountLevelSetting struct {
	AccountLevel string `json:"acctLv"`
}

AccountLevelSetting is the set-account-level acknowledgement.

type AccountPositionRisk

type AccountPositionRisk struct {
	Timestamp      time.Time                    `json:"ts"`
	AdjustedEquity decimal.Decimal              `json:"adjEq"`
	BalanceData    []AccountPositionRiskBalance `json:"balData"`
	PositionData   []AccountPositionRiskPos     `json:"posData"`
}

AccountPositionRisk is the account/position risk snapshot.

type AccountPositionRiskBalance

type AccountPositionRiskBalance struct {
	Currency       string          `json:"ccy"`
	Equity         decimal.Decimal `json:"eq"`
	DiscountEquity decimal.Decimal `json:"disEq"`
}

AccountPositionRiskBalance is one currency's equity within the risk snapshot.

type AccountPositionRiskPos

type AccountPositionRiskPos struct {
	InstrumentType   InstType        `json:"instType"`
	InstrumentID     string          `json:"instId"`
	MarginMode       MgnMode         `json:"mgnMode"`
	PositionID       string          `json:"posId"`
	PositionSide     PosSide         `json:"posSide"`
	Position         decimal.Decimal `json:"pos"`
	BaseBalance      decimal.Decimal `json:"baseBal"`
	QuoteBalance     decimal.Decimal `json:"quoteBal"`
	PositionCurrency string          `json:"posCcy"`
	Currency         string          `json:"ccy"`
	NotionalCurrency decimal.Decimal `json:"notionalCcy"`
	NotionalUSD      decimal.Decimal `json:"notionalUsd"`
}

AccountPositionRiskPos is one position's risk data within the snapshot. The account used to validate this SDK had no open positions, so this field set is modeled from the OKX doc field table.

type AccountPositionTier

type AccountPositionTier struct {
	Underlying       string          `json:"uly"`
	InstrumentFamily string          `json:"instFamily"`
	MaxSize          decimal.Decimal `json:"maxSz"`
	PositionType     string          `json:"posType"`
}

AccountPositionTier is the account's maximum position size for an underlying or instrument family.

type AccountRateLimit

type AccountRateLimit struct {
	AccountRateLimit     decimal.Decimal `json:"accRateLimit"`
	FillRatio            decimal.Decimal `json:"fillRatio"`
	MainFillRatio        decimal.Decimal `json:"mainFillRatio"`
	NextAccountRateLimit decimal.Decimal `json:"nextAccRateLimit"`
	Timestamp            time.Time       `json:"ts"`
}

AccountRateLimit is the account's order rate-limit snapshot.

type ActivateOption

type ActivateOption struct {
	Result    bool      `json:"result"`
	Timestamp time.Time `json:"ts"`
}

ActivateOption is the activate-option acknowledgement. Some account states also return a "result" boolean.

type ActivateOptionService

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

ActivateOptionService -- POST /api/v5/account/activate-option (Trade)

Activates option trading for the account. Returns the activation timestamp.

func (*ActivateOptionService) Do

type AdjustFlexLoanCollateralService

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

AdjustFlexLoanCollateralService -- POST /api/v5/finance/flexible-loan/adjust-collateral (Trade)

Adds or reduces collateral on a flexible-loan position. State-changing: implemented but never executed by the test suite. The acknowledgement shape is modeled from the OKX doc field table.

func (*AdjustFlexLoanCollateralService) Do

type AdjustGridInvestmentService

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

AdjustGridInvestmentService -- POST /api/v5/tradingBot/grid/adjust-investment (Trade)

Adds investment to a running spot grid. IMPLEMENT-ONLY.

func (*AdjustGridInvestmentService) Do

type AdjustGridMarginBalanceService

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

AdjustGridMarginBalanceService -- POST /api/v5/tradingBot/grid/margin-balance (Trade)

Adds or reduces the margin of a running contract grid. IMPLEMENT-ONLY.

func (*AdjustGridMarginBalanceService) Do

func (*AdjustGridMarginBalanceService) SetAmt

SetAmt sets the margin amount to add/reduce (mutually exclusive with percent).

func (*AdjustGridMarginBalanceService) SetPercent

SetPercent sets the percentage of margin to add/reduce.

type AdjustLeverageInfo

type AdjustLeverageInfo struct {
	EstimatedAvailableQuoteTransfer decimal.Decimal `json:"estAvailQuoteTrans"`
	EstimatedAvailableTransfer      decimal.Decimal `json:"estAvailTrans"`
	EstimatedLiquidationPrice       decimal.Decimal `json:"estLiqPx"`
	EstimatedMargin                 decimal.Decimal `json:"estMgn"`
	EstimatedQuoteMargin            decimal.Decimal `json:"estQuoteMgn"`
	EstimatedMaxAmount              decimal.Decimal `json:"estMaxAmt"`
	EstimatedQuoteMaxAmount         decimal.Decimal `json:"estQuoteMaxAmt"`
	ExistOrder                      bool            `json:"existOrd"`
	MaxLeverage                     decimal.Decimal `json:"maxLever"`
	MinLeverage                     decimal.Decimal `json:"minLever"`
}

AdjustLeverageInfo is the estimated impact of adjusting leverage.

type AdvChaseParam added in v0.20260723.0

type AdvChaseParam struct {
	ChaseType     string          `json:"chaseType,omitempty"`
	ChaseValue    decimal.Decimal `json:"chaseVal,omitzero"`
	MaxChaseType  string          `json:"maxChaseType,omitempty"`
	MaxChaseValue decimal.Decimal `json:"maxChaseVal,omitzero"`
}

AdvChaseParam carries the chase execution parameters of a FUTURES/SWAP trigger order whose advanceOrdType is "chase": when the trigger fires the spawned order chases the order book. Mirrors the standalone chase order fields.

type AffiliateInviteeDetail

type AffiliateInviteeDetail struct {
	InviteeLevel                string          `json:"inviteeLv"`
	JoinTime                    time.Time       `json:"joinTime"`
	InviteeRebateRate           decimal.Decimal `json:"inviteeRebateRate"`
	TotalCommission             decimal.Decimal `json:"totalCommission"`
	FirstTradeTime              time.Time       `json:"firstTradeTime"`
	Level                       string          `json:"level"`
	DepositAmount               decimal.Decimal `json:"depAmt"`
	Volume                      decimal.Decimal `json:"vol"`
	KYCTime                     time.Time       `json:"kycTime"`
	Region                      string          `json:"region"`
	AffiliateCode               string          `json:"affiliateCode"`
	InvitedTradeVolumeThirtyDay decimal.Decimal `json:"invitedTradeVolThirtyD"`
}

AffiliateInviteeDetail is one invitee's affiliate-relationship detail. The validating account does not have the affiliate role (the endpoint returns code 51620), so the field set is modeled from the OKX affiliate doc field table.

type AlgoAttachOrd

type AlgoAttachOrd struct {
	AttachAlgoClientOrderID    string          `json:"attachAlgoClOrdId,omitempty"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx,omitzero"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType,omitempty"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx,omitzero"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx,omitzero"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType,omitempty"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx,omitzero"`
	Size                       decimal.Decimal `json:"sz,omitzero"`
	AmendPriceOnTriggerType    string          `json:"amendPxOnTriggerType,omitempty"`
}

AlgoAttachOrd is a take-profit / stop-loss order attached to a trigger order.

type AlgoAttachOrdInfo

type AlgoAttachOrdInfo struct {
	AttachAlgoID               string          `json:"attachAlgoId"`
	AttachAlgoClientOrderID    string          `json:"attachAlgoClOrdId"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx"`
	Size                       decimal.Decimal `json:"sz"`
	AmendPriceOnTriggerType    string          `json:"amendPxOnTriggerType"`
	FailCode                   string          `json:"failCode"`
	FailReason                 string          `json:"failReason"`
}

AlgoAttachOrdInfo is a take-profit / stop-loss order attached to a trigger order as returned by the read endpoints.

type AlgoCancelArg

type AlgoCancelArg struct {
	AlgoID       string `json:"algoId"`
	InstrumentID string `json:"instId"`
}

AlgoCancelArg identifies one algo order to cancel.

type AlgoLinkedOrd

type AlgoLinkedOrd struct {
	OrderID string `json:"ordId"`
}

AlgoLinkedOrd is the order linked to an algo order (OCO/conditional).

type AlgoOrdType

type AlgoOrdType string

AlgoOrdType is the type of an algo (trigger / advanced) order.

const (
	AlgoOrdTypeConditional   AlgoOrdType = "conditional"
	AlgoOrdTypeOCO           AlgoOrdType = "oco"
	AlgoOrdTypeTrigger       AlgoOrdType = "trigger"
	AlgoOrdTypeMoveOrderStop AlgoOrdType = "move_order_stop"
	AlgoOrdTypeTwap          AlgoOrdType = "twap"
	AlgoOrdTypeIceberg       AlgoOrdType = "iceberg"
	AlgoOrdTypeChase         AlgoOrdType = "chase"
)

type AlgoOrder

type AlgoOrder struct {
	InstrumentType             InstType        `json:"instType"`
	InstrumentID               string          `json:"instId"`
	Currency                   string          `json:"ccy"`
	OrderID                    string          `json:"ordId"`
	OrderIDList                []string        `json:"ordIdList"`
	AlgoID                     string          `json:"algoId"`
	AlgoClientOrderID          string          `json:"algoClOrdId"`
	ClientOrderID              string          `json:"clOrdId"`
	Size                       decimal.Decimal `json:"sz"`
	CloseFraction              decimal.Decimal `json:"closeFraction"`
	OrderType                  AlgoOrdType     `json:"ordType"`
	Side                       Side            `json:"side"`
	PositionSide               PosSide         `json:"posSide"`
	TradeMode                  TdMode          `json:"tdMode"`
	TargetCurrency             TgtCcy          `json:"tgtCcy"`
	State                      AlgoState       `json:"state"`
	Leverage                   decimal.Decimal `json:"lever"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx"`
	TakeProfitOrderKind        string          `json:"tpOrdKind"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx"`
	TriggerPrice               decimal.Decimal `json:"triggerPx"`
	TriggerPriceType           string          `json:"triggerPxType"`
	OrderPrice                 decimal.Decimal `json:"ordPx"`
	ActualSize                 decimal.Decimal `json:"actualSz"`
	ActualPrice                decimal.Decimal `json:"actualPx"`
	ActualSide                 string          `json:"actualSide"`
	TriggerTime                time.Time       `json:"triggerTime"`
	PriceVariation             decimal.Decimal `json:"pxVar"`
	PriceSpread                decimal.Decimal `json:"pxSpread"`
	SizeLimit                  decimal.Decimal `json:"szLimit"`
	PriceLimit                 decimal.Decimal `json:"pxLimit"`
	TimeInterval               string          `json:"timeInterval"`
	CallbackRatio              decimal.Decimal `json:"callbackRatio"`
	CallbackSpread             decimal.Decimal `json:"callbackSpread"`
	ActivePrice                decimal.Decimal `json:"activePx"`
	MoveTriggerPrice           decimal.Decimal `json:"moveTriggerPx"`
	ChaseType                  string          `json:"chaseType"`
	ChaseValue                 decimal.Decimal `json:"chaseVal"`
	MaxChaseType               string          `json:"maxChaseType"`
	MaxChaseValue              decimal.Decimal `json:"maxChaseVal"`
	// SubAlgoIDList holds the algoId(s) of the chase order(s) spawned when a
	// trigger order with advanceOrdType "chase" fires (FUTURES/SWAP).
	SubAlgoIDList           []string            `json:"subAlgoIdList"`
	ReduceOnly              string              `json:"reduceOnly"`
	QuickMarginType         string              `json:"quickMgnType"`
	Last                    decimal.Decimal     `json:"last"`
	FailCode                string              `json:"failCode"`
	AlgoClientOrderIDParent string              `json:"algoClOrdIdParent"`
	AmendPriceOnTriggerType string              `json:"amendPxOnTriggerType"`
	LinkedOrder             *AlgoLinkedOrd      `json:"linkedOrd"`
	AttachAlgoOrders        []AlgoAttachOrdInfo `json:"attachAlgoOrds"`
	Tag                     string              `json:"tag"`
	CancelOnClosePosition   string              `json:"cxlOnClosePos"`
	IsTradeBorrowMode       string              `json:"isTradeBorrowMode"`
	CreationTime            time.Time           `json:"cTime"`
	UpdateTime              time.Time           `json:"uTime"`
}

AlgoOrder is a single algo (trigger / advanced) order. The validating account had no algo orders, so the field set is modeled from the OKX doc field tables for order-algo / orders-algo-pending / orders-algo-history (a union covering all algo order types).

type AlgoResult

type AlgoResult struct {
	AlgoID            string `json:"algoId"`
	AlgoClientOrderID string `json:"algoClOrdId"`
	ClientOrderID     string `json:"clOrdId"`
	Tag               string `json:"tag"`
	RequestID         string `json:"reqId"`
	SCode             string `json:"sCode"`
	SMsg              string `json:"sMsg"`
}

AlgoResult is the per-item ack returned by the algo place / amend / cancel endpoints. On a top-level code of "1" the real reason is in sCode/sMsg.

func (AlgoResult) Err added in v0.20260623.1

func (r AlgoResult) Err() error

type AlgoState

type AlgoState string

AlgoState is the lifecycle state of an algo order. "live"/"pause" appear on the pending endpoint; "effective"/"canceled"/"order_failed"/"partially_failed" appear on the history endpoint.

const (
	AlgoStateLive            AlgoState = "live"
	AlgoStatePause           AlgoState = "pause"
	AlgoStatePartiallyEff    AlgoState = "partially_effective"
	AlgoStateEffective       AlgoState = "effective"
	AlgoStateCanceled        AlgoState = "canceled"
	AlgoStateOrderFailed     AlgoState = "order_failed"
	AlgoStatePartiallyFailed AlgoState = "partially_failed"
)

type AmendAlgoOrderService

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

AmendAlgoOrderService -- POST /api/v5/trade/amend-algos (Trade)

Amends a single pending algo order. One of algoId / algoClOrdId is required.

func (*AmendAlgoOrderService) Do

func (*AmendAlgoOrderService) SetAlgoClOrdId

func (s *AmendAlgoOrderService) SetAlgoClOrdId(algoClOrdId string) *AmendAlgoOrderService

SetAlgoClOrdId targets the algo order by client-supplied id.

func (*AmendAlgoOrderService) SetAlgoId

func (s *AmendAlgoOrderService) SetAlgoId(algoId string) *AmendAlgoOrderService

SetAlgoId targets the algo order by id (one of algoId / algoClOrdId required).

func (*AmendAlgoOrderService) SetAttachAlgoOrds

func (s *AmendAlgoOrderService) SetAttachAlgoOrds(ords []AlgoAttachOrd) *AmendAlgoOrderService

SetAttachAlgoOrds amends the attached TP/SL orders.

func (*AmendAlgoOrderService) SetCxlOnFail

func (s *AmendAlgoOrderService) SetCxlOnFail(cxl bool) *AmendAlgoOrderService

SetCxlOnFail cancels the order if amendment fails.

func (*AmendAlgoOrderService) SetNewOrdPx

SetNewOrdPx sets the new order price ("-1" for market).

func (*AmendAlgoOrderService) SetNewSlOrdPx

SetNewSlOrdPx sets the new stop-loss order price ("-1" for market).

func (*AmendAlgoOrderService) SetNewSlTriggerPx

func (s *AmendAlgoOrderService) SetNewSlTriggerPx(px decimal.Decimal) *AmendAlgoOrderService

SetNewSlTriggerPx sets the new stop-loss trigger price.

func (*AmendAlgoOrderService) SetNewSlTriggerPxType

func (s *AmendAlgoOrderService) SetNewSlTriggerPxType(pxType string) *AmendAlgoOrderService

SetNewSlTriggerPxType sets the new stop-loss trigger price type.

func (*AmendAlgoOrderService) SetNewSz

SetNewSz sets the new size.

func (*AmendAlgoOrderService) SetNewTpOrdKind

func (s *AmendAlgoOrderService) SetNewTpOrdKind(kind string) *AmendAlgoOrderService

SetNewTpOrdKind sets the new take-profit order kind (condition / limit).

func (*AmendAlgoOrderService) SetNewTpOrdPx

SetNewTpOrdPx sets the new take-profit order price ("-1" for market).

func (*AmendAlgoOrderService) SetNewTpTriggerPx

func (s *AmendAlgoOrderService) SetNewTpTriggerPx(px decimal.Decimal) *AmendAlgoOrderService

SetNewTpTriggerPx sets the new take-profit trigger price.

func (*AmendAlgoOrderService) SetNewTpTriggerPxType

func (s *AmendAlgoOrderService) SetNewTpTriggerPxType(pxType string) *AmendAlgoOrderService

SetNewTpTriggerPxType sets the new take-profit trigger price type.

func (*AmendAlgoOrderService) SetNewTriggerPx

SetNewTriggerPx sets the new trigger price.

func (*AmendAlgoOrderService) SetNewTriggerPxType

func (s *AmendAlgoOrderService) SetNewTriggerPxType(pxType string) *AmendAlgoOrderService

SetNewTriggerPxType sets the new trigger price type.

func (*AmendAlgoOrderService) SetReqId

SetReqId sets a client-supplied request id for the amendment.

type AmendBatchOrdersService

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

AmendBatchOrdersService -- POST /api/v5/trade/amend-batch-orders (Trade)

Amends up to 20 pending orders in a single request (array body).

func (*AmendBatchOrdersService) Do

type AmendCopyCopySettingsService

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

AmendCopyCopySettingsService -- POST /api/v5/copytrading/amend-copy-settings (Trade)

Updates the copy configuration for a lead trader already being copied.

func (*AmendCopyCopySettingsService) Do

func (*AmendCopyCopySettingsService) SetCopyAmt

SetCopyAmt sets the fixed copy amount per order (copyMode=fixed_amount).

func (*AmendCopyCopySettingsService) SetCopyRatio

SetCopyRatio sets the copy ratio (copyMode=ratio_copy).

func (*AmendCopyCopySettingsService) SetCopyTotalAmt

SetCopyTotalAmt sets the total amount budgeted for copying.

func (*AmendCopyCopySettingsService) SetInstId

SetInstId sets the comma-separated instruments to copy (copyInstIdType=custom).

func (*AmendCopyCopySettingsService) SetInstType

SetInstType sets the product line (SWAP).

func (*AmendCopyCopySettingsService) SetSlRatio

SetSlRatio sets the stop-loss ratio.

func (*AmendCopyCopySettingsService) SetSlTotalAmt

SetSlTotalAmt sets the total stop-loss amount.

func (*AmendCopyCopySettingsService) SetTpRatio

SetTpRatio sets the take-profit ratio.

type AmendCopyLeadingInstrumentsService

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

AmendCopyLeadingInstrumentsService -- POST /api/v5/copytrading/amend-leading-instruments (Trade)

Updates the set of instruments the current lead trader leads on.

func (*AmendCopyLeadingInstrumentsService) Do

func (*AmendCopyLeadingInstrumentsService) SetInstType

SetInstType sets the product line (SWAP).

type AmendCopyProfitSharingRatioService

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

AmendCopyProfitSharingRatioService -- POST /api/v5/copytrading/amend-profit-sharing-ratio (Trade)

Updates the lead trader's profit-sharing ratio.

func (*AmendCopyProfitSharingRatioService) Do

func (*AmendCopyProfitSharingRatioService) SetInstType

SetInstType sets the product line (SWAP).

type AmendFixedLoanLendingOrderService

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

AmendFixedLoanLendingOrderService -- POST /api/v5/finance/fixed-loan/amend-lending-order (Trade)

Amends an existing fixed-loan lending order. State-changing: implemented but never executed by the test suite. The acknowledgement shape is modeled from the OKX doc field table.

func (*AmendFixedLoanLendingOrderService) Do

func (*AmendFixedLoanLendingOrderService) SetAutoRenewal

SetAutoRenewal toggles auto-renewal of the order.

func (*AmendFixedLoanLendingOrderService) SetChangeAmt

SetChangeAmt sets the amount to add to (or reduce from) the order.

func (*AmendFixedLoanLendingOrderService) SetRate

SetRate sets a new lending rate for the order.

type AmendGridAlgoOrderService

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

AmendGridAlgoOrderService -- POST /api/v5/tradingBot/grid/amend-order-algo (Trade)

Amends the take-profit / stop-loss settings of a running grid algo order. IMPLEMENT-ONLY.

func (*AmendGridAlgoOrderService) Do

func (*AmendGridAlgoOrderService) SetSlRatio

SetSlRatio sets the stop-loss ratio (contract grid).

func (*AmendGridAlgoOrderService) SetSlTriggerPx

SetSlTriggerPx sets the stop-loss trigger price.

func (*AmendGridAlgoOrderService) SetTpRatio

SetTpRatio sets the take-profit ratio (contract grid).

func (*AmendGridAlgoOrderService) SetTpTriggerPx

SetTpTriggerPx sets the take-profit trigger price.

func (*AmendGridAlgoOrderService) SetTriggerParams

SetTriggerParams sets the trigger-parameter list (advanced trigger config).

type AmendOrderArg

type AmendOrderArg struct {
	InstrumentID                  string          `json:"instId"`
	OrderID                       string          `json:"ordId,omitempty"`
	ClientOrderID                 string          `json:"clOrdId,omitempty"`
	CancelOnFail                  bool            `json:"cxlOnFail,omitempty"`
	RequestID                     string          `json:"reqId,omitempty"`
	NewSize                       decimal.Decimal `json:"newSz,omitzero"`
	NewPrice                      decimal.Decimal `json:"newPx,omitzero"`
	NewPriceUSD                   decimal.Decimal `json:"newPxUsd,omitzero"`
	NewPriceVolatility            decimal.Decimal `json:"newPxVol,omitzero"`
	NewTakeProfitTriggerPrice     decimal.Decimal `json:"newTpTriggerPx,omitzero"`
	NewTakeProfitOrderPrice       decimal.Decimal `json:"newTpOrdPx,omitzero"`
	NewStopLossTriggerPrice       decimal.Decimal `json:"newSlTriggerPx,omitzero"`
	NewStopLossOrderPrice         decimal.Decimal `json:"newSlOrdPx,omitzero"`
	NewTakeProfitTriggerPriceType string          `json:"newTpTriggerPxType,omitempty"`
	NewStopLossTriggerPriceType   string          `json:"newSlTriggerPxType,omitempty"`
	AttachAlgoOrders              []AttachAlgoOrd `json:"attachAlgoOrds,omitempty"`
}

AmendOrderArg is one leg of an amend-batch-orders request body.

type AmendOrderService

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

AmendOrderService -- POST /api/v5/trade/amend-order (Trade)

Amends a single pending order's size and/or price by ordId or clOrdId.

func (*AmendOrderService) Do

func (*AmendOrderService) SetAttachAlgoOrds

func (s *AmendOrderService) SetAttachAlgoOrds(orders []AttachAlgoOrd) *AmendOrderService

SetAttachAlgoOrds amends the attached take-profit / stop-loss algo orders.

func (*AmendOrderService) SetClOrdId

func (s *AmendOrderService) SetClOrdId(clOrdId string) *AmendOrderService

SetClOrdId sets the client-supplied order id (either ordId or clOrdId is required).

func (*AmendOrderService) SetCxlOnFail

func (s *AmendOrderService) SetCxlOnFail(cxlOnFail bool) *AmendOrderService

SetCxlOnFail cancels the order if the amendment fails.

func (*AmendOrderService) SetNewPx

func (s *AmendOrderService) SetNewPx(newPx decimal.Decimal) *AmendOrderService

SetNewPx sets the new order price.

func (*AmendOrderService) SetNewPxUsd

func (s *AmendOrderService) SetNewPxUsd(newPxUsd decimal.Decimal) *AmendOrderService

SetNewPxUsd sets the new options price in USD (OPTION only).

func (*AmendOrderService) SetNewPxVol

func (s *AmendOrderService) SetNewPxVol(newPxVol decimal.Decimal) *AmendOrderService

SetNewPxVol sets the new implied volatility (OPTION only).

func (*AmendOrderService) SetNewSlOrdPx

func (s *AmendOrderService) SetNewSlOrdPx(px decimal.Decimal) *AmendOrderService

SetNewSlOrdPx sets the new stop-loss order price.

func (*AmendOrderService) SetNewSlTriggerPx

func (s *AmendOrderService) SetNewSlTriggerPx(px decimal.Decimal) *AmendOrderService

SetNewSlTriggerPx sets the new stop-loss trigger price.

func (*AmendOrderService) SetNewSlTriggerPxType

func (s *AmendOrderService) SetNewSlTriggerPxType(pxType string) *AmendOrderService

SetNewSlTriggerPxType sets the new stop-loss trigger price type.

func (*AmendOrderService) SetNewSz

func (s *AmendOrderService) SetNewSz(newSz decimal.Decimal) *AmendOrderService

SetNewSz sets the new order size.

func (*AmendOrderService) SetNewTpOrdPx

func (s *AmendOrderService) SetNewTpOrdPx(px decimal.Decimal) *AmendOrderService

SetNewTpOrdPx sets the new take-profit order price.

func (*AmendOrderService) SetNewTpTriggerPx

func (s *AmendOrderService) SetNewTpTriggerPx(px decimal.Decimal) *AmendOrderService

SetNewTpTriggerPx sets the new take-profit trigger price.

func (*AmendOrderService) SetNewTpTriggerPxType

func (s *AmendOrderService) SetNewTpTriggerPxType(pxType string) *AmendOrderService

SetNewTpTriggerPxType sets the new take-profit trigger price type.

func (*AmendOrderService) SetOrdId

func (s *AmendOrderService) SetOrdId(ordId string) *AmendOrderService

SetOrdId sets the order id (either ordId or clOrdId is required).

func (*AmendOrderService) SetReqId

func (s *AmendOrderService) SetReqId(reqId string) *AmendOrderService

SetReqId sets the client-supplied request id for the amendment.

type AmendRecurringOrderService

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

AmendRecurringOrderService -- POST /api/v5/tradingBot/recurring/amend-order-algo (Trade)

Amends the display name of a running recurring-buy strategy. Implement-only; not exercised against the live account.

func (*AmendRecurringOrderService) Do

func (*AmendRecurringOrderService) SetStgyName

SetStgyName sets the new display name for the strategy.

type AmendResult

type AmendResult struct {
	OrderID       string    `json:"ordId"`
	ClientOrderID string    `json:"clOrdId"`
	Timestamp     time.Time `json:"ts"`
	RequestID     string    `json:"reqId"`
	SCode         string    `json:"sCode"`
	SMsg          string    `json:"sMsg"`
}

AmendResult is the ack returned by the amend / batch-amend order endpoints.

func (AmendResult) Err added in v0.20260623.1

func (r AmendResult) Err() error

type AmendSprdOrderService

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

AmendSprdOrderService -- POST /api/v5/sprd/amend-order (Trade)

Amends an existing spread order's price and/or size. Either ordId or clOrdId is required, plus at least one of newSz / newPx.

func (*AmendSprdOrderService) Do

func (*AmendSprdOrderService) SetClOrdId

func (s *AmendSprdOrderService) SetClOrdId(clOrdId string) *AmendSprdOrderService

SetClOrdId identifies the order to amend by its client-supplied id.

func (*AmendSprdOrderService) SetNewPx

SetNewPx sets the new order price.

func (*AmendSprdOrderService) SetNewSz

SetNewSz sets the new order size.

func (*AmendSprdOrderService) SetOrdId

SetOrdId identifies the order to amend by its OKX order id.

func (*AmendSprdOrderService) SetReqId

SetReqId sets a client request id echoed back in the response.

type AnnouncementItem

type AnnouncementItem struct {
	AnnouncementType string    `json:"annType"`
	Title            string    `json:"title"`
	URL              string    `json:"url"`
	PushTime         time.Time `json:"pTime"`
	BusinessPTime    time.Time `json:"businessPTime"`
}

AnnouncementItem is a single announcement entry.

type AnnouncementType

type AnnouncementType struct {
	AnnouncementType            string `json:"annType"`
	AnnouncementTypeDescription string `json:"annTypeDesc"`
}

AnnouncementType is a selectable announcement category.

type Announcements

type Announcements struct {
	TotalPage string             `json:"totalPage"`
	Details   []AnnouncementItem `json:"details"`
}

Announcements is one page of OKX support announcements.

type ApplyBillsHistoryArchiveService

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

ApplyBillsHistoryArchiveService -- POST /api/v5/account/bills-history-archive (Trade)

Applies for a downloadable archive of one quarter's bill records. After the request is processed the download link is fetched via GetBillsHistoryArchiveService.

func (*ApplyBillsHistoryArchiveService) Do

type ApplyCopyLeadTradingService

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

ApplyCopyLeadTradingService -- POST /api/v5/copytrading/apply-lead-trading (Trade)

Applies to become a lead trader on the given instruments.

func (*ApplyCopyLeadTradingService) Do

func (*ApplyCopyLeadTradingService) SetInstType

SetInstType sets the product line (SWAP).

type ApplyMonthlyStatementService

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

ApplyMonthlyStatementService -- POST /api/v5/asset/monthly-statement (private)

Applies for a downloadable monthly transaction statement. IMPLEMENT-ONLY: this creates an export job on a real account and is not executed by the test suite.

func (*ApplyMonthlyStatementService) Do

func (*ApplyMonthlyStatementService) SetMonth

SetMonth sets the statement month (e.g. "Jan"); defaults to the previous month.

type AssetAcctType

type AssetAcctType string

AssetAcctType is a funding/transfer account-type code used by the asset (funding) endpoints. 6 is the funding account, 18 the unified trading account.

const (
	AssetAcctTypeFunding AssetAcctType = "6"
	AssetAcctTypeTrading AssetAcctType = "18"
)

type AssetBill

type AssetBill struct {
	BillID        string          `json:"billId"`
	Currency      string          `json:"ccy"`
	ClientID      string          `json:"clientId"`
	BalanceChange decimal.Decimal `json:"balChg"`
	Balance       decimal.Decimal `json:"bal"`
	Type          string          `json:"type"`
	Notes         string          `json:"notes"`
	Timestamp     time.Time       `json:"ts"`
}

AssetBill is one funding-account balance-change record.

type AssetTransferType

type AssetTransferType string

AssetTransferType selects the kind of transfer for /asset/transfer and /asset/transfer-state: "0" within own account (default), "1" master->sub, "2" sub->master (via master key), "3" sub->master (via sub key), "4" sub->sub.

const (
	AssetTransferTypeWithinAccount       AssetTransferType = "0"
	AssetTransferTypeMasterToSub         AssetTransferType = "1"
	AssetTransferTypeSubToMaster         AssetTransferType = "2"
	AssetTransferTypeSubToMasterBySubKey AssetTransferType = "3"
	AssetTransferTypeSubToSub            AssetTransferType = "4"
)

type AssetValuation

type AssetValuation struct {
	TotalBalance decimal.Decimal       `json:"totalBal"`
	Timestamp    time.Time             `json:"ts"`
	Details      AssetValuationDetails `json:"details"`
}

AssetValuation is the account-wide asset valuation and its per-account-type breakdown.

type AssetValuationDetails

type AssetValuationDetails struct {
	Funding decimal.Decimal `json:"funding"`
	Trading decimal.Decimal `json:"trading"`
	Classic decimal.Decimal `json:"classic"`
	Earn    decimal.Decimal `json:"earn"`
}

AssetValuationDetails breaks the valuation down by account type.

type AttachAlgoOrd

type AttachAlgoOrd struct {
	AttachAlgoID               string          `json:"attachAlgoId,omitempty"`
	AttachAlgoClientOrderID    string          `json:"attachAlgoClOrdId,omitempty"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx,omitzero"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType,omitempty"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx,omitzero"`
	TakeProfitOrderKind        string          `json:"tpOrdKind,omitempty"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx,omitzero"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType,omitempty"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx,omitzero"`
	Size                       decimal.Decimal `json:"sz,omitzero"`
	AmendPriceOnTriggerType    string          `json:"amendPxOnTriggerType,omitempty"`
}

AttachAlgoOrd is an attached take-profit / stop-loss algo order that can be supplied when placing or amending an order. It is used both in the request body (attachAlgoOrds) and as a sub-object of Order in responses.

type AutoLoanSetting

type AutoLoanSetting struct {
	AutoLoan bool `json:"autoLoan"`
}

AutoLoanSetting is the set-auto-loan acknowledgement.

type AutoRepay

type AutoRepay struct {
	AutoRepay bool `json:"autoRepay"`
}

AutoRepay is the ack of a set-auto-repay action.

type Balance

type Balance struct {
	UpdateTime            time.Time       `json:"uTime"`
	TotalEquity           decimal.Decimal `json:"totalEq"`
	IsolatedEquity        decimal.Decimal `json:"isoEq"`
	AdjustedEquity        decimal.Decimal `json:"adjEq"`
	AvailableEquity       decimal.Decimal `json:"availEq"`
	OrderFrozen           decimal.Decimal `json:"ordFroz"`
	IMR                   decimal.Decimal `json:"imr"`
	MMR                   decimal.Decimal `json:"mmr"`
	BorrowFrozen          decimal.Decimal `json:"borrowFroz"`
	MarginRatio           decimal.Decimal `json:"mgnRatio"`
	NotionalUSD           decimal.Decimal `json:"notionalUsd"`
	NotionalUSDForBorrow  decimal.Decimal `json:"notionalUsdForBorrow"`
	NotionalUSDForSwap    decimal.Decimal `json:"notionalUsdForSwap"`
	NotionalUSDForFutures decimal.Decimal `json:"notionalUsdForFutures"`
	NotionalUSDForOption  decimal.Decimal `json:"notionalUsdForOption"`
	UPL                   decimal.Decimal `json:"upl"`
	Delta                 decimal.Decimal `json:"delta"`
	DeltaLeverage         decimal.Decimal `json:"deltaLever"`
	DeltaNeutralStatus    string          `json:"deltaNeutralStatus"`
	Details               []BalanceDetail `json:"details"`
}

Balance is the account-level balance summary plus per-currency details.

type BalanceDetail

type BalanceDetail struct {
	Currency                       string          `json:"ccy"`
	Equity                         decimal.Decimal `json:"eq"`
	CashBalance                    decimal.Decimal `json:"cashBal"`
	UpdateTime                     time.Time       `json:"uTime"`
	IsolatedEquity                 decimal.Decimal `json:"isoEq"`
	AvailableEquity                decimal.Decimal `json:"availEq"`
	DiscountEquity                 decimal.Decimal `json:"disEq"`
	FixedBalance                   decimal.Decimal `json:"fixedBal"`
	AvailableBalance               decimal.Decimal `json:"availBal"`
	FrozenBalance                  decimal.Decimal `json:"frozenBal"`
	OrderFrozen                    decimal.Decimal `json:"ordFrozen"`
	Liability                      decimal.Decimal `json:"liab"`
	UPL                            decimal.Decimal `json:"upl"`
	UPLLiability                   decimal.Decimal `json:"uplLiab"`
	CrossLiability                 decimal.Decimal `json:"crossLiab"`
	IsolatedLiability              decimal.Decimal `json:"isoLiab"`
	RewardBalance                  decimal.Decimal `json:"rewardBal"`
	MarginRatio                    decimal.Decimal `json:"mgnRatio"`
	IMR                            decimal.Decimal `json:"imr"`
	MMR                            decimal.Decimal `json:"mmr"`
	Interest                       decimal.Decimal `json:"interest"`
	TWAP                           decimal.Decimal `json:"twap"`
	MaxLoan                        decimal.Decimal `json:"maxLoan"`
	EquityUSD                      decimal.Decimal `json:"eqUsd"`
	BorrowFrozen                   decimal.Decimal `json:"borrowFroz"`
	NotionalLeverage               decimal.Decimal `json:"notionalLever"`
	StrategyEquity                 decimal.Decimal `json:"stgyEq"`
	IsolatedUPL                    decimal.Decimal `json:"isoUpl"`
	SpotInUseAmount                decimal.Decimal `json:"spotInUseAmt"`
	ClientSpotInUseAmount          decimal.Decimal `json:"clSpotInUseAmt"`
	MaxSpotInUse                   decimal.Decimal `json:"maxSpotInUse"`
	SpotIsolatedBalance            decimal.Decimal `json:"spotIsoBal"`
	SmtSyncEquity                  decimal.Decimal `json:"smtSyncEq"`
	SpotCopyTradingEquity          decimal.Decimal `json:"spotCopyTradingEq"`
	SpotBalance                    decimal.Decimal `json:"spotBal"`
	OpenAveragePrice               decimal.Decimal `json:"openAvgPx"`
	AccumulatedAveragePrice        decimal.Decimal `json:"accAvgPx"`
	SpotUPL                        decimal.Decimal `json:"spotUpl"`
	SpotUPLRatio                   decimal.Decimal `json:"spotUplRatio"`
	TotalPnl                       decimal.Decimal `json:"totalPnl"`
	TotalPnlRatio                  decimal.Decimal `json:"totalPnlRatio"`
	CollateralEnabled              bool            `json:"collateralEnabled"`
	CollateralRestrict             bool            `json:"collateralRestrict"`
	CollateralBorrowAutoConversion decimal.Decimal `json:"colBorrAutoConversion"`
	ColRes                         string          `json:"colRes"`
	AutoLendStatus                 string          `json:"autoLendStatus"`
	AutoLendAmount                 decimal.Decimal `json:"autoLendAmt"`
	AutoLendMatchedAmount          decimal.Decimal `json:"autoLendMtAmt"`
	AutoStakingStatus              string          `json:"autoStakingStatus"`
	FrpType                        string          `json:"frpType"`
}

BalanceDetail is a single currency's balance within the trading account.

type BatchOrdersService

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

BatchOrdersService -- POST /api/v5/trade/batch-orders (Trade)

Places up to 20 orders in a single request (array body). Each result carries its own sCode/sMsg.

func (*BatchOrdersService) Do

type Bill

type Bill struct {
	InstrumentType        InstType        `json:"instType"`
	InstrumentID          string          `json:"instId"`
	BillID                string          `json:"billId"`
	Type                  string          `json:"type"`
	SubType               string          `json:"subType"`
	Timestamp             time.Time       `json:"ts"`
	BalanceChange         decimal.Decimal `json:"balChg"`
	PositionBalanceChange decimal.Decimal `json:"posBalChg"`
	Balance               decimal.Decimal `json:"bal"`
	PositionBalance       decimal.Decimal `json:"posBal"`
	Size                  decimal.Decimal `json:"sz"`
	Price                 decimal.Decimal `json:"px"`
	Pnl                   decimal.Decimal `json:"pnl"`
	Fee                   decimal.Decimal `json:"fee"`
	Currency              string          `json:"ccy"`
	OrderID               string          `json:"ordId"`
	ClientOrderID         string          `json:"clOrdId"`
	TradeID               string          `json:"tradeId"`
	ExecutionType         ExecType        `json:"execType"`
	MarginMode            MgnMode         `json:"mgnMode"`
	ContractType          CtType          `json:"ctType"`
	From                  string          `json:"from"`
	To                    string          `json:"to"`
	Notes                 string          `json:"notes"`
	Interest              decimal.Decimal `json:"interest"`
	Tag                   string          `json:"tag"`
	EarnAmount            decimal.Decimal `json:"earnAmt"`
	EarnAPR               decimal.Decimal `json:"earnApr"`
	FillTime              time.Time       `json:"fillTime"`
	FillForwardPrice      decimal.Decimal `json:"fillFwdPx"`
	FillIndexPrice        decimal.Decimal `json:"fillIdxPx"`
	FillMarkPrice         decimal.Decimal `json:"fillMarkPx"`
	FillMarkVolatility    decimal.Decimal `json:"fillMarkVol"`
	FillPriceVolatility   decimal.Decimal `json:"fillPxVol"`
	FillPriceUSD          decimal.Decimal `json:"fillPxUsd"`
}

Bill is a single account balance-change record, shared by /account/bills and /account/bills-archive.

type BillsHistoryArchive

type BillsHistoryArchive struct {
	Timestamp time.Time `json:"ts"`
	FileHref  string    `json:"fileHref"`
	State     string    `json:"state"`
}

BillsHistoryArchive is the state and download link of a quarterly bills archive request.

type BillsHistoryArchiveQuarter

type BillsHistoryArchiveQuarter string

BillsHistoryArchiveQuarter selects the quarter of a yearly bills-history archive request.

const (
	BillsHistoryArchiveQuarterQ1 BillsHistoryArchiveQuarter = "Q1"
	BillsHistoryArchiveQuarterQ2 BillsHistoryArchiveQuarter = "Q2"
	BillsHistoryArchiveQuarterQ3 BillsHistoryArchiveQuarter = "Q3"
	BillsHistoryArchiveQuarterQ4 BillsHistoryArchiveQuarter = "Q4"
)

type BlockTicker

type BlockTicker struct {
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	VolumeCurrency24h decimal.Decimal `json:"volCcy24h"`
	Volume24h         decimal.Decimal `json:"vol24h"`
	Timestamp         time.Time       `json:"ts"`
}

BlockTicker is the 24h block-trade volume snapshot for an instrument.

type BorrowRepay

type BorrowRepay struct {
	Currency string          `json:"ccy"`
	Side     BorrowRepayType `json:"side"`
	Amount   decimal.Decimal `json:"amt"`
	OrderID  string          `json:"ordId"`
	State    VipLoanState    `json:"state"`
}

BorrowRepay is the ack of a VIP-loan borrow/repay action.

type BorrowRepayHistory

type BorrowRepayHistory struct {
	Currency            string          `json:"ccy"`
	Type                BorrowRepayType `json:"type"`
	Amount              decimal.Decimal `json:"amt"`
	AccumulatedBorrowed decimal.Decimal `json:"accBorrowed"`
	Timestamp           time.Time       `json:"ts"`
}

BorrowRepayHistory is one VIP-loan borrow/repay event.

type BorrowRepayType

type BorrowRepayType string

BorrowRepayType selects whether a borrow/repay record (or action) is a borrow or a repayment.

const (
	BorrowRepayTypeBorrow BorrowRepayType = "borrow"
	BorrowRepayTypeRepay  BorrowRepayType = "repay"
)

type CancelAdvanceAlgoOrdersService

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

CancelAdvanceAlgoOrdersService -- POST /api/v5/trade/cancel-advance-algos (Trade)

Cancels up to 10 pending advanced algo orders (iceberg / twap / move_order_stop) in one request. The body is a JSON ARRAY of {algoId, instId} items.

func (*CancelAdvanceAlgoOrdersService) Do

type CancelAlgoOrdersService

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

CancelAlgoOrdersService -- POST /api/v5/trade/cancel-algos (Trade)

Cancels up to 10 pending algo orders in one request. The body is a JSON ARRAY of {algoId, instId} items.

func (*CancelAlgoOrdersService) Do

type CancelAllAfterResult

type CancelAllAfterResult struct {
	TriggerTime time.Time `json:"triggerTime"`
	Tag         string    `json:"tag"`
	Timestamp   time.Time `json:"ts"`
}

CancelAllAfterResult is the ack returned by the cancel-all-after endpoint.

type CancelAllAfterRfqService

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

CancelAllAfterRfqService -- POST /api/v5/rfq/cancel-all-after (Trade)

Arms a dead-man's-switch: cancels all quotes after the given number of seconds unless re-armed (0 disarms).

func (*CancelAllAfterRfqService) Do

type CancelAllAfterService

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

CancelAllAfterService -- POST /api/v5/trade/cancel-all-after (Trade)

Arms (or disarms with timeOut 0) a dead-man's-switch that cancels all pending orders after the given number of seconds if not refreshed.

func (*CancelAllAfterService) Do

func (*CancelAllAfterService) SetTag

SetTag sets the order tag scope for the timer.

type CancelAllRfqQuotesService

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

CancelAllRfqQuotesService -- POST /api/v5/rfq/cancel-all-quotes (Trade)

Cancels all of the account's active quotes.

func (*CancelAllRfqQuotesService) Do

type CancelAllRfqsService

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

CancelAllRfqsService -- POST /api/v5/rfq/cancel-all-rfqs (Trade)

Cancels all of the account's active RFQs.

func (*CancelAllRfqsService) Do

type CancelAllSprdOrdersService

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

CancelAllSprdOrdersService -- POST /api/v5/sprd/cancel-all-orders (Trade)

Cancels all pending spread orders, optionally scoped to one spread.

func (*CancelAllSprdOrdersService) Do

func (*CancelAllSprdOrdersService) SetSprdId

SetSprdId scopes the cancellation to a single spread.

type CancelBatchOrdersService

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

CancelBatchOrdersService -- POST /api/v5/trade/cancel-batch-orders (Trade)

Cancels up to 20 pending orders in a single request (array body).

func (*CancelBatchOrdersService) Do

type CancelBatchRfqQuotesService

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

CancelBatchRfqQuotesService -- POST /api/v5/rfq/cancel-batch-quotes (Trade)

Cancels multiple active quotes in one request.

func (*CancelBatchRfqQuotesService) Do

func (*CancelBatchRfqQuotesService) SetClQuoteIds

func (s *CancelBatchRfqQuotesService) SetClQuoteIds(clQuoteIds []string) *CancelBatchRfqQuotesService

SetClQuoteIds targets the quotes by client-supplied id.

func (*CancelBatchRfqQuotesService) SetQuoteIds

SetQuoteIds targets the quotes by id.

type CancelBatchRfqsService

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

CancelBatchRfqsService -- POST /api/v5/rfq/cancel-batch-rfqs (Trade)

Cancels multiple active RFQs in one request.

func (*CancelBatchRfqsService) Do

func (*CancelBatchRfqsService) SetClRfqIds

func (s *CancelBatchRfqsService) SetClRfqIds(clRfqIds []string) *CancelBatchRfqsService

SetClRfqIds targets the RFQs by client-supplied id.

func (*CancelBatchRfqsService) SetRfqIds

func (s *CancelBatchRfqsService) SetRfqIds(rfqIds []string) *CancelBatchRfqsService

SetRfqIds targets the RFQs by id.

type CancelGridCloseOrderService

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

CancelGridCloseOrderService -- POST /api/v5/tradingBot/grid/cancel-close-order (Trade)

Cancels an outstanding close-position order of a stopped contract grid. IMPLEMENT-ONLY.

func (*CancelGridCloseOrderService) Do

type CancelOrderArg

type CancelOrderArg struct {
	InstrumentID  string `json:"instId"`
	OrderID       string `json:"ordId,omitempty"`
	ClientOrderID string `json:"clOrdId,omitempty"`
}

CancelOrderArg is one leg of a cancel-batch-orders request body.

type CancelOrderService

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

CancelOrderService -- POST /api/v5/trade/cancel-order (Trade)

Cancels a single pending order by ordId or clOrdId.

func (*CancelOrderService) Do

func (*CancelOrderService) SetClOrdId

func (s *CancelOrderService) SetClOrdId(clOrdId string) *CancelOrderService

SetClOrdId sets the client-supplied order id (either ordId or clOrdId is required).

func (*CancelOrderService) SetOrdId

func (s *CancelOrderService) SetOrdId(ordId string) *CancelOrderService

SetOrdId sets the order id (either ordId or clOrdId is required).

type CancelRfqQuoteService

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

CancelRfqQuoteService -- POST /api/v5/rfq/cancel-quote (Trade)

Cancels a single active quote.

func (*CancelRfqQuoteService) Do

func (*CancelRfqQuoteService) SetClQuoteId

func (s *CancelRfqQuoteService) SetClQuoteId(clQuoteId string) *CancelRfqQuoteService

SetClQuoteId targets the quote by client-supplied id.

func (*CancelRfqQuoteService) SetClRfqId

func (s *CancelRfqQuoteService) SetClRfqId(clRfqId string) *CancelRfqQuoteService

SetClRfqId restricts cancellation to quotes on the given client RFQ id.

func (*CancelRfqQuoteService) SetQuoteId

func (s *CancelRfqQuoteService) SetQuoteId(quoteId string) *CancelRfqQuoteService

SetQuoteId targets the quote by id (one of quoteId / clQuoteId is required).

func (*CancelRfqQuoteService) SetRfqId

SetRfqId restricts cancellation to quotes on the given RFQ.

type CancelRfqService

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

CancelRfqService -- POST /api/v5/rfq/cancel-rfq (Trade)

Cancels a single active RFQ.

func (*CancelRfqService) Do

func (*CancelRfqService) SetClRfqId

func (s *CancelRfqService) SetClRfqId(clRfqId string) *CancelRfqService

SetClRfqId targets the RFQ by client-supplied id.

func (*CancelRfqService) SetRfqId

func (s *CancelRfqService) SetRfqId(rfqId string) *CancelRfqService

SetRfqId targets the RFQ by id (one of rfqId / clRfqId is required).

type CancelSprdOrderAlgoService

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

CancelSprdOrderAlgoService -- POST /api/v5/sprd/cancel-order-algo (Trade)

Cancels a single spread algo order by algoId or algoClOrdId.

func (*CancelSprdOrderAlgoService) Do

func (*CancelSprdOrderAlgoService) SetAlgoClOrdId

func (s *CancelSprdOrderAlgoService) SetAlgoClOrdId(algoClOrdId string) *CancelSprdOrderAlgoService

SetAlgoClOrdId cancels by client-supplied algo id.

func (*CancelSprdOrderAlgoService) SetAlgoId

SetAlgoId cancels by OKX algo id.

type CancelSprdOrderService

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

CancelSprdOrderService -- POST /api/v5/sprd/cancel-order (Trade)

Cancels a single spread order by ordId or clOrdId.

func (*CancelSprdOrderService) Do

func (*CancelSprdOrderService) SetClOrdId

func (s *CancelSprdOrderService) SetClOrdId(clOrdId string) *CancelSprdOrderService

SetClOrdId cancels by client-supplied order id.

func (*CancelSprdOrderService) SetOrdId

SetOrdId cancels by OKX order id.

type CancelStakingService

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

CancelStakingService -- POST /api/v5/finance/staking-defi/cancel (Trade)

Cancels a pending purchase/redemption of an on-chain earn order. State-changing: implement-only.

func (*CancelStakingService) Do

type CancelWithdrawal

type CancelWithdrawal struct {
	WithdrawalID string `json:"wdId"`
}

CancelWithdrawal is the acknowledgement of a withdrawal cancellation.

type CancelWithdrawalService

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

CancelWithdrawalService -- POST /api/v5/asset/cancel-withdrawal (private)

Cancels a pending withdrawal. IMPLEMENT-ONLY: acts on a real withdrawal and is not executed by the test suite.

func (*CancelWithdrawalService) Do

type Candle

type Candle struct {
	Timestamp           time.Time
	Open                decimal.Decimal
	High                decimal.Decimal
	Low                 decimal.Decimal
	Close               decimal.Decimal
	Volume              decimal.Decimal
	VolumeCurrency      decimal.Decimal
	VolumeCurrencyQuote decimal.Decimal
	Confirm             string
}

Candle is one OHLCV candlestick from the market candle endpoints. The raw response is an array-of-arrays with 9 columns: [ts, o, h, l, c, vol, volCcy, volCcyQuote, confirm].

type Client

type Client struct {
	*client.Client
}

Client is the REST client for OKX's v5 unified-account (/api/v5/*) endpoints. It embeds the shared core client, which holds the signing/transport machinery and the client/server clock offset.

func NewClient

func NewClient(options ...client.Options) *Client

NewClient constructs an OKX v5 REST client.

func (*Client) NewActivateOptionService

func (c *Client) NewActivateOptionService() *ActivateOptionService

func (*Client) NewAdjustFlexLoanCollateralService

func (c *Client) NewAdjustFlexLoanCollateralService(typ FlexLoanAdjustType, collateralCcy string, collateralAmt decimal.Decimal) *AdjustFlexLoanCollateralService

func (*Client) NewAdjustGridInvestmentService

func (c *Client) NewAdjustGridInvestmentService(algoId string, amt decimal.Decimal) *AdjustGridInvestmentService

func (*Client) NewAdjustGridMarginBalanceService

func (c *Client) NewAdjustGridMarginBalanceService(algoId, typ string) *AdjustGridMarginBalanceService

NewAdjustGridMarginBalanceService builds the request. typ is "add" or "reduce".

func (*Client) NewAmendAlgoOrderService

func (c *Client) NewAmendAlgoOrderService(instId string) *AmendAlgoOrderService

func (*Client) NewAmendBatchOrdersService

func (c *Client) NewAmendBatchOrdersService(orders []AmendOrderArg) *AmendBatchOrdersService

func (*Client) NewAmendCopyCopySettingsService

func (c *Client) NewAmendCopyCopySettingsService(uniqueCode, copyMgnMode, copyInstIdType, copyMode, subPosCloseType string) *AmendCopyCopySettingsService

func (*Client) NewAmendCopyLeadingInstrumentsService

func (c *Client) NewAmendCopyLeadingInstrumentsService(instId string) *AmendCopyLeadingInstrumentsService

func (*Client) NewAmendCopyProfitSharingRatioService

func (c *Client) NewAmendCopyProfitSharingRatioService(profitSharingRatio decimal.Decimal) *AmendCopyProfitSharingRatioService

func (*Client) NewAmendFixedLoanLendingOrderService

func (c *Client) NewAmendFixedLoanLendingOrderService(ordId string) *AmendFixedLoanLendingOrderService

func (*Client) NewAmendGridAlgoOrderService

func (c *Client) NewAmendGridAlgoOrderService(algoId, instId string) *AmendGridAlgoOrderService

func (*Client) NewAmendOrderService

func (c *Client) NewAmendOrderService(instId string) *AmendOrderService

func (*Client) NewAmendRecurringOrderService

func (c *Client) NewAmendRecurringOrderService(algoId string) *AmendRecurringOrderService

func (*Client) NewAmendSprdOrderService

func (c *Client) NewAmendSprdOrderService() *AmendSprdOrderService

func (*Client) NewApplyBillsHistoryArchiveService

func (c *Client) NewApplyBillsHistoryArchiveService(year string, quarter BillsHistoryArchiveQuarter) *ApplyBillsHistoryArchiveService

NewApplyBillsHistoryArchiveService builds the apply request. year is a 4-digit year (e.g. "2024"); quarter is Q1..Q4.

func (*Client) NewApplyCopyLeadTradingService

func (c *Client) NewApplyCopyLeadTradingService(instId string) *ApplyCopyLeadTradingService

func (*Client) NewApplyMonthlyStatementService

func (c *Client) NewApplyMonthlyStatementService() *ApplyMonthlyStatementService

func (*Client) NewBatchOrdersService

func (c *Client) NewBatchOrdersService(orders []OrderArg) *BatchOrdersService

func (*Client) NewCancelAdvanceAlgoOrdersService

func (c *Client) NewCancelAdvanceAlgoOrdersService(items []AlgoCancelArg) *CancelAdvanceAlgoOrdersService

func (*Client) NewCancelAlgoOrdersService

func (c *Client) NewCancelAlgoOrdersService(items []AlgoCancelArg) *CancelAlgoOrdersService

func (*Client) NewCancelAllAfterRfqService

func (c *Client) NewCancelAllAfterRfqService(timeOut int) *CancelAllAfterRfqService

func (*Client) NewCancelAllAfterService

func (c *Client) NewCancelAllAfterService(timeOut int) *CancelAllAfterService

func (*Client) NewCancelAllRfqQuotesService

func (c *Client) NewCancelAllRfqQuotesService() *CancelAllRfqQuotesService

func (*Client) NewCancelAllRfqsService

func (c *Client) NewCancelAllRfqsService() *CancelAllRfqsService

func (*Client) NewCancelAllSprdOrdersService

func (c *Client) NewCancelAllSprdOrdersService() *CancelAllSprdOrdersService

func (*Client) NewCancelBatchOrdersService

func (c *Client) NewCancelBatchOrdersService(orders []CancelOrderArg) *CancelBatchOrdersService

func (*Client) NewCancelBatchRfqQuotesService

func (c *Client) NewCancelBatchRfqQuotesService() *CancelBatchRfqQuotesService

func (*Client) NewCancelBatchRfqsService

func (c *Client) NewCancelBatchRfqsService() *CancelBatchRfqsService

func (*Client) NewCancelGridCloseOrderService

func (c *Client) NewCancelGridCloseOrderService(algoId, ordId string) *CancelGridCloseOrderService

func (*Client) NewCancelOrderService

func (c *Client) NewCancelOrderService(instId string) *CancelOrderService

func (*Client) NewCancelRfqQuoteService

func (c *Client) NewCancelRfqQuoteService() *CancelRfqQuoteService

func (*Client) NewCancelRfqService

func (c *Client) NewCancelRfqService() *CancelRfqService

func (*Client) NewCancelSprdOrderAlgoService

func (c *Client) NewCancelSprdOrderAlgoService() *CancelSprdOrderAlgoService

func (*Client) NewCancelSprdOrderService

func (c *Client) NewCancelSprdOrderService() *CancelSprdOrderService

func (*Client) NewCancelStakingService

func (c *Client) NewCancelStakingService(ordId string, protocolType StakingProtocolType) *CancelStakingService

func (*Client) NewCancelWithdrawalService

func (c *Client) NewCancelWithdrawalService(wdId string) *CancelWithdrawalService

func (*Client) NewCloseCopySubpositionService

func (c *Client) NewCloseCopySubpositionService(subPosId string) *CloseCopySubpositionService

func (*Client) NewCloseGridPositionService

func (c *Client) NewCloseGridPositionService(algoId string, mktClose bool) *CloseGridPositionService

func (*Client) NewClosePositionService

func (c *Client) NewClosePositionService(instId string, mgnMode MgnMode) *ClosePositionService

func (*Client) NewComputeGridMarginBalanceService

func (c *Client) NewComputeGridMarginBalanceService(algoId, typ string) *ComputeGridMarginBalanceService

NewComputeGridMarginBalanceService builds the estimate. typ is "add" or "reduce".

func (*Client) NewConvertEstimateQuoteService

func (c *Client) NewConvertEstimateQuoteService(baseCcy, quoteCcy string, side Side, rfqSz decimal.Decimal, rfqSzCcy string) *ConvertEstimateQuoteService

NewConvertEstimateQuoteService builds an estimate-quote request. side is the trade direction relative to baseCcy; rfqSz is the requested size denominated in rfqSzCcy (which must be either baseCcy or quoteCcy).

func (*Client) NewConvertTradeService

func (c *Client) NewConvertTradeService(quoteId, baseCcy, quoteCcy string, side Side, sz decimal.Decimal, szCcy string) *ConvertTradeService

NewConvertTradeService builds a convert-trade request. quoteId is the id from estimate-quote; sz is the size denominated in szCcy (which must be either baseCcy or quoteCcy).

func (*Client) NewCreateRfqQuoteService

func (c *Client) NewCreateRfqQuoteService(rfqId string, quoteSide RfqQuoteSide, legs []RfqQuoteCreateLeg) *CreateRfqQuoteService

func (*Client) NewCreateRfqService

func (c *Client) NewCreateRfqService(counterparties []string, legs []RfqCreateLeg) *CreateRfqService

func (*Client) NewCreateSubAccountApiKeyService

func (c *Client) NewCreateSubAccountApiKeyService(subAcct, label, passphrase string) *CreateSubAccountApiKeyService

func (*Client) NewDeleteSubAccountApiKeyService

func (c *Client) NewDeleteSubAccountApiKeyService(subAcct, apiKey string) *DeleteSubAccountApiKeyService

func (*Client) NewExecuteQuoteService

func (c *Client) NewExecuteQuoteService(rfqId, quoteId string) *ExecuteQuoteService

func (*Client) NewFirstCopyCopySettingsService

func (c *Client) NewFirstCopyCopySettingsService(uniqueCode, copyMgnMode, copyInstIdType, copyMode, subPosCloseType string) *FirstCopyCopySettingsService

func (*Client) NewFundsTransferService

func (c *Client) NewFundsTransferService(ccy string, amt decimal.Decimal, from, to AssetAcctType) *FundsTransferService

NewFundsTransferService builds a transfer. ccy is the currency, amt the amount, from/to the source and destination account types.

func (*Client) NewGetAccountConfigService

func (c *Client) NewGetAccountConfigService() *GetAccountConfigService

func (*Client) NewGetAccountInstrumentsService

func (c *Client) NewGetAccountInstrumentsService(instType InstType) *GetAccountInstrumentsService

func (*Client) NewGetAccountPositionRiskService

func (c *Client) NewGetAccountPositionRiskService() *GetAccountPositionRiskService

func (*Client) NewGetAccountPositionTiersService

func (c *Client) NewGetAccountPositionTiersService(instType InstType) *GetAccountPositionTiersService

func (*Client) NewGetAccountRateLimitService

func (c *Client) NewGetAccountRateLimitService() *GetAccountRateLimitService

func (*Client) NewGetAdjustLeverageInfoService

func (c *Client) NewGetAdjustLeverageInfoService(instType InstType, mgnMode MgnMode, lever decimal.Decimal) *GetAdjustLeverageInfoService

func (*Client) NewGetAffiliateInviteeDetailService

func (c *Client) NewGetAffiliateInviteeDetailService(uid string) *GetAffiliateInviteeDetailService

func (*Client) NewGetAlgoOrderService

func (c *Client) NewGetAlgoOrderService() *GetAlgoOrderService

func (*Client) NewGetAlgoOrdersHistoryService

func (c *Client) NewGetAlgoOrdersHistoryService(ordType AlgoOrdType) *GetAlgoOrdersHistoryService

func (*Client) NewGetAlgoOrdersPendingService

func (c *Client) NewGetAlgoOrdersPendingService(ordType AlgoOrdType) *GetAlgoOrdersPendingService

func (*Client) NewGetAnnouncementTypesService

func (c *Client) NewGetAnnouncementTypesService() *GetAnnouncementTypesService

func (*Client) NewGetAnnouncementsService

func (c *Client) NewGetAnnouncementsService() *GetAnnouncementsService

func (*Client) NewGetAssetBillsService

func (c *Client) NewGetAssetBillsService() *GetAssetBillsService

func (*Client) NewGetAssetValuationService

func (c *Client) NewGetAssetValuationService() *GetAssetValuationService

func (*Client) NewGetBalanceService

func (c *Client) NewGetBalanceService() *GetBalanceService

func (*Client) NewGetBillsArchiveService

func (c *Client) NewGetBillsArchiveService() *GetBillsArchiveService

func (*Client) NewGetBillsHistoryArchiveService

func (c *Client) NewGetBillsHistoryArchiveService(year string, quarter BillsHistoryArchiveQuarter) *GetBillsHistoryArchiveService

NewGetBillsHistoryArchiveService builds the request. year is a 4-digit year (e.g. "2024"); quarter is Q1..Q4.

func (*Client) NewGetBillsService

func (c *Client) NewGetBillsService() *GetBillsService

func (*Client) NewGetBlockTickersService

func (c *Client) NewGetBlockTickersService(instType InstType) *GetBlockTickersService

func (*Client) NewGetBooksFullService

func (c *Client) NewGetBooksFullService(instId string) *GetBooksFullService

func (*Client) NewGetBooksService

func (c *Client) NewGetBooksService(instId string) *GetBooksService

func (*Client) NewGetBorrowRepayHistoryService

func (c *Client) NewGetBorrowRepayHistoryService() *GetBorrowRepayHistoryService

func (*Client) NewGetCandlesService

func (c *Client) NewGetCandlesService(instId string) *GetCandlesService

func (*Client) NewGetCollateralAssetsService

func (c *Client) NewGetCollateralAssetsService() *GetCollateralAssetsService

func (*Client) NewGetContractsOpenInterestVolumeService

func (c *Client) NewGetContractsOpenInterestVolumeService(ccy string) *GetContractsOpenInterestVolumeService

func (*Client) NewGetConvertContractCoinService

func (c *Client) NewGetConvertContractCoinService(typ, instId, sz string) *GetConvertContractCoinService

NewGetConvertContractCoinService builds the conversion. typ is "1" (coin -> to contract) or "2" (contract -> to coin); instId is the derivatives instrument; sz is the quantity to convert.

func (*Client) NewGetConvertCurrenciesService

func (c *Client) NewGetConvertCurrenciesService() *GetConvertCurrenciesService

func (*Client) NewGetConvertCurrencyPairService

func (c *Client) NewGetConvertCurrencyPairService(fromCcy, toCcy string) *GetConvertCurrencyPairService

func (*Client) NewGetConvertHistoryService

func (c *Client) NewGetConvertHistoryService() *GetConvertHistoryService

func (*Client) NewGetCopyBatchLeverageInfoService

func (c *Client) NewGetCopyBatchLeverageInfoService(mgnMode MgnMode, uniqueCode string) *GetCopyBatchLeverageInfoService

func (*Client) NewGetCopyConfigService

func (c *Client) NewGetCopyConfigService() *GetCopyConfigService

func (*Client) NewGetCopyCurrentSubpositionsService

func (c *Client) NewGetCopyCurrentSubpositionsService() *GetCopyCurrentSubpositionsService

func (*Client) NewGetCopyInstrumentsService

func (c *Client) NewGetCopyInstrumentsService() *GetCopyInstrumentsService

func (*Client) NewGetCopyLeadTradersService

func (c *Client) NewGetCopyLeadTradersService() *GetCopyLeadTradersService

func (*Client) NewGetCopyProfitSharingDetailsService

func (c *Client) NewGetCopyProfitSharingDetailsService() *GetCopyProfitSharingDetailsService

func (*Client) NewGetCopyPublicConfigService

func (c *Client) NewGetCopyPublicConfigService() *GetCopyPublicConfigService

func (*Client) NewGetCopyPublicLeadTradersService

func (c *Client) NewGetCopyPublicLeadTradersService() *GetCopyPublicLeadTradersService

func (*Client) NewGetCopySettingsService

func (c *Client) NewGetCopySettingsService(instType InstType, uniqueCode string) *GetCopySettingsService

func (*Client) NewGetCopySubpositionsHistoryService

func (c *Client) NewGetCopySubpositionsHistoryService() *GetCopySubpositionsHistoryService

func (*Client) NewGetCopyTotalProfitSharingService

func (c *Client) NewGetCopyTotalProfitSharingService() *GetCopyTotalProfitSharingService

func (*Client) NewGetCopyTotalUnrealizedProfitSharingService

func (c *Client) NewGetCopyTotalUnrealizedProfitSharingService() *GetCopyTotalUnrealizedProfitSharingService

func (*Client) NewGetCopyTradersService

func (c *Client) NewGetCopyTradersService(uniqueCode string) *GetCopyTradersService

func (*Client) NewGetCopyUnrealizedProfitSharingDetailsService

func (c *Client) NewGetCopyUnrealizedProfitSharingDetailsService() *GetCopyUnrealizedProfitSharingDetailsService

func (*Client) NewGetCurrenciesService

func (c *Client) NewGetCurrenciesService() *GetCurrenciesService

func (*Client) NewGetDeliveryExerciseHistoryService

func (c *Client) NewGetDeliveryExerciseHistoryService(instType InstType) *GetDeliveryExerciseHistoryService

func (*Client) NewGetDepositAddressService

func (c *Client) NewGetDepositAddressService(ccy string) *GetDepositAddressService

func (*Client) NewGetDepositHistoryService

func (c *Client) NewGetDepositHistoryService() *GetDepositHistoryService

func (*Client) NewGetDepositWithdrawStatusService

func (c *Client) NewGetDepositWithdrawStatusService() *GetDepositWithdrawStatusService

func (*Client) NewGetDiscountRateInterestFreeQuotaService

func (c *Client) NewGetDiscountRateInterestFreeQuotaService() *GetDiscountRateInterestFreeQuotaService

func (*Client) NewGetEasyConvertCurrencyListService

func (c *Client) NewGetEasyConvertCurrencyListService() *GetEasyConvertCurrencyListService

func (*Client) NewGetEasyConvertHistoryService

func (c *Client) NewGetEasyConvertHistoryService() *GetEasyConvertHistoryService

func (*Client) NewGetEconomicCalendarService

func (c *Client) NewGetEconomicCalendarService() *GetEconomicCalendarService

func (*Client) NewGetEntrustSubAccountListService

func (c *Client) NewGetEntrustSubAccountListService() *GetEntrustSubAccountListService

func (*Client) NewGetEstimatedPriceService

func (c *Client) NewGetEstimatedPriceService(instId string) *GetEstimatedPriceService

func (*Client) NewGetEthStakingApyHistoryService

func (c *Client) NewGetEthStakingApyHistoryService(days int) *GetEthStakingApyHistoryService

func (*Client) NewGetEthStakingBalanceService

func (c *Client) NewGetEthStakingBalanceService() *GetEthStakingBalanceService

func (*Client) NewGetEthStakingHistoryService

func (c *Client) NewGetEthStakingHistoryService() *GetEthStakingHistoryService

func (*Client) NewGetEthStakingProductInfoService

func (c *Client) NewGetEthStakingProductInfoService() *GetEthStakingProductInfoService

func (*Client) NewGetExchangeListService

func (c *Client) NewGetExchangeListService() *GetExchangeListService

func (*Client) NewGetExchangeRateService

func (c *Client) NewGetExchangeRateService() *GetExchangeRateService

func (*Client) NewGetFillsHistoryService

func (c *Client) NewGetFillsHistoryService(instType InstType) *GetFillsHistoryService

func (*Client) NewGetFillsService

func (c *Client) NewGetFillsService() *GetFillsService

func (*Client) NewGetFixedLoanLendingApyHistoryService

func (c *Client) NewGetFixedLoanLendingApyHistoryService(ccy, term string) *GetFixedLoanLendingApyHistoryService

func (*Client) NewGetFixedLoanLendingOffersService

func (c *Client) NewGetFixedLoanLendingOffersService() *GetFixedLoanLendingOffersService

func (*Client) NewGetFixedLoanLendingOrdersListService

func (c *Client) NewGetFixedLoanLendingOrdersListService() *GetFixedLoanLendingOrdersListService

func (*Client) NewGetFixedLoanLendingSubOrdersService

func (c *Client) NewGetFixedLoanLendingSubOrdersService(ordId string) *GetFixedLoanLendingSubOrdersService

func (*Client) NewGetFixedLoanPendingLendingVolumeService

func (c *Client) NewGetFixedLoanPendingLendingVolumeService(ccy, term string) *GetFixedLoanPendingLendingVolumeService

func (*Client) NewGetFlexLoanBorrowCurrenciesService

func (c *Client) NewGetFlexLoanBorrowCurrenciesService() *GetFlexLoanBorrowCurrenciesService

func (*Client) NewGetFlexLoanCollateralAssetsService

func (c *Client) NewGetFlexLoanCollateralAssetsService() *GetFlexLoanCollateralAssetsService

func (*Client) NewGetFlexLoanInterestAccruedService

func (c *Client) NewGetFlexLoanInterestAccruedService() *GetFlexLoanInterestAccruedService

func (*Client) NewGetFlexLoanLoanHistoryService

func (c *Client) NewGetFlexLoanLoanHistoryService() *GetFlexLoanLoanHistoryService

func (*Client) NewGetFlexLoanLoanInfoService

func (c *Client) NewGetFlexLoanLoanInfoService() *GetFlexLoanLoanInfoService

func (*Client) NewGetFlexLoanMaxLoanService

func (c *Client) NewGetFlexLoanMaxLoanService(borrowCcy string) *GetFlexLoanMaxLoanService

func (*Client) NewGetFundingBalanceService

func (c *Client) NewGetFundingBalanceService() *GetFundingBalanceService

func (*Client) NewGetFundingRateHistoryService

func (c *Client) NewGetFundingRateHistoryService(instId string) *GetFundingRateHistoryService

func (*Client) NewGetFundingRateService

func (c *Client) NewGetFundingRateService(instId string) *GetFundingRateService

func (*Client) NewGetGLPHistoricalPerformanceService added in v0.20260723.0

func (c *Client) NewGetGLPHistoricalPerformanceService(program GLPProgram) *GetGLPHistoricalPerformanceService

NewGetGLPHistoricalPerformanceService requires the GLP program (SPOT/PERP/FUT_NTO).

func (*Client) NewGetGLPTodayPerformanceService added in v0.20260723.0

func (c *Client) NewGetGLPTodayPerformanceService() *GetGLPTodayPerformanceService

func (*Client) NewGetGreeksService

func (c *Client) NewGetGreeksService() *GetGreeksService

func (*Client) NewGetGridAIParamService

func (c *Client) NewGetGridAIParamService(algoOrdType GridAlgoOrdType, instId string) *GetGridAIParamService

func (*Client) NewGetGridAlgoDetailsService

func (c *Client) NewGetGridAlgoDetailsService(algoOrdType GridAlgoOrdType, algoId string) *GetGridAlgoDetailsService

func (*Client) NewGetGridAlgoHistoryService

func (c *Client) NewGetGridAlgoHistoryService(algoOrdType GridAlgoOrdType) *GetGridAlgoHistoryService

func (*Client) NewGetGridAlgoPendingService

func (c *Client) NewGetGridAlgoPendingService(algoOrdType GridAlgoOrdType) *GetGridAlgoPendingService

func (*Client) NewGetGridMinInvestmentService

func (c *Client) NewGetGridMinInvestmentService(instId string, algoOrdType GridAlgoOrdType, maxPx, minPx decimal.Decimal, gridNum int, runType GridRunType) *GetGridMinInvestmentService

func (*Client) NewGetGridPositionsService

func (c *Client) NewGetGridPositionsService(algoOrdType GridAlgoOrdType, algoId string) *GetGridPositionsService

func (*Client) NewGetGridRSIBackTestingService

func (c *Client) NewGetGridRSIBackTestingService(instId, timeframe, thold string, timePeriod int, triggerCond, duration string) *GetGridRSIBackTestingService

NewGetGridRSIBackTestingService builds the back-test. triggerCond is e.g. "cross_up"/"cross_down"/"above"/"below"; timeframe is e.g. "3m"/"15m"/"1H".

func (*Client) NewGetGridSubOrdersService

func (c *Client) NewGetGridSubOrdersService(algoId string, algoOrdType GridAlgoOrdType, typ GridSubOrderType) *GetGridSubOrdersService

func (*Client) NewGetHistoryCandlesService

func (c *Client) NewGetHistoryCandlesService(instId string) *GetHistoryCandlesService

func (*Client) NewGetHistoryIndexCandlesService

func (c *Client) NewGetHistoryIndexCandlesService(instId string) *GetHistoryIndexCandlesService

func (*Client) NewGetHistoryMarkPriceCandlesService

func (c *Client) NewGetHistoryMarkPriceCandlesService(instId string) *GetHistoryMarkPriceCandlesService

func (*Client) NewGetHistoryTradesService

func (c *Client) NewGetHistoryTradesService(instId string) *GetHistoryTradesService

func (*Client) NewGetIndexCandlesService

func (c *Client) NewGetIndexCandlesService(instId string) *GetIndexCandlesService

func (*Client) NewGetIndexComponentsService

func (c *Client) NewGetIndexComponentsService(index string) *GetIndexComponentsService

func (*Client) NewGetIndexTickersService

func (c *Client) NewGetIndexTickersService() *GetIndexTickersService

func (*Client) NewGetInstrumentTickBandsService

func (c *Client) NewGetInstrumentTickBandsService(instType InstType) *GetInstrumentTickBandsService

func (*Client) NewGetInstrumentsService

func (c *Client) NewGetInstrumentsService(instType InstType) *GetInstrumentsService

func (*Client) NewGetInsuranceFundService

func (c *Client) NewGetInsuranceFundService(instType InstType) *GetInsuranceFundService

func (*Client) NewGetInterestAccruedService

func (c *Client) NewGetInterestAccruedService() *GetInterestAccruedService

func (*Client) NewGetInterestLimitsService

func (c *Client) NewGetInterestLimitsService() *GetInterestLimitsService

func (*Client) NewGetInterestRateLoanQuotaService

func (c *Client) NewGetInterestRateLoanQuotaService() *GetInterestRateLoanQuotaService

func (*Client) NewGetInterestRateService

func (c *Client) NewGetInterestRateService() *GetInterestRateService

func (*Client) NewGetLeverageInfoService

func (c *Client) NewGetLeverageInfoService(instId string, mgnMode MgnMode) *GetLeverageInfoService

func (*Client) NewGetLoanRatioService

func (c *Client) NewGetLoanRatioService(ccy string) *GetLoanRatioService

func (*Client) NewGetLongShortAccountRatioContractService

func (c *Client) NewGetLongShortAccountRatioContractService(instId string) *GetLongShortAccountRatioContractService

func (*Client) NewGetLongShortAccountRatioContractTopTraderService

func (c *Client) NewGetLongShortAccountRatioContractTopTraderService(instId string) *GetLongShortAccountRatioContractTopTraderService

func (*Client) NewGetLongShortAccountRatioService

func (c *Client) NewGetLongShortAccountRatioService(ccy string) *GetLongShortAccountRatioService

func (*Client) NewGetLongShortPositionRatioContractTopTraderService

func (c *Client) NewGetLongShortPositionRatioContractTopTraderService(instId string) *GetLongShortPositionRatioContractTopTraderService

func (*Client) NewGetMMInstrumentTypesService added in v0.20260703.0

func (c *Client) NewGetMMInstrumentTypesService() *GetMMInstrumentTypesService

func (*Client) NewGetMMPConfigService

func (c *Client) NewGetMMPConfigService(instFamily string) *GetMMPConfigService

func (*Client) NewGetManagedSubAccountBillsService

func (c *Client) NewGetManagedSubAccountBillsService() *GetManagedSubAccountBillsService

func (*Client) NewGetMarkPriceCandlesService

func (c *Client) NewGetMarkPriceCandlesService(instId string) *GetMarkPriceCandlesService

func (*Client) NewGetMarkPriceService

func (c *Client) NewGetMarkPriceService(instType InstType) *GetMarkPriceService

func (*Client) NewGetMaxAvailSizeService

func (c *Client) NewGetMaxAvailSizeService(instId string, tdMode TdMode) *GetMaxAvailSizeService

func (*Client) NewGetMaxLoanService

func (c *Client) NewGetMaxLoanService(mgnMode MgnMode) *GetMaxLoanService

func (*Client) NewGetMaxSizeService

func (c *Client) NewGetMaxSizeService(instId string, tdMode TdMode) *GetMaxSizeService

func (*Client) NewGetMaxWithdrawalService

func (c *Client) NewGetMaxWithdrawalService() *GetMaxWithdrawalService

func (*Client) NewGetMonthlyStatementService

func (c *Client) NewGetMonthlyStatementService(month string) *GetMonthlyStatementService

func (*Client) NewGetMovePositionsHistoryService

func (c *Client) NewGetMovePositionsHistoryService() *GetMovePositionsHistoryService

func (*Client) NewGetNonTradableAssetsService

func (c *Client) NewGetNonTradableAssetsService() *GetNonTradableAssetsService

func (*Client) NewGetOKUSDLimitsService added in v0.20260703.0

func (c *Client) NewGetOKUSDLimitsService() *GetOKUSDLimitsService

func (*Client) NewGetOneClickRepayCurrencyListService

func (c *Client) NewGetOneClickRepayCurrencyListService() *GetOneClickRepayCurrencyListService

func (*Client) NewGetOneClickRepayCurrencyListV2Service

func (c *Client) NewGetOneClickRepayCurrencyListV2Service() *GetOneClickRepayCurrencyListV2Service

func (*Client) NewGetOneClickRepayHistoryService

func (c *Client) NewGetOneClickRepayHistoryService() *GetOneClickRepayHistoryService

func (*Client) NewGetOneClickRepayHistoryV2Service

func (c *Client) NewGetOneClickRepayHistoryV2Service() *GetOneClickRepayHistoryV2Service

func (*Client) NewGetOpenInterestHistoryService

func (c *Client) NewGetOpenInterestHistoryService(instId string) *GetOpenInterestHistoryService

func (*Client) NewGetOpenInterestService

func (c *Client) NewGetOpenInterestService(instType InstType) *GetOpenInterestService

func (*Client) NewGetOptSummaryService

func (c *Client) NewGetOptSummaryService() *GetOptSummaryService

func (*Client) NewGetOptionInstrumentFamilyTradesService

func (c *Client) NewGetOptionInstrumentFamilyTradesService(instFamily string) *GetOptionInstrumentFamilyTradesService

func (*Client) NewGetOptionOpenInterestVolumeExpiryService

func (c *Client) NewGetOptionOpenInterestVolumeExpiryService(ccy string) *GetOptionOpenInterestVolumeExpiryService

func (*Client) NewGetOptionOpenInterestVolumeService

func (c *Client) NewGetOptionOpenInterestVolumeService(ccy string) *GetOptionOpenInterestVolumeService

func (*Client) NewGetOptionOpenInterestVolumeStrikeService

func (c *Client) NewGetOptionOpenInterestVolumeStrikeService(ccy, expTime string) *GetOptionOpenInterestVolumeStrikeService

func (*Client) NewGetOptionTakerBlockVolumeService

func (c *Client) NewGetOptionTakerBlockVolumeService(ccy string) *GetOptionTakerBlockVolumeService

func (*Client) NewGetOrderService

func (c *Client) NewGetOrderService(instId string) *GetOrderService

func (*Client) NewGetOrdersHistoryArchiveService

func (c *Client) NewGetOrdersHistoryArchiveService(instType InstType) *GetOrdersHistoryArchiveService

func (*Client) NewGetOrdersHistoryService

func (c *Client) NewGetOrdersHistoryService(instType InstType) *GetOrdersHistoryService

func (*Client) NewGetOrdersPendingService

func (c *Client) NewGetOrdersPendingService() *GetOrdersPendingService

func (*Client) NewGetPlatform24VolumeService

func (c *Client) NewGetPlatform24VolumeService() *GetPlatform24VolumeService

func (*Client) NewGetPositionTiersService

func (c *Client) NewGetPositionTiersService(instType InstType, tdMode TdMode) *GetPositionTiersService

func (*Client) NewGetPositionsHistoryService

func (c *Client) NewGetPositionsHistoryService() *GetPositionsHistoryService

func (*Client) NewGetPositionsService

func (c *Client) NewGetPositionsService() *GetPositionsService

func (*Client) NewGetPremiumHistoryService

func (c *Client) NewGetPremiumHistoryService(instId string) *GetPremiumHistoryService

func (*Client) NewGetPriceLimitService

func (c *Client) NewGetPriceLimitService(instId string) *GetPriceLimitService

func (*Client) NewGetRecurringOrderDetailsService

func (c *Client) NewGetRecurringOrderDetailsService(algoId string) *GetRecurringOrderDetailsService

func (*Client) NewGetRecurringOrdersHistoryService

func (c *Client) NewGetRecurringOrdersHistoryService() *GetRecurringOrdersHistoryService

func (*Client) NewGetRecurringOrdersPendingService

func (c *Client) NewGetRecurringOrdersPendingService() *GetRecurringOrdersPendingService

func (*Client) NewGetRecurringSubOrdersService

func (c *Client) NewGetRecurringSubOrdersService(algoId string) *GetRecurringSubOrdersService

func (*Client) NewGetRfqBlockTickerService

func (c *Client) NewGetRfqBlockTickerService(instId string) *GetRfqBlockTickerService

func (*Client) NewGetRfqBlockTickersService

func (c *Client) NewGetRfqBlockTickersService(instType InstType) *GetRfqBlockTickersService

func (*Client) NewGetRfqCounterpartiesService

func (c *Client) NewGetRfqCounterpartiesService() *GetRfqCounterpartiesService

func (*Client) NewGetRfqMakerInstrumentSettingsService

func (c *Client) NewGetRfqMakerInstrumentSettingsService() *GetRfqMakerInstrumentSettingsService

func (*Client) NewGetRfqMmpConfigService

func (c *Client) NewGetRfqMmpConfigService() *GetRfqMmpConfigService

func (*Client) NewGetRfqPublicTradesService

func (c *Client) NewGetRfqPublicTradesService() *GetRfqPublicTradesService

func (*Client) NewGetRfqQuoteProductsService

func (c *Client) NewGetRfqQuoteProductsService() *GetRfqQuoteProductsService

func (*Client) NewGetRfqQuotesService

func (c *Client) NewGetRfqQuotesService() *GetRfqQuotesService

func (*Client) NewGetRfqTradesService

func (c *Client) NewGetRfqTradesService() *GetRfqTradesService

func (*Client) NewGetRfqsService

func (c *Client) NewGetRfqsService() *GetRfqsService

func (*Client) NewGetRiskStateService

func (c *Client) NewGetRiskStateService() *GetRiskStateService

func (*Client) NewGetSavingsBalanceService

func (c *Client) NewGetSavingsBalanceService() *GetSavingsBalanceService

func (*Client) NewGetSavingsLendingHistoryService

func (c *Client) NewGetSavingsLendingHistoryService() *GetSavingsLendingHistoryService

func (*Client) NewGetSavingsLendingRateHistoryService

func (c *Client) NewGetSavingsLendingRateHistoryService() *GetSavingsLendingRateHistoryService

func (*Client) NewGetSavingsLendingRateSummaryService

func (c *Client) NewGetSavingsLendingRateSummaryService() *GetSavingsLendingRateSummaryService

func (*Client) NewGetSettlementHistoryService

func (c *Client) NewGetSettlementHistoryService(instType InstType, instFamily string) *GetSettlementHistoryService

func (*Client) NewGetSolStakingApyHistoryService

func (c *Client) NewGetSolStakingApyHistoryService(days int) *GetSolStakingApyHistoryService

func (*Client) NewGetSolStakingBalanceService

func (c *Client) NewGetSolStakingBalanceService() *GetSolStakingBalanceService

func (*Client) NewGetSolStakingHistoryService

func (c *Client) NewGetSolStakingHistoryService() *GetSolStakingHistoryService

func (*Client) NewGetSolStakingProductInfoService

func (c *Client) NewGetSolStakingProductInfoService() *GetSolStakingProductInfoService

func (*Client) NewGetSpotBorrowRepayHistoryService

func (c *Client) NewGetSpotBorrowRepayHistoryService() *GetSpotBorrowRepayHistoryService

func (*Client) NewGetSprdBooksService

func (c *Client) NewGetSprdBooksService(sprdId string) *GetSprdBooksService

func (*Client) NewGetSprdCandlesService

func (c *Client) NewGetSprdCandlesService(sprdId string) *GetSprdCandlesService

func (*Client) NewGetSprdHistoryCandlesService

func (c *Client) NewGetSprdHistoryCandlesService(sprdId string) *GetSprdHistoryCandlesService

func (*Client) NewGetSprdOrderAlgoService

func (c *Client) NewGetSprdOrderAlgoService() *GetSprdOrderAlgoService

func (*Client) NewGetSprdOrderService

func (c *Client) NewGetSprdOrderService() *GetSprdOrderService

func (*Client) NewGetSprdOrdersAlgoHistoryService

func (c *Client) NewGetSprdOrdersAlgoHistoryService() *GetSprdOrdersAlgoHistoryService

func (*Client) NewGetSprdOrdersAlgoPendingService

func (c *Client) NewGetSprdOrdersAlgoPendingService() *GetSprdOrdersAlgoPendingService

func (*Client) NewGetSprdOrdersHistoryArchiveService

func (c *Client) NewGetSprdOrdersHistoryArchiveService() *GetSprdOrdersHistoryArchiveService

func (*Client) NewGetSprdOrdersHistoryService

func (c *Client) NewGetSprdOrdersHistoryService() *GetSprdOrdersHistoryService

func (*Client) NewGetSprdOrdersPendingService

func (c *Client) NewGetSprdOrdersPendingService() *GetSprdOrdersPendingService

func (*Client) NewGetSprdPublicTradesService

func (c *Client) NewGetSprdPublicTradesService() *GetSprdPublicTradesService

func (*Client) NewGetSprdSpreadsService

func (c *Client) NewGetSprdSpreadsService() *GetSprdSpreadsService

func (*Client) NewGetSprdTickerService

func (c *Client) NewGetSprdTickerService(sprdId string) *GetSprdTickerService

func (*Client) NewGetSprdTradesService

func (c *Client) NewGetSprdTradesService() *GetSprdTradesService

func (*Client) NewGetStakingActiveOrdersService

func (c *Client) NewGetStakingActiveOrdersService() *GetStakingActiveOrdersService

func (*Client) NewGetStakingOffersService

func (c *Client) NewGetStakingOffersService() *GetStakingOffersService

func (*Client) NewGetStakingOrdersHistoryService

func (c *Client) NewGetStakingOrdersHistoryService() *GetStakingOrdersHistoryService

func (*Client) NewGetSubAccountApiKeyService

func (c *Client) NewGetSubAccountApiKeyService(subAcct string) *GetSubAccountApiKeyService

func (*Client) NewGetSubAccountBillsService

func (c *Client) NewGetSubAccountBillsService() *GetSubAccountBillsService

func (*Client) NewGetSubAccountFundingBalancesService

func (c *Client) NewGetSubAccountFundingBalancesService(subAcct string) *GetSubAccountFundingBalancesService

func (*Client) NewGetSubAccountListService

func (c *Client) NewGetSubAccountListService() *GetSubAccountListService

func (*Client) NewGetSubAccountMaxWithdrawalService

func (c *Client) NewGetSubAccountMaxWithdrawalService(subAcct string) *GetSubAccountMaxWithdrawalService

func (*Client) NewGetSubAccountTradingBalancesService

func (c *Client) NewGetSubAccountTradingBalancesService(subAcct string) *GetSubAccountTradingBalancesService

func (*Client) NewGetSupportCoinService

func (c *Client) NewGetSupportCoinService() *GetSupportCoinService

func (*Client) NewGetSystemStatusService

func (c *Client) NewGetSystemStatusService() *GetSystemStatusService

func (*Client) NewGetSystemTimeService

func (c *Client) NewGetSystemTimeService() *GetSystemTimeService

func (*Client) NewGetTakerVolumeService

func (c *Client) NewGetTakerVolumeService(ccy string, instType InstType) *GetTakerVolumeService

func (*Client) NewGetTickerService

func (c *Client) NewGetTickerService(instId string) *GetTickerService

func (*Client) NewGetTickersService

func (c *Client) NewGetTickersService(instType InstType) *GetTickersService

func (*Client) NewGetTradeFeeService

func (c *Client) NewGetTradeFeeService(instType InstType) *GetTradeFeeService

func (*Client) NewGetTradesService

func (c *Client) NewGetTradesService(instId string) *GetTradesService

func (*Client) NewGetTransferStateService

func (c *Client) NewGetTransferStateService() *GetTransferStateService

func (*Client) NewGetUnderlyingService

func (c *Client) NewGetUnderlyingService(instType InstType) *GetUnderlyingService

func (*Client) NewGetVipInterestAccruedService

func (c *Client) NewGetVipInterestAccruedService() *GetVipInterestAccruedService

func (*Client) NewGetVipInterestDeductedService

func (c *Client) NewGetVipInterestDeductedService() *GetVipInterestDeductedService

func (*Client) NewGetVipLoanOrderDetailService

func (c *Client) NewGetVipLoanOrderDetailService(ordId string) *GetVipLoanOrderDetailService

func (*Client) NewGetVipLoanOrderListService

func (c *Client) NewGetVipLoanOrderListService() *GetVipLoanOrderListService

func (*Client) NewGetWithdrawalHistoryService

func (c *Client) NewGetWithdrawalHistoryService() *GetWithdrawalHistoryService

func (*Client) NewInstantTriggerGridService

func (c *Client) NewInstantTriggerGridService(algoId string, algoOrdType GridAlgoOrdType) *InstantTriggerGridService

func (*Client) NewMassCancelService

func (c *Client) NewMassCancelService(instType InstType, instFamily string) *MassCancelService

func (*Client) NewModifySubAccountApiKeyService

func (c *Client) NewModifySubAccountApiKeyService(subAcct, apiKey string) *ModifySubAccountApiKeyService

func (*Client) NewMovePositionsService

func (c *Client) NewMovePositionsService(fromAcct, toAcct, clientId string, legs []MovePositionLeg) *MovePositionsService

func (*Client) NewOrderPrecheckService

func (c *Client) NewOrderPrecheckService(instId string, tdMode TdMode, side Side, ordType OrdType, sz decimal.Decimal) *OrderPrecheckService

func (*Client) NewPlaceAlgoOrderService

func (c *Client) NewPlaceAlgoOrderService(instId string, tdMode TdMode, side Side, ordType AlgoOrdType, sz decimal.Decimal) *PlaceAlgoOrderService

func (*Client) NewPlaceCopyLeadStopOrderService

func (c *Client) NewPlaceCopyLeadStopOrderService(subPosId string) *PlaceCopyLeadStopOrderService

func (*Client) NewPlaceEasyConvertService

func (c *Client) NewPlaceEasyConvertService(fromCcy []string, toCcy string) *PlaceEasyConvertService

NewPlaceEasyConvertService starts an easy-convert order. fromCcy is the list of dust currencies (max 5); toCcy is the single mainstream currency to receive.

func (*Client) NewPlaceFixedLoanLendingOrderService

func (c *Client) NewPlaceFixedLoanLendingOrderService(ccy string, amt, rate decimal.Decimal, term string) *PlaceFixedLoanLendingOrderService

func (*Client) NewPlaceGridAlgoOrderService

func (c *Client) NewPlaceGridAlgoOrderService(instId string, algoOrdType GridAlgoOrdType, maxPx, minPx decimal.Decimal, gridNum int) *PlaceGridAlgoOrderService

func (*Client) NewPlaceOrderService

func (c *Client) NewPlaceOrderService(instId string, tdMode TdMode, side Side, ordType OrdType, sz decimal.Decimal) *PlaceOrderService

func (*Client) NewPlaceRecurringOrderService

func (c *Client) NewPlaceRecurringOrderService(stgyName string, recurringList []RecurringItem, period RecurringPeriod, recurringTime string, timeZone string, amt decimal.Decimal, investmentCcy string, tdMode TdMode) *PlaceRecurringOrderService

func (*Client) NewPlaceSprdOrderAlgoService

func (c *Client) NewPlaceSprdOrderAlgoService(sprdId string, side Side, ordType, sz string) *PlaceSprdOrderAlgoService

func (*Client) NewPlaceSprdOrderService

func (c *Client) NewPlaceSprdOrderService(sprdId string, side Side, ordType SprdOrdType, sz string) *PlaceSprdOrderService

func (*Client) NewPositionBuilderService

func (c *Client) NewPositionBuilderService() *PositionBuilderService

func (*Client) NewPurchaseEthStakingService

func (c *Client) NewPurchaseEthStakingService(amt decimal.Decimal) *PurchaseEthStakingService

func (*Client) NewPurchaseSolStakingService

func (c *Client) NewPurchaseSolStakingService(amt decimal.Decimal) *PurchaseSolStakingService

func (*Client) NewPurchaseStakingService

func (c *Client) NewPurchaseStakingService(productId string, investData []StakingPurchaseInvest) *PurchaseStakingService

func (*Client) NewRedeemEthStakingService

func (c *Client) NewRedeemEthStakingService(amt decimal.Decimal) *RedeemEthStakingService

func (*Client) NewRedeemSolStakingService

func (c *Client) NewRedeemSolStakingService(amt decimal.Decimal) *RedeemSolStakingService

func (*Client) NewRedeemStakingService

func (c *Client) NewRedeemStakingService(ordId string, protocolType StakingProtocolType) *RedeemStakingService

func (*Client) NewResetMMPService

func (c *Client) NewResetMMPService(instFamily string) *ResetMMPService

func (*Client) NewResetRfqMmpService

func (c *Client) NewResetRfqMmpService() *ResetRfqMmpService

func (*Client) NewSetAccountLevelService

func (c *Client) NewSetAccountLevelService(acctLv string) *SetAccountLevelService

func (*Client) NewSetAutoLoanService

func (c *Client) NewSetAutoLoanService(autoLoan bool) *SetAutoLoanService

func (*Client) NewSetAutoRepayService

func (c *Client) NewSetAutoRepayService(autoRepay bool) *SetAutoRepayService

func (*Client) NewSetBorrowRepayService

func (c *Client) NewSetBorrowRepayService(ccy string, side BorrowRepayType, amt decimal.Decimal) *SetBorrowRepayService

func (*Client) NewSetCollateralAssetsService

func (c *Client) NewSetCollateralAssetsService(typ CollateralAssetType, collateralEnabled bool) *SetCollateralAssetsService

func (*Client) NewSetCopyLeverageService

func (c *Client) NewSetCopyLeverageService(mgnMode MgnMode, lever decimal.Decimal) *SetCopyLeverageService

func (*Client) NewSetGreeksService

func (c *Client) NewSetGreeksService(greeksType GreeksType) *SetGreeksService

func (*Client) NewSetIsolatedModeService

func (c *Client) NewSetIsolatedModeService(isoMode IsoMode, typ IsoModeType) *SetIsolatedModeService

func (*Client) NewSetLeverageService

func (c *Client) NewSetLeverageService(lever string, mgnMode MgnMode) *SetLeverageService

func (*Client) NewSetMMPConfigService

func (c *Client) NewSetMMPConfigService(instFamily, timeInterval, frozenInterval, qtyLimit string) *SetMMPConfigService

func (*Client) NewSetMarginBalanceService

func (c *Client) NewSetMarginBalanceService(instId string, posSide PosSide, typ MarginBalanceType, amt string) *SetMarginBalanceService

func (*Client) NewSetOKUSDRedeemService added in v0.20260703.0

func (c *Client) NewSetOKUSDRedeemService(amt decimal.Decimal, redeemType OKUSDRedeemType) *SetOKUSDRedeemService

func (*Client) NewSetOKUSDSubscribeService added in v0.20260703.0

func (c *Client) NewSetOKUSDSubscribeService(amt decimal.Decimal) *SetOKUSDSubscribeService

func (*Client) NewSetPositionModeService

func (c *Client) NewSetPositionModeService(posMode PosMode) *SetPositionModeService

func (*Client) NewSetRfqMakerInstrumentSettingsService

func (c *Client) NewSetRfqMakerInstrumentSettingsService(settings []RfqMakerInstrumentSetting) *SetRfqMakerInstrumentSettingsService

func (*Client) NewSetRfqMmpService

func (c *Client) NewSetRfqMmpService(timeInterval, frozenInterval, countLimit int) *SetRfqMmpService

func (*Client) NewSetRfqQuoteProductsService

func (c *Client) NewSetRfqQuoteProductsService(products []RfqQuoteProduct) *SetRfqQuoteProductsService

func (*Client) NewSetSavingsLendingRateService

func (c *Client) NewSetSavingsLendingRateService(ccy string, rate decimal.Decimal) *SetSavingsLendingRateService

func (*Client) NewSetSavingsPurchaseRedemptionService

func (c *Client) NewSetSavingsPurchaseRedemptionService(ccy string, amt decimal.Decimal, side SavingsSide) *SetSavingsPurchaseRedemptionService

func (*Client) NewSetSpotManualBorrowRepayService

func (c *Client) NewSetSpotManualBorrowRepayService(ccy string, side BorrowRepayType, amt decimal.Decimal) *SetSpotManualBorrowRepayService

func (*Client) NewSetSubAccountTransferOutService

func (c *Client) NewSetSubAccountTransferOutService(subAcct string, canTransOut bool) *SetSubAccountTransferOutService

func (*Client) NewSprdCancelAllAfterService

func (c *Client) NewSprdCancelAllAfterService(timeOut int) *SprdCancelAllAfterService

func (*Client) NewSprdMassCancelOrdersService

func (c *Client) NewSprdMassCancelOrdersService() *SprdMassCancelOrdersService

func (*Client) NewStopCopyCopyTradingService

func (c *Client) NewStopCopyCopyTradingService(uniqueCode, subPosCloseType string) *StopCopyCopyTradingService

func (*Client) NewStopCopyLeadTradingService

func (c *Client) NewStopCopyLeadTradingService() *StopCopyLeadTradingService

func (*Client) NewStopGridAlgoOrderService

func (c *Client) NewStopGridAlgoOrderService(items []GridStopArg) *StopGridAlgoOrderService

func (*Client) NewStopRecurringOrderService

func (c *Client) NewStopRecurringOrderService(algoIds []string) *StopRecurringOrderService

func (*Client) NewSubAccountTransferService

func (c *Client) NewSubAccountTransferService(ccy string, amt decimal.Decimal, froms, to, fromSubAccount, toSubAccount string) *SubAccountTransferService

NewSubAccountTransferService builds the transfer. froms/to are the source/dest account types ("6" funding, "18" trading); fromSubAccount/toSubAccount are the sub-account names.

func (*Client) NewTradeOneClickRepayService

func (c *Client) NewTradeOneClickRepayService(debtCcy []string, repayCcy string) *TradeOneClickRepayService

NewTradeOneClickRepayService starts a one-click repay. debtCcy is the list of debt currencies (max 5); repayCcy is the single currency used to repay.

func (*Client) NewTradeOneClickRepayV2Service

func (c *Client) NewTradeOneClickRepayV2Service(debtCcy string, repayCcyList []string) *TradeOneClickRepayV2Service

NewTradeOneClickRepayV2Service starts a one-click repay (v2). debtCcy is the single debt currency; repayCcyList is the prioritized list of currencies used to repay it.

func (*Client) NewWithdrawGridIncomeService

func (c *Client) NewWithdrawGridIncomeService(algoId string) *WithdrawGridIncomeService

func (*Client) NewWithdrawalService

func (c *Client) NewWithdrawalService(ccy string, amt decimal.Decimal, dest, toAddr string) *WithdrawalService

NewWithdrawalService builds a withdrawal. ccy is the currency, amt the amount, dest the destination ("3" internal, "4" on-chain), toAddr the recipient address (suffix ":tag" / ":memo" when required).

func (*Client) SyncServerTime

func (c *Client) SyncServerTime(ctx context.Context) error

SyncServerTime measures the client/server clock offset and stores it so that signed requests carry a timestamp the server accepts. OKX rejects requests whose OK-ACCESS-TIMESTAMP drifts more than 30s from its own clock, so call this once at startup (and periodically for long-lived processes).

type CloseCopySubpositionService

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

CloseCopySubpositionService -- POST /api/v5/copytrading/close-subposition (Trade)

Market-closes a lead trader's open sub-position.

func (*CloseCopySubpositionService) Do

type CloseGridPositionService

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

CloseGridPositionService -- POST /api/v5/tradingBot/grid/close-position (Trade)

Closes the position of a stopped contract grid (market or limit). IMPLEMENT-ONLY.

func (*CloseGridPositionService) Do

func (*CloseGridPositionService) SetPx

SetPx sets the close price (required when mktClose is false).

func (*CloseGridPositionService) SetSz

SetSz sets the quantity to close (required when mktClose is false).

type ClosePositionResult

type ClosePositionResult struct {
	InstrumentID  string  `json:"instId"`
	PositionSide  PosSide `json:"posSide"`
	ClientOrderID string  `json:"clOrdId"`
	Tag           string  `json:"tag"`
}

ClosePositionResult is the ack returned by the close-position endpoint.

type ClosePositionService

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

ClosePositionService -- POST /api/v5/trade/close-position (Trade)

Market-closes the position of an instrument under the given margin mode.

func (*ClosePositionService) Do

func (*ClosePositionService) SetAutoCxl

func (s *ClosePositionService) SetAutoCxl(autoCxl bool) *ClosePositionService

SetAutoCxl cancels pending orders that would prevent the close.

func (*ClosePositionService) SetCcy

SetCcy sets the margin currency (single-currency margin cross only).

func (*ClosePositionService) SetClOrdId

func (s *ClosePositionService) SetClOrdId(clOrdId string) *ClosePositionService

SetClOrdId sets the client-supplied order id.

func (*ClosePositionService) SetPosSide

func (s *ClosePositionService) SetPosSide(posSide PosSide) *ClosePositionService

SetPosSide sets the position side (long/short; required in long/short mode).

func (*ClosePositionService) SetTag

SetTag sets the order tag.

type CollateralAsset

type CollateralAsset struct {
	Currency          string `json:"ccy"`
	CollateralEnabled bool   `json:"collateralEnabled"`
}

CollateralAsset is a currency's collateral-enabled state.

type CollateralAssetType

type CollateralAssetType string

CollateralAssetType selects whether a set-collateral-assets request applies to all currencies or to a custom currency list.

const (
	CollateralAssetTypeAll    CollateralAssetType = "all"
	CollateralAssetTypeCustom CollateralAssetType = "custom"
)

type CollateralAssetsSetting

type CollateralAssetsSetting struct {
	Type              CollateralAssetType `json:"type"`
	CollateralEnabled bool                `json:"collateralEnabled"`
	CurrencyList      []string            `json:"ccyList"`
}

CollateralAssetsSetting is the set-collateral-assets acknowledgement.

type ComputeGridMarginBalanceService

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

ComputeGridMarginBalanceService -- POST /api/v5/tradingBot/grid/compute-margin-balance (Trade)

Estimates the impact of adding/reducing the margin of a contract grid. IMPLEMENT-ONLY.

func (*ComputeGridMarginBalanceService) Do

func (*ComputeGridMarginBalanceService) SetAmt

SetAmt sets the margin amount to add/reduce.

type ConvertContractCoin

type ConvertContractCoin struct {
	Type         string          `json:"type"`
	InstrumentID string          `json:"instId"`
	Price        decimal.Decimal `json:"px"`
	Size         decimal.Decimal `json:"sz"`
	Unit         string          `json:"unit"`
}

ConvertContractCoin is the result of a contract/coin conversion.

type ConvertCurrency

type ConvertCurrency struct {
	Currency string          `json:"ccy"`
	Min      decimal.Decimal `json:"min"`
	Max      decimal.Decimal `json:"max"`
}

ConvertCurrency is a single convertible currency and its conversion bounds.

type ConvertCurrencyPair

type ConvertCurrencyPair struct {
	InstrumentID     string          `json:"instId"`
	BaseCurrency     string          `json:"baseCcy"`
	BaseCurrencyMax  decimal.Decimal `json:"baseCcyMax"`
	BaseCurrencyMin  decimal.Decimal `json:"baseCcyMin"`
	QuoteCurrency    string          `json:"quoteCcy"`
	QuoteCurrencyMax decimal.Decimal `json:"quoteCcyMax"`
	QuoteCurrencyMin decimal.Decimal `json:"quoteCcyMin"`
}

ConvertCurrencyPair is a convert pair and its base/quote size limits.

type ConvertEstimateQuote

type ConvertEstimateQuote struct {
	QuoteID              string          `json:"quoteId"`
	ClientQuoteRequestID string          `json:"clQReqId"`
	BaseCurrency         string          `json:"baseCcy"`
	QuoteCurrency        string          `json:"quoteCcy"`
	Side                 Side            `json:"side"`
	OriginalRFQSize      decimal.Decimal `json:"origRfqSz"`
	RFQSize              decimal.Decimal `json:"rfqSz"`
	RFQSizeCurrency      string          `json:"rfqSzCcy"`
	ConvertedPrice       decimal.Decimal `json:"cnvtPx"`
	BaseSize             decimal.Decimal `json:"baseSz"`
	QuoteSize            decimal.Decimal `json:"quoteSz"`
	TTLMilliseconds      decimal.Decimal `json:"ttlMs"`
	QuoteTime            time.Time       `json:"quoteTime"`
}

ConvertEstimateQuote is the binding quote returned by estimate-quote.

type ConvertEstimateQuoteService

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

ConvertEstimateQuoteService -- POST /api/v5/asset/convert/estimate-quote (Trade)

Requests a binding conversion quote (returns a quoteId valid for a short window) for a base/quote currency and side.

State-changing: NOT exercised by the test suite.

func (*ConvertEstimateQuoteService) Do

func (*ConvertEstimateQuoteService) SetClQReqId

SetClQReqId sets the client-supplied quote-request id (used for idempotency).

func (*ConvertEstimateQuoteService) SetTag

SetTag sets the order tag (broker id).

type ConvertHistory

type ConvertHistory struct {
	InstrumentID  string          `json:"instId"`
	Side          Side            `json:"side"`
	FillPrice     decimal.Decimal `json:"fillPx"`
	BaseCurrency  string          `json:"baseCcy"`
	QuoteCurrency string          `json:"quoteCcy"`
	FillBaseSize  decimal.Decimal `json:"fillBaseSz"`
	FillQuoteSize decimal.Decimal `json:"fillQuoteSz"`
	State         convertState    `json:"state"`
	TradeID       string          `json:"tradeId"`
	Timestamp     time.Time       `json:"ts"`
}

ConvertHistory is a single past conversion record.

type ConvertSource

type ConvertSource string

ConvertSource selects the funding source for an easy-convert order: "1" (trading account) or "2" (funding account).

const (
	ConvertSourceTrading ConvertSource = "1"
	ConvertSourceFunding ConvertSource = "2"
)

type ConvertStatus

type ConvertStatus string

ConvertStatus is the lifecycle state of an easy-convert / one-click-repay job.

const (
	ConvertStatusRunning ConvertStatus = "running"
	ConvertStatusFilled  ConvertStatus = "filled"
	ConvertStatusFailed  ConvertStatus = "failed"
)

type ConvertTrade

type ConvertTrade struct {
	TradeID              string          `json:"tradeId"`
	QuoteID              string          `json:"quoteId"`
	ClientTradeRequestID string          `json:"clTReqId"`
	State                convertState    `json:"state"`
	InstrumentID         string          `json:"instId"`
	BaseCurrency         string          `json:"baseCcy"`
	QuoteCurrency        string          `json:"quoteCcy"`
	Side                 Side            `json:"side"`
	FillPrice            decimal.Decimal `json:"fillPx"`
	FillBaseSize         decimal.Decimal `json:"fillBaseSz"`
	FillQuoteSize        decimal.Decimal `json:"fillQuoteSz"`
	Timestamp            time.Time       `json:"ts"`
}

ConvertTrade is the result of an executed conversion.

type ConvertTradeService

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

ConvertTradeService -- POST /api/v5/asset/convert/trade (Trade)

Executes a conversion against a quoteId previously obtained from estimate-quote.

State-changing: NOT exercised by the test suite.

func (*ConvertTradeService) Do

func (*ConvertTradeService) SetClTReqId

func (s *ConvertTradeService) SetClTReqId(clTReqId string) *ConvertTradeService

SetClTReqId sets the client-supplied trade-request id (used for idempotency).

func (*ConvertTradeService) SetTag

SetTag sets the order tag (broker id).

type CopyBatchLeverageInfo

type CopyBatchLeverageInfo struct {
	InstrumentID string          `json:"instId"`
	MarginMode   MgnMode         `json:"mgnMode"`
	Leverage     decimal.Decimal `json:"lever"`
	PositionSide PosSide         `json:"posSide"`
}

CopyBatchLeverageInfo is a lead trader's leverage for an instrument. The validating account is not on the copy-trading allowlist (code 59263), so the field set is modeled from the OKX doc field table.

type CopyConfig

type CopyConfig struct {
	NickName   string    `json:"nickName"`
	PortLink   string    `json:"portLink"`
	Roles      []string  `json:"roles"`
	CopyState  CopyState `json:"copyState"`
	LeadState  CopyState `json:"leadState"`
	UniqueCode string    `json:"uniqueCode"`
}

CopyConfig is the account's copy-trading role configuration. The validating account has neither led nor copied any trades (the endpoint returns code 59285), so the field set is modeled from the OKX doc field table.

type CopyInstrument

type CopyInstrument struct {
	InstrumentID string `json:"instId"`
	Enabled      bool   `json:"enabled"`
}

CopyInstrument is one lead-tradable instrument and its enabled flag.

type CopyLeadTrader

type CopyLeadTrader struct {
	UniqueCode                  string                   `json:"uniqueCode"`
	NickName                    string                   `json:"nickName"`
	PortLink                    string                   `json:"portLink"`
	Currency                    string                   `json:"ccy"`
	ChannelType                 string                   `json:"chanType"`
	CopyState                   CopyState                `json:"copyState"`
	AUM                         decimal.Decimal          `json:"aum"`
	Pnl                         decimal.Decimal          `json:"pnl"`
	PnlRatio                    decimal.Decimal          `json:"pnlRatio"`
	WinRatio                    decimal.Decimal          `json:"winRatio"`
	LeadDays                    decimal.Decimal          `json:"leadDays"`
	CopyTraderNumber            decimal.Decimal          `json:"copyTraderNum"`
	MaxCopyTraderNumber         decimal.Decimal          `json:"maxCopyTraderNum"`
	AccumulatedCopyTraderNumber decimal.Decimal          `json:"accCopyTraderNum"`
	TraderInstruments           []string                 `json:"traderInsts"`
	PnlRatios                   []CopyLeadTraderPnlRatio `json:"pnlRatios"`
}

CopyLeadTrader is one lead trader's ranking row. chanType is only present in the signed lead-traders response.

type CopyLeadTraderPnlRatio

type CopyLeadTraderPnlRatio struct {
	BeginTimestamp time.Time       `json:"beginTs"`
	PnlRatio       decimal.Decimal `json:"pnlRatio"`
}

CopyLeadTraderPnlRatio is a single dated pnl-ratio point in a lead trader's history curve.

type CopyLeadTradersPage

type CopyLeadTradersPage struct {
	DataVersion string           `json:"dataVer"`
	TotalPage   decimal.Decimal  `json:"totalPage"`
	Ranks       []CopyLeadTrader `json:"ranks"`
}

CopyLeadTradersPage is one page of the lead-trader ranking.

type CopyProfitSharingDetail

type CopyProfitSharingDetail struct {
	InstrumentType      InstType        `json:"instType"`
	Currency            string          `json:"ccy"`
	NickName            string          `json:"nickName"`
	ProfitSharingAmount decimal.Decimal `json:"profitSharingAmt"`
	ProfitSharingID     string          `json:"profitSharingId"`
	Timestamp           time.Time       `json:"ts"`
}

CopyProfitSharingDetail is one profit-sharing record. The validating account has not led any trades (the endpoint returns an empty array), so the field set is modeled from the OKX doc field table.

type CopyPublicConfig

type CopyPublicConfig struct {
	MaxCopyAmount      decimal.Decimal `json:"maxCopyAmt"`
	MinCopyAmount      decimal.Decimal `json:"minCopyAmt"`
	MaxCopyTotalAmount decimal.Decimal `json:"maxCopyTotalAmt"`
	MaxCopyRatio       decimal.Decimal `json:"maxCopyRatio"`
	MinCopyRatio       decimal.Decimal `json:"minCopyRatio"`
	MaxTakeProfitRatio decimal.Decimal `json:"maxTpRatio"`
	MaxStopLossRatio   decimal.Decimal `json:"maxSlRatio"`
}

CopyPublicConfig is the platform-wide copy-trading configuration.

type CopyResult

type CopyResult struct {
	Result bool `json:"result"`
}

CopyResult is the generic ack for the copy/lead settings POST endpoints.

type CopySettings

type CopySettings struct {
	Currency             string          `json:"ccy"`
	CopyAmount           decimal.Decimal `json:"copyAmt"`
	CopyTotalAmount      decimal.Decimal `json:"copyTotalAmt"`
	CopyInstrumentIDType string          `json:"copyInstIdType"`
	CopyMarginMode       string          `json:"copyMgnMode"`
	CopyMode             string          `json:"copyMode"`
	CopyRatio            decimal.Decimal `json:"copyRatio"`
	CopyState            CopyState       `json:"copyState"`
	InstrumentIDs        []string        `json:"instIds"`
	StopLossRatio        decimal.Decimal `json:"slRatio"`
	StopLossTotalAmount  decimal.Decimal `json:"slTotalAmt"`
	SubPositionCloseType string          `json:"subPosCloseType"`
	Tag                  string          `json:"tag"`
	TakeProfitRatio      decimal.Decimal `json:"tpRatio"`
}

CopySettings is the current account's copy configuration for a lead trader.

type CopySortType

type CopySortType string

CopySortType is the lead-trader ranking sort key (overview/pnl/aum/winRatio/...).

const (
	CopySortTypeOverview CopySortType = "overview"
	CopySortTypePnl      CopySortType = "pnl"
	CopySortTypePnlRatio CopySortType = "pnlRatio"
	CopySortTypeAum      CopySortType = "aum"
	CopySortTypeWinRatio CopySortType = "winRatio"
)

type CopyState

type CopyState string

CopyState is the copy/lead state flag ("0" not copying / "1" copying).

const (
	CopyStateNo  CopyState = "0"
	CopyStateYes CopyState = "1"
)

type CopySubPosAck

type CopySubPosAck struct {
	SubPositionID string `json:"subPosId"`
	Tag           string `json:"tag"`
}

CopySubPosAck is the acknowledgement for a sub-position lead order/close.

type CopySubPosType

type CopySubPosType string

CopySubPosType is a copy-trading sub-position side selector.

const (
	CopySubPosTypeLong  CopySubPosType = "long"
	CopySubPosTypeShort CopySubPosType = "short"
)

type CopySubPosition

type CopySubPosition struct {
	InstrumentType         InstType        `json:"instType"`
	InstrumentID           string          `json:"instId"`
	SubPositionID          string          `json:"subPosId"`
	PositionSide           PosSide         `json:"posSide"`
	MarginMode             MgnMode         `json:"mgnMode"`
	Leverage               decimal.Decimal `json:"lever"`
	OpenOrderID            string          `json:"openOrdId"`
	OpenAveragePrice       decimal.Decimal `json:"openAvgPx"`
	OpenTime               time.Time       `json:"openTime"`
	SubPosition            decimal.Decimal `json:"subPos"`
	Currency               string          `json:"ccy"`
	MarkPrice              decimal.Decimal `json:"markPx"`
	UPL                    decimal.Decimal `json:"upl"`
	UPLRatio               decimal.Decimal `json:"uplRatio"`
	StopLossTriggerPrice   decimal.Decimal `json:"slTriggerPx"`
	TakeProfitTriggerPrice decimal.Decimal `json:"tpTriggerPx"`
	Margin                 decimal.Decimal `json:"margin"`
	UniqueCode             string          `json:"uniqueCode"`
	AvailableSubPosition   decimal.Decimal `json:"availSubPos"`
}

CopySubPosition is a single lead-trader sub-position. The validating account has not led any trades (the endpoint returns an empty array), so the field set is modeled from the OKX doc field table.

type CopySubPositionHistory

type CopySubPositionHistory struct {
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	SubPositionID     string          `json:"subPosId"`
	PositionSide      PosSide         `json:"posSide"`
	MarginMode        MgnMode         `json:"mgnMode"`
	Leverage          decimal.Decimal `json:"lever"`
	OpenAveragePrice  decimal.Decimal `json:"openAvgPx"`
	OpenTime          time.Time       `json:"openTime"`
	CloseAveragePrice decimal.Decimal `json:"closeAvgPx"`
	CloseTime         time.Time       `json:"closeTime"`
	SubPosition       decimal.Decimal `json:"subPos"`
	Currency          string          `json:"ccy"`
	Pnl               decimal.Decimal `json:"pnl"`
	PnlRatio          decimal.Decimal `json:"pnlRatio"`
	UniqueCode        string          `json:"uniqueCode"`
	Type              string          `json:"type"`
}

CopySubPositionHistory is a single closed lead-trader sub-position. The validating account has not led any trades (the endpoint returns an empty array), so the field set is modeled from the OKX doc field table.

type CopyTotalProfitSharing

type CopyTotalProfitSharing struct {
	InstrumentType           InstType        `json:"instType"`
	Currency                 string          `json:"ccy"`
	TotalProfitSharingAmount decimal.Decimal `json:"totalProfitSharingAmt"`
}

CopyTotalProfitSharing is the lead trader's total profit-sharing for a currency.

type CopyTotalUnrealizedProfitSharing

type CopyTotalUnrealizedProfitSharing struct {
	InstrumentType                     InstType        `json:"instType"`
	Currency                           string          `json:"ccy"`
	TotalUnrealizedProfitSharingAmount decimal.Decimal `json:"totalUnrealizedProfitSharingAmt"`
}

CopyTotalUnrealizedProfitSharing is the lead trader's total pending profit-sharing for a currency. The validating account lacks permission for this endpoint (code 50030), so the field set is modeled from the OKX doc field table.

type CopyTrader

type CopyTrader struct {
	NickName      string          `json:"nickName"`
	PortLink      string          `json:"portLink"`
	BeginCopyTime time.Time       `json:"beginCopyTime"`
	Pnl           decimal.Decimal `json:"pnl"`
}

CopyTrader is one copier following a lead trader.

type CopyTradersPage

type CopyTradersPage struct {
	InstrumentType   InstType        `json:"instType"`
	CopyTotalAmount  decimal.Decimal `json:"copyTotalAmt"`
	CopyTotalPnl     decimal.Decimal `json:"copyTotalPnl"`
	Currency         string          `json:"ccy"`
	CopyTraderNumber decimal.Decimal `json:"copyTraderNum"`
	CopyTraders      []CopyTrader    `json:"copyTraders"`
}

CopyTradersPage is the summary plus per-copier list following a lead trader. The validating account is not on the copy-trading allowlist (code 59263), so the field set is modeled from the OKX doc field table.

type CopyUnrealizedProfitSharingDetail

type CopyUnrealizedProfitSharingDetail struct {
	InstrumentType                InstType        `json:"instType"`
	Currency                      string          `json:"ccy"`
	NickName                      string          `json:"nickName"`
	UnrealizedProfitSharingAmount decimal.Decimal `json:"unrealizedProfitSharingAmt"`
}

CopyUnrealizedProfitSharingDetail is one copier's pending profit-sharing. The validating account lacks permission for this endpoint (code 50030), so the field set is modeled from the OKX doc field table.

type CreateRfqQuoteService

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

CreateRfqQuoteService -- POST /api/v5/rfq/create-quote (Trade)

Creates a quote against an RFQ as a maker.

func (*CreateRfqQuoteService) Do

func (*CreateRfqQuoteService) SetAnonymous

func (s *CreateRfqQuoteService) SetAnonymous(anonymous bool) *CreateRfqQuoteService

SetAnonymous toggles whether the quote is anonymous.

func (*CreateRfqQuoteService) SetClQuoteId

func (s *CreateRfqQuoteService) SetClQuoteId(clQuoteId string) *CreateRfqQuoteService

SetClQuoteId sets a client-supplied quote id.

func (*CreateRfqQuoteService) SetExpiresIn

func (s *CreateRfqQuoteService) SetExpiresIn(seconds int) *CreateRfqQuoteService

SetExpiresIn sets the quote validity window in seconds.

func (*CreateRfqQuoteService) SetTag

SetTag sets an order tag for the quote.

type CreateRfqService

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

CreateRfqService -- POST /api/v5/rfq/create-rfq (Trade)

Creates an RFQ as a taker and broadcasts it to the chosen counterparties.

func (*CreateRfqService) Do

func (s *CreateRfqService) Do(ctx context.Context) (*Rfq, error)

func (*CreateRfqService) SetAllowPartialExecution

func (s *CreateRfqService) SetAllowPartialExecution(allow bool) *CreateRfqService

SetAllowPartialExecution toggles whether partial execution is allowed.

func (*CreateRfqService) SetClRfqId

func (s *CreateRfqService) SetClRfqId(clRfqId string) *CreateRfqService

SetClRfqId sets a client-supplied RFQ id.

func (*CreateRfqService) SetTag

func (s *CreateRfqService) SetTag(tag string) *CreateRfqService

SetTag sets an order tag for the RFQ.

type CreateSubAccountApiKeyService

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

CreateSubAccountApiKeyService -- POST /api/v5/users/subaccount/apikey (Trade)

Creates an API key for a sub-account (master account). Implement-only: never executed by the live test suite.

func (*CreateSubAccountApiKeyService) Do

func (*CreateSubAccountApiKeyService) SetIP

SetIP sets the IP allow-list (comma-separated, up to 20 addresses).

func (*CreateSubAccountApiKeyService) SetPerm

SetPerm sets the API key permissions (comma-separated: read_only, trade).

type CtType

type CtType string

CtType is a futures/swap contract type.

const (
	CtTypeLinear  CtType = "linear"
	CtTypeInverse CtType = "inverse"
)

type Currency

type Currency struct {
	Currency                    string          `json:"ccy"`
	Name                        string          `json:"name"`
	LogoLink                    string          `json:"logoLink"`
	Chain                       string          `json:"chain"`
	CanDeposit                  bool            `json:"canDep"`
	CanWithdrawal               bool            `json:"canWd"`
	CanInternal                 bool            `json:"canInternal"`
	MinDeposit                  decimal.Decimal `json:"minDep"`
	MinWithdrawal               decimal.Decimal `json:"minWd"`
	MaxWithdrawal               decimal.Decimal `json:"maxWd"`
	WithdrawalTickSize          decimal.Decimal `json:"wdTickSz"`
	WithdrawalQuota             decimal.Decimal `json:"wdQuota"`
	UsedWithdrawalQuota         decimal.Decimal `json:"usedWdQuota"`
	Fee                         decimal.Decimal `json:"fee"`
	MinFee                      decimal.Decimal `json:"minFee"`
	MaxFee                      decimal.Decimal `json:"maxFee"`
	MinFeeForContractAddress    decimal.Decimal `json:"minFeeForCtAddr"`
	MaxFeeForContractAddress    decimal.Decimal `json:"maxFeeForCtAddr"`
	BurningFeeRate              decimal.Decimal `json:"burningFeeRate"`
	MinInternal                 decimal.Decimal `json:"minInternal"`
	MinDepositArrivalConfirm    decimal.Decimal `json:"minDepArrivalConfirm"`
	MinWithdrawalUnlockConfirm  decimal.Decimal `json:"minWdUnlockConfirm"`
	MainNet                     bool            `json:"mainNet"`
	NeedTag                     bool            `json:"needTag"`
	ContractAddress             string          `json:"ctAddr"`
	DepositEstimatedOpenTime    time.Time       `json:"depEstOpenTime"`
	WithdrawalEstimatedOpenTime time.Time       `json:"wdEstOpenTime"`
	DepositQuotaFixed           decimal.Decimal `json:"depQuotaFixed"`
	UsedDepositQuotaFixed       decimal.Decimal `json:"usedDepQuotaFixed"`
	DepositQuoteDailyLayer2     decimal.Decimal `json:"depQuoteDailyLayer2"`
	StablecoinDailyQuota        decimal.Decimal `json:"stablecoinDailyQuota"`
	StablecoinMonthlyQuota      decimal.Decimal `json:"stablecoinMonthlyQuota"`
	UsedStablecoinDailyQuota    decimal.Decimal `json:"usedStablecoinDailyQuota"`
	UsedStablecoinMonthlyQuota  decimal.Decimal `json:"usedStablecoinMonthlyQuota"`
}

Currency is a single currency-on-chain entry and its deposit/withdrawal rules.

type DebtType

type DebtType string

DebtType selects whether a one-click-repay currency list reports cross or isolated debt.

const (
	DebtTypeCross    DebtType = "cross"
	DebtTypeIsolated DebtType = "isolated"
)

type DeleteSubAccountApiKeyService

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

DeleteSubAccountApiKeyService -- POST /api/v5/users/subaccount/delete-apikey (Trade)

Deletes a sub-account API key (master account). Implement-only: never executed by the live test suite.

func (*DeleteSubAccountApiKeyService) Do

type DeliveryExerciseHistory

type DeliveryExerciseHistory struct {
	Timestamp time.Time                       `json:"ts"`
	Details   []DeliveryExerciseHistoryDetail `json:"details"`
}

DeliveryExerciseHistory is one delivery/exercise event and its per-instrument details.

type DeliveryExerciseHistoryDetail

type DeliveryExerciseHistoryDetail struct {
	InstrumentID string          `json:"insId"`
	Price        decimal.Decimal `json:"px"`
	Type         string          `json:"type"`
}

DeliveryExerciseHistoryDetail is a single instrument's delivery/exercise record.

type DepositAddress

type DepositAddress struct {
	Address         string        `json:"addr"`
	Tag             string        `json:"tag"`
	Memo            string        `json:"memo"`
	PaymentID       string        `json:"pmtId"`
	AddrEx          any           `json:"addrEx"`
	Currency        string        `json:"ccy"`
	Chain           string        `json:"chain"`
	To              AssetAcctType `json:"to"`
	Selected        bool          `json:"selected"`
	ContractAddress string        `json:"ctAddr"`
	VerifiedName    string        `json:"verifiedName"`
}

DepositAddress is a single deposit address for a currency on a chain.

type DepositHistory

type DepositHistory struct {
	Currency                  string          `json:"ccy"`
	Chain                     string          `json:"chain"`
	Amount                    decimal.Decimal `json:"amt"`
	From                      string          `json:"from"`
	AreaCodeFrom              string          `json:"areaCodeFrom"`
	To                        string          `json:"to"`
	TransactionID             string          `json:"txId"`
	DepositID                 string          `json:"depId"`
	FromWithdrawalID          string          `json:"fromWdId"`
	State                     string          `json:"state"`
	ActualDepositBlockConfirm decimal.Decimal `json:"actualDepBlkConfirm"`
	Timestamp                 time.Time       `json:"ts"`
}

DepositHistory is one deposit record.

type DepositWithdrawStatus

type DepositWithdrawStatus struct {
	WithdrawalID          string    `json:"wdId"`
	TransactionID         string    `json:"txId"`
	State                 string    `json:"state"`
	EstimatedCompleteTime time.Time `json:"estCompleteTime"`
}

DepositWithdrawStatus is the on-chain progress of a deposit/withdrawal.

type DiscountRateInterestFreeQuota

type DiscountRateInterestFreeQuota struct {
	Currency           string             `json:"ccy"`
	Amount             decimal.Decimal    `json:"amt"`
	DiscountLevel      string             `json:"discountLv"`
	MinDiscountRate    decimal.Decimal    `json:"minDiscountRate"`
	CollateralRestrict bool               `json:"collateralRestrict"`
	ColRes             string             `json:"colRes"`
	Details            []DiscountRateTier `json:"details"`
}

DiscountRateInterestFreeQuota is a currency's interest-free quota and its tiered discount-rate schedule.

type DiscountRateTier

type DiscountRateTier struct {
	DiscountRate           decimal.Decimal `json:"discountRate"`
	LiquidationPenaltyRate decimal.Decimal `json:"liqPenaltyRate"`
	DiscountCurrencyEquity decimal.Decimal `json:"disCcyEq"`
	MinAmount              decimal.Decimal `json:"minAmt"`
	MaxAmount              decimal.Decimal `json:"maxAmt"`
	Tier                   string          `json:"tier"`
}

DiscountRateTier is one tier of a currency's discount-rate schedule.

type EasyConvertCurrencyList

type EasyConvertCurrencyList struct {
	FromData   []EasyConvertFromCcy `json:"fromData"`
	ToCurrency []string             `json:"toCcy"`
}

EasyConvertCurrencyList is the set of convertible dust currencies and the mainstream currencies they can be converted into.

type EasyConvertFromCcy

type EasyConvertFromCcy struct {
	FromCurrency string          `json:"fromCcy"`
	FromAmount   decimal.Decimal `json:"fromAmt"`
}

EasyConvertFromCcy is a single dust currency and its convertible balance.

type EasyConvertHistory

type EasyConvertHistory struct {
	FromCurrency string          `json:"fromCcy"`
	FillFromSize decimal.Decimal `json:"fillFromSz"`
	ToCurrency   string          `json:"toCcy"`
	FillToSize   decimal.Decimal `json:"fillToSz"`
	Account      string          `json:"acct"`
	Status       ConvertStatus   `json:"status"`
	UpdateTime   time.Time       `json:"uTime"`
}

EasyConvertHistory is a single past easy-convert order.

type EasyConvertResult

type EasyConvertResult struct {
	Status       ConvertStatus   `json:"status"`
	FromCurrency string          `json:"fromCcy"`
	ToCurrency   string          `json:"toCcy"`
	FillFromSize decimal.Decimal `json:"fillFromSz"`
	FillToSize   decimal.Decimal `json:"fillToSz"`
	UpdateTime   time.Time       `json:"uTime"`
}

EasyConvertResult is the acknowledgement for an easy-convert order.

type EconomicCalendar

type EconomicCalendar struct {
	CalendarID      string                     `json:"calendarId"`
	Date            time.Time                  `json:"date"`
	Region          string                     `json:"region"`
	Category        string                     `json:"category"`
	Event           string                     `json:"event"`
	ReferenceDate   time.Time                  `json:"refDate"`
	Actual          string                     `json:"actual"`
	Previous        string                     `json:"previous"`
	Forecast        string                     `json:"forecast"`
	DateSpan        string                     `json:"dateSpan"`
	Importance      EconomicCalendarImportance `json:"importance"`
	UpdateTime      time.Time                  `json:"uTime"`
	PreviousInitial string                     `json:"prevInitial"`
	Currency        string                     `json:"ccy"`
	Unit            string                     `json:"unit"`
}

EconomicCalendar is one macro-economic calendar event. The numeric-looking fields (actual, previous, forecast, prevInitial) are kept as strings because OKX returns them with trailing units/symbols (e.g. "2.4%", "1.2K", "-").

type EconomicCalendarImportance

type EconomicCalendarImportance string

EconomicCalendarImportance is the market-impact rating of a calendar event.

const (
	EconomicCalendarImportanceLow    EconomicCalendarImportance = "1"
	EconomicCalendarImportanceMedium EconomicCalendarImportance = "2"
	EconomicCalendarImportanceHigh   EconomicCalendarImportance = "3"
)

type EntrustSubAccount

type EntrustSubAccount struct {
	SubAccount string `json:"subAcct"`
}

EntrustSubAccount is one custody (entrusted) trading sub-account.

type EstimatedPrice

type EstimatedPrice struct {
	InstrumentType InstType        `json:"instType"`
	InstrumentID   string          `json:"instId"`
	SettlePrice    decimal.Decimal `json:"settlePx"`
	Timestamp      time.Time       `json:"ts"`
}

EstimatedPrice is the estimated delivery/exercise price of an instrument.

type EthStakingAck

type EthStakingAck struct{}

EthStakingAck is the (empty) acknowledgement returned by ETH purchase/redeem.

type EthStakingBalance

type EthStakingBalance struct {
	Currency              string          `json:"ccy"`
	Amount                decimal.Decimal `json:"amt"`
	LatestInterestAccrual decimal.Decimal `json:"latestInterestAccrual"`
	TotalInterestAccrual  decimal.Decimal `json:"totalInterestAccrual"`
	Timestamp             time.Time       `json:"ts"`
}

EthStakingBalance is the BETH balance and accrued interest.

type EthStakingHistory

type EthStakingHistory struct {
	Type                   string          `json:"type"`
	Amount                 decimal.Decimal `json:"amt"`
	Status                 string          `json:"status"`
	RequestTime            time.Time       `json:"requestTime"`
	CompletedTime          time.Time       `json:"completedTime"`
	EstimatedCompletedTime time.Time       `json:"estCompletedTime"`
}

EthStakingHistory is one ETH staking purchase/redemption record. The validating account has no ETH staking history, so the field set is modeled from the OKX doc field table.

type EthStakingProductInfo

type EthStakingProductInfo struct {
	FastRedemptionDailyLimit decimal.Decimal `json:"fastRedemptionDailyLimit"`
	MinAmount                decimal.Decimal `json:"minAmt"`
	Rate                     decimal.Decimal `json:"rate"`
	RedemptionDays           decimal.Decimal `json:"redemptDays"`
}

EthStakingProductInfo is the ETH staking product configuration.

type Exchange

type Exchange struct {
	ExchID   string `json:"exchId"`
	ExchName string `json:"exchName"`
}

Exchange is a supported counterparty exchange.

type ExchangeRate

type ExchangeRate struct {
	USDCNY decimal.Decimal `json:"usdCny"`
}

ExchangeRate is the USD-CNY reference exchange rate.

type ExecType

type ExecType string

ExecType is the liquidity role of a fill.

const (
	ExecTypeTaker ExecType = "T"
	ExecTypeMaker ExecType = "M"
)

type ExecuteQuoteService

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

ExecuteQuoteService -- POST /api/v5/rfq/execute-quote (Trade)

Executes (accepts) a maker's quote as the taker, producing a block trade.

func (*ExecuteQuoteService) Do

func (*ExecuteQuoteService) SetLegs

SetLegs restricts execution to a subset of legs (partial execution).

type Fill

type Fill struct {
	InstrumentType      InstType        `json:"instType"`
	InstrumentID        string          `json:"instId"`
	TradeID             string          `json:"tradeId"`
	OrderID             string          `json:"ordId"`
	ClientOrderID       string          `json:"clOrdId"`
	BillID              string          `json:"billId"`
	SubType             string          `json:"subType"`
	Tag                 string          `json:"tag"`
	FillPrice           decimal.Decimal `json:"fillPx"`
	FillSize            decimal.Decimal `json:"fillSz"`
	FillIndexPrice      decimal.Decimal `json:"fillIdxPx"`
	FillPnl             decimal.Decimal `json:"fillPnl"`
	FillPriceVolatility decimal.Decimal `json:"fillPxVol"`
	FillPriceUSD        decimal.Decimal `json:"fillPxUsd"`
	FillMarkVolatility  decimal.Decimal `json:"fillMarkVol"`
	FillForwardPrice    decimal.Decimal `json:"fillFwdPx"`
	FillMarkPrice       decimal.Decimal `json:"fillMarkPx"`
	Side                Side            `json:"side"`
	PositionSide        PosSide         `json:"posSide"`
	ExecutionType       ExecType        `json:"execType"`
	FeeCurrency         string          `json:"feeCcy"`
	Fee                 decimal.Decimal `json:"fee"`
	TradeQuoteCurrency  string          `json:"tradeQuoteCcy"`
	Timestamp           time.Time       `json:"ts"`
	FillTime            time.Time       `json:"fillTime"`
}

Fill is one transaction (fill) detail, shared by /api/v5/trade/fills and /api/v5/trade/fills-history.

type FirstCopyCopySettingsService

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

FirstCopyCopySettingsService -- POST /api/v5/copytrading/first-copy-settings (Trade)

Starts copy-trading a lead trader for the first time, with the given copy configuration.

func (*FirstCopyCopySettingsService) Do

func (*FirstCopyCopySettingsService) SetCopyAmt

SetCopyAmt sets the fixed copy amount per order (copyMode=fixed_amount).

func (*FirstCopyCopySettingsService) SetCopyRatio

SetCopyRatio sets the copy ratio (copyMode=ratio_copy).

func (*FirstCopyCopySettingsService) SetCopyTotalAmt

SetCopyTotalAmt sets the total amount budgeted for copying.

func (*FirstCopyCopySettingsService) SetInstId

SetInstId sets the comma-separated instruments to copy (copyInstIdType=custom).

func (*FirstCopyCopySettingsService) SetInstType

SetInstType sets the product line (SWAP).

func (*FirstCopyCopySettingsService) SetSlRatio

SetSlRatio sets the stop-loss ratio.

func (*FirstCopyCopySettingsService) SetSlTotalAmt

SetSlTotalAmt sets the total stop-loss amount.

func (*FirstCopyCopySettingsService) SetTpRatio

SetTpRatio sets the take-profit ratio.

type FixedLoanAmendLendingOrderAck

type FixedLoanAmendLendingOrderAck struct {
	OrderID string `json:"ordId"`
}

FixedLoanAmendLendingOrderAck is the acknowledgement of an amended lending order.

type FixedLoanLendingApyHistory

type FixedLoanLendingApyHistory struct {
	Rate      decimal.Decimal `json:"rate"`
	Timestamp time.Time       `json:"ts"`
}

FixedLoanLendingApyHistory is one historical APY data point.

type FixedLoanLendingOffer

type FixedLoanLendingOffer struct {
	Currency        string                        `json:"ccy"`
	Term            string                        `json:"term"`
	Lend            decimal.Decimal               `json:"lend"`
	APY             decimal.Decimal               `json:"apy"`
	EarningCurrency []FixedLoanOfferEarning       `json:"earningCcy"`
	Details         []FixedLoanLendingOfferDetail `json:"details"`
}

FixedLoanLendingOffer is one available fixed-loan lending offer.

type FixedLoanLendingOfferDetail

type FixedLoanLendingOfferDetail struct {
	MinLend decimal.Decimal `json:"minLend"`
	MaxLend decimal.Decimal `json:"maxLend"`
}

FixedLoanLendingOfferDetail is one min/max amount detail of a lending offer.

type FixedLoanLendingOrder

type FixedLoanLendingOrder struct {
	OrderID         string          `json:"ordId"`
	Currency        string          `json:"ccy"`
	Amount          decimal.Decimal `json:"amt"`
	Term            string          `json:"term"`
	Rate            decimal.Decimal `json:"rate"`
	EarningCurrency string          `json:"earningCcy"`
	Earnings        decimal.Decimal `json:"earnings"`
	State           string          `json:"state"`
	AutoRenewal     bool            `json:"autoRenewal"`
	SettledRate     decimal.Decimal `json:"settledRate"`
	PendingAmount   decimal.Decimal `json:"pendingAmt"`
	UsedAmount      decimal.Decimal `json:"usedAmt"`
	CreationTime    time.Time       `json:"cTime"`
	UpdateTime      time.Time       `json:"uTime"`
}

FixedLoanLendingOrder is one fixed-loan lending order.

type FixedLoanLendingOrderAck

type FixedLoanLendingOrderAck struct {
	OrderID string `json:"ordId"`
}

FixedLoanLendingOrderAck is the acknowledgement of a placed lending order.

type FixedLoanLendingSubOrder

type FixedLoanLendingSubOrder struct {
	OrderID            string          `json:"ordId"`
	SubOrderID         string          `json:"subOrdId"`
	Currency           string          `json:"ccy"`
	Amount             decimal.Decimal `json:"amt"`
	Term               string          `json:"term"`
	Rate               decimal.Decimal `json:"rate"`
	EarningCurrency    string          `json:"earningCcy"`
	Earnings           decimal.Decimal `json:"earnings"`
	State              string          `json:"state"`
	SettledRate        decimal.Decimal `json:"settledRate"`
	CreationTime       time.Time       `json:"cTime"`
	UpdateTime         time.Time       `json:"uTime"`
	EffectiveTimestamp time.Time       `json:"effectiveTs"`
	ExpiryTimestamp    time.Time       `json:"expiryTs"`
}

FixedLoanLendingSubOrder is one sub-order of a fixed-loan lending order.

type FixedLoanOfferEarning

type FixedLoanOfferEarning struct {
	EarningCurrency string `json:"earningCcy"`
}

FixedLoanOfferEarning is one earning-currency entry of a lending offer.

type FixedLoanPendingLendingVolume

type FixedLoanPendingLendingVolume struct {
	Currency string          `json:"ccy"`
	Term     string          `json:"term"`
	Amount   decimal.Decimal `json:"amt"`
	MinRate  decimal.Decimal `json:"minRate"`
	MaxRate  decimal.Decimal `json:"maxRate"`
}

FixedLoanPendingLendingVolume is the pending lending volume for a currency/term.

type FlexLoanAdjustCollateral

type FlexLoanAdjustCollateral struct {
	Type               FlexLoanAdjustType `json:"type"`
	CollateralCurrency string             `json:"collateralCcy"`
	CollateralAmount   decimal.Decimal    `json:"collateralAmt"`
}

FlexLoanAdjustCollateral is the acknowledgement of a collateral adjustment.

type FlexLoanAdjustType

type FlexLoanAdjustType string

FlexLoanAdjustType selects whether collateral is added or reduced when adjusting a flexible-loan position.

const (
	FlexLoanAdjustTypeAdd    FlexLoanAdjustType = "add"
	FlexLoanAdjustTypeReduce FlexLoanAdjustType = "reduce"
)

type FlexLoanBorrowCurrency

type FlexLoanBorrowCurrency struct {
	BorrowCurrency string `json:"borrowCcy"`
}

FlexLoanBorrowCurrency is a single borrowable flexible-loan currency.

type FlexLoanCollateralAsset

type FlexLoanCollateralAsset struct {
	Currency string          `json:"ccy"`
	Amount   decimal.Decimal `json:"amt"`
}

FlexLoanCollateralAsset is one asset usable as flexible-loan collateral.

type FlexLoanCollateralAssets

type FlexLoanCollateralAssets struct {
	Assets []FlexLoanCollateralAsset `json:"assets"`
}

FlexLoanCollateralAssets wraps the list of collateral assets. The validating account had no eligible collateral (assets is []), so FlexLoanCollateralAsset is modeled from the OKX doc field table.

type FlexLoanHistory

type FlexLoanHistory struct {
	ReferenceID string          `json:"refId"`
	Type        string          `json:"type"`
	Currency    string          `json:"ccy"`
	Amount      decimal.Decimal `json:"amt"`
	Timestamp   time.Time       `json:"ts"`
}

FlexLoanHistory is one flexible-loan event record.

type FlexLoanInfo

type FlexLoanInfo struct {
	LiquidationLTV          decimal.Decimal          `json:"liquidationLTV"`
	CurrentLTV              decimal.Decimal          `json:"curLTV"`
	RiskWarningLTV          decimal.Decimal          `json:"riskWarningLTV"`
	InitialLTV              decimal.Decimal          `json:"initLTV"`
	TotalBorrowValueUSD     decimal.Decimal          `json:"totalBorrowValueUsd"`
	TotalCollateralValueUSD decimal.Decimal          `json:"totalCollateralValueUsd"`
	LoanData                []FlexLoanInfoLoan       `json:"loanData"`
	CollateralData          []FlexLoanInfoCollateral `json:"collateralData"`
}

FlexLoanInfo is the account's current flexible-loan position.

type FlexLoanInfoCollateral

type FlexLoanInfoCollateral struct {
	CollateralCurrency string          `json:"collateralCcy"`
	Amount             decimal.Decimal `json:"amt"`
	NotionalUSD        decimal.Decimal `json:"notionalUsd"`
}

FlexLoanInfoCollateral is one collateral currency within a flexible-loan position.

type FlexLoanInfoLoan

type FlexLoanInfoLoan struct {
	BorrowCurrency string          `json:"borrowCcy"`
	Amount         decimal.Decimal `json:"amt"`
	NotionalUSD    decimal.Decimal `json:"notionalUsd"`
}

FlexLoanInfoLoan is one borrowed currency within a flexible-loan position.

type FlexLoanInterestAccrued

type FlexLoanInterestAccrued struct {
	Currency     string          `json:"ccy"`
	Interest     decimal.Decimal `json:"interest"`
	InterestRate decimal.Decimal `json:"interestRate"`
	Timestamp    time.Time       `json:"ts"`
}

FlexLoanInterestAccrued is one accrued-interest record.

type FlexLoanMaxLoan

type FlexLoanMaxLoan struct {
	BorrowCurrency string          `json:"borrowCcy"`
	MaxLoan        decimal.Decimal `json:"maxLoan"`
	NotionalUSD    decimal.Decimal `json:"notionalUsd"`
	RemainingQuota decimal.Decimal `json:"remainingQuota"`
}

FlexLoanMaxLoan is the computed max-loan result for a borrow currency.

type FlexLoanSupCollateral

type FlexLoanSupCollateral struct {
	Currency string          `json:"ccy"`
	Amount   decimal.Decimal `json:"amt"`
}

FlexLoanSupCollateral is one supplementary-collateral item passed to the max-loan calculation.

type FundingBalance

type FundingBalance struct {
	Currency         string          `json:"ccy"`
	Balance          decimal.Decimal `json:"bal"`
	FrozenBalance    decimal.Decimal `json:"frozenBal"`
	AvailableBalance decimal.Decimal `json:"availBal"`
}

FundingBalance is a currency's balance in the funding account.

type FundingRate

type FundingRate struct {
	InstrumentType        InstType        `json:"instType"`
	InstrumentID          string          `json:"instId"`
	Method                string          `json:"method"`
	FormulaType           string          `json:"formulaType"`
	FundingRate           decimal.Decimal `json:"fundingRate"`
	NextFundingRate       decimal.Decimal `json:"nextFundingRate"`
	FundingTime           time.Time       `json:"fundingTime"`
	NextFundingTime       time.Time       `json:"nextFundingTime"`
	MinFundingRate        decimal.Decimal `json:"minFundingRate"`
	MaxFundingRate        decimal.Decimal `json:"maxFundingRate"`
	InterestRate          decimal.Decimal `json:"interestRate"`
	ImpactValue           decimal.Decimal `json:"impactValue"`
	SettlementState       publicSettState `json:"settState"`
	SettlementFundingRate decimal.Decimal `json:"settFundingRate"`
	Premium               decimal.Decimal `json:"premium"`
	PreviousFundingTime   time.Time       `json:"prevFundingTime"`
	Timestamp             time.Time       `json:"ts"`
}

FundingRate is a perpetual swap's current funding rate.

type FundingRateHistory

type FundingRateHistory struct {
	InstrumentType InstType        `json:"instType"`
	InstrumentID   string          `json:"instId"`
	Method         string          `json:"method"`
	FormulaType    string          `json:"formulaType"`
	FundingRate    decimal.Decimal `json:"fundingRate"`
	RealizedRate   decimal.Decimal `json:"realizedRate"`
	FundingTime    time.Time       `json:"fundingTime"`
}

FundingRateHistory is one realized funding-rate record.

type FundsTransfer

type FundsTransfer struct {
	TransferID string          `json:"transId"`
	ClientID   string          `json:"clientId"`
	Currency   string          `json:"ccy"`
	Amount     decimal.Decimal `json:"amt"`
	From       AssetAcctType   `json:"from"`
	To         AssetAcctType   `json:"to"`
}

FundsTransfer is the acknowledgement of a funds transfer.

type FundsTransferService

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

FundsTransferService -- POST /api/v5/asset/transfer (private)

Transfers funds between the funding account and the trading account, or between a master account and its sub-accounts. IMPLEMENT-ONLY: this moves real funds and must never be executed by the test suite.

func (*FundsTransferService) Do

func (*FundsTransferService) SetClientId

func (s *FundsTransferService) SetClientId(clientId string) *FundsTransferService

SetClientId sets a client-supplied transfer id.

func (*FundsTransferService) SetLoanTrans

func (s *FundsTransferService) SetLoanTrans(loanTrans bool) *FundsTransferService

SetLoanTrans enables transfer of borrowed funds under Spot mode / Multi-currency margin / Portfolio margin.

func (*FundsTransferService) SetOmitPosRisk

func (s *FundsTransferService) SetOmitPosRisk(omitPosRisk string) *FundsTransferService

SetOmitPosRisk skips the position-risk check (Portfolio margin only).

func (*FundsTransferService) SetSubAcct

func (s *FundsTransferService) SetSubAcct(subAcct string) *FundsTransferService

SetSubAcct sets the sub-account name (required for master<->sub transfers).

func (*FundsTransferService) SetType

SetType sets the transfer type (default "0" within own account).

type GLPAccount added in v0.20260723.0

type GLPAccount struct {
	MasterAccountID    string   `json:"masterAccountId"`
	CombinedAccountIDs []string `json:"combinedAccountIds"`
}

GLPAccount identifies the master account and any combined accounts assessed together for GLP.

type GLPCategoryBreakdown added in v0.20260723.0

type GLPCategoryBreakdown struct {
	TypeA      GLPMakerTaker `json:"typeA"`
	TypeBTotal GLPMakerTaker `json:"typeBTotal"`
	TypeBAdj   GLPMakerTaker `json:"typeBAdj"`
	TradFiX2   GLPMakerTaker `json:"tradfiX2"`
	Total      GLPMakerTaker `json:"total"`
}

GLPCategoryBreakdown splits a metric (volume or share) by GLP pair-type category, each carrying a maker/taker pair.

type GLPHistoricalPerformance added in v0.20260723.0

type GLPHistoricalPerformance struct {
	Date   string               `json:"date"`
	Volume GLPCategoryBreakdown `json:"volume"`
	Share  GLPCategoryBreakdown `json:"share"`
}

GLPHistoricalPerformance is one day of a program's GLP performance history.

type GLPMakerTaker added in v0.20260723.0

type GLPMakerTaker struct {
	Maker decimal.Decimal `json:"maker"`
	Taker decimal.Decimal `json:"taker"`
}

GLPMakerTaker is a maker/taker value pair (decimal-encoded strings).

type GLPPeriodPerf added in v0.20260723.0

type GLPPeriodPerf struct {
	Volume GLPCategoryBreakdown `json:"volume"`
	Share  GLPCategoryBreakdown `json:"share"`
}

GLPPeriodPerf holds a period's volume and share breakdowns.

type GLPProgram added in v0.20260723.0

type GLPProgram string

GLPProgram selects a GLP (Global Liquidity Program) business line for the historical-performance endpoint.

const (
	GLPProgramSpot   GLPProgram = "SPOT"
	GLPProgramPerp   GLPProgram = "PERP"
	GLPProgramFutNto GLPProgram = "FUT_NTO"
)

type GLPProgramPerf added in v0.20260723.0

type GLPProgramPerf struct {
	Program               string             `json:"program"`
	MarketMakerBusinessID string             `json:"marketMakerBusinessId"`
	EnrollmentStatus      string             `json:"enrollmentStatus"`
	MarketMakerLevelID    string             `json:"marketMakerLevelId"`
	EnrolledTierDisplay   string             `json:"enrolledTierDisplay"`
	QualifyingPool        string             `json:"qualifyingPool"`
	QualifyingRows        []GLPQualifyingRow `json:"qualifyingRows"`
	Daily                 GLPPeriodPerf      `json:"daily"`
	MonthToDate           GLPPeriodPerf      `json:"mtd"`
}

GLPProgramPerf is one enrolled program's daily and month-to-date performance.

type GLPQualifyingRow added in v0.20260723.0

type GLPQualifyingRow struct {
	PairType string          `json:"pairType"`
	Volume   decimal.Decimal `json:"volume"`
	Share    decimal.Decimal `json:"share"`
}

GLPQualifyingRow is one row of a program's qualifying-pool breakdown. Modeled from the OKX docs; unknown keys decode away.

type GLPTodayPerformance added in v0.20260723.0

type GLPTodayPerformance struct {
	DataReady bool             `json:"dataReady"`
	DataDate  string           `json:"dataDate"`
	Account   GLPAccount       `json:"account"`
	Programs  []GLPProgramPerf `json:"programs"`
}

GLPTodayPerformance is the today / month-to-date GLP snapshot. The validating account is not enrolled in any GLP program, so the field set is modeled from the OKX doc field tables.

type GetAccountConfigService

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

GetAccountConfigService -- GET /api/v5/account/config (Read)

Returns the account's configuration: account level, position mode, fee/greeks settings and related flags.

func (*GetAccountConfigService) Do

type GetAccountInstrumentsService

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

GetAccountInstrumentsService -- GET /api/v5/account/instruments (Read)

Returns the instruments tradable by the current account for a product line. The shape matches the public instruments endpoint, so it reuses Instrument.

func (*GetAccountInstrumentsService) Do

func (*GetAccountInstrumentsService) SetInstFamily

SetInstFamily filters by instrument family (FUTURES/SWAP/OPTION).

func (*GetAccountInstrumentsService) SetInstId

SetInstId filters by a single instrument id.

func (*GetAccountInstrumentsService) SetUly

SetUly filters by underlying (FUTURES/SWAP/OPTION).

type GetAccountPositionRiskService

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

GetAccountPositionRiskService -- GET /api/v5/account/account-position-risk (Read)

Returns the account- and position-level risk snapshot (equity per currency and per-position notional/quantity) at a single point in time.

func (*GetAccountPositionRiskService) Do

func (*GetAccountPositionRiskService) SetInstType

SetInstType filters by product line (MARGIN/SWAP/FUTURES/OPTION).

type GetAccountPositionTiersService

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

GetAccountPositionTiersService -- GET /api/v5/account/position-tiers (Read)

Returns the account's maximum position size per underlying / instrument family (the per-account view of the public position-tier schedule).

func (*GetAccountPositionTiersService) Do

func (*GetAccountPositionTiersService) SetInstFamily

SetInstFamily filters by instrument family (comma-separated for several).

func (*GetAccountPositionTiersService) SetUly

SetUly filters by underlying (comma-separated for several).

type GetAccountRateLimitService

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

GetAccountRateLimitService -- GET /api/v5/trade/account-rate-limit (Read)

Returns the account's order-placement rate limit and current fill ratio.

func (*GetAccountRateLimitService) Do

type GetAdjustLeverageInfoService

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

GetAdjustLeverageInfoService -- GET /api/v5/account/adjust-leverage-info (Read)

Returns the estimated information (available transfer, liq price, max amount) for adjusting leverage to a target value.

func (*GetAdjustLeverageInfoService) Do

func (*GetAdjustLeverageInfoService) SetCcy

SetCcy sets the margin currency (required for cross MARGIN unless instId is set).

func (*GetAdjustLeverageInfoService) SetInstId

SetInstId sets the instrument id (required unless ccy is set).

func (*GetAdjustLeverageInfoService) SetPosSide

SetPosSide sets the position side (long/short/net).

type GetAffiliateInviteeDetailService

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

GetAffiliateInviteeDetailService -- GET /api/v5/affiliate/invitee/detail (Read)

Returns the affiliate-relationship detail for one of the calling affiliate's invitees, identified by the invitee's user id (uid). Only accounts with the affiliate/agent role may call this; other accounts get OKX code 51620 ("Only affiliates can perform this action").

Path is curl-verified live: an account without the affiliate role receives code 51620 (path REAL, capability-gated). The other affiliate paths probed (performance-summary, invitee-list, co-inviter-link-list, link-list, sub-affiliate-list) return HTTP 404 — they are not part of the public OKX v5 REST API and were therefore dropped.

func (*GetAffiliateInviteeDetailService) Do

type GetAlgoOrderService

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

GetAlgoOrderService -- GET /api/v5/trade/order-algo (Read)

Returns the details of a single algo order. One of algoId / algoClOrdId is required.

func (*GetAlgoOrderService) Do

func (*GetAlgoOrderService) SetAlgoClOrdId

func (s *GetAlgoOrderService) SetAlgoClOrdId(algoClOrdId string) *GetAlgoOrderService

SetAlgoClOrdId targets the algo order by client-supplied id.

func (*GetAlgoOrderService) SetAlgoId

func (s *GetAlgoOrderService) SetAlgoId(algoId string) *GetAlgoOrderService

SetAlgoId targets the algo order by id.

type GetAlgoOrdersHistoryService

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

GetAlgoOrdersHistoryService -- GET /api/v5/trade/orders-algo-history (Read)

Returns the account's completed algo orders (canceled or effective) for a given ordType over the last three months. Either state or algoId is required in addition to ordType.

func (*GetAlgoOrdersHistoryService) Do

func (*GetAlgoOrdersHistoryService) SetAfter

SetAfter pages to records with an algoId earlier than the given one.

func (*GetAlgoOrdersHistoryService) SetAlgoId

SetAlgoId filters by algo order id.

func (*GetAlgoOrdersHistoryService) SetBefore

SetBefore pages to records with an algoId later than the given one.

func (*GetAlgoOrdersHistoryService) SetInstId

SetInstId filters by instrument id.

func (*GetAlgoOrdersHistoryService) SetInstType

SetInstType filters by product line (SPOT/MARGIN/SWAP/FUTURES).

func (*GetAlgoOrdersHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetAlgoOrdersHistoryService) SetState

SetState filters by terminal state (effective / canceled / order_failed).

type GetAlgoOrdersPendingService

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

GetAlgoOrdersPendingService -- GET /api/v5/trade/orders-algo-pending (Read)

Returns the account's incomplete algo orders for a given ordType.

func (*GetAlgoOrdersPendingService) Do

func (*GetAlgoOrdersPendingService) SetAfter

SetAfter pages to records with an algoId earlier than the given one.

func (*GetAlgoOrdersPendingService) SetAlgoClOrdId

func (s *GetAlgoOrdersPendingService) SetAlgoClOrdId(algoClOrdId string) *GetAlgoOrdersPendingService

SetAlgoClOrdId filters by client-supplied algo order id.

func (*GetAlgoOrdersPendingService) SetAlgoId

SetAlgoId filters by algo order id.

func (*GetAlgoOrdersPendingService) SetBefore

SetBefore pages to records with an algoId later than the given one.

func (*GetAlgoOrdersPendingService) SetInstId

SetInstId filters by instrument id.

func (*GetAlgoOrdersPendingService) SetInstType

SetInstType filters by product line (SPOT/MARGIN/SWAP/FUTURES).

func (*GetAlgoOrdersPendingService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetAnnouncementTypesService

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

GetAnnouncementTypesService -- GET /api/v5/support/announcement-types (signed)

Returns the set of announcement types usable as the annType filter of GetAnnouncementsService.

func (*GetAnnouncementTypesService) Do

type GetAnnouncementsService

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

GetAnnouncementsService -- GET /api/v5/support/announcements (signed)

Returns paginated OKX support announcements. Each data element wraps a page of announcement details plus the total page count.

func (*GetAnnouncementsService) Do

func (*GetAnnouncementsService) SetAnnType

func (s *GetAnnouncementsService) SetAnnType(annType string) *GetAnnouncementsService

SetAnnType filters by announcement type (see GetAnnouncementTypesService for the available values).

func (*GetAnnouncementsService) SetPage

SetPage selects the page of results (1-based).

type GetAssetBillsService

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

GetAssetBillsService -- GET /api/v5/asset/bills (private)

Returns the funding-account bill (balance-change) history of the last year.

func (*GetAssetBillsService) Do

func (*GetAssetBillsService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetAssetBillsService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetAssetBillsService) SetCcy

SetCcy filters by currency.

func (*GetAssetBillsService) SetClientId

func (s *GetAssetBillsService) SetClientId(clientId string) *GetAssetBillsService

SetClientId filters by client-supplied id.

func (*GetAssetBillsService) SetLimit

func (s *GetAssetBillsService) SetLimit(limit int) *GetAssetBillsService

SetLimit caps the number of records returned (max 100).

func (*GetAssetBillsService) SetType

SetType filters by bill type (see OKX docs for the numeric type codes).

type GetAssetValuationService

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

GetAssetValuationService -- GET /api/v5/asset/asset-valuation (private)

Returns the total valuation of all assets across the account's sub-accounts (funding, trading, classic, earn), denominated in a chosen currency.

func (*GetAssetValuationService) Do

func (*GetAssetValuationService) SetCcy

SetCcy sets the valuation currency (e.g. BTC, USDT; default BTC).

type GetBalanceService

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

GetBalanceService -- GET /api/v5/account/balance (Read)

Returns the trading account's balance, total equity and per-currency details.

func (*GetBalanceService) Do

func (*GetBalanceService) SetCcy

func (s *GetBalanceService) SetCcy(ccy string) *GetBalanceService

SetCcy filters the details to a single currency (comma-separated for several).

type GetBillsArchiveService

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

GetBillsArchiveService -- GET /api/v5/account/bills-archive (Read)

Returns the account's bill (balance-change) records for the last 3 months, most recent first. Same shape and filters as /account/bills.

func (*GetBillsArchiveService) Do

func (*GetBillsArchiveService) SetAfter

SetAfter paginates to bills with a billId smaller than the given value (older).

func (*GetBillsArchiveService) SetBefore

SetBefore paginates to bills with a billId larger than the given value (newer).

func (*GetBillsArchiveService) SetBegin

SetBegin filters to bills at or after the given time (by ts).

func (*GetBillsArchiveService) SetCcy

SetCcy filters bills by currency.

func (*GetBillsArchiveService) SetCtType

SetCtType filters bills by contract type (linear/inverse).

func (*GetBillsArchiveService) SetEnd

SetEnd filters to bills at or before the given time (by ts).

func (*GetBillsArchiveService) SetInstId

SetInstId filters bills by a single instrument id.

func (*GetBillsArchiveService) SetInstType

func (s *GetBillsArchiveService) SetInstType(instType InstType) *GetBillsArchiveService

SetInstType filters bills by instrument type (SPOT/MARGIN/SWAP/FUTURES/OPTION).

func (*GetBillsArchiveService) SetLimit

SetLimit caps the number of records returned (max 100, default 100).

func (*GetBillsArchiveService) SetMgnMode

func (s *GetBillsArchiveService) SetMgnMode(mgnMode MgnMode) *GetBillsArchiveService

SetMgnMode filters bills by margin mode (isolated/cross).

func (*GetBillsArchiveService) SetSubType

func (s *GetBillsArchiveService) SetSubType(subType string) *GetBillsArchiveService

SetSubType filters bills by bill sub-type (e.g. "1" buy, "2" sell).

func (*GetBillsArchiveService) SetType

SetType filters bills by bill type (e.g. "1" transfer, "2" trade, "8" funding fee).

type GetBillsHistoryArchiveService

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

GetBillsHistoryArchiveService -- GET /api/v5/account/bills-history-archive (Read)

Returns the download link and state of a previously requested quarterly bills archive (apply first via ApplyBillsHistoryArchiveService).

func (*GetBillsHistoryArchiveService) Do

type GetBillsService

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

GetBillsService -- GET /api/v5/account/bills (Read)

Returns the account's bill (balance-change) records for the last 7 days, most recent first.

func (*GetBillsService) Do

func (s *GetBillsService) Do(ctx context.Context) ([]Bill, error)

func (*GetBillsService) SetAfter

func (s *GetBillsService) SetAfter(billId string) *GetBillsService

SetAfter paginates to bills with a billId smaller than the given value (older).

func (*GetBillsService) SetBefore

func (s *GetBillsService) SetBefore(billId string) *GetBillsService

SetBefore paginates to bills with a billId larger than the given value (newer).

func (*GetBillsService) SetBegin

func (s *GetBillsService) SetBegin(t time.Time) *GetBillsService

SetBegin filters to bills at or after the given time (by ts).

func (*GetBillsService) SetCcy

func (s *GetBillsService) SetCcy(ccy string) *GetBillsService

SetCcy filters bills by currency.

func (*GetBillsService) SetCtType

func (s *GetBillsService) SetCtType(ctType CtType) *GetBillsService

SetCtType filters bills by contract type (linear/inverse).

func (*GetBillsService) SetEnd

func (s *GetBillsService) SetEnd(t time.Time) *GetBillsService

SetEnd filters to bills at or before the given time (by ts).

func (*GetBillsService) SetInstId

func (s *GetBillsService) SetInstId(instId string) *GetBillsService

SetInstId filters bills by a single instrument id.

func (*GetBillsService) SetInstType

func (s *GetBillsService) SetInstType(instType InstType) *GetBillsService

SetInstType filters bills by instrument type (SPOT/MARGIN/SWAP/FUTURES/OPTION).

func (*GetBillsService) SetLimit

func (s *GetBillsService) SetLimit(limit int) *GetBillsService

SetLimit caps the number of records returned (max 100, default 100).

func (*GetBillsService) SetMgnMode

func (s *GetBillsService) SetMgnMode(mgnMode MgnMode) *GetBillsService

SetMgnMode filters bills by margin mode (isolated/cross).

func (*GetBillsService) SetSubType

func (s *GetBillsService) SetSubType(subType string) *GetBillsService

SetSubType filters bills by bill sub-type (e.g. "1" buy, "2" sell).

func (*GetBillsService) SetType

func (s *GetBillsService) SetType(typ string) *GetBillsService

SetType filters bills by bill type (e.g. "1" transfer, "2" trade, "8" funding fee).

type GetBlockTickersService

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

GetBlockTickersService -- GET /api/v5/market/block-tickers (public)

Returns the block-trade tickers for every instrument of a product line.

func (*GetBlockTickersService) Do

func (*GetBlockTickersService) SetInstFamily

func (s *GetBlockTickersService) SetInstFamily(instFamily string) *GetBlockTickersService

SetInstFamily filters block tickers by instrument family (FUTURES/SWAP/OPTION).

func (*GetBlockTickersService) SetUly

SetUly filters block tickers by underlying (FUTURES/SWAP/OPTION).

type GetBooksFullService

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

GetBooksFullService -- GET /api/v5/market/books-full (public)

Returns the full-depth order book (up to 5000 levels) for an instrument.

func (*GetBooksFullService) Do

func (*GetBooksFullService) SetSz

SetSz sets the order book depth (number of price levels, max 5000).

type GetBooksService

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

GetBooksService -- GET /api/v5/market/books (public)

Returns the order book (up to 400 levels) for an instrument.

func (*GetBooksService) Do

func (*GetBooksService) SetSz

func (s *GetBooksService) SetSz(sz int) *GetBooksService

SetSz sets the order book depth (number of price levels).

type GetBorrowRepayHistoryService

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

GetBorrowRepayHistoryService -- GET /api/v5/account/borrow-repay-history (Read)

Returns the VIP-loan borrow and repay history.

func (*GetBorrowRepayHistoryService) Do

func (*GetBorrowRepayHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetBorrowRepayHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetBorrowRepayHistoryService) SetCcy

SetCcy filters by currency.

func (*GetBorrowRepayHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetCandlesService

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

GetCandlesService -- GET /api/v5/market/candles (public)

Returns recent candlestick data for an instrument.

func (*GetCandlesService) Do

func (s *GetCandlesService) Do(ctx context.Context) ([]Candle, error)

func (*GetCandlesService) SetAfter

func (s *GetCandlesService) SetAfter(after time.Time) *GetCandlesService

SetAfter requests candles before the given timestamp (paging backward).

func (*GetCandlesService) SetBar

SetBar sets the candle time granularity (default 1m).

func (*GetCandlesService) SetBefore

func (s *GetCandlesService) SetBefore(before time.Time) *GetCandlesService

SetBefore requests candles after the given timestamp (paging forward).

func (*GetCandlesService) SetLimit

func (s *GetCandlesService) SetLimit(limit int) *GetCandlesService

SetLimit caps the number of returned candles (max 300, default 100).

type GetCollateralAssetsService

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

GetCollateralAssetsService -- GET /api/v5/account/collateral-assets (Read)

Returns the per-currency collateral-enabled state of the account.

func (*GetCollateralAssetsService) Do

func (*GetCollateralAssetsService) SetCcy

SetCcy filters by a single currency.

func (*GetCollateralAssetsService) SetCollateralEnabled

func (s *GetCollateralAssetsService) SetCollateralEnabled(enabled bool) *GetCollateralAssetsService

SetCollateralEnabled filters by collateral-enabled state.

type GetContractsOpenInterestVolumeService

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

GetContractsOpenInterestVolumeService -- GET /api/v5/rubik/stat/contracts/open-interest-volume (public)

Returns the aggregated contract open interest and trading volume per time bar for a currency.

func (*GetContractsOpenInterestVolumeService) Do

func (*GetContractsOpenInterestVolumeService) SetBegin

func (*GetContractsOpenInterestVolumeService) SetEnd

func (*GetContractsOpenInterestVolumeService) SetPeriod

type GetConvertContractCoinService

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

GetConvertContractCoinService -- GET /api/v5/public/convert-contract-coin (public)

Converts between a contract quantity and its coin amount for a derivatives instrument.

func (*GetConvertContractCoinService) Do

func (*GetConvertContractCoinService) SetPx

SetPx sets the order price (required for inverse contracts, ignored for linear).

func (*GetConvertContractCoinService) SetUnit

SetUnit sets the coin unit ("coin" or "usds") when converting to coin.

type GetConvertCurrenciesService

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

GetConvertCurrenciesService -- GET /api/v5/asset/convert/currencies (Read)

Returns the list of currencies that can be used in small-asset conversions.

func (*GetConvertCurrenciesService) Do

type GetConvertCurrencyPairService

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

GetConvertCurrencyPairService -- GET /api/v5/asset/convert/currency-pair (Read)

Returns the tradable convert pair and its per-currency size bounds for a from/to currency combination.

func (*GetConvertCurrencyPairService) Do

type GetConvertHistoryService

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

GetConvertHistoryService -- GET /api/v5/asset/convert/history (Read)

Returns the account's past conversions (last three months).

func (*GetConvertHistoryService) Do

func (*GetConvertHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetConvertHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetConvertHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetConvertHistoryService) SetTag

SetTag filters by order tag (broker id).

type GetCopyBatchLeverageInfoService

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

GetCopyBatchLeverageInfoService -- GET /api/v5/copytrading/batch-leverage-info (Read)

Returns the leverage a lead trader uses for a set of instruments under the given margin mode.

func (*GetCopyBatchLeverageInfoService) Do

func (*GetCopyBatchLeverageInfoService) SetInstId

SetInstId filters by instrument id (single or comma-separated).

type GetCopyConfigService

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

GetCopyConfigService -- GET /api/v5/copytrading/config (Read)

Returns the current account's copy-trading role configuration (lead / copy state and per-role nick names / unique codes).

func (*GetCopyConfigService) Do

type GetCopyCurrentSubpositionsService

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

GetCopyCurrentSubpositionsService -- GET /api/v5/copytrading/current-subpositions (Read)

Returns the lead trader's currently open sub-positions (the positions copiers are mirroring).

func (*GetCopyCurrentSubpositionsService) Do

func (*GetCopyCurrentSubpositionsService) SetAfter

SetAfter paginates to records with subPosId earlier than the given id.

func (*GetCopyCurrentSubpositionsService) SetBefore

SetBefore paginates to records with subPosId newer than the given id.

func (*GetCopyCurrentSubpositionsService) SetInstId

SetInstId filters by a single instrument id.

func (*GetCopyCurrentSubpositionsService) SetInstType

SetInstType filters by product line (SWAP).

func (*GetCopyCurrentSubpositionsService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetCopyCurrentSubpositionsService) SetSubPosType

SetSubPosType filters by sub-position side (long/short).

type GetCopyInstrumentsService

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

GetCopyInstrumentsService -- GET /api/v5/copytrading/instruments (Read)

Returns the instruments the current lead trader can lead-trade and whether each is enabled for leading.

func (*GetCopyInstrumentsService) Do

func (*GetCopyInstrumentsService) SetInstType

SetInstType filters by product line (SWAP).

type GetCopyLeadTradersService

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

GetCopyLeadTradersService -- GET /api/v5/copytrading/lead-traders (Read)

Returns the lead-trader ranking visible to the current (signed) account. Shape matches the public ranking but the rows additionally carry chanType.

func (*GetCopyLeadTradersService) Do

func (*GetCopyLeadTradersService) SetDataVer

SetDataVer sets the data version (snapshot id from a prior call).

func (*GetCopyLeadTradersService) SetInstType

SetInstType filters by product line (SWAP).

func (*GetCopyLeadTradersService) SetLimit

SetLimit caps the number of records returned (max 20, default 10).

func (*GetCopyLeadTradersService) SetMaxAssets

SetMaxAssets filters by maximum trading assets.

func (*GetCopyLeadTradersService) SetMaxAum

SetMaxAum filters by maximum assets under management.

func (*GetCopyLeadTradersService) SetMinAssets

SetMinAssets filters by minimum trading assets.

func (*GetCopyLeadTradersService) SetMinAum

SetMinAum filters by minimum assets under management.

func (*GetCopyLeadTradersService) SetMinLeadDays

func (s *GetCopyLeadTradersService) SetMinLeadDays(minLeadDays string) *GetCopyLeadTradersService

SetMinLeadDays filters by minimum lead days (1/2/3/4 buckets).

func (*GetCopyLeadTradersService) SetPage

SetPage sets the page number.

func (*GetCopyLeadTradersService) SetSortType

SetSortType sets the ranking sort key (overview/pnl/pnlRatio/aum/winRatio).

func (*GetCopyLeadTradersService) SetState

SetState filters by copy state ("0" not copying / "1" copying).

type GetCopyProfitSharingDetailsService

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

GetCopyProfitSharingDetailsService -- GET /api/v5/copytrading/profit-sharing-details (Read)

Returns the lead trader's profit-sharing detail records (the share collected from each copier).

func (*GetCopyProfitSharingDetailsService) Do

func (*GetCopyProfitSharingDetailsService) SetAfter

SetAfter paginates to records with profitSharingId earlier than the given id.

func (*GetCopyProfitSharingDetailsService) SetBefore

SetBefore paginates to records with profitSharingId newer than the given id.

func (*GetCopyProfitSharingDetailsService) SetInstType

SetInstType filters by product line (SWAP).

func (*GetCopyProfitSharingDetailsService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetCopyPublicConfigService

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

GetCopyPublicConfigService -- GET /api/v5/copytrading/public-config (public)

Returns the platform-wide copy-trading limits (min/max copy amounts, ratios and SL/TP caps). Public; no signing required.

func (*GetCopyPublicConfigService) Do

func (*GetCopyPublicConfigService) SetInstType

SetInstType filters by product line (SWAP).

type GetCopyPublicLeadTradersService

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

GetCopyPublicLeadTradersService -- GET /api/v5/copytrading/public-lead-traders (public)

Returns the public lead-trader ranking. Public; no signing required.

func (*GetCopyPublicLeadTradersService) Do

func (*GetCopyPublicLeadTradersService) SetDataVer

SetDataVer sets the data version (snapshot id from a prior call).

func (*GetCopyPublicLeadTradersService) SetInstType

SetInstType filters by product line (SWAP).

func (*GetCopyPublicLeadTradersService) SetLimit

SetLimit caps the number of records returned (max 20, default 10).

func (*GetCopyPublicLeadTradersService) SetMaxAssets

SetMaxAssets filters by maximum trading assets.

func (*GetCopyPublicLeadTradersService) SetMaxAum

SetMaxAum filters by maximum assets under management.

func (*GetCopyPublicLeadTradersService) SetMinAssets

SetMinAssets filters by minimum trading assets.

func (*GetCopyPublicLeadTradersService) SetMinAum

SetMinAum filters by minimum assets under management.

func (*GetCopyPublicLeadTradersService) SetMinLeadDays

SetMinLeadDays filters by minimum lead days (1/2/3/4 buckets).

func (*GetCopyPublicLeadTradersService) SetPage

SetPage sets the page number.

func (*GetCopyPublicLeadTradersService) SetSortType

SetSortType sets the ranking sort key (overview/pnl/pnlRatio/aum/winRatio).

func (*GetCopyPublicLeadTradersService) SetState

SetState filters by copy state ("0" not copying / "1" copying).

type GetCopySettingsService

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

GetCopySettingsService -- GET /api/v5/copytrading/copy-settings (Read)

Returns the current account's copy settings for a specific lead trader.

func (*GetCopySettingsService) Do

type GetCopySubpositionsHistoryService

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

GetCopySubpositionsHistoryService -- GET /api/v5/copytrading/subpositions-history (Read)

Returns the lead trader's closed sub-position history.

func (*GetCopySubpositionsHistoryService) Do

func (*GetCopySubpositionsHistoryService) SetAfter

SetAfter paginates to records with subPosId earlier than the given id.

func (*GetCopySubpositionsHistoryService) SetBefore

SetBefore paginates to records with subPosId newer than the given id.

func (*GetCopySubpositionsHistoryService) SetInstId

SetInstId filters by a single instrument id.

func (*GetCopySubpositionsHistoryService) SetInstType

SetInstType filters by product line (SWAP).

func (*GetCopySubpositionsHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetCopyTotalProfitSharingService

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

GetCopyTotalProfitSharingService -- GET /api/v5/copytrading/total-profit-sharing (Read)

Returns the lead trader's accumulated profit-sharing amount per currency.

func (*GetCopyTotalProfitSharingService) Do

func (*GetCopyTotalProfitSharingService) SetInstType

SetInstType filters by product line (SWAP).

type GetCopyTotalUnrealizedProfitSharingService

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

GetCopyTotalUnrealizedProfitSharingService -- GET /api/v5/copytrading/total-unrealized-profit-sharing (Read)

Returns the lead trader's total pending (unrealized) profit-sharing per currency.

func (*GetCopyTotalUnrealizedProfitSharingService) Do

func (*GetCopyTotalUnrealizedProfitSharingService) SetInstType

SetInstType filters by product line (SWAP).

type GetCopyTradersService

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

GetCopyTradersService -- GET /api/v5/copytrading/copy-traders (Read)

Returns the copiers currently following a given lead trader.

func (*GetCopyTradersService) Do

func (*GetCopyTradersService) SetInstType

func (s *GetCopyTradersService) SetInstType(instType InstType) *GetCopyTradersService

SetInstType filters by product line (SWAP).

func (*GetCopyTradersService) SetLimit

func (s *GetCopyTradersService) SetLimit(limit int) *GetCopyTradersService

SetLimit caps the number of records returned (max 10, default 10).

type GetCopyUnrealizedProfitSharingDetailsService

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

GetCopyUnrealizedProfitSharingDetailsService -- GET /api/v5/copytrading/unrealized-profit-sharing-details (Read)

Returns the lead trader's pending (unrealized) profit-sharing per copier.

func (*GetCopyUnrealizedProfitSharingDetailsService) Do

func (*GetCopyUnrealizedProfitSharingDetailsService) SetInstType

SetInstType filters by product line (SWAP).

type GetCurrenciesService

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

GetCurrenciesService -- GET /api/v5/asset/currencies (private)

Returns the list of all currencies (per chain) available to the account, including deposit/withdrawal capability flags, fee schedule and quotas.

func (*GetCurrenciesService) Do

func (*GetCurrenciesService) SetCcy

SetCcy filters by a single (or comma-separated) currency.

type GetDeliveryExerciseHistoryService

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

GetDeliveryExerciseHistoryService -- GET /api/v5/public/delivery-exercise-history (public)

Returns the delivery (FUTURES) / exercise (OPTION) records of an underlying or instrument family over the last three months.

func (*GetDeliveryExerciseHistoryService) Do

func (*GetDeliveryExerciseHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetDeliveryExerciseHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetDeliveryExerciseHistoryService) SetInstFamily

SetInstFamily filters by instrument family.

func (*GetDeliveryExerciseHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetDeliveryExerciseHistoryService) SetUly

SetUly filters by underlying.

type GetDepositAddressService

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

GetDepositAddressService -- GET /api/v5/asset/deposit-address (private)

Returns the deposit addresses of a currency (one per chain / sub-address).

func (*GetDepositAddressService) Do

type GetDepositHistoryService

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

GetDepositHistoryService -- GET /api/v5/asset/deposit-history (private)

Returns the deposit records of the account.

func (*GetDepositHistoryService) Do

func (*GetDepositHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetDepositHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetDepositHistoryService) SetCcy

SetCcy filters by currency.

func (*GetDepositHistoryService) SetDepId

SetDepId filters by deposit id.

func (*GetDepositHistoryService) SetFromWdId

func (s *GetDepositHistoryService) SetFromWdId(fromWdId string) *GetDepositHistoryService

SetFromWdId filters by the internal-transfer withdrawal id of the sender.

func (*GetDepositHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetDepositHistoryService) SetState

SetState filters by deposit state code.

func (*GetDepositHistoryService) SetTxId

SetTxId filters by the on-chain transaction hash.

func (*GetDepositHistoryService) SetType

SetType filters by deposit type code.

type GetDepositWithdrawStatusService

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

GetDepositWithdrawStatusService -- GET /api/v5/asset/deposit-withdraw-status (private)

Returns the on-chain status of a deposit or withdrawal. Query by withdrawal id (wdId) for a withdrawal, or by txId + ccy + to + chain for a deposit.

func (*GetDepositWithdrawStatusService) Do

func (*GetDepositWithdrawStatusService) SetCcy

SetCcy sets the currency (deposit query).

func (*GetDepositWithdrawStatusService) SetChain

SetChain sets the chain (deposit query).

func (*GetDepositWithdrawStatusService) SetTo

SetTo sets the receiving address (deposit query).

func (*GetDepositWithdrawStatusService) SetTxId

SetTxId queries by the on-chain transaction hash (deposit; with ccy/to/chain).

func (*GetDepositWithdrawStatusService) SetWdId

SetWdId queries by withdrawal id.

type GetDiscountRateInterestFreeQuotaService

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

GetDiscountRateInterestFreeQuotaService -- GET /api/v5/public/discount-rate-interest-free-quota (public)

Returns the discount-rate tiers and interest-free quota per currency.

func (*GetDiscountRateInterestFreeQuotaService) Do

func (*GetDiscountRateInterestFreeQuotaService) SetCcy

SetCcy filters by currency.

func (*GetDiscountRateInterestFreeQuotaService) SetDiscountLv

SetDiscountLv filters by discount level.

type GetEasyConvertCurrencyListService

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

GetEasyConvertCurrencyListService -- GET /api/v5/trade/easy-convert-currency-list (Read)

Returns the small-balance ("dust") currencies eligible for one-click easy-convert and the mainstream currencies they can be converted to.

func (*GetEasyConvertCurrencyListService) Do

func (*GetEasyConvertCurrencyListService) SetSource

SetSource sets the funding source: "1" (trading account, default) or "2" (funding account).

type GetEasyConvertHistoryService

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

GetEasyConvertHistoryService -- GET /api/v5/trade/easy-convert-history (Read)

Returns the easy-convert order history (last 7 days).

func (*GetEasyConvertHistoryService) Do

func (*GetEasyConvertHistoryService) SetAfter

SetAfter returns records earlier than the given time (paginates by uTime).

func (*GetEasyConvertHistoryService) SetBefore

SetBefore returns records newer than the given time (paginates by uTime).

func (*GetEasyConvertHistoryService) SetLimit

SetLimit sets the number of results per request (max 100, default 100).

type GetEconomicCalendarService

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

GetEconomicCalendarService -- GET /api/v5/public/economic-calendar (signed)

Returns macro-economic calendar events (releases, forecasts and actuals) scoped by region and importance.

func (*GetEconomicCalendarService) Do

func (*GetEconomicCalendarService) SetAfter

SetAfter returns events occurring after the given time (pagination by event date, exclusive).

func (*GetEconomicCalendarService) SetBefore

SetBefore returns events occurring before the given time (pagination by event date, exclusive).

func (*GetEconomicCalendarService) SetImportance

SetImportance filters by market-impact rating (1 low / 2 medium / 3 high).

func (*GetEconomicCalendarService) SetLimit

SetLimit caps the number of results (default 100, max 100).

func (*GetEconomicCalendarService) SetRegion

SetRegion filters by country/region.

type GetEntrustSubAccountListService

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

GetEntrustSubAccountListService -- GET /api/v5/users/entrust-subaccount-list (Read)

Returns the custody (entrusted) trading sub-accounts the trading-team master account manages.

func (*GetEntrustSubAccountListService) Do

func (*GetEntrustSubAccountListService) SetSubAcct

SetSubAcct filters by sub-account name.

type GetEstimatedPriceService

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

GetEstimatedPriceService -- GET /api/v5/public/estimated-price (public)

Returns the estimated delivery/exercise price of a FUTURES or OPTION instrument (only available within the hour before delivery/exercise).

func (*GetEstimatedPriceService) Do

type GetEthStakingApyHistoryService

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

GetEthStakingApyHistoryService -- GET /api/v5/finance/staking-defi/eth/apy-history (Read)

Returns the ETH staking APY history for the trailing number of days.

func (*GetEthStakingApyHistoryService) Do

type GetEthStakingBalanceService

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

GetEthStakingBalanceService -- GET /api/v5/finance/staking-defi/eth/balance (Read)

Returns the account's BETH balance and accrued staking interest.

func (*GetEthStakingBalanceService) Do

type GetEthStakingHistoryService

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

GetEthStakingHistoryService -- GET /api/v5/finance/staking-defi/eth/purchase-redeem-history (Read)

Returns the account's ETH staking purchase and redemption history.

func (*GetEthStakingHistoryService) Do

func (*GetEthStakingHistoryService) SetAfter

SetAfter paginates to records earlier than the given request time (older).

func (*GetEthStakingHistoryService) SetBefore

SetBefore paginates to records later than the given request time (newer).

func (*GetEthStakingHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetEthStakingHistoryService) SetStatus

SetStatus filters by record status (pending/success/failed).

func (*GetEthStakingHistoryService) SetType

SetType filters by record type (purchase/redeem).

type GetEthStakingProductInfoService

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

GetEthStakingProductInfoService -- GET /api/v5/finance/staking-defi/eth/product-info (Read)

Returns the ETH staking product parameters (rate, min amount, redemption window and fast-redemption daily limit).

func (*GetEthStakingProductInfoService) Do

type GetExchangeListService

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

GetExchangeListService -- GET /api/v5/asset/exchange-list (private)

Returns the list of supported exchanges and their ids (used to tag counterparty exchanges for travel-rule withdrawals).

func (*GetExchangeListService) Do

type GetExchangeRateService

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

GetExchangeRateService -- GET /api/v5/market/exchange-rate (public)

Retrieves the average exchange rate for USD-CNY over the past 2 weeks.

func (*GetExchangeRateService) Do

type GetFillsHistoryService

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

GetFillsHistoryService -- GET /api/v5/trade/fills-history (Read)

Returns the account's transaction (fill) details over the last three months. instType is required.

func (*GetFillsHistoryService) Do

func (*GetFillsHistoryService) SetAfter

SetAfter paginates to records with a billId earlier than the given one (older).

func (*GetFillsHistoryService) SetBefore

SetBefore paginates to records with a billId later than the given one (newer).

func (*GetFillsHistoryService) SetBegin

SetBegin filters to fills at or after the given time (by ts).

func (*GetFillsHistoryService) SetEnd

SetEnd filters to fills at or before the given time (by ts).

func (*GetFillsHistoryService) SetInstFamily

func (s *GetFillsHistoryService) SetInstFamily(instFamily string) *GetFillsHistoryService

SetInstFamily filters by instrument family.

func (*GetFillsHistoryService) SetInstId

SetInstId filters by instrument id.

func (*GetFillsHistoryService) SetLimit

SetLimit caps the number of records returned (max 100, default 100).

func (*GetFillsHistoryService) SetOrdId

SetOrdId filters by order id.

func (*GetFillsHistoryService) SetSubType

func (s *GetFillsHistoryService) SetSubType(subType string) *GetFillsHistoryService

SetSubType filters by transaction type (e.g. 1 buy, 2 sell, ...).

func (*GetFillsHistoryService) SetUly

SetUly filters by underlying.

type GetFillsService

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

GetFillsService -- GET /api/v5/trade/fills (Read)

Returns the account's transaction (fill) details for the last three days.

func (*GetFillsService) Do

func (s *GetFillsService) Do(ctx context.Context) ([]Fill, error)

func (*GetFillsService) SetAfter

func (s *GetFillsService) SetAfter(after string) *GetFillsService

SetAfter paginates to records with a billId earlier than the given one (older).

func (*GetFillsService) SetBefore

func (s *GetFillsService) SetBefore(before string) *GetFillsService

SetBefore paginates to records with a billId later than the given one (newer).

func (*GetFillsService) SetBegin

func (s *GetFillsService) SetBegin(t time.Time) *GetFillsService

SetBegin filters to fills at or after the given time (by ts).

func (*GetFillsService) SetEnd

func (s *GetFillsService) SetEnd(t time.Time) *GetFillsService

SetEnd filters to fills at or before the given time (by ts).

func (*GetFillsService) SetInstFamily

func (s *GetFillsService) SetInstFamily(instFamily string) *GetFillsService

SetInstFamily filters by instrument family.

func (*GetFillsService) SetInstId

func (s *GetFillsService) SetInstId(instId string) *GetFillsService

SetInstId filters by instrument id.

func (*GetFillsService) SetInstType

func (s *GetFillsService) SetInstType(instType InstType) *GetFillsService

SetInstType filters by product line (SPOT/MARGIN/SWAP/FUTURES/OPTION).

func (*GetFillsService) SetLimit

func (s *GetFillsService) SetLimit(limit int) *GetFillsService

SetLimit caps the number of records returned (max 100, default 100).

func (*GetFillsService) SetOrdId

func (s *GetFillsService) SetOrdId(ordId string) *GetFillsService

SetOrdId filters by order id.

func (*GetFillsService) SetSubType

func (s *GetFillsService) SetSubType(subType string) *GetFillsService

SetSubType filters by transaction type (e.g. 1 buy, 2 sell, ...).

func (*GetFillsService) SetUly

func (s *GetFillsService) SetUly(uly string) *GetFillsService

SetUly filters by underlying.

type GetFixedLoanLendingApyHistoryService

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

GetFixedLoanLendingApyHistoryService -- GET /api/v5/finance/fixed-loan/lending-apy-history (Read)

Returns the historical lending APY for a currency/term.

func (*GetFixedLoanLendingApyHistoryService) Do

type GetFixedLoanLendingOffersService

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

GetFixedLoanLendingOffersService -- GET /api/v5/finance/fixed-loan/lending-offers (Read)

Returns the available fixed-loan lending offers (estimated APY and limits per currency/term).

func (*GetFixedLoanLendingOffersService) Do

func (*GetFixedLoanLendingOffersService) SetCcy

SetCcy filters by lending currency.

func (*GetFixedLoanLendingOffersService) SetTerm

SetTerm filters by lending term (e.g. 30D).

type GetFixedLoanLendingOrdersListService

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

GetFixedLoanLendingOrdersListService -- GET /api/v5/finance/fixed-loan/lending-orders-list (Read)

Returns the account's fixed-loan lending orders.

func (*GetFixedLoanLendingOrdersListService) Do

func (*GetFixedLoanLendingOrdersListService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetFixedLoanLendingOrdersListService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetFixedLoanLendingOrdersListService) SetCcy

SetCcy filters by lending currency.

func (*GetFixedLoanLendingOrdersListService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetFixedLoanLendingOrdersListService) SetOrdId

SetOrdId filters by order id.

func (*GetFixedLoanLendingOrdersListService) SetState

SetState filters by order state.

func (*GetFixedLoanLendingOrdersListService) SetTerm

SetTerm filters by lending term.

type GetFixedLoanLendingSubOrdersService

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

GetFixedLoanLendingSubOrdersService -- GET /api/v5/finance/fixed-loan/lending-sub-orders (Read)

Returns the sub-orders of a fixed-loan lending order.

func (*GetFixedLoanLendingSubOrdersService) Do

type GetFixedLoanPendingLendingVolumeService

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

GetFixedLoanPendingLendingVolumeService -- GET /api/v5/finance/fixed-loan/pending-lending-volume (Read)

Returns the pending (queued) lending volume for a currency/term.

func (*GetFixedLoanPendingLendingVolumeService) Do

type GetFlexLoanBorrowCurrenciesService

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

GetFlexLoanBorrowCurrenciesService -- GET /api/v5/finance/flexible-loan/borrow-currencies (Read)

Returns the currencies that can be borrowed via flexible loan.

func (*GetFlexLoanBorrowCurrenciesService) Do

type GetFlexLoanCollateralAssetsService

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

GetFlexLoanCollateralAssetsService -- GET /api/v5/finance/flexible-loan/collateral-assets (Read)

Returns the assets eligible as flexible-loan collateral. The data is a single object wrapping an "assets" array.

func (*GetFlexLoanCollateralAssetsService) Do

func (*GetFlexLoanCollateralAssetsService) SetCcy

SetCcy filters by collateral currency.

type GetFlexLoanInterestAccruedService

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

GetFlexLoanInterestAccruedService -- GET /api/v5/finance/flexible-loan/interest-accrued (Read)

Returns the account's accrued flexible-loan interest records. The validating account has no records (empty data), so FlexLoanInterestAccrued is modeled from the OKX doc field table.

func (*GetFlexLoanInterestAccruedService) Do

func (*GetFlexLoanInterestAccruedService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetFlexLoanInterestAccruedService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetFlexLoanInterestAccruedService) SetCcy

SetCcy filters by borrowed currency.

func (*GetFlexLoanInterestAccruedService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetFlexLoanLoanHistoryService

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

GetFlexLoanLoanHistoryService -- GET /api/v5/finance/flexible-loan/loan-history (Read)

Returns the account's flexible-loan event history (borrow / repay / liquidation). The validating account has no history (empty data), so FlexLoanHistory is modeled from the OKX doc field table.

func (*GetFlexLoanLoanHistoryService) Do

func (*GetFlexLoanLoanHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetFlexLoanLoanHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetFlexLoanLoanHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetFlexLoanLoanHistoryService) SetType

SetType filters by event type.

type GetFlexLoanLoanInfoService

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

GetFlexLoanLoanInfoService -- GET /api/v5/finance/flexible-loan/loan-info (Read)

Returns the account's current flexible-loan position (borrowed amounts, collateral and loan-to-value ratios). The validating account has no flexible loan (empty data), so FlexLoanInfo is modeled from the OKX doc field table.

func (*GetFlexLoanLoanInfoService) Do

type GetFlexLoanMaxLoanService

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

GetFlexLoanMaxLoanService -- POST /api/v5/finance/flexible-loan/max-loan (Read)

Computes the maximum loanable amount for a borrow currency given the supplied (or current) collateral. This is a non-state-changing calculation served over POST (it returns 405 to GET).

func (*GetFlexLoanMaxLoanService) Do

func (*GetFlexLoanMaxLoanService) SetSupCollateral

func (s *GetFlexLoanMaxLoanService) SetSupCollateral(supCollateral []FlexLoanSupCollateral) *GetFlexLoanMaxLoanService

SetSupCollateral sets the supplementary collateral used in the calculation (each item a {ccy, amt} pair).

type GetFundingBalanceService

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

GetFundingBalanceService -- GET /api/v5/asset/balances (private)

Returns the balances in the funding account.

func (*GetFundingBalanceService) Do

func (*GetFundingBalanceService) SetCcy

SetCcy filters by a single (or comma-separated) currency.

type GetFundingRateHistoryService

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

GetFundingRateHistoryService -- GET /api/v5/public/funding-rate-history (public)

Returns the historical (realized) funding rates of a perpetual swap.

func (*GetFundingRateHistoryService) Do

func (*GetFundingRateHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetFundingRateHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetFundingRateHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetFundingRateService

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

GetFundingRateService -- GET /api/v5/public/funding-rate (public)

Returns the current funding rate of a perpetual swap.

func (*GetFundingRateService) Do

type GetGLPHistoricalPerformanceService added in v0.20260723.0

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

GetGLPHistoricalPerformanceService -- GET /api/v5/users/glp/historical-performance (Read)

Returns the enrolled GLP account's daily performance history for one program, sorted newest-first.

func (*GetGLPHistoricalPerformanceService) Do added in v0.20260723.0

func (*GetGLPHistoricalPerformanceService) SetBegin added in v0.20260723.0

SetBegin filters to records at or after the given ms timestamp.

func (*GetGLPHistoricalPerformanceService) SetEnd added in v0.20260723.0

SetEnd filters to records at or before the given ms timestamp.

func (*GetGLPHistoricalPerformanceService) SetLimit added in v0.20260723.0

SetLimit caps the number of daily records returned (default 31, max 100).

type GetGLPTodayPerformanceService added in v0.20260723.0

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

GetGLPTodayPerformanceService -- GET /api/v5/users/glp/today-performance (Read)

Returns the enrolled GLP (Global Liquidity Program) account's current-day and month-to-date assessment snapshots across all programs. Only available to accounts enrolled in a GLP market-maker program; the account is resolved from the API key, so there are no request parameters.

func (*GetGLPTodayPerformanceService) Do added in v0.20260723.0

type GetGreeksService

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

GetGreeksService -- GET /api/v5/account/greeks (Read)

Returns the account's per-currency option greeks.

func (*GetGreeksService) Do

func (s *GetGreeksService) Do(ctx context.Context) ([]Greeks, error)

func (*GetGreeksService) SetCcy

func (s *GetGreeksService) SetCcy(ccy string) *GetGreeksService

SetCcy filters by currency.

type GetGridAIParamService

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

GetGridAIParamService -- GET /api/v5/tradingBot/grid/ai-param (public)

Returns OKX's AI-recommended grid parameters for an instrument. Public (no signing required).

func (*GetGridAIParamService) Do

func (*GetGridAIParamService) SetDirection

func (s *GetGridAIParamService) SetDirection(direction GridDirection) *GetGridAIParamService

SetDirection sets the contract grid direction (contract_grid only).

func (*GetGridAIParamService) SetDuration

func (s *GetGridAIParamService) SetDuration(duration string) *GetGridAIParamService

SetDuration sets the back-test duration (e.g. "7D", "30D", "180D").

type GetGridAlgoDetailsService

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

GetGridAlgoDetailsService -- GET /api/v5/tradingBot/grid/orders-algo-details (Read)

Returns the full detail of a single grid algo order.

func (*GetGridAlgoDetailsService) Do

type GetGridAlgoHistoryService

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

GetGridAlgoHistoryService -- GET /api/v5/tradingBot/grid/orders-algo-history (Read)

Returns the account's stopped (historical) grid algo orders.

func (*GetGridAlgoHistoryService) Do

func (*GetGridAlgoHistoryService) SetAfter

SetAfter paginates to records earlier than the given algoId (older).

func (*GetGridAlgoHistoryService) SetAlgoId

SetAlgoId filters by algo order id.

func (*GetGridAlgoHistoryService) SetBefore

SetBefore paginates to records later than the given algoId (newer).

func (*GetGridAlgoHistoryService) SetInstId

SetInstId filters by instrument id.

func (*GetGridAlgoHistoryService) SetInstType

SetInstType filters by product line.

func (*GetGridAlgoHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetGridAlgoPendingService

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

GetGridAlgoPendingService -- GET /api/v5/tradingBot/grid/orders-algo-pending (Read)

Returns the account's currently running (pending) grid algo orders.

func (*GetGridAlgoPendingService) Do

func (*GetGridAlgoPendingService) SetAfter

SetAfter paginates to records earlier than the given algoId (older).

func (*GetGridAlgoPendingService) SetAlgoId

SetAlgoId filters by algo order id.

func (*GetGridAlgoPendingService) SetBefore

SetBefore paginates to records later than the given algoId (newer).

func (*GetGridAlgoPendingService) SetInstId

SetInstId filters by instrument id.

func (*GetGridAlgoPendingService) SetInstType

SetInstType filters by product line.

func (*GetGridAlgoPendingService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetGridMinInvestmentService

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

GetGridMinInvestmentService -- POST /api/v5/tradingBot/grid/min-investment (public calc)

Computes the minimum investment required for a given grid configuration. This is a public stateless calculator (no signing required), but its body carries several conditional fields, so it is provided implement-only and is not exercised by the live test. Returns the minimum investable amount per currency.

func (*GetGridMinInvestmentService) Do

func (*GetGridMinInvestmentService) SetAmt

SetAmt sets the planned investment amount.

func (*GetGridMinInvestmentService) SetBasePos

SetBasePos toggles whether to open a base position (contract_grid only).

func (*GetGridMinInvestmentService) SetDirection

SetDirection sets the contract grid direction (contract_grid only).

func (*GetGridMinInvestmentService) SetInvestmentData

SetInvestmentData sets per-currency planned investment entries.

func (*GetGridMinInvestmentService) SetInvestmentType

func (s *GetGridMinInvestmentService) SetInvestmentType(investmentType string) *GetGridMinInvestmentService

SetInvestmentType sets the investment type ("quote", "base").

func (*GetGridMinInvestmentService) SetLever

SetLever sets the leverage (contract_grid only).

type GetGridPositionsService

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

GetGridPositionsService -- GET /api/v5/tradingBot/grid/positions (Read)

Returns the open positions held by a contract grid algo order.

func (*GetGridPositionsService) Do

type GetGridRSIBackTestingService

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

GetGridRSIBackTestingService -- GET /api/v5/tradingBot/public/rsi-back-testing (public)

Back-tests how many times an RSI trigger condition would have fired for an instrument over a duration. Public (no signing required).

func (*GetGridRSIBackTestingService) Do

type GetGridSubOrdersService

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

GetGridSubOrdersService -- GET /api/v5/tradingBot/grid/sub-orders (Read)

Returns the live or filled sub-orders of a grid algo order.

func (*GetGridSubOrdersService) Do

func (*GetGridSubOrdersService) SetAfter

SetAfter paginates to records earlier than the given ordId (older).

func (*GetGridSubOrdersService) SetBefore

SetBefore paginates to records later than the given ordId (newer).

func (*GetGridSubOrdersService) SetGroupId

func (s *GetGridSubOrdersService) SetGroupId(groupId string) *GetGridSubOrdersService

SetGroupId filters by grid group id.

func (*GetGridSubOrdersService) SetInstType

func (s *GetGridSubOrdersService) SetInstType(instType InstType) *GetGridSubOrdersService

SetInstType filters by product line.

func (*GetGridSubOrdersService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetHistoryCandlesService

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

GetHistoryCandlesService -- GET /api/v5/market/history-candles (public)

Returns historical candlestick data for an instrument.

func (*GetHistoryCandlesService) Do

func (*GetHistoryCandlesService) SetAfter

SetAfter requests candles before the given timestamp (paging backward).

func (*GetHistoryCandlesService) SetBar

SetBar sets the candle time granularity (default 1m).

func (*GetHistoryCandlesService) SetBefore

SetBefore requests candles after the given timestamp (paging forward).

func (*GetHistoryCandlesService) SetLimit

SetLimit caps the number of returned candles (max 100, default 100).

type GetHistoryIndexCandlesService

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

GetHistoryIndexCandlesService -- GET /api/v5/market/history-index-candles (public)

Retrieves the older candlestick charts of an index from the last 3 months.

func (*GetHistoryIndexCandlesService) Do

func (*GetHistoryIndexCandlesService) SetAfter

SetAfter requests records earlier than the given timestamp (pagination).

func (*GetHistoryIndexCandlesService) SetBar

SetBar sets the bar size (e.g. 1m, 5m, 1H, 1D). Default is 1m.

func (*GetHistoryIndexCandlesService) SetBefore

SetBefore requests records newer than the given timestamp (pagination).

func (*GetHistoryIndexCandlesService) SetLimit

SetLimit sets the number of results per request (max 100, default 100).

type GetHistoryMarkPriceCandlesService

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

GetHistoryMarkPriceCandlesService -- GET /api/v5/market/history-mark-price-candles (public)

Retrieves the older candlestick charts of the mark price from the last 3 months.

func (*GetHistoryMarkPriceCandlesService) Do

func (*GetHistoryMarkPriceCandlesService) SetAfter

SetAfter requests records earlier than the given timestamp (pagination).

func (*GetHistoryMarkPriceCandlesService) SetBar

SetBar sets the bar size (e.g. 1m, 5m, 1H, 1D). Default is 1m.

func (*GetHistoryMarkPriceCandlesService) SetBefore

SetBefore requests records newer than the given timestamp (pagination).

func (*GetHistoryMarkPriceCandlesService) SetLimit

SetLimit sets the number of results per request (max 100, default 100).

type GetHistoryTradesService

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

GetHistoryTradesService -- GET /api/v5/market/history-trades (public)

Returns historical public trades for an instrument (paged).

func (*GetHistoryTradesService) Do

func (*GetHistoryTradesService) SetAfter

SetAfter pages backward from the given tradeId or timestamp (per type).

func (*GetHistoryTradesService) SetBefore

SetBefore pages forward from the given tradeId (type=1 only).

func (*GetHistoryTradesService) SetLimit

SetLimit caps the number of returned trades (max 100, default 100).

func (*GetHistoryTradesService) SetType

SetType selects the paging field: "1" by tradeId (default), "2" by ts.

type GetIndexCandlesService

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

GetIndexCandlesService -- GET /api/v5/market/index-candles (public)

Retrieves the candlestick charts of an index. Data is sorted newest-first and is returned for up to the most recent ~1440 bars.

func (*GetIndexCandlesService) Do

func (*GetIndexCandlesService) SetAfter

SetAfter requests records earlier than the given timestamp (pagination).

func (*GetIndexCandlesService) SetBar

SetBar sets the bar size (e.g. 1m, 5m, 1H, 1D). Default is 1m.

func (*GetIndexCandlesService) SetBefore

SetBefore requests records newer than the given timestamp (pagination).

func (*GetIndexCandlesService) SetLimit

SetLimit sets the number of results per request (max 100, default 100).

type GetIndexComponentsService

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

GetIndexComponentsService -- GET /api/v5/market/index-components (public)

Retrieves the constituent components of an index and their weights.

func (*GetIndexComponentsService) Do

type GetIndexTickersService

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

GetIndexTickersService -- GET /api/v5/market/index-tickers (public)

Retrieves index tickers. Either quoteCcy or instId is required.

func (*GetIndexTickersService) Do

func (*GetIndexTickersService) SetInstId

SetInstId sets the index instrument ID (e.g. BTC-USDT).

func (*GetIndexTickersService) SetQuoteCcy

SetQuoteCcy sets the quote currency filter (e.g. USD, USDT, BTC). Currently only USD, USDT and BTC are supported.

type GetInstrumentTickBandsService

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

GetInstrumentTickBandsService -- GET /api/v5/public/instrument-tick-bands (public)

Returns the tick-size bands of OPTION instruments by instrument family.

func (*GetInstrumentTickBandsService) Do

func (*GetInstrumentTickBandsService) SetInstFamily

SetInstFamily filters by instrument family.

type GetInstrumentsService

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

GetInstrumentsService -- GET /api/v5/public/instruments (public)

Returns the tradable instruments for a product line, including their lot/tick sizes, contract specs and listing state.

func (*GetInstrumentsService) Do

func (*GetInstrumentsService) SetInstFamily

func (s *GetInstrumentsService) SetInstFamily(instFamily string) *GetInstrumentsService

SetInstFamily filters by instrument family (applicable to FUTURES/SWAP/OPTION).

func (*GetInstrumentsService) SetInstId

func (s *GetInstrumentsService) SetInstId(instId string) *GetInstrumentsService

SetInstId filters by a single instrument id.

func (*GetInstrumentsService) SetSeriesID added in v0.20260707.0

func (s *GetInstrumentsService) SetSeriesID(seriesId string) *GetInstrumentsService

SetSeriesID filters by event-contract series id (required when instType is EVENTS), e.g. "BTC-ABOVE-DAILY".

func (*GetInstrumentsService) SetUly

SetUly filters by underlying (applicable to FUTURES/SWAP/OPTION).

type GetInsuranceFundService

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

GetInsuranceFundService -- GET /api/v5/public/insurance-fund (public)

Returns the insurance-fund balance and its recent change records for a product line.

func (*GetInsuranceFundService) Do

func (*GetInsuranceFundService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetInsuranceFundService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetInsuranceFundService) SetCcy

SetCcy filters by currency (MARGIN/OPTION).

func (*GetInsuranceFundService) SetInstFamily

func (s *GetInsuranceFundService) SetInstFamily(instFamily string) *GetInsuranceFundService

SetInstFamily filters by instrument family.

func (*GetInsuranceFundService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetInsuranceFundService) SetType

SetType filters by record type (e.g. liquidation_balance_deposit, bankruptcy_loss, platform_revenue).

func (*GetInsuranceFundService) SetUly

SetUly filters by underlying.

type GetInterestAccruedService

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

GetInterestAccruedService -- GET /api/v5/account/interest-accrued (Read)

Returns the interest accrued on margin and quick-margin borrowings.

func (*GetInterestAccruedService) Do

func (*GetInterestAccruedService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetInterestAccruedService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetInterestAccruedService) SetCcy

SetCcy filters by currency.

func (*GetInterestAccruedService) SetInstId

SetInstId filters by instrument id (only applicable to isolated margin).

func (*GetInterestAccruedService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetInterestAccruedService) SetMgnMode

SetMgnMode filters by margin mode (cross / isolated).

func (*GetInterestAccruedService) SetType

SetType filters by loan type ("1" VIP loan, "2" market loan).

type GetInterestLimitsService

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

GetInterestLimitsService -- GET /api/v5/account/interest-limits (Read)

Returns the borrowing-interest summary and the per-currency loan-quota / interest schedule for the account.

func (*GetInterestLimitsService) Do

func (*GetInterestLimitsService) SetCcy

SetCcy filters by currency.

func (*GetInterestLimitsService) SetType

SetType filters by loan type ("1" VIP loan, "2" market loan).

type GetInterestRateLoanQuotaService

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

GetInterestRateLoanQuotaService -- GET /api/v5/public/interest-rate-loan-quota (public)

Returns the basic and VIP interest rates plus the margin-loan quota schedule.

func (*GetInterestRateLoanQuotaService) Do

type GetInterestRateService

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

GetInterestRateService -- GET /api/v5/account/interest-rate (Read)

Returns the current per-currency borrowing interest rate for the account.

func (*GetInterestRateService) Do

func (*GetInterestRateService) SetCcy

SetCcy filters by currency.

type GetLeverageInfoService

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

GetLeverageInfoService -- GET /api/v5/account/leverage-info (Read)

Returns the account's current leverage setting for an instrument under the given margin mode.

func (*GetLeverageInfoService) Do

type GetLoanRatioService

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

GetLoanRatioService -- GET /api/v5/rubik/stat/margin/loan-ratio (public)

Returns the margin lending ratio (margin long vs short) per time bar for a currency.

func (*GetLoanRatioService) Do

func (*GetLoanRatioService) SetBegin

func (*GetLoanRatioService) SetEnd

func (*GetLoanRatioService) SetPeriod

type GetLongShortAccountRatioContractService

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

GetLongShortAccountRatioContractService -- GET /api/v5/rubik/stat/contracts/long-short-account-ratio-contract (public)

Returns the long/short account ratio per time bar for a single contract instrument.

func (*GetLongShortAccountRatioContractService) Do

func (*GetLongShortAccountRatioContractService) SetBegin

func (*GetLongShortAccountRatioContractService) SetEnd

func (*GetLongShortAccountRatioContractService) SetPeriod

type GetLongShortAccountRatioContractTopTraderService

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

GetLongShortAccountRatioContractTopTraderService -- GET /api/v5/rubik/stat/contracts/long-short-account-ratio-contract-top-trader (public)

Returns the long/short account ratio of top traders per time bar for a single contract instrument.

func (*GetLongShortAccountRatioContractTopTraderService) Do

func (*GetLongShortAccountRatioContractTopTraderService) SetBegin

func (*GetLongShortAccountRatioContractTopTraderService) SetEnd

func (*GetLongShortAccountRatioContractTopTraderService) SetPeriod

type GetLongShortAccountRatioService

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

GetLongShortAccountRatioService -- GET /api/v5/rubik/stat/contracts/long-short-account-ratio (public)

Returns the ratio of accounts net-long vs net-short on derivatives per time bar for a currency.

func (*GetLongShortAccountRatioService) Do

func (*GetLongShortAccountRatioService) SetBegin

func (*GetLongShortAccountRatioService) SetEnd

func (*GetLongShortAccountRatioService) SetPeriod

type GetLongShortPositionRatioContractTopTraderService

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

GetLongShortPositionRatioContractTopTraderService -- GET /api/v5/rubik/stat/contracts/long-short-position-ratio-contract-top-trader (public)

Returns the long/short position ratio of top traders per time bar for a single contract instrument.

func (*GetLongShortPositionRatioContractTopTraderService) Do

func (*GetLongShortPositionRatioContractTopTraderService) SetBegin

func (*GetLongShortPositionRatioContractTopTraderService) SetEnd

func (*GetLongShortPositionRatioContractTopTraderService) SetPeriod

type GetMMInstrumentTypesService added in v0.20260703.0

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

GetMMInstrumentTypesService -- GET /api/v5/public/mm-instrument-types (public)

Returns the MM (market-maker) program instrument-type classifications for SPOT and SWAP (and FUTURES) instruments. With no filter it lists every classified instrument.

func (*GetMMInstrumentTypesService) Do added in v0.20260703.0

func (*GetMMInstrumentTypesService) SetInstFamily added in v0.20260703.0

func (s *GetMMInstrumentTypesService) SetInstFamily(instFamily string) *GetMMInstrumentTypesService

SetInstFamily filters by instrument family (requires instType).

func (*GetMMInstrumentTypesService) SetInstId added in v0.20260703.0

SetInstId filters by a single instrument id.

func (*GetMMInstrumentTypesService) SetInstType added in v0.20260703.0

SetInstType filters by instrument type (SPOT/SWAP/FUTURES).

type GetMMPConfigService

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

GetMMPConfigService -- GET /api/v5/account/mmp-config (Read)

Returns the Market Maker Protection configuration of an option instrument family. Requires market-maker permission.

func (*GetMMPConfigService) Do

type GetManagedSubAccountBillsService

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

GetManagedSubAccountBillsService -- GET /api/v5/asset/subaccount/managed-subaccount-bills (Read)

Returns the asset-transfer history of managed (custody) sub-accounts, callable only by the trading-team master account.

Note: /api/v5/account/subaccount/managed-subaccount-bills does NOT exist (HTTP 404); the real path is under /api/v5/asset/.

func (*GetManagedSubAccountBillsService) Do

func (*GetManagedSubAccountBillsService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetManagedSubAccountBillsService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetManagedSubAccountBillsService) SetCcy

SetCcy filters by currency.

func (*GetManagedSubAccountBillsService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetManagedSubAccountBillsService) SetSubAcct

SetSubAcct filters by managed sub-account name.

func (*GetManagedSubAccountBillsService) SetSubUid

SetSubUid filters by managed sub-account uid.

func (*GetManagedSubAccountBillsService) SetType

SetType filters by transfer type ("0" transfer in, "1" transfer out).

type GetMarkPriceCandlesService

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

GetMarkPriceCandlesService -- GET /api/v5/market/mark-price-candles (public)

Retrieves the candlestick charts of the mark price. Data is sorted newest-first for up to the most recent ~1440 bars.

func (*GetMarkPriceCandlesService) Do

func (*GetMarkPriceCandlesService) SetAfter

SetAfter requests records earlier than the given timestamp (pagination).

func (*GetMarkPriceCandlesService) SetBar

SetBar sets the bar size (e.g. 1m, 5m, 1H, 1D). Default is 1m.

func (*GetMarkPriceCandlesService) SetBefore

SetBefore requests records newer than the given timestamp (pagination).

func (*GetMarkPriceCandlesService) SetLimit

SetLimit sets the number of results per request (max 100, default 100).

type GetMarkPriceService

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

GetMarkPriceService -- GET /api/v5/public/mark-price (public)

Returns the mark prices of instruments in a product line.

func (*GetMarkPriceService) Do

func (*GetMarkPriceService) SetInstFamily

func (s *GetMarkPriceService) SetInstFamily(instFamily string) *GetMarkPriceService

SetInstFamily filters by instrument family.

func (*GetMarkPriceService) SetInstId

func (s *GetMarkPriceService) SetInstId(instId string) *GetMarkPriceService

SetInstId filters by a single instrument id.

func (*GetMarkPriceService) SetUly

SetUly filters by underlying.

type GetMaxAvailSizeService

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

GetMaxAvailSizeService -- GET /api/v5/account/max-avail-size (Read)

Returns the maximum available tradable amount of an instrument under the given trade mode (accounting for current balance and positions).

func (*GetMaxAvailSizeService) Do

func (*GetMaxAvailSizeService) SetCcy

SetCcy sets the margin currency (MARGIN cross only).

func (*GetMaxAvailSizeService) SetPx

SetPx sets the order price used to estimate the available size.

func (*GetMaxAvailSizeService) SetQuickMgnType

func (s *GetMaxAvailSizeService) SetQuickMgnType(quickMgnType string) *GetMaxAvailSizeService

SetQuickMgnType sets the quick-margin borrow type (manual/auto_borrow/auto_borrow_repay).

func (*GetMaxAvailSizeService) SetReduceOnly

func (s *GetMaxAvailSizeService) SetReduceOnly(reduceOnly bool) *GetMaxAvailSizeService

SetReduceOnly restricts the estimate to reduce-only sizing.

func (*GetMaxAvailSizeService) SetUnSpotOffset

func (s *GetMaxAvailSizeService) SetUnSpotOffset(unSpotOffset bool) *GetMaxAvailSizeService

SetUnSpotOffset toggles whether spot-derivatives offset is excluded.

type GetMaxLoanService

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

GetMaxLoanService -- GET /api/v5/account/max-loan (Read)

Returns the account's maximum loanable amount for an instrument/currency under the given margin mode.

func (*GetMaxLoanService) Do

func (s *GetMaxLoanService) Do(ctx context.Context) ([]MaxLoan, error)

func (*GetMaxLoanService) SetCcy

func (s *GetMaxLoanService) SetCcy(ccy string) *GetMaxLoanService

SetCcy sets the borrow currency (cross MARGIN).

func (*GetMaxLoanService) SetInstId

func (s *GetMaxLoanService) SetInstId(instId string) *GetMaxLoanService

SetInstId sets the instrument id (single or comma-separated).

func (*GetMaxLoanService) SetMgnCcy

func (s *GetMaxLoanService) SetMgnCcy(mgnCcy string) *GetMaxLoanService

SetMgnCcy sets the margin currency (cross MARGIN).

type GetMaxSizeService

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

GetMaxSizeService -- GET /api/v5/account/max-size (Read)

Returns the maximum buyable/sellable (or openable) size of an instrument under the given trade mode.

func (*GetMaxSizeService) Do

func (s *GetMaxSizeService) Do(ctx context.Context) ([]MaxSize, error)

func (*GetMaxSizeService) SetCcy

func (s *GetMaxSizeService) SetCcy(ccy string) *GetMaxSizeService

SetCcy sets the margin currency (MARGIN cross only).

func (*GetMaxSizeService) SetLeverage

func (s *GetMaxSizeService) SetLeverage(leverage decimal.Decimal) *GetMaxSizeService

SetLeverage sets the leverage used to estimate the max size.

func (*GetMaxSizeService) SetPx

SetPx sets the order price used to estimate the max size.

func (*GetMaxSizeService) SetUnSpotOffset

func (s *GetMaxSizeService) SetUnSpotOffset(unSpotOffset bool) *GetMaxSizeService

SetUnSpotOffset toggles whether spot-derivatives offset is excluded.

type GetMaxWithdrawalService

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

GetMaxWithdrawalService -- GET /api/v5/account/max-withdrawal (Read)

Returns the maximum amount that can be transferred out of the trading account per currency.

func (*GetMaxWithdrawalService) Do

func (*GetMaxWithdrawalService) SetCcy

SetCcy filters by currency (comma-separated for several).

type GetMonthlyStatementService

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

GetMonthlyStatementService -- GET /api/v5/asset/monthly-statement (private)

Returns the download link for a previously applied-for monthly statement.

func (*GetMonthlyStatementService) Do

type GetMovePositionsHistoryService

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

GetMovePositionsHistoryService -- GET /api/v5/account/move-positions-history (Read)

Returns the history of move-positions (block transfer) requests.

func (*GetMovePositionsHistoryService) Do

func (*GetMovePositionsHistoryService) SetBeginTs

SetBeginTs filters to requests at or after the given time.

func (*GetMovePositionsHistoryService) SetBlockTdId

SetBlockTdId filters by block trade id.

func (*GetMovePositionsHistoryService) SetClientId

SetClientId filters by client-supplied id.

func (*GetMovePositionsHistoryService) SetEndTs

SetEndTs filters to requests at or before the given time.

func (*GetMovePositionsHistoryService) SetLimit

SetLimit caps the number of records returned.

func (*GetMovePositionsHistoryService) SetState

SetState filters by transfer state ("filled" / "pending").

type GetNonTradableAssetsService

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

GetNonTradableAssetsService -- GET /api/v5/asset/non-tradable-assets (private)

Returns the non-tradable assets held in the funding account (assets that can only be withdrawn, not traded).

func (*GetNonTradableAssetsService) Do

func (*GetNonTradableAssetsService) SetCcy

SetCcy filters by a single (or comma-separated) currency.

type GetOKUSDLimitsService added in v0.20260703.0

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

GetOKUSDLimitsService -- GET /api/v5/finance/okusd/limits (Read)

Returns the account's remaining daily OKUSD subscription and redemption limits (personal VIP-tier limits and platform-wide limits, plus redemption fee rates).

func (*GetOKUSDLimitsService) Do added in v0.20260703.0

type GetOneClickRepayCurrencyListService

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

GetOneClickRepayCurrencyListService -- GET /api/v5/trade/one-click-repay-currency-list (Read)

Returns the cross/isolated debt currencies eligible for one-click repay and the currencies that can be used to repay them.

func (*GetOneClickRepayCurrencyListService) Do

func (*GetOneClickRepayCurrencyListService) SetDebtType

SetDebtType filters by debt type: "cross" or "isolated".

type GetOneClickRepayCurrencyListV2Service

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

GetOneClickRepayCurrencyListV2Service -- GET /api/v5/trade/one-click-repay-currency-list-v2 (Read)

Returns the debt currencies eligible for one-click repay (v2) and the currencies that can be used to repay them.

func (*GetOneClickRepayCurrencyListV2Service) Do

type GetOneClickRepayHistoryService

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

GetOneClickRepayHistoryService -- GET /api/v5/trade/one-click-repay-history (Read)

Returns the one-click repay order history (last 7 days).

func (*GetOneClickRepayHistoryService) Do

func (*GetOneClickRepayHistoryService) SetAfter

SetAfter returns records earlier than the given time (paginates by uTime).

func (*GetOneClickRepayHistoryService) SetBefore

SetBefore returns records newer than the given time (paginates by uTime).

func (*GetOneClickRepayHistoryService) SetLimit

SetLimit sets the number of results per request (max 100, default 100).

type GetOneClickRepayHistoryV2Service

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

GetOneClickRepayHistoryV2Service -- GET /api/v5/trade/one-click-repay-history-v2 (Read)

Returns the one-click repay (v2) order history.

func (*GetOneClickRepayHistoryV2Service) Do

func (*GetOneClickRepayHistoryV2Service) SetAfter

SetAfter returns records earlier than (included) the given ts.

func (*GetOneClickRepayHistoryV2Service) SetBefore

SetBefore returns records newer than (included) the given ts.

func (*GetOneClickRepayHistoryV2Service) SetLimit

SetLimit sets the number of results per request (max 100, default 100).

type GetOpenInterestHistoryService

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

GetOpenInterestHistoryService -- GET /api/v5/rubik/stat/contracts/open-interest-history (public)

Returns the historical open interest per time bar for a single contract instrument, in contracts, base currency and USD.

func (*GetOpenInterestHistoryService) Do

func (*GetOpenInterestHistoryService) SetBegin

func (*GetOpenInterestHistoryService) SetEnd

func (*GetOpenInterestHistoryService) SetLimit

func (*GetOpenInterestHistoryService) SetPeriod

type GetOpenInterestService

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

GetOpenInterestService -- GET /api/v5/public/open-interest (public)

Returns the open interest of derivatives (SWAP/FUTURES/OPTION).

func (*GetOpenInterestService) Do

func (*GetOpenInterestService) SetInstFamily

func (s *GetOpenInterestService) SetInstFamily(instFamily string) *GetOpenInterestService

SetInstFamily filters by instrument family.

func (*GetOpenInterestService) SetInstId

SetInstId filters by a single instrument id.

func (*GetOpenInterestService) SetUly

SetUly filters by underlying.

type GetOptSummaryService

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

GetOptSummaryService -- GET /api/v5/public/opt-summary (public)

Returns the option market-data summary (greeks and implied volatilities) for an underlying or instrument family.

func (*GetOptSummaryService) Do

func (*GetOptSummaryService) SetExpTime

func (s *GetOptSummaryService) SetExpTime(expTime string) *GetOptSummaryService

SetExpTime filters by an option expiry (YYYYMMdd).

func (*GetOptSummaryService) SetInstFamily

func (s *GetOptSummaryService) SetInstFamily(instFamily string) *GetOptSummaryService

SetInstFamily filters by instrument family.

func (*GetOptSummaryService) SetUly

SetUly filters by underlying.

type GetOptionInstrumentFamilyTradesService

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

GetOptionInstrumentFamilyTradesService -- GET /api/v5/market/option/instrument-family-trades (public)

Returns the most recent trades per strike for an option instrument family.

func (*GetOptionInstrumentFamilyTradesService) Do

type GetOptionOpenInterestVolumeExpiryService

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

GetOptionOpenInterestVolumeExpiryService -- GET /api/v5/rubik/stat/option/open-interest-volume-expiry (public)

Returns option open interest and volume broken down by expiry per time bar for a currency.

func (*GetOptionOpenInterestVolumeExpiryService) Do

func (*GetOptionOpenInterestVolumeExpiryService) SetPeriod

type GetOptionOpenInterestVolumeService

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

GetOptionOpenInterestVolumeService -- GET /api/v5/rubik/stat/option/open-interest-volume (public)

Returns the aggregated option open interest and trading volume per time bar for a currency.

func (*GetOptionOpenInterestVolumeService) Do

func (*GetOptionOpenInterestVolumeService) SetPeriod

type GetOptionOpenInterestVolumeStrikeService

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

GetOptionOpenInterestVolumeStrikeService -- GET /api/v5/rubik/stat/option/open-interest-volume-strike (public)

Returns option open interest and volume broken down by strike price for a given expiry per time bar for a currency.

func (*GetOptionOpenInterestVolumeStrikeService) Do

func (*GetOptionOpenInterestVolumeStrikeService) SetPeriod

type GetOptionTakerBlockVolumeService

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

GetOptionTakerBlockVolumeService -- GET /api/v5/rubik/stat/option/taker-block-volume (public)

Returns the latest option taker buy/sell and block-trade volumes for calls and puts of a currency. Unlike the other rubik endpoints, the data array is a single flat positional array (one snapshot), not an array of bars.

func (*GetOptionTakerBlockVolumeService) Do

func (*GetOptionTakerBlockVolumeService) SetPeriod

type GetOrderService

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

GetOrderService -- GET /api/v5/trade/order (Read)

Returns the details of a single order by ordId or clOrdId.

func (*GetOrderService) Do

func (s *GetOrderService) Do(ctx context.Context) (*Order, error)

func (*GetOrderService) SetClOrdId

func (s *GetOrderService) SetClOrdId(clOrdId string) *GetOrderService

SetClOrdId sets the client-supplied order id (either ordId or clOrdId is required).

func (*GetOrderService) SetOrdId

func (s *GetOrderService) SetOrdId(ordId string) *GetOrderService

SetOrdId sets the order id (either ordId or clOrdId is required).

type GetOrdersHistoryArchiveService

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

GetOrdersHistoryArchiveService -- GET /api/v5/trade/orders-history-archive (Read)

Returns the account's completed orders from the last three months.

func (*GetOrdersHistoryArchiveService) Do

func (*GetOrdersHistoryArchiveService) SetAfter

SetAfter pages to orders with an ordId earlier than this value.

func (*GetOrdersHistoryArchiveService) SetBefore

SetBefore pages to orders with an ordId later than this value.

func (*GetOrdersHistoryArchiveService) SetBegin

SetBegin filters to orders created at or after the given time.

func (*GetOrdersHistoryArchiveService) SetCategory

SetCategory filters by order category.

func (*GetOrdersHistoryArchiveService) SetEnd

SetEnd filters to orders created at or before the given time.

func (*GetOrdersHistoryArchiveService) SetInstFamily

SetInstFamily filters by instrument family.

func (*GetOrdersHistoryArchiveService) SetInstId

SetInstId filters by instrument id.

func (*GetOrdersHistoryArchiveService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetOrdersHistoryArchiveService) SetOrdType

SetOrdType filters by order type.

func (*GetOrdersHistoryArchiveService) SetState

SetState filters by order state (canceled/filled/mmp_canceled).

func (*GetOrdersHistoryArchiveService) SetUly

SetUly filters by underlying.

type GetOrdersHistoryService

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

GetOrdersHistoryService -- GET /api/v5/trade/orders-history (Read)

Returns the account's completed orders from the last seven days.

func (*GetOrdersHistoryService) Do

func (*GetOrdersHistoryService) SetAfter

SetAfter pages to orders with an ordId earlier than this value.

func (*GetOrdersHistoryService) SetBefore

SetBefore pages to orders with an ordId later than this value.

func (*GetOrdersHistoryService) SetBegin

SetBegin filters to orders created at or after the given time.

func (*GetOrdersHistoryService) SetCategory

func (s *GetOrdersHistoryService) SetCategory(category string) *GetOrdersHistoryService

SetCategory filters by order category (twap/adl/full_liquidation/...).

func (*GetOrdersHistoryService) SetEnd

SetEnd filters to orders created at or before the given time.

func (*GetOrdersHistoryService) SetInstFamily

func (s *GetOrdersHistoryService) SetInstFamily(instFamily string) *GetOrdersHistoryService

SetInstFamily filters by instrument family.

func (*GetOrdersHistoryService) SetInstId

SetInstId filters by instrument id.

func (*GetOrdersHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetOrdersHistoryService) SetOrdType

SetOrdType filters by order type.

func (*GetOrdersHistoryService) SetState

SetState filters by order state (canceled/filled/mmp_canceled).

func (*GetOrdersHistoryService) SetUly

SetUly filters by underlying.

type GetOrdersPendingService

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

GetOrdersPendingService -- GET /api/v5/trade/orders-pending (Read)

Returns the account's currently live (incomplete) orders.

func (*GetOrdersPendingService) Do

func (*GetOrdersPendingService) SetAfter

SetAfter pages to orders with an ordId earlier than this value.

func (*GetOrdersPendingService) SetBefore

SetBefore pages to orders with an ordId later than this value.

func (*GetOrdersPendingService) SetInstFamily

func (s *GetOrdersPendingService) SetInstFamily(instFamily string) *GetOrdersPendingService

SetInstFamily filters by instrument family.

func (*GetOrdersPendingService) SetInstId

SetInstId filters by instrument id.

func (*GetOrdersPendingService) SetInstType

func (s *GetOrdersPendingService) SetInstType(instType InstType) *GetOrdersPendingService

SetInstType filters by product line (SPOT/MARGIN/SWAP/FUTURES/OPTION).

func (*GetOrdersPendingService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetOrdersPendingService) SetOrdType

SetOrdType filters by order type (market/limit/post_only/fok/ioc/...).

func (*GetOrdersPendingService) SetState

SetState filters by order state (live/partially_filled).

func (*GetOrdersPendingService) SetUly

SetUly filters by underlying.

type GetPlatform24VolumeService

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

GetPlatform24VolumeService -- GET /api/v5/market/platform-24-volume (public)

Returns the platform-wide 24h trading volume.

func (*GetPlatform24VolumeService) Do

type GetPositionTiersService

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

GetPositionTiersService -- GET /api/v5/public/position-tiers (public)

Returns the position-tier (leverage / margin requirement) schedule for an instrument family or underlying.

func (*GetPositionTiersService) Do

func (*GetPositionTiersService) SetCcy

SetCcy filters by margin currency (MARGIN cross only).

func (*GetPositionTiersService) SetInstFamily

func (s *GetPositionTiersService) SetInstFamily(instFamily string) *GetPositionTiersService

SetInstFamily filters by instrument family (comma-separated for multiple).

func (*GetPositionTiersService) SetInstId

SetInstId filters by a single instrument id (SPOT/MARGIN).

func (*GetPositionTiersService) SetTier

SetTier filters by a single tier.

func (*GetPositionTiersService) SetUly

SetUly filters by underlying (comma-separated for multiple).

type GetPositionsHistoryService

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

GetPositionsHistoryService -- GET /api/v5/account/positions-history (Read)

Returns the account's closed-position history over the last three months.

func (*GetPositionsHistoryService) Do

func (*GetPositionsHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetPositionsHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetPositionsHistoryService) SetInstId

SetInstId filters by instrument id.

func (*GetPositionsHistoryService) SetInstType

SetInstType filters by product line (MARGIN/SWAP/FUTURES/OPTION).

func (*GetPositionsHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetPositionsHistoryService) SetMgnMode

SetMgnMode filters by margin mode (cross/isolated).

func (*GetPositionsHistoryService) SetPosId

SetPosId filters by position id.

func (*GetPositionsHistoryService) SetType

SetType filters by close type (1 partial close ... 5 partial liquidation, ...).

type GetPositionsService

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

GetPositionsService -- GET /api/v5/account/positions (Read)

Returns the account's currently open positions.

func (*GetPositionsService) Do

func (*GetPositionsService) SetInstId

func (s *GetPositionsService) SetInstId(instId string) *GetPositionsService

SetInstId filters by instrument id (comma-separated for several).

func (*GetPositionsService) SetInstType

func (s *GetPositionsService) SetInstType(instType InstType) *GetPositionsService

SetInstType filters by product line (MARGIN/SWAP/FUTURES/OPTION).

func (*GetPositionsService) SetPosId

func (s *GetPositionsService) SetPosId(posId string) *GetPositionsService

SetPosId filters by position id (comma-separated for several).

type GetPremiumHistoryService

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

GetPremiumHistoryService -- GET /api/v5/public/premium-history (public)

Returns the premium-index history (spot vs perpetual mid) of an instrument.

func (*GetPremiumHistoryService) Do

func (*GetPremiumHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetPremiumHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetPremiumHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetPriceLimitService

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

GetPriceLimitService -- GET /api/v5/public/price-limit (public)

Returns the highest buy and lowest sell limit prices of an instrument.

func (*GetPriceLimitService) Do

type GetRecurringOrderDetailsService

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

GetRecurringOrderDetailsService -- GET /api/v5/tradingBot/recurring/orders-algo-details (Read)

Returns the full detail of a single recurring-buy strategy.

func (*GetRecurringOrderDetailsService) Do

type GetRecurringOrdersHistoryService

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

GetRecurringOrdersHistoryService -- GET /api/v5/tradingBot/recurring/orders-algo-history (Read)

Returns the account's stopped recurring-buy strategies.

func (*GetRecurringOrdersHistoryService) Do

func (*GetRecurringOrdersHistoryService) SetAfter

SetAfter pages backward from the given algoId (records older than it).

func (*GetRecurringOrdersHistoryService) SetAlgoId

SetAlgoId filters to a single strategy id.

func (*GetRecurringOrdersHistoryService) SetBefore

SetBefore pages forward from the given algoId (records newer than it).

func (*GetRecurringOrdersHistoryService) SetLimit

SetLimit caps the number of returned strategies (max 100, default 100).

type GetRecurringOrdersPendingService

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

GetRecurringOrdersPendingService -- GET /api/v5/tradingBot/recurring/orders-algo-pending (Read)

Returns the account's active (not-yet-stopped) recurring-buy strategies.

func (*GetRecurringOrdersPendingService) Do

func (*GetRecurringOrdersPendingService) SetAfter

SetAfter pages backward from the given algoId (records older than it).

func (*GetRecurringOrdersPendingService) SetAlgoId

SetAlgoId filters to a single strategy id.

func (*GetRecurringOrdersPendingService) SetBefore

SetBefore pages forward from the given algoId (records newer than it).

func (*GetRecurringOrdersPendingService) SetLimit

SetLimit caps the number of returned strategies (max 100, default 100).

type GetRecurringSubOrdersService

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

GetRecurringSubOrdersService -- GET /api/v5/tradingBot/recurring/sub-orders (Read)

Returns the individual sub-orders placed by a recurring-buy strategy.

func (*GetRecurringSubOrdersService) Do

func (*GetRecurringSubOrdersService) SetAfter

SetAfter pages backward from the given ordId (records older than it).

func (*GetRecurringSubOrdersService) SetBefore

SetBefore pages forward from the given ordId (records newer than it).

func (*GetRecurringSubOrdersService) SetLimit

SetLimit caps the number of returned sub-orders (max 100, default 100).

func (*GetRecurringSubOrdersService) SetOrdId

SetOrdId filters to a single sub-order id.

type GetRfqBlockTickerService

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

GetRfqBlockTickerService -- GET /api/v5/market/block-ticker (public)

Returns the 24h block-trade volume ticker for a single instrument. NOTE: OKX documents this under /api/v5/rfq/block-ticker but that path returns HTTP 404; the live endpoint is /api/v5/market/block-ticker.

func (*GetRfqBlockTickerService) Do

type GetRfqBlockTickersService

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

GetRfqBlockTickersService -- GET /api/v5/market/block-tickers (public)

Returns the 24h block-trade volume tickers for every instrument of a product line. NOTE: OKX documents this under /api/v5/rfq/block-tickers but that path returns HTTP 404; the live endpoint is /api/v5/market/block-tickers.

func (*GetRfqBlockTickersService) Do

func (*GetRfqBlockTickersService) SetInstFamily

func (s *GetRfqBlockTickersService) SetInstFamily(instFamily string) *GetRfqBlockTickersService

SetInstFamily filters by instrument family (FUTURES/SWAP/OPTION).

func (*GetRfqBlockTickersService) SetUly

SetUly filters by underlying (FUTURES/SWAP/OPTION).

type GetRfqCounterpartiesService

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

GetRfqCounterpartiesService -- GET /api/v5/rfq/counterparties (Read)

Returns the list of counterparties (makers) the account may direct RFQs to.

func (*GetRfqCounterpartiesService) Do

type GetRfqMakerInstrumentSettingsService

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

GetRfqMakerInstrumentSettingsService -- GET /api/v5/rfq/maker-instrument-settings (Read)

Returns the maker's per-instrument-type quoting settings (the instruments a maker is configured to quote and their parameters).

func (*GetRfqMakerInstrumentSettingsService) Do

type GetRfqMmpConfigService

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

GetRfqMmpConfigService -- GET /api/v5/rfq/mmp-config (Read)

Returns the maker's MMP (market-maker protection) configuration.

func (*GetRfqMmpConfigService) Do

type GetRfqPublicTradesService

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

GetRfqPublicTradesService -- GET /api/v5/rfq/public-trades (public)

Returns the most recent public block trades across all counterparties.

func (*GetRfqPublicTradesService) Do

func (*GetRfqPublicTradesService) SetBeginId

SetBeginId pages from a starting block-trade id (records newer than the id).

func (*GetRfqPublicTradesService) SetEndId

SetEndId pages up to an ending block-trade id (records older than the id).

func (*GetRfqPublicTradesService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetRfqQuoteProductsService

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

GetRfqQuoteProductsService -- GET /api/v5/rfq/quote-products (deprecated)

Returns the maker's configured quote products. DEPRECATED: this legacy path now returns HTTP 404; OKX folded quote-product configuration into /api/v5/rfq/maker-instrument-settings. Kept implement-only and NOT exercised by the test suite. Prefer GetRfqMakerInstrumentSettingsService.

func (*GetRfqQuoteProductsService) Do

type GetRfqQuotesService

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

GetRfqQuotesService -- GET /api/v5/rfq/quotes (Read)

Returns the account's quote records (quotes it made, or quotes it received as taker).

func (*GetRfqQuotesService) Do

func (*GetRfqQuotesService) SetBeginId

func (s *GetRfqQuotesService) SetBeginId(beginId string) *GetRfqQuotesService

SetBeginId pages from a starting quote id (records newer than the id).

func (*GetRfqQuotesService) SetClQuoteId

func (s *GetRfqQuotesService) SetClQuoteId(clQuoteId string) *GetRfqQuotesService

SetClQuoteId filters by client-supplied quote id.

func (*GetRfqQuotesService) SetClRfqId

func (s *GetRfqQuotesService) SetClRfqId(clRfqId string) *GetRfqQuotesService

SetClRfqId filters by client-supplied RFQ id.

func (*GetRfqQuotesService) SetEndId

func (s *GetRfqQuotesService) SetEndId(endId string) *GetRfqQuotesService

SetEndId pages up to an ending quote id (records older than the id).

func (*GetRfqQuotesService) SetLimit

func (s *GetRfqQuotesService) SetLimit(limit int) *GetRfqQuotesService

SetLimit caps the number of records returned (max 100).

func (*GetRfqQuotesService) SetQuoteId

func (s *GetRfqQuotesService) SetQuoteId(quoteId string) *GetRfqQuotesService

SetQuoteId filters by quote id.

func (*GetRfqQuotesService) SetRfqId

func (s *GetRfqQuotesService) SetRfqId(rfqId string) *GetRfqQuotesService

SetRfqId filters by RFQ id.

func (*GetRfqQuotesService) SetState

SetState filters by quote state.

type GetRfqTradesService

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

GetRfqTradesService -- GET /api/v5/rfq/trades (Read)

Returns the account's executed block trades (RFQ trades).

func (*GetRfqTradesService) Do

func (*GetRfqTradesService) SetBeginId

func (s *GetRfqTradesService) SetBeginId(beginId string) *GetRfqTradesService

SetBeginId pages from a starting block-trade id (records newer than the id).

func (*GetRfqTradesService) SetBeginTs

SetBeginTs filters to trades at or after the given time (ms).

func (*GetRfqTradesService) SetClQuoteId

func (s *GetRfqTradesService) SetClQuoteId(clQuoteId string) *GetRfqTradesService

SetClQuoteId filters by client-supplied quote id.

func (*GetRfqTradesService) SetClRfqId

func (s *GetRfqTradesService) SetClRfqId(clRfqId string) *GetRfqTradesService

SetClRfqId filters by client-supplied RFQ id.

func (*GetRfqTradesService) SetEndId

func (s *GetRfqTradesService) SetEndId(endId string) *GetRfqTradesService

SetEndId pages up to an ending block-trade id (records older than the id).

func (*GetRfqTradesService) SetEndTs

SetEndTs filters to trades at or before the given time (ms).

func (*GetRfqTradesService) SetLimit

func (s *GetRfqTradesService) SetLimit(limit int) *GetRfqTradesService

SetLimit caps the number of records returned (max 100).

func (*GetRfqTradesService) SetQuoteId

func (s *GetRfqTradesService) SetQuoteId(quoteId string) *GetRfqTradesService

SetQuoteId filters by quote id.

func (*GetRfqTradesService) SetRfqId

func (s *GetRfqTradesService) SetRfqId(rfqId string) *GetRfqTradesService

SetRfqId filters by RFQ id.

func (*GetRfqTradesService) SetState

func (s *GetRfqTradesService) SetState(state string) *GetRfqTradesService

SetState filters by trade state.

type GetRfqsService

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

GetRfqsService -- GET /api/v5/rfq/rfqs (Read)

Returns the account's RFQ records, both created (taker) and received (maker).

func (*GetRfqsService) Do

func (s *GetRfqsService) Do(ctx context.Context) ([]Rfq, error)

func (*GetRfqsService) SetBeginId

func (s *GetRfqsService) SetBeginId(beginId string) *GetRfqsService

SetBeginId pages from a starting RFQ id (records newer than the id).

func (*GetRfqsService) SetClRfqId

func (s *GetRfqsService) SetClRfqId(clRfqId string) *GetRfqsService

SetClRfqId filters by client-supplied RFQ id.

func (*GetRfqsService) SetEndId

func (s *GetRfqsService) SetEndId(endId string) *GetRfqsService

SetEndId pages up to an ending RFQ id (records older than the id).

func (*GetRfqsService) SetLimit

func (s *GetRfqsService) SetLimit(limit int) *GetRfqsService

SetLimit caps the number of records returned (max 100).

func (*GetRfqsService) SetRfqId

func (s *GetRfqsService) SetRfqId(rfqId string) *GetRfqsService

SetRfqId filters by RFQ id.

func (*GetRfqsService) SetState

func (s *GetRfqsService) SetState(state RfqState) *GetRfqsService

SetState filters by RFQ state.

type GetRiskStateService

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

GetRiskStateService -- GET /api/v5/account/risk-state (Read)

Returns the portfolio-margin account's auto-borrow/auto-repay risk state. Only available when the account is in portfolio-margin mode.

func (*GetRiskStateService) Do

type GetSavingsBalanceService

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

GetSavingsBalanceService -- GET /api/v5/finance/savings/balance (Read)

Returns the Simple Earn Flexible (savings) balance of each currency the account is subscribed to.

func (*GetSavingsBalanceService) Do

func (*GetSavingsBalanceService) SetCcy

SetCcy filters by currency.

type GetSavingsLendingHistoryService

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

GetSavingsLendingHistoryService -- GET /api/v5/finance/savings/lending-history (Read)

Returns the account's savings lending history.

func (*GetSavingsLendingHistoryService) Do

func (*GetSavingsLendingHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetSavingsLendingHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetSavingsLendingHistoryService) SetCcy

SetCcy filters by currency.

func (*GetSavingsLendingHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetSavingsLendingRateHistoryService

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

GetSavingsLendingRateHistoryService -- GET /api/v5/finance/savings/lending-rate-history (Read)

Returns the historical public lending rates per savings currency.

func (*GetSavingsLendingRateHistoryService) Do

func (*GetSavingsLendingRateHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetSavingsLendingRateHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetSavingsLendingRateHistoryService) SetCcy

SetCcy filters by currency.

func (*GetSavingsLendingRateHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetSavingsLendingRateSummaryService

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

GetSavingsLendingRateSummaryService -- GET /api/v5/finance/savings/lending-rate-summary (Read)

Returns the current public lending-rate summary (estimated/previous/average rates) per savings currency.

func (*GetSavingsLendingRateSummaryService) Do

func (*GetSavingsLendingRateSummaryService) SetCcy

SetCcy filters by currency.

type GetSettlementHistoryService

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

GetSettlementHistoryService -- GET /api/v5/public/settlement-history (public)

Returns the futures settlement history of an instrument family.

func (*GetSettlementHistoryService) Do

func (*GetSettlementHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetSettlementHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetSettlementHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetSolStakingApyHistoryService

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

GetSolStakingApyHistoryService -- GET /api/v5/finance/staking-defi/sol/apy-history (Read)

Returns the SOL staking APY history for the trailing number of days.

func (*GetSolStakingApyHistoryService) Do

type GetSolStakingBalanceService

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

GetSolStakingBalanceService -- GET /api/v5/finance/staking-defi/sol/balance (Read)

Returns the account's OKSOL balance and accrued staking interest.

func (*GetSolStakingBalanceService) Do

type GetSolStakingHistoryService

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

GetSolStakingHistoryService -- GET /api/v5/finance/staking-defi/sol/purchase-redeem-history (Read)

Returns the account's SOL staking purchase and redemption history.

func (*GetSolStakingHistoryService) Do

func (*GetSolStakingHistoryService) SetAfter

SetAfter paginates to records earlier than the given request time (older).

func (*GetSolStakingHistoryService) SetBefore

SetBefore paginates to records later than the given request time (newer).

func (*GetSolStakingHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSolStakingHistoryService) SetStatus

SetStatus filters by record status (pending/success/failed).

func (*GetSolStakingHistoryService) SetType

SetType filters by record type (purchase/redeem).

type GetSolStakingProductInfoService

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

GetSolStakingProductInfoService -- GET /api/v5/finance/staking-defi/sol/product-info (Read)

Returns the SOL staking product parameters. Unlike the ETH variant, OKX returns this endpoint's "data" as a single JSON object, so it decodes via DoObject.

func (*GetSolStakingProductInfoService) Do

type GetSpotBorrowRepayHistoryService

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

GetSpotBorrowRepayHistoryService -- GET /api/v5/account/spot-borrow-repay-history (Read)

Returns the history of spot (auto / manual) borrows and repayments.

func (*GetSpotBorrowRepayHistoryService) Do

func (*GetSpotBorrowRepayHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetSpotBorrowRepayHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetSpotBorrowRepayHistoryService) SetCcy

SetCcy filters by currency.

func (*GetSpotBorrowRepayHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSpotBorrowRepayHistoryService) SetType

SetType filters by event type (auto_borrow / auto_repay / manual_borrow / manual_repay).

type GetSprdBooksService

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

GetSprdBooksService -- GET /api/v5/sprd/books (public)

Returns the order book of a spread.

func (*GetSprdBooksService) Do

func (*GetSprdBooksService) SetSz

SetSz sets the order book depth (number of price levels, max 400).

type GetSprdCandlesService

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

GetSprdCandlesService -- GET /api/v5/market/sprd-candles (public)

Returns recent candlestick data for a spread. Note the path lives under /market/, not /sprd/.

func (*GetSprdCandlesService) Do

func (*GetSprdCandlesService) SetAfter

SetAfter requests candles before the given timestamp (paging backward).

func (*GetSprdCandlesService) SetBar

SetBar sets the candle time granularity (default 1m).

func (*GetSprdCandlesService) SetBefore

func (s *GetSprdCandlesService) SetBefore(before time.Time) *GetSprdCandlesService

SetBefore requests candles after the given timestamp (paging forward).

func (*GetSprdCandlesService) SetLimit

func (s *GetSprdCandlesService) SetLimit(limit int) *GetSprdCandlesService

SetLimit caps the number of returned candles (max 100, default 100).

type GetSprdHistoryCandlesService

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

GetSprdHistoryCandlesService -- GET /api/v5/market/sprd-history-candles (public)

Returns historical candlestick data for a spread. Note the path lives under /market/, not /sprd/.

func (*GetSprdHistoryCandlesService) Do

func (*GetSprdHistoryCandlesService) SetAfter

SetAfter requests candles before the given timestamp (paging backward).

func (*GetSprdHistoryCandlesService) SetBar

SetBar sets the candle time granularity (default 1m).

func (*GetSprdHistoryCandlesService) SetBefore

SetBefore requests candles after the given timestamp (paging forward).

func (*GetSprdHistoryCandlesService) SetLimit

SetLimit caps the number of returned candles (max 100, default 100).

type GetSprdOrderAlgoService

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

GetSprdOrderAlgoService -- GET /api/v5/sprd/order-algo (Read)

Returns the details of a single spread algo order. Either algoId or algoClOrdId must be supplied.

NOTE: live verification (2026-06) returns HTTP 404 for this path on www.okx.com; the spread algo-order endpoints are not currently deployed. The service is modeled from the OKX docs so it works if/when OKX enables it.

func (*GetSprdOrderAlgoService) Do

func (*GetSprdOrderAlgoService) SetAlgoClOrdId

func (s *GetSprdOrderAlgoService) SetAlgoClOrdId(algoClOrdId string) *GetSprdOrderAlgoService

SetAlgoClOrdId looks the algo order up by its client-supplied id.

func (*GetSprdOrderAlgoService) SetAlgoId

SetAlgoId looks the algo order up by its OKX algo id.

type GetSprdOrderService

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

GetSprdOrderService -- GET /api/v5/sprd/order (Read)

Returns the details of a single spread order. Either ordId or clOrdId must be supplied.

func (*GetSprdOrderService) Do

func (*GetSprdOrderService) SetClOrdId

func (s *GetSprdOrderService) SetClOrdId(clOrdId string) *GetSprdOrderService

SetClOrdId looks the order up by its client-supplied order id.

func (*GetSprdOrderService) SetOrdId

func (s *GetSprdOrderService) SetOrdId(ordId string) *GetSprdOrderService

SetOrdId looks the order up by its OKX order id.

type GetSprdOrdersAlgoHistoryService

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

GetSprdOrdersAlgoHistoryService -- GET /api/v5/sprd/orders-algo-history (Read)

Returns the account's completed spread algo orders.

NOTE: live verification (2026-06) returns HTTP 404 for this path on www.okx.com; the spread algo-order endpoints are not currently deployed.

func (*GetSprdOrdersAlgoHistoryService) Do

func (*GetSprdOrdersAlgoHistoryService) SetAlgoId

SetAlgoId filters by a single algo id.

func (*GetSprdOrdersAlgoHistoryService) SetBegin

SetBegin filters to algo orders created at or after the given time.

func (*GetSprdOrdersAlgoHistoryService) SetEnd

SetEnd filters to algo orders created at or before the given time.

func (*GetSprdOrdersAlgoHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSprdOrdersAlgoHistoryService) SetOrdType

SetOrdType filters by algo order type.

func (*GetSprdOrdersAlgoHistoryService) SetSprdId

SetSprdId filters by spread id.

func (*GetSprdOrdersAlgoHistoryService) SetState

SetState filters by algo order state.

type GetSprdOrdersAlgoPendingService

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

GetSprdOrdersAlgoPendingService -- GET /api/v5/sprd/orders-algo-pending (Read)

Returns the account's currently open spread algo orders.

NOTE: live verification (2026-06) returns HTTP 404 for this path on www.okx.com; the spread algo-order endpoints are not currently deployed.

func (*GetSprdOrdersAlgoPendingService) Do

func (*GetSprdOrdersAlgoPendingService) SetAlgoId

SetAlgoId filters by a single algo id.

func (*GetSprdOrdersAlgoPendingService) SetOrdType

SetOrdType filters by algo order type.

func (*GetSprdOrdersAlgoPendingService) SetSprdId

SetSprdId filters by spread id.

func (*GetSprdOrdersAlgoPendingService) SetState

SetState filters by algo order state.

type GetSprdOrdersHistoryArchiveService

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

GetSprdOrdersHistoryArchiveService -- GET /api/v5/sprd/orders-history-archive (Read)

Returns the account's archived (older than 21 days) completed spread orders.

func (*GetSprdOrdersHistoryArchiveService) Do

func (*GetSprdOrdersHistoryArchiveService) SetBegin

SetBegin filters to orders created at or after the given time.

func (*GetSprdOrdersHistoryArchiveService) SetBeginId

SetBeginId pages from orders with an id newer than beginId.

func (*GetSprdOrdersHistoryArchiveService) SetEnd

SetEnd filters to orders created at or before the given time.

func (*GetSprdOrdersHistoryArchiveService) SetEndId

SetEndId pages to orders with an id older than endId.

func (*GetSprdOrdersHistoryArchiveService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSprdOrdersHistoryArchiveService) SetOrdType

SetOrdType filters by order type.

func (*GetSprdOrdersHistoryArchiveService) SetSprdId

SetSprdId filters by spread id.

func (*GetSprdOrdersHistoryArchiveService) SetState

SetState filters by order state (canceled / filled).

type GetSprdOrdersHistoryService

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

GetSprdOrdersHistoryService -- GET /api/v5/sprd/orders-history (Read)

Returns the account's completed spread orders from the last 21 days.

func (*GetSprdOrdersHistoryService) Do

func (*GetSprdOrdersHistoryService) SetBegin

SetBegin filters to orders created at or after the given time.

func (*GetSprdOrdersHistoryService) SetBeginId

SetBeginId pages from orders with an id newer than beginId.

func (*GetSprdOrdersHistoryService) SetEnd

SetEnd filters to orders created at or before the given time.

func (*GetSprdOrdersHistoryService) SetEndId

SetEndId pages to orders with an id older than endId.

func (*GetSprdOrdersHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSprdOrdersHistoryService) SetOrdType

SetOrdType filters by order type.

func (*GetSprdOrdersHistoryService) SetSprdId

SetSprdId filters by spread id.

func (*GetSprdOrdersHistoryService) SetState

SetState filters by order state (canceled / filled).

type GetSprdOrdersPendingService

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

GetSprdOrdersPendingService -- GET /api/v5/sprd/orders-pending (Read)

Returns the account's currently open (incomplete) spread orders.

func (*GetSprdOrdersPendingService) Do

func (*GetSprdOrdersPendingService) SetBeginId

SetBeginId pages from orders with an id newer than beginId.

func (*GetSprdOrdersPendingService) SetEndId

SetEndId pages to orders with an id older than endId.

func (*GetSprdOrdersPendingService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSprdOrdersPendingService) SetOrdType

SetOrdType filters by order type.

func (*GetSprdOrdersPendingService) SetSprdId

SetSprdId filters by spread id.

func (*GetSprdOrdersPendingService) SetState

SetState filters by order state (live / partially_filled).

type GetSprdPublicTradesService

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

GetSprdPublicTradesService -- GET /api/v5/sprd/public-trades (public)

Returns the most recent public trades for spreads.

func (*GetSprdPublicTradesService) Do

func (*GetSprdPublicTradesService) SetSprdId

SetSprdId filters trades to a single spread.

type GetSprdSpreadsService

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

GetSprdSpreadsService -- GET /api/v5/sprd/spreads (public)

Returns the tradable spreads, their legs and lot/tick sizes.

func (*GetSprdSpreadsService) Do

func (*GetSprdSpreadsService) SetBaseCcy

func (s *GetSprdSpreadsService) SetBaseCcy(baseCcy string) *GetSprdSpreadsService

SetBaseCcy filters by base currency.

func (*GetSprdSpreadsService) SetInstId

func (s *GetSprdSpreadsService) SetInstId(instId string) *GetSprdSpreadsService

SetInstId filters to spreads that include the given instrument as a leg.

func (*GetSprdSpreadsService) SetSprdId

func (s *GetSprdSpreadsService) SetSprdId(sprdId string) *GetSprdSpreadsService

SetSprdId filters by a single spread id.

func (*GetSprdSpreadsService) SetState

SetState filters by spread state.

type GetSprdTickerService

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

GetSprdTickerService -- GET /api/v5/sprd/ticker (public)

Returns the latest ticker for a spread.

func (*GetSprdTickerService) Do

type GetSprdTradesService

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

GetSprdTradesService -- GET /api/v5/sprd/trades (Read)

Returns the account's spread fills from the last 21 days.

func (*GetSprdTradesService) Do

func (*GetSprdTradesService) SetBegin

SetBegin filters to fills at or after the given time.

func (*GetSprdTradesService) SetBeginId

func (s *GetSprdTradesService) SetBeginId(beginId string) *GetSprdTradesService

SetBeginId pages from fills with an id newer than beginId.

func (*GetSprdTradesService) SetEnd

SetEnd filters to fills at or before the given time.

func (*GetSprdTradesService) SetEndId

func (s *GetSprdTradesService) SetEndId(endId string) *GetSprdTradesService

SetEndId pages to fills with an id older than endId.

func (*GetSprdTradesService) SetLimit

func (s *GetSprdTradesService) SetLimit(limit int) *GetSprdTradesService

SetLimit caps the number of records returned (max 100).

func (*GetSprdTradesService) SetOrdId

func (s *GetSprdTradesService) SetOrdId(ordId string) *GetSprdTradesService

SetOrdId filters fills by their parent order id.

func (*GetSprdTradesService) SetSprdId

func (s *GetSprdTradesService) SetSprdId(sprdId string) *GetSprdTradesService

SetSprdId filters by spread id.

func (*GetSprdTradesService) SetTradeId

func (s *GetSprdTradesService) SetTradeId(tradeId string) *GetSprdTradesService

SetTradeId filters by a single trade id.

type GetStakingActiveOrdersService

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

GetStakingActiveOrdersService -- GET /api/v5/finance/staking-defi/orders-active (Read)

Returns the account's active (not yet fully redeemed) on-chain earn orders.

func (*GetStakingActiveOrdersService) Do

func (*GetStakingActiveOrdersService) SetCcy

SetCcy filters by investment currency.

func (*GetStakingActiveOrdersService) SetProductId

SetProductId filters by product id.

func (*GetStakingActiveOrdersService) SetProtocolType

SetProtocolType filters by protocol category (defi/staking).

func (*GetStakingActiveOrdersService) SetState

SetState filters by order state.

type GetStakingOffersService

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

GetStakingOffersService -- GET /api/v5/finance/staking-defi/offers (Read)

Returns the available on-chain earn (staking/defi) offers, including the per-currency invest constraints and the assets earned.

func (*GetStakingOffersService) Do

func (*GetStakingOffersService) SetCcy

SetCcy filters by investment currency.

func (*GetStakingOffersService) SetProductId

func (s *GetStakingOffersService) SetProductId(productId string) *GetStakingOffersService

SetProductId filters by a single product id.

func (*GetStakingOffersService) SetProtocolType

func (s *GetStakingOffersService) SetProtocolType(protocolType StakingProtocolType) *GetStakingOffersService

SetProtocolType filters by protocol category (defi/staking).

type GetStakingOrdersHistoryService

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

GetStakingOrdersHistoryService -- GET /api/v5/finance/staking-defi/orders-history (Read)

Returns the account's completed/redeemed on-chain earn orders.

func (*GetStakingOrdersHistoryService) Do

func (*GetStakingOrdersHistoryService) SetAfter

SetAfter paginates to records earlier than the given order-creation time (older).

func (*GetStakingOrdersHistoryService) SetBefore

SetBefore paginates to records later than the given order-creation time (newer).

func (*GetStakingOrdersHistoryService) SetCcy

SetCcy filters by investment currency.

func (*GetStakingOrdersHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetStakingOrdersHistoryService) SetProductId

SetProductId filters by product id.

func (*GetStakingOrdersHistoryService) SetProtocolType

SetProtocolType filters by protocol category (defi/staking).

type GetSubAccountApiKeyService

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

GetSubAccountApiKeyService -- GET /api/v5/users/subaccount/apikey (Read)

Returns the API keys (excluding the secret) of a sub-account.

func (*GetSubAccountApiKeyService) Do

func (*GetSubAccountApiKeyService) SetApiKey

SetApiKey filters by a single API key.

type GetSubAccountBillsService

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

GetSubAccountBillsService -- GET /api/v5/asset/subaccount/bills (Read)

Returns the master-account funding transfer records to/from sub-accounts over the last three months.

func (*GetSubAccountBillsService) Do

func (*GetSubAccountBillsService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetSubAccountBillsService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetSubAccountBillsService) SetCcy

SetCcy filters by currency.

func (*GetSubAccountBillsService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSubAccountBillsService) SetSubAcct

SetSubAcct filters by sub-account name.

func (*GetSubAccountBillsService) SetType

SetType filters by transfer type ("0" master->sub, "1" sub->master).

type GetSubAccountFundingBalancesService

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

GetSubAccountFundingBalancesService -- GET /api/v5/asset/subaccount/balances (Read)

Returns a sub-account's funding-account balances (master account).

func (*GetSubAccountFundingBalancesService) Do

func (*GetSubAccountFundingBalancesService) SetCcy

SetCcy filters by a single currency.

type GetSubAccountListService

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

GetSubAccountListService -- GET /api/v5/users/subaccount/list (Read)

Returns the list of sub-accounts under the (master) account, with their enable/trade-out flags and creation time.

func (*GetSubAccountListService) Do

func (*GetSubAccountListService) SetAfter

SetAfter paginates to sub-accounts created earlier than the given time (older).

func (*GetSubAccountListService) SetBefore

SetBefore paginates to sub-accounts created later than the given time (newer).

func (*GetSubAccountListService) SetEnable

SetEnable filters by sub-account enabled state.

func (*GetSubAccountListService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetSubAccountListService) SetSubAcct

SetSubAcct filters by a single sub-account name.

type GetSubAccountMaxWithdrawalService

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

GetSubAccountMaxWithdrawalService -- GET /api/v5/account/subaccount/max-withdrawal (Read)

Returns a sub-account's maximum withdrawal amount per currency (master account).

func (*GetSubAccountMaxWithdrawalService) Do

func (*GetSubAccountMaxWithdrawalService) SetCcy

SetCcy filters by a single currency.

type GetSubAccountTradingBalancesService

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

GetSubAccountTradingBalancesService -- GET /api/v5/account/subaccount/balances (Read)

Returns a sub-account's trading-account balance details (master account).

func (*GetSubAccountTradingBalancesService) Do

type GetSupportCoinService

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

GetSupportCoinService -- GET /api/v5/rubik/stat/trading-data/support-coin (public)

Returns the currencies supported by the trading-statistics endpoints, grouped by product line.

func (*GetSupportCoinService) Do

type GetSystemStatusService

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

GetSystemStatusService -- GET /api/v5/system/status (public)

Returns scheduled and ongoing system maintenance windows. The data array is empty when no maintenance is planned or in progress.

func (*GetSystemStatusService) Do

func (*GetSystemStatusService) SetState

SetState filters by maintenance state (scheduled / ongoing / pre_open / completed / canceled).

type GetSystemTimeService

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

GetSystemTimeService -- GET /api/v5/public/time

Returns the current OKX server time. Used by Client.SyncServerTime to align the request-signing clock.

func (*GetSystemTimeService) Do

type GetTakerVolumeService

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

GetTakerVolumeService -- GET /api/v5/rubik/stat/taker-volume (public)

Returns the taker buy/sell trading volume per time bar for a currency and product line.

func (*GetTakerVolumeService) Do

func (*GetTakerVolumeService) SetBegin

func (*GetTakerVolumeService) SetEnd

func (*GetTakerVolumeService) SetPeriod

type GetTickerService

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

GetTickerService -- GET /api/v5/market/ticker (public)

Returns the latest ticker for a single instrument.

func (*GetTickerService) Do

func (s *GetTickerService) Do(ctx context.Context) (*Ticker, error)

type GetTickersService

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

GetTickersService -- GET /api/v5/market/tickers (public)

Returns the latest tickers for every instrument of a product line.

func (*GetTickersService) Do

func (s *GetTickersService) Do(ctx context.Context) ([]Ticker, error)

func (*GetTickersService) SetInstFamily

func (s *GetTickersService) SetInstFamily(instFamily string) *GetTickersService

SetInstFamily filters tickers by instrument family (FUTURES/SWAP/OPTION).

func (*GetTickersService) SetUly

func (s *GetTickersService) SetUly(uly string) *GetTickersService

SetUly filters tickers by underlying (FUTURES/SWAP/OPTION).

type GetTradeFeeService

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

GetTradeFeeService -- GET /api/v5/account/trade-fee (Read)

Returns the account's maker/taker trading fee rates for a product line.

func (*GetTradeFeeService) Do

func (*GetTradeFeeService) SetInstFamily

func (s *GetTradeFeeService) SetInstFamily(instFamily string) *GetTradeFeeService

SetInstFamily filters by instrument family (FUTURES/SWAP/OPTION).

func (*GetTradeFeeService) SetInstId

func (s *GetTradeFeeService) SetInstId(instId string) *GetTradeFeeService

SetInstId filters by a single instrument id (SPOT/MARGIN).

func (*GetTradeFeeService) SetRuleType

func (s *GetTradeFeeService) SetRuleType(ruleType string) *GetTradeFeeService

SetRuleType filters by rule type (normal/pre_market).

func (*GetTradeFeeService) SetUly

SetUly filters by underlying (FUTURES/SWAP/OPTION).

type GetTradesService

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

GetTradesService -- GET /api/v5/market/trades (public)

Returns the most recent public trades for an instrument.

func (*GetTradesService) Do

func (s *GetTradesService) Do(ctx context.Context) ([]Trade, error)

func (*GetTradesService) SetLimit

func (s *GetTradesService) SetLimit(limit int) *GetTradesService

SetLimit caps the number of returned trades (max 500, default 100).

type GetTransferStateService

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

GetTransferStateService -- GET /api/v5/asset/transfer-state (private)

Returns the status of a funds transfer by transfer id or client id.

func (*GetTransferStateService) Do

func (*GetTransferStateService) SetClientId

func (s *GetTransferStateService) SetClientId(clientId string) *GetTransferStateService

SetClientId filters by client-supplied transfer id.

func (*GetTransferStateService) SetTransId

func (s *GetTransferStateService) SetTransId(transId string) *GetTransferStateService

SetTransId filters by transfer id (mutually exclusive with clientId).

func (*GetTransferStateService) SetType

SetType sets the transfer type (default "0").

type GetUnderlyingService

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

GetUnderlyingService -- GET /api/v5/public/underlying (public)

Returns the underlyings available for a derivatives product line. The data is an array containing a single array of underlying strings.

func (*GetUnderlyingService) Do

func (s *GetUnderlyingService) Do(ctx context.Context) ([][]string, error)

type GetVipInterestAccruedService

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

GetVipInterestAccruedService -- GET /api/v5/account/vip-interest-accrued (Read)

Returns the interest accrued on the account's VIP loans.

func (*GetVipInterestAccruedService) Do

func (*GetVipInterestAccruedService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetVipInterestAccruedService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetVipInterestAccruedService) SetCcy

SetCcy filters by currency.

func (*GetVipInterestAccruedService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetVipInterestAccruedService) SetOrdId

SetOrdId filters by VIP loan order id.

type GetVipInterestDeductedService

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

GetVipInterestDeductedService -- GET /api/v5/account/vip-interest-deducted (Read)

Returns the interest deducted from the account's VIP loans.

func (*GetVipInterestDeductedService) Do

func (*GetVipInterestDeductedService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetVipInterestDeductedService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetVipInterestDeductedService) SetCcy

SetCcy filters by currency.

func (*GetVipInterestDeductedService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetVipInterestDeductedService) SetOrdId

SetOrdId filters by VIP loan order id.

type GetVipLoanOrderDetailService

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

GetVipLoanOrderDetailService -- GET /api/v5/account/vip-loan-order-detail (Read)

Returns the detail (per-event borrow/repay records) of a single VIP loan order.

func (*GetVipLoanOrderDetailService) Do

func (*GetVipLoanOrderDetailService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetVipLoanOrderDetailService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetVipLoanOrderDetailService) SetCcy

SetCcy filters by currency.

func (*GetVipLoanOrderDetailService) SetLimit

SetLimit caps the number of records returned (max 100).

type GetVipLoanOrderListService

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

GetVipLoanOrderListService -- GET /api/v5/account/vip-loan-order-list (Read)

Returns the account's VIP loan orders.

func (*GetVipLoanOrderListService) Do

func (*GetVipLoanOrderListService) SetAfter

SetAfter paginates to orders earlier than the given time (older).

func (*GetVipLoanOrderListService) SetBefore

SetBefore paginates to orders later than the given time (newer).

func (*GetVipLoanOrderListService) SetCcy

SetCcy filters by currency.

func (*GetVipLoanOrderListService) SetLimit

SetLimit caps the number of orders returned (max 100).

func (*GetVipLoanOrderListService) SetOrdId

SetOrdId filters by VIP loan order id.

func (*GetVipLoanOrderListService) SetState

SetState filters by loan order state (1 borrowing / 2 borrowed / 3 partially repaid / 4 repaid / 5 repaying).

type GetWithdrawalHistoryService

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

GetWithdrawalHistoryService -- GET /api/v5/asset/withdrawal-history (private)

Returns the withdrawal records of the account.

func (*GetWithdrawalHistoryService) Do

func (*GetWithdrawalHistoryService) SetAfter

SetAfter paginates to records earlier than the given time (older).

func (*GetWithdrawalHistoryService) SetBefore

SetBefore paginates to records later than the given time (newer).

func (*GetWithdrawalHistoryService) SetCcy

SetCcy filters by currency.

func (*GetWithdrawalHistoryService) SetClientId

SetClientId filters by client-supplied id.

func (*GetWithdrawalHistoryService) SetLimit

SetLimit caps the number of records returned (max 100).

func (*GetWithdrawalHistoryService) SetState

SetState filters by withdrawal state code.

func (*GetWithdrawalHistoryService) SetTxId

SetTxId filters by the on-chain transaction hash.

func (*GetWithdrawalHistoryService) SetType

SetType filters by withdrawal type code.

func (*GetWithdrawalHistoryService) SetWdId

SetWdId filters by withdrawal id.

type Greeks

type Greeks struct {
	Currency  string          `json:"ccy"`
	DeltaBS   decimal.Decimal `json:"deltaBS"`
	DeltaPA   decimal.Decimal `json:"deltaPA"`
	GammaBS   decimal.Decimal `json:"gammaBS"`
	GammaPA   decimal.Decimal `json:"gammaPA"`
	ThetaBS   decimal.Decimal `json:"thetaBS"`
	ThetaPA   decimal.Decimal `json:"thetaPA"`
	VegaBS    decimal.Decimal `json:"vegaBS"`
	VegaPA    decimal.Decimal `json:"vegaPA"`
	Timestamp time.Time       `json:"ts"`
}

Greeks is a currency's aggregated option greeks. The account used to validate this SDK had no option positions, so the field set is modeled from the OKX doc field table.

type GreeksSetting

type GreeksSetting struct {
	GreeksType GreeksType `json:"greeksType"`
}

GreeksSetting is the set-greeks acknowledgement.

type GreeksType

type GreeksType string

GreeksType is the display type of option greeks: "PA" (in coins) or "BS" (Black-Scholes, in dollars).

const (
	GreeksTypePA GreeksType = "PA"
	GreeksTypeBS GreeksType = "BS"
)

type GridAIParam

type GridAIParam struct {
	AlgoOrderType      GridAlgoOrdType `json:"algoOrdType"`
	AnnualizedRate     decimal.Decimal `json:"annualizedRate"`
	Currency           string          `json:"ccy"`
	Direction          GridDirection   `json:"direction"`
	Duration           string          `json:"duration"`
	GridNumber         decimal.Decimal `json:"gridNum"`
	InstrumentID       string          `json:"instId"`
	Leverage           decimal.Decimal `json:"lever"`
	MaxPrice           decimal.Decimal `json:"maxPx"`
	MinPrice           decimal.Decimal `json:"minPx"`
	MinInvestment      decimal.Decimal `json:"minInvestment"`
	PerMaxProfitRate   decimal.Decimal `json:"perMaxProfitRate"`
	PerMinProfitRate   decimal.Decimal `json:"perMinProfitRate"`
	PerGridProfitRatio decimal.Decimal `json:"perGridProfitRatio"`
	RunType            GridRunType     `json:"runType"`
	SourceCurrency     string          `json:"sourceCcy"`
}

GridAIParam is OKX's AI-recommended grid parameters for an instrument.

type GridAdjustInvestmentResult

type GridAdjustInvestmentResult struct {
	AlgoID     string          `json:"algoId"`
	Investment decimal.Decimal `json:"investment"`
}

GridAdjustInvestmentResult is the ack of a grid investment top-up.

type GridAlgoOrdType

type GridAlgoOrdType string

GridAlgoOrdType is the kind of grid bot: spot/margin grid ("grid") or contract (perpetual/futures) grid ("contract_grid").

const (
	GridAlgoOrdTypeGrid         GridAlgoOrdType = "grid"
	GridAlgoOrdTypeContractGrid GridAlgoOrdType = "contract_grid"
)

type GridAlgoOrder

type GridAlgoOrder struct {
	AlgoID                 string             `json:"algoId"`
	AlgoClientOrderID      string             `json:"algoClOrdId"`
	AlgoOrderType          GridAlgoOrdType    `json:"algoOrdType"`
	InstrumentType         InstType           `json:"instType"`
	InstrumentID           string             `json:"instId"`
	State                  string             `json:"state"`
	RunType                GridRunType        `json:"runType"`
	GridNumber             decimal.Decimal    `json:"gridNum"`
	MaxPrice               decimal.Decimal    `json:"maxPx"`
	MinPrice               decimal.Decimal    `json:"minPx"`
	GridProfit             decimal.Decimal    `json:"gridProfit"`
	TotalPnl               decimal.Decimal    `json:"totalPnl"`
	PnlRatio               decimal.Decimal    `json:"pnlRatio"`
	FloatProfit            decimal.Decimal    `json:"floatProfit"`
	TotalAnnualizedRate    decimal.Decimal    `json:"totalAnnualizedRate"`
	AnnualizedRate         decimal.Decimal    `json:"annualizedRate"`
	Investment             decimal.Decimal    `json:"investment"`
	TakeProfitTriggerPrice decimal.Decimal    `json:"tpTriggerPx"`
	StopLossTriggerPrice   decimal.Decimal    `json:"slTriggerPx"`
	TriggerPrice           decimal.Decimal    `json:"triggerPx"`
	CancelType             string             `json:"cancelType"`
	StopType               string             `json:"stopType"`
	StopResult             string             `json:"stopResult"`
	ActiveOrderNumber      decimal.Decimal    `json:"activeOrdNum"`
	Tag                    string             `json:"tag"`
	ProfitSharingRatio     decimal.Decimal    `json:"profitSharingRatio"`
	CopyType               string             `json:"copyType"`
	Fee                    decimal.Decimal    `json:"fee"`
	FundingFee             decimal.Decimal    `json:"fundingFee"`
	RebateTransfer         []GridRebateTrans  `json:"rebateTrans"`
	TriggerParams          []GridTriggerParam `json:"triggerParams"`
	TriggerTime            time.Time          `json:"triggerTime"`
	CreationTime           time.Time          `json:"cTime"`
	UpdateTime             time.Time          `json:"uTime"`

	// --- spot/margin grid ("grid") ---
	BaseSize                decimal.Decimal `json:"baseSz"`
	QuoteSize               decimal.Decimal `json:"quoteSz"`
	BaseCurrency            string          `json:"baseCcy"`
	QuoteCurrency           string          `json:"quoteCcy"`
	TradeMode               TdMode          `json:"tdMode"`
	Leverage                decimal.Decimal `json:"lever"`
	ProfitAndLoss           decimal.Decimal `json:"profitAndLoss"`
	GridArithmeticGeometric string          `json:"gridArithGeo"`
	MinTradeFeeRate         decimal.Decimal `json:"minTradeFeeRate"`

	// --- contract grid ("contract_grid") ---
	Direction          GridDirection   `json:"direction"`
	BasePosition       bool            `json:"basePos"`
	Size               decimal.Decimal `json:"sz"`
	Currency           string          `json:"ccy"`
	Equity             decimal.Decimal `json:"eq"`
	Underlying         string          `json:"uly"`
	InstrumentFamily   string          `json:"instFamily"`
	TakeProfitRatio    decimal.Decimal `json:"tpRatio"`
	StopLossRatio      decimal.Decimal `json:"slRatio"`
	AvailableEquity    decimal.Decimal `json:"availEq"`
	LiquidationPrice   decimal.Decimal `json:"liqPx"`
	UPLRatio           decimal.Decimal `json:"uplRatio"`
	UPL                decimal.Decimal `json:"upl"`
	TotalInvestment    decimal.Decimal `json:"totalInvestment"`
	GridInvestment     decimal.Decimal `json:"gridInvestment"`
	MarginRatio        decimal.Decimal `json:"marginRatio"`
	Arbitrage          decimal.Decimal `json:"arbitrage"`
	SingleAmount       decimal.Decimal `json:"singleAmt"`
	PerMaxProfitRate   decimal.Decimal `json:"perMaxProfitRate"`
	PerMinProfitRate   decimal.Decimal `json:"perMinProfitRate"`
	OrderFrozen        decimal.Decimal `json:"ordFrozen"`
	ActualLeverage     decimal.Decimal `json:"actualLever"`
	InvestmentCurrency string          `json:"investmentCcy"`
}

GridAlgoOrder is a single grid algo order (spot/margin or contract grid). The validating account had no grid orders, so the field set is modeled from the OKX doc field table (union of spot-grid and contract-grid fields). Fields that apply to only one grid kind are simply empty for the other.

type GridCancelCloseOrderResult

type GridCancelCloseOrderResult struct {
	AlgoID  string `json:"algoId"`
	OrderID string `json:"ordId"`
}

GridCancelCloseOrderResult is the ack of a cancel-close-order request.

type GridClosePositionResult

type GridClosePositionResult struct {
	AlgoID            string `json:"algoId"`
	OrderID           string `json:"ordId"`
	AlgoClientOrderID string `json:"algoClOrdId"`
	Tag               string `json:"tag"`
}

GridClosePositionResult is the ack of a contract-grid close-position request.

type GridComputeMarginBalance

type GridComputeMarginBalance struct {
	Leverage  decimal.Decimal `json:"lever"`
	MaxAmount decimal.Decimal `json:"maxAmt"`
}

GridComputeMarginBalance is the estimated result of a margin-balance change.

type GridDirection

type GridDirection string

GridDirection is the direction of a contract grid (long/short/neutral).

const (
	GridDirectionLong    GridDirection = "long"
	GridDirectionShort   GridDirection = "short"
	GridDirectionNeutral GridDirection = "neutral"
)

type GridInstantTriggerResult

type GridInstantTriggerResult struct {
	AlgoID string `json:"algoId"`
}

GridInstantTriggerResult is the ack of an order-instant-trigger request.

type GridInvestmentDataInput

type GridInvestmentDataInput struct {
	Amount   decimal.Decimal `json:"amt"`
	Currency string          `json:"ccy"`
}

GridInvestmentDataInput is one per-currency planned investment entry of a min-investment request.

type GridMarginBalanceResult

type GridMarginBalanceResult struct {
	AlgoID string `json:"algoId"`
}

GridMarginBalanceResult is the ack of a margin-balance adjustment.

type GridMinInvestment

type GridMinInvestment struct {
	MinInvestmentData []GridMinInvestmentData `json:"minInvestmentData"`
	SingleAmount      decimal.Decimal         `json:"singleAmt"`
}

GridMinInvestment is the minimum-investment computation result.

type GridMinInvestmentData

type GridMinInvestmentData struct {
	Amount   decimal.Decimal `json:"amt"`
	Currency string          `json:"ccy"`
}

GridMinInvestmentData is one currency's minimum investable amount.

type GridPosition

type GridPosition struct {
	AlgoID            string          `json:"algoId"`
	AlgoClientOrderID string          `json:"algoClOrdId"`
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	Currency          string          `json:"ccy"`
	PositionSide      PosSide         `json:"posSide"`
	MarginMode        MgnMode         `json:"mgnMode"`
	Position          decimal.Decimal `json:"pos"`
	AveragePrice      decimal.Decimal `json:"avgPx"`
	LiquidationPrice  decimal.Decimal `json:"liqPx"`
	MarkPrice         decimal.Decimal `json:"markPx"`
	Leverage          decimal.Decimal `json:"lever"`
	IMR               decimal.Decimal `json:"imr"`
	MMR               decimal.Decimal `json:"mmr"`
	MarginRatio       decimal.Decimal `json:"mgnRatio"`
	Margin            decimal.Decimal `json:"margin"`
	NotionalUSD       decimal.Decimal `json:"notionalUsd"`
	Last              decimal.Decimal `json:"last"`
	UPL               decimal.Decimal `json:"upl"`
	UPLRatio          decimal.Decimal `json:"uplRatio"`
	CreationTime      time.Time       `json:"cTime"`
	UpdateTime        time.Time       `json:"uTime"`
}

GridPosition is the position held by a contract grid algo order. The validating account had no grid orders, so the field set is modeled from the OKX doc field table.

type GridRSIBackTesting

type GridRSIBackTesting struct {
	TriggerNumber string `json:"triggerNum"`
}

GridRSIBackTesting is the RSI back-test result (how many times the condition fired over the duration).

type GridRebateTrans

type GridRebateTrans struct {
	Rebate         decimal.Decimal `json:"rebate"`
	RebateCurrency string          `json:"rebateCcy"`
}

GridRebateTrans is one rebate-transfer record attached to a grid algo order.

type GridResult

type GridResult struct {
	AlgoID            string `json:"algoId"`
	AlgoClientOrderID string `json:"algoClOrdId"`
	SCode             string `json:"sCode"`
	SMsg              string `json:"sMsg"`
	Tag               string `json:"tag"`
}

GridResult is the per-item ack of a grid algo place/amend/stop operation. The real reason for a failure is carried in sCode/sMsg even when the top-level envelope code is "1".

func (GridResult) Err added in v0.20260623.1

func (r GridResult) Err() error

type GridRunType

type GridRunType string

GridRunType is the grid spacing mode: "1" arithmetic, "2" geometric.

const (
	GridRunTypeArithmetic GridRunType = "1"
	GridRunTypeGeometric  GridRunType = "2"
)

type GridStopArg

type GridStopArg struct {
	AlgoID        string          `json:"algoId"`
	InstrumentID  string          `json:"instId"`
	AlgoOrderType GridAlgoOrdType `json:"algoOrdType"`
	StopType      string          `json:"stopType"`
}

GridStopArg is one entry of a batch grid-stop request.

type GridSubOrder

type GridSubOrder struct {
	AlgoID              string          `json:"algoId"`
	AlgoClientOrderID   string          `json:"algoClOrdId"`
	AlgoOrderType       GridAlgoOrdType `json:"algoOrdType"`
	InstrumentType      InstType        `json:"instType"`
	InstrumentID        string          `json:"instId"`
	GroupID             string          `json:"groupId"`
	OrderID             string          `json:"ordId"`
	ClientOrderID       string          `json:"clOrdId"`
	Tag                 string          `json:"tag"`
	OrderType           OrdType         `json:"ordType"`
	Side                Side            `json:"side"`
	PositionSide        PosSide         `json:"posSide"`
	TradeMode           TdMode          `json:"tdMode"`
	Currency            string          `json:"ccy"`
	Price               decimal.Decimal `json:"px"`
	Size                decimal.Decimal `json:"sz"`
	State               OrdState        `json:"state"`
	AccumulatedFillSize decimal.Decimal `json:"accFillSz"`
	AveragePrice        decimal.Decimal `json:"avgPx"`
	Leverage            decimal.Decimal `json:"lever"`
	Fee                 decimal.Decimal `json:"fee"`
	FeeCurrency         string          `json:"feeCcy"`
	Rebate              decimal.Decimal `json:"rebate"`
	RebateCurrency      string          `json:"rebateCcy"`
	Pnl                 decimal.Decimal `json:"pnl"`
	CreationTime        time.Time       `json:"cTime"`
	UpdateTime          time.Time       `json:"uTime"`
}

GridSubOrder is one sub-order (working leg) of a grid algo order. The validating account had no grid orders, so the field set is modeled from the OKX doc field table.

type GridSubOrderType

type GridSubOrderType string

GridSubOrderType selects which sub-orders to return: "live" (open) or "filled".

const (
	GridSubOrderTypeLive   GridSubOrderType = "live"
	GridSubOrderTypeFilled GridSubOrderType = "filled"
)

type GridTriggerParam

type GridTriggerParam struct {
	TriggerAction   string          `json:"triggerAction"`
	TriggerStrategy string          `json:"triggerStrategy"`
	DelaySeconds    string          `json:"delaySeconds"`
	TriggerType     string          `json:"triggerType"`
	Timeframe       string          `json:"timeframe"`
	Thold           string          `json:"thold"`
	TriggerCond     string          `json:"triggerCond"`
	TimePeriod      string          `json:"timePeriod"`
	TriggerPrice    decimal.Decimal `json:"triggerPx"`
	StopType        string          `json:"stopType"`
	TriggerTime     time.Time       `json:"triggerTime"`
}

GridTriggerParam is one advanced trigger configuration of a grid algo order (used both in the order detail and in the amend request body).

type GridWithdrawIncomeResult

type GridWithdrawIncomeResult struct {
	AlgoID string          `json:"algoId"`
	Profit decimal.Decimal `json:"profit"`
}

GridWithdrawIncomeResult is the ack of a grid income withdrawal.

type IndexCandle

type IndexCandle struct {
	Timestamp time.Time       `json:"ts"`
	Open      decimal.Decimal `json:"o"`
	High      decimal.Decimal `json:"h"`
	Low       decimal.Decimal `json:"l"`
	Close     decimal.Decimal `json:"c"`
	Confirm   string          `json:"confirm"`
}

IndexCandle is one row of an index or mark-price candlestick. OKX returns these endpoints as arrays-of-arrays with 6 columns: [ts, o, h, l, c, confirm]. Confirm is "0" for an in-progress bar and "1" once the bar is closed.

type IndexComponent

type IndexComponent struct {
	Symbol       string          `json:"symbol"`
	SymbolPrice  decimal.Decimal `json:"symPx"`
	Weight       decimal.Decimal `json:"wgt"`
	ConvertPrice decimal.Decimal `json:"cnvPx"`
	Exch         string          `json:"exch"`
}

IndexComponent is one venue's contribution to an index.

type IndexComponents

type IndexComponents struct {
	Index      string           `json:"index"`
	Last       decimal.Decimal  `json:"last"`
	Timestamp  time.Time        `json:"ts"`
	Components []IndexComponent `json:"components"`
}

IndexComponents describes an index, its latest value and the venues that make it up.

type IndexTicker

type IndexTicker struct {
	InstrumentID   string          `json:"instId"`
	IndexPrice     decimal.Decimal `json:"idxPx"`
	High24h        decimal.Decimal `json:"high24h"`
	StartOfDayUTC0 decimal.Decimal `json:"sodUtc0"`
	Open24h        decimal.Decimal `json:"open24h"`
	Low24h         decimal.Decimal `json:"low24h"`
	StartOfDayUTC8 decimal.Decimal `json:"sodUtc8"`
	Timestamp      time.Time       `json:"ts"`
}

IndexTicker is the latest index price snapshot for an index instrument.

type InstState

type InstState string

InstState is the listing state of an instrument.

const (
	InstStateLive    InstState = "live"
	InstStateSuspend InstState = "suspend"
	InstStatePreOpen InstState = "preopen"
	InstStateTest    InstState = "test"
)

type InstType

type InstType string

InstType is an OKX instrument type. It selects the product line for market and account queries.

const (
	InstTypeSpot    InstType = "SPOT"
	InstTypeMargin  InstType = "MARGIN"
	InstTypeSwap    InstType = "SWAP"
	InstTypeFutures InstType = "FUTURES"
	InstTypeOption  InstType = "OPTION"
	InstTypeEvents  InstType = "EVENTS"
	InstTypeAny     InstType = "ANY"
)

type InstantTriggerGridService

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

InstantTriggerGridService -- POST /api/v5/tradingBot/grid/order-instant-trigger (Trade)

Manually triggers a pending grid algo order immediately. IMPLEMENT-ONLY.

func (*InstantTriggerGridService) Do

type Instrument

type Instrument struct {
	InstrumentType            InstType        `json:"instType"`
	InstrumentID              string          `json:"instId"`
	InstrumentIDCode          int64           `json:"instIdCode"`
	Underlying                string          `json:"uly"`
	InstrumentFamily          string          `json:"instFamily"`
	Category                  string          `json:"category"`
	InstrumentCategory        string          `json:"instCategory"`
	BaseCurrency              string          `json:"baseCcy"`
	QuoteCurrency             string          `json:"quoteCcy"`
	SettleCurrency            string          `json:"settleCcy"`
	ContractValue             decimal.Decimal `json:"ctVal"`
	ContractMultiplier        decimal.Decimal `json:"ctMult"`
	ContractValueCurrency     string          `json:"ctValCcy"`
	OptionType                OptType         `json:"optType"`
	Strike                    decimal.Decimal `json:"stk"`
	ListTime                  time.Time       `json:"listTime"`
	AuctionEndTime            time.Time       `json:"auctionEndTime"`
	ContinuousTradeSwitchTime time.Time       `json:"contTdSwTime"`
	OpenType                  publicOpenType  `json:"openType"`
	ExpiryTime                time.Time       `json:"expTime"`
	Leverage                  decimal.Decimal `json:"lever"`
	TickSize                  decimal.Decimal `json:"tickSz"`
	LotSize                   decimal.Decimal `json:"lotSz"`
	MinSize                   decimal.Decimal `json:"minSz"`
	ContractType              CtType          `json:"ctType"`
	Alias                     string          `json:"alias"`
	State                     InstState       `json:"state"`
	// RuleType is the trading rule type: "normal" (normal trading),
	// "pre_market" (pre-market trading, including pre-market X-Perp FUTURES),
	// "rebase_contract" (pre-market rebase contract) and "xperp"
	// (perpetual-style FUTURES; a pre-market X-Perp changes from "pre_market"
	// to "xperp" once it converts to a normal X-Perp).
	RuleType                         string             `json:"ruleType"`
	MaxLimitSize                     decimal.Decimal    `json:"maxLmtSz"`
	MaxMarketSize                    decimal.Decimal    `json:"maxMktSz"`
	MaxLimitAmount                   decimal.Decimal    `json:"maxLmtAmt"`
	MaxMarketAmount                  decimal.Decimal    `json:"maxMktAmt"`
	MaxTWAPSize                      decimal.Decimal    `json:"maxTwapSz"`
	MaxIcebergSize                   decimal.Decimal    `json:"maxIcebergSz"`
	MaxTriggerSize                   decimal.Decimal    `json:"maxTriggerSz"`
	MaxStopSize                      decimal.Decimal    `json:"maxStopSz"`
	MaxPlatformOpenInterestLimit     decimal.Decimal    `json:"maxPlatOILmt"`
	MaxPlatformOpenInterestCoinLimit decimal.Decimal    `json:"maxPlatOICoinLmt"`
	FutureSettlement                 bool               `json:"futureSettlement"`
	TradeQuoteCurrencyList           []string           `json:"tradeQuoteCcyList"`
	UpcomingChange                   []InstrumentUpcChg `json:"upcChg"`
	Freq                             string             `json:"freq"`
	GroupID                          string             `json:"groupId"`
	SeriesID                         string             `json:"seriesId"`
	// Method is the settlement method for EVENTS. Values include "hit" (price
	// touches the strike, settles immediately) and "between" (settle price
	// within a range).
	Method                      string          `json:"method"`
	LongPositionRemainingQuota  decimal.Decimal `json:"longPosRemainingQuota"`
	ShortPositionRemainingQuota decimal.Decimal `json:"shortPosRemainingQuota"`
	PositionLimitAmount         decimal.Decimal `json:"posLmtAmt"`
	PositionLimitPercent        decimal.Decimal `json:"posLmtPct"`
	// PreMarketSwitchTime is the time a pre-market instrument switched to normal
	// trading. Only applicable to pre-market SWAP and pre-market X-Perp FUTURES;
	// populated when a pre-market X-Perp converts to a normal X-Perp.
	PreMarketSwitchTime time.Time `json:"preMktSwTime"`
	// InitialPriceLimitPercent is the initial price-limit band applied during the
	// first 10 minutes after contract listing. Empty for OPTION and EVENTS.
	InitialPriceLimitPercent decimal.Decimal `json:"initPxLmtPct"`
	// FloatingPriceLimitPercent is the floating price-limit band during normal
	// trading. Empty for OPTION and EVENTS.
	FloatingPriceLimitPercent decimal.Decimal `json:"floatPxLmtPct"`
	// MaxPriceLimitPercent is the maximum price-limit cap (hard ceiling). Empty
	// for OPTION and EVENTS.
	MaxPriceLimitPercent decimal.Decimal `json:"maxPxLmtPct"`
	// CapStrike is the maximum expiration value that leads to a YES outcome for
	// the "between" settlement method (EVENTS only). "INF" means no upper bound
	// (the topmost bracket); empty for non-"between" methods.
	CapStrike string `json:"capStrike"`
	// HitDirection is the hit direction, applicable only when the settlement
	// method is "hit" (EVENTS only). "up": price hit from below; "dn": price hit
	// from above; empty for non-"hit" methods.
	HitDirection string `json:"hitDir"`
	// Elp is the ELP (Enhanced Liquidity Program) maker permission, returned only
	// by the private GET /api/v5/account/instruments variant (empty on the public
	// endpoint): "0" ELP not enabled for this symbol; "1" enabled but the current
	// user lacks permission to place ELP orders; "2" enabled and permitted. OKX is
	// rebranding ELP to RPI (Retail Price Improvement); the json key stays "elp"
	// until the old names retire on 2026-10-31, after which it becomes "rpi".
	Elp string `json:"elp"`
}

Instrument is a single tradable instrument.

type InstrumentTickBands

type InstrumentTickBands struct {
	InstrumentType   InstType   `json:"instType"`
	InstrumentFamily string     `json:"instFamily"`
	SeriesID         string     `json:"seriesId"`
	TickBand         []TickBand `json:"tickBand"`
}

InstrumentTickBands is the tick-size band schedule of an instrument family.

type InstrumentUpcChg

type InstrumentUpcChg struct {
	EffectiveTime time.Time `json:"effTime"`
	NewValue      string    `json:"newValue"`
	Param         string    `json:"param"`
}

InstrumentUpcChg is a scheduled upcoming change to one of an instrument's trading rules (e.g. a tickSz adjustment).

type InsuranceFund

type InsuranceFund struct {
	InstrumentType   InstType              `json:"instType"`
	InstrumentFamily string                `json:"instFamily"`
	Total            decimal.Decimal       `json:"total"`
	Details          []InsuranceFundDetail `json:"details"`
}

InsuranceFund is the insurance-fund summary and its change records.

type InsuranceFundDetail

type InsuranceFundDetail struct {
	Type                string          `json:"type"`
	Currency            string          `json:"ccy"`
	Amount              decimal.Decimal `json:"amt"`
	Balance             decimal.Decimal `json:"balance"`
	MaxBalance          decimal.Decimal `json:"maxBal"`
	MaxBalanceTimestamp time.Time       `json:"maxBalTs"`
	DecRate             decimal.Decimal `json:"decRate"`
	ADLType             string          `json:"adlType"`
	Timestamp           time.Time       `json:"ts"`
}

InsuranceFundDetail is one insurance-fund change record.

type InterestAccrued

type InterestAccrued struct {
	Type         string          `json:"type"`
	Currency     string          `json:"ccy"`
	InstrumentID string          `json:"instId"`
	MarginMode   MgnMode         `json:"mgnMode"`
	Interest     decimal.Decimal `json:"interest"`
	InterestRate decimal.Decimal `json:"interestRate"`
	Liability    decimal.Decimal `json:"liab"`
	Timestamp    time.Time       `json:"ts"`
}

InterestAccrued is one accrued-interest record.

type InterestLimits

type InterestLimits struct {
	Debt             decimal.Decimal        `json:"debt"`
	Interest         decimal.Decimal        `json:"interest"`
	NextDiscountTime time.Time              `json:"nextDiscountTime"`
	NextInterestTime time.Time              `json:"nextInterestTime"`
	LoanAlloc        decimal.Decimal        `json:"loanAlloc"`
	Records          []InterestLimitsRecord `json:"records"`
}

InterestLimits is the account's interest summary and per-currency loan-quota schedule.

type InterestLimitsRecord

type InterestLimitsRecord struct {
	Currency                 string            `json:"ccy"`
	Rate                     decimal.Decimal   `json:"rate"`
	LoanQuota                decimal.Decimal   `json:"loanQuota"`
	SurplusLimit             decimal.Decimal   `json:"surplusLmt"`
	SurplusLimitDetails      SurplusLmtDetails `json:"surplusLmtDetails"`
	UsedLimit                decimal.Decimal   `json:"usedLmt"`
	Interest                 decimal.Decimal   `json:"interest"`
	InterestFreeLiability    decimal.Decimal   `json:"interestFreeLiab"`
	PositionLoan             decimal.Decimal   `json:"posLoan"`
	AvailableLoan            decimal.Decimal   `json:"availLoan"`
	UsedLoan                 decimal.Decimal   `json:"usedLoan"`
	AverageRate              decimal.Decimal   `json:"avgRate"`
	PotentialBorrowingAmount decimal.Decimal   `json:"potentialBorrowingAmt"`
}

InterestLimitsRecord is one currency's loan-quota and interest detail within the account interest-limits schedule.

type InterestRate

type InterestRate struct {
	Currency          string          `json:"ccy"`
	InterestRate      decimal.Decimal `json:"interestRate"`
	NextEstimatedRate decimal.Decimal `json:"nextEstRate"`
	Timestamp         time.Time       `json:"ts"`
}

InterestRate is a currency's current account borrowing interest rate.

type InterestRateBasic

type InterestRateBasic struct {
	Currency string          `json:"ccy"`
	Rate     decimal.Decimal `json:"rate"`
	Quota    decimal.Decimal `json:"quota"`
}

InterestRateBasic is the basic per-currency interest rate and borrow quota.

type InterestRateCcy

type InterestRateCcy struct {
	Currency string          `json:"ccy"`
	Rate     decimal.Decimal `json:"rate"`
}

InterestRateCcy is a currency's configured base interest rate.

type InterestRateConfig

type InterestRateConfig struct {
	Currency     string          `json:"ccy"`
	Level        string          `json:"level"`
	Quota        decimal.Decimal `json:"quota"`
	StrategyType string          `json:"stgyType"`
}

InterestRateConfig is one currency's per-level loan-quota config entry.

type InterestRateLevel

type InterestRateLevel struct {
	Level                string          `json:"level"`
	LoanQuotaCoefficient decimal.Decimal `json:"loanQuotaCoef"`
	InterestRateDiscount decimal.Decimal `json:"irDiscount"`
}

InterestRateLevel is a VIP/regular tier's interest discount and quota coefficient.

type InterestRateLoanQuota

type InterestRateLoanQuota struct {
	Basic              []InterestRateBasic  `json:"basic"`
	VIP                []InterestRateLevel  `json:"vip"`
	Regular            []InterestRateLevel  `json:"regular"`
	Config             []InterestRateConfig `json:"config"`
	ConfigCurrencyList []InterestRateCcy    `json:"configCcyList"`
}

InterestRateLoanQuota is the platform's interest-rate and loan-quota schedule.

type IsoMode

type IsoMode string

IsoMode is the isolated-margin transfer behaviour.

const (
	IsoModeAutomatic        IsoMode = "automatic"
	IsoModeAutonomy         IsoMode = "autonomy"
	IsoModeAutoTransfersCcy IsoMode = "auto_transfers_ccy"
)

type IsoModeType

type IsoModeType string

IsoModeType is the instrument scope of an isolated-margin setting.

const (
	IsoModeTypeMargin    IsoModeType = "MARGIN"
	IsoModeTypeContracts IsoModeType = "CONTRACTS"
)

type IsolatedModeSetting

type IsolatedModeSetting struct {
	IsolatedMode IsoMode `json:"isoMode"`
}

IsolatedModeSetting is the set-isolated-mode acknowledgement.

type LeverageInfo

type LeverageInfo struct {
	InstrumentID string          `json:"instId"`
	Currency     string          `json:"ccy"`
	MarginMode   MgnMode         `json:"mgnMode"`
	PositionSide PosSide         `json:"posSide"`
	Leverage     decimal.Decimal `json:"lever"`
}

LeverageInfo is the account's leverage setting for an instrument/side.

type LeverageSetting

type LeverageSetting struct {
	Leverage     decimal.Decimal `json:"lever"`
	MarginMode   MgnMode         `json:"mgnMode"`
	InstrumentID string          `json:"instId"`
	PositionSide PosSide         `json:"posSide"`
}

LeverageSetting is the set-leverage acknowledgement.

type MMInstrumentType added in v0.20260703.0

type MMInstrumentType struct {
	InstrumentType InstType `json:"instType"`
	InstrumentID   string   `json:"instId"`
	PairType       string   `json:"pairType"`
}

MMInstrumentType is one instrument's MM-program classification. PairType is a free-form tier label (e.g. "Type A", "Type B-Crypto", "Type B-TradFi", "FULL").

type MMPConfig

type MMPConfig struct {
	InstrumentFamily string          `json:"instFamily"`
	MMPFrozen        bool            `json:"mmpFrozen"`
	MMPFrozenUntil   time.Time       `json:"mmpFrozenUntil"`
	TimeInterval     decimal.Decimal `json:"timeInterval"`
	FrozenInterval   decimal.Decimal `json:"frozenInterval"`
	QtyLimit         decimal.Decimal `json:"qtyLimit"`
}

MMPConfig is a Market Maker Protection configuration and current state.

type MMPConfigSetting

type MMPConfigSetting struct {
	InstrumentFamily string          `json:"instFamily"`
	TimeInterval     decimal.Decimal `json:"timeInterval"`
	FrozenInterval   decimal.Decimal `json:"frozenInterval"`
	QtyLimit         decimal.Decimal `json:"qtyLimit"`
}

MMPConfigSetting is the set-MMP acknowledgement.

type MMPReset

type MMPReset struct {
	Result bool `json:"result"`
}

MMPReset is the mmp-reset acknowledgement.

type ManagedSubAccountBill

type ManagedSubAccountBill struct {
	BillID     string          `json:"billId"`
	Type       string          `json:"type"`
	Currency   string          `json:"ccy"`
	Amount     decimal.Decimal `json:"amt"`
	SubAccount string          `json:"subAcct"`
	SubUID     string          `json:"subUid"`
	Timestamp  time.Time       `json:"ts"`
}

ManagedSubAccountBill is one managed-sub-account asset-transfer record.

type MarginBalance

type MarginBalance struct {
	InstrumentID string            `json:"instId"`
	PositionSide PosSide           `json:"posSide"`
	Amount       decimal.Decimal   `json:"amt"`
	Type         MarginBalanceType `json:"type"`
	Leverage     decimal.Decimal   `json:"leverage"`
	Currency     string            `json:"ccy"`
}

MarginBalance is the position-margin adjustment acknowledgement.

type MarginBalanceType

type MarginBalanceType string

MarginBalanceType selects whether a position-margin adjustment adds or reduces margin.

const (
	MarginBalanceTypeAdd    MarginBalanceType = "add"
	MarginBalanceTypeReduce MarginBalanceType = "reduce"
)

type MarkPrice

type MarkPrice struct {
	InstrumentType InstType        `json:"instType"`
	InstrumentID   string          `json:"instId"`
	MarkPrice      decimal.Decimal `json:"markPx"`
	Timestamp      time.Time       `json:"ts"`
}

MarkPrice is an instrument's mark price.

type MarketBar

type MarketBar string

MarketBar is a candlestick time granularity (e.g. "1m", "1H", "1D").

const (
	MarketBar1m  MarketBar = "1m"
	MarketBar3m  MarketBar = "3m"
	MarketBar5m  MarketBar = "5m"
	MarketBar15m MarketBar = "15m"
	MarketBar30m MarketBar = "30m"
	MarketBar1H  MarketBar = "1H"
	MarketBar2H  MarketBar = "2H"
	MarketBar4H  MarketBar = "4H"
	MarketBar6H  MarketBar = "6H"
	MarketBar12H MarketBar = "12H"
	MarketBar1D  MarketBar = "1D"
	MarketBar2D  MarketBar = "2D"
	MarketBar3D  MarketBar = "3D"
	MarketBar1W  MarketBar = "1W"
	MarketBar1M  MarketBar = "1M"
	MarketBar3M  MarketBar = "3M"

	MarketBar6Hutc  MarketBar = "6Hutc"
	MarketBar12Hutc MarketBar = "12Hutc"
	MarketBar1Dutc  MarketBar = "1Dutc"
	MarketBar2Dutc  MarketBar = "2Dutc"
	MarketBar3Dutc  MarketBar = "3Dutc"
	MarketBar1Wutc  MarketBar = "1Wutc"
	MarketBar1Mutc  MarketBar = "1Mutc"
	MarketBar3Mutc  MarketBar = "3Mutc"
)

OKX candle bar granularities. Note the case convention OKX requires: minute bars are lower-case "m" while hour/day/week/month bars are upper-case (H/D/W/M). The ...UTC variants align the bar boundary to 00:00 UTC instead of the default Hong Kong time (UTC+8).

type MarketHistoryTradeType

type MarketHistoryTradeType string

MarketHistoryTradeType selects the paging field for history-trades: "1" by tradeId (default), "2" by ts.

const (
	MarketHistoryTradeTypeTradeId MarketHistoryTradeType = "1"
	MarketHistoryTradeTypeTs      MarketHistoryTradeType = "2"
)

type MassCancelResult

type MassCancelResult struct {
	Result bool `json:"result"`
}

MassCancelResult is the ack returned by the mass-cancel endpoint.

type MassCancelService

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

MassCancelService -- POST /api/v5/trade/mass-cancel (Trade)

Cancels all pending MMP orders for an instrument family (market-maker protection).

func (*MassCancelService) Do

func (*MassCancelService) SetLockInterval

func (s *MassCancelService) SetLockInterval(ms int) *MassCancelService

SetLockInterval sets the auto-cancel lock interval in milliseconds (0-10000).

type MaxAvailSize

type MaxAvailSize struct {
	InstrumentID       string          `json:"instId"`
	AvailableBuy       decimal.Decimal `json:"availBuy"`
	AvailableSell      decimal.Decimal `json:"availSell"`
	TradeQuoteCurrency string          `json:"tradeQuoteCcy"`
}

MaxAvailSize is the maximum available buy/sell amount of an instrument.

type MaxLoan

type MaxLoan struct {
	InstrumentID   string          `json:"instId"`
	MarginMode     MgnMode         `json:"mgnMode"`
	MarginCurrency string          `json:"mgnCcy"`
	MaxLoan        decimal.Decimal `json:"maxLoan"`
	Currency       string          `json:"ccy"`
	Side           Side            `json:"side"`
}

MaxLoan is the account's maximum loanable amount for an instrument side.

type MaxSize

type MaxSize struct {
	InstrumentID       string          `json:"instId"`
	Currency           string          `json:"ccy"`
	MaxBuy             decimal.Decimal `json:"maxBuy"`
	MaxSell            decimal.Decimal `json:"maxSell"`
	TradeQuoteCurrency string          `json:"tradeQuoteCcy"`
}

MaxSize is the maximum buy/sell size of an instrument.

type MaxWithdrawal

type MaxWithdrawal struct {
	Currency                string          `json:"ccy"`
	MaxWithdrawal           decimal.Decimal `json:"maxWd"`
	MaxWdEx                 decimal.Decimal `json:"maxWdEx"`
	SpotOffsetMaxWithdrawal decimal.Decimal `json:"spotOffsetMaxWd"`
	SpotOffsetMaxWdEx       decimal.Decimal `json:"spotOffsetMaxWdEx"`
}

MaxWithdrawal is a currency's maximum transferable-out amount.

type MgnMode

type MgnMode string

MgnMode is a margin mode (used by positions, leverage and borrowing).

const (
	MgnModeIsolated MgnMode = "isolated"
	MgnModeCross    MgnMode = "cross"
)

type ModifySubAccountApiKeyService

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

ModifySubAccountApiKeyService -- POST /api/v5/users/subaccount/modify-apikey (Trade)

Modifies (master account) a sub-account API key's permissions, label or IP allow-list. Implement-only: never executed by the live test suite.

func (*ModifySubAccountApiKeyService) Do

func (*ModifySubAccountApiKeyService) SetIP

SetIP sets the IP allow-list (comma-separated, up to 20 addresses).

func (*ModifySubAccountApiKeyService) SetLabel

SetLabel sets a new label for the API key.

func (*ModifySubAccountApiKeyService) SetPerm

SetPerm sets the API key permissions (comma-separated: read_only, trade).

type MonthlyStatement

type MonthlyStatement struct {
	FileHref  string    `json:"fileHref"`
	State     string    `json:"state"`
	Timestamp time.Time `json:"ts"`
}

MonthlyStatement is the download link and state of a monthly statement.

type MonthlyStatementApply

type MonthlyStatementApply struct {
	Timestamp time.Time `json:"ts"`
}

MonthlyStatementApply is the acknowledgement of a monthly-statement request.

type MovePositionLeg

type MovePositionLeg struct {
	From MovePositionLegFromReq `json:"from"`
	To   MovePositionLegToReq   `json:"to"`
}

MovePositionLeg is one position to move in a move-positions request. From describes the source-account leg and To the destination-account leg.

type MovePositionLegFromReq

type MovePositionLegFromReq struct {
	PositionID string `json:"posId"`
	Size       string `json:"sz"`
	Side       Side   `json:"side"`
}

MovePositionLegFromReq is the source leg of a move-positions request.

type MovePositionLegToReq

type MovePositionLegToReq struct {
	TradeMode    TdMode  `json:"tdMode,omitempty"`
	PositionSide PosSide `json:"posSide,omitempty"`
	Currency     string  `json:"ccy,omitempty"`
}

MovePositionLegToReq is the destination leg of a move-positions request.

type MovePositions

type MovePositions struct {
	BlockTradeID string             `json:"blockTdId"`
	ClientID     string             `json:"clientId"`
	State        string             `json:"state"`
	FromAccount  string             `json:"fromAcct"`
	ToAccount    string             `json:"toAcct"`
	Legs         []MovePositionsLeg `json:"legs"`
	Timestamp    time.Time          `json:"ts"`
}

MovePositions is the move-positions acknowledgement.

type MovePositionsHistory

type MovePositionsHistory struct {
	ClientID     string                    `json:"clientId"`
	BlockTradeID string                    `json:"blockTdId"`
	State        string                    `json:"state"`
	Timestamp    time.Time                 `json:"ts"`
	FromAccount  string                    `json:"fromAcct"`
	ToAccount    string                    `json:"toAcct"`
	Legs         []MovePositionsHistoryLeg `json:"legs"`
}

MovePositionsHistory is one move-positions (block transfer) record.

type MovePositionsHistoryLeg

type MovePositionsHistoryLeg struct {
	From MovePositionsHistoryLegFrom `json:"from"`
	To   MovePositionsHistoryLegTo   `json:"to"`
}

MovePositionsHistoryLeg is one leg of a move-positions history record.

type MovePositionsHistoryLegFrom

type MovePositionsHistoryLegFrom struct {
	InstrumentID string          `json:"instId"`
	PositionID   string          `json:"posId"`
	Price        decimal.Decimal `json:"px"`
	Side         Side            `json:"side"`
	Size         decimal.Decimal `json:"sz"`
}

MovePositionsHistoryLegFrom is the source-account side of a history leg.

type MovePositionsHistoryLegTo

type MovePositionsHistoryLegTo struct {
	InstrumentID string          `json:"instId"`
	Price        decimal.Decimal `json:"px"`
	Side         Side            `json:"side"`
	Size         decimal.Decimal `json:"sz"`
	TradeMode    TdMode          `json:"tdMode"`
	PositionSide PosSide         `json:"posSide"`
	Currency     string          `json:"ccy"`
}

MovePositionsHistoryLegTo is the destination-account side of a history leg.

type MovePositionsLeg

type MovePositionsLeg struct {
	From MovePositionsLegFrom `json:"from"`
	To   MovePositionsLegTo   `json:"to"`
}

MovePositionsLeg is one moved-position leg in a move-positions response.

type MovePositionsLegFrom

type MovePositionsLegFrom struct {
	InstrumentID string          `json:"instId"`
	PositionID   string          `json:"posId"`
	Price        decimal.Decimal `json:"px"`
	Side         Side            `json:"side"`
	Size         decimal.Decimal `json:"sz"`
	SCode        string          `json:"sCode"`
	SMsg         string          `json:"sMsg"`
}

MovePositionsLegFrom is the source-account side of a moved-position leg.

type MovePositionsLegTo

type MovePositionsLegTo struct {
	InstrumentID string          `json:"instId"`
	Side         Side            `json:"side"`
	PositionSide PosSide         `json:"posSide"`
	TradeMode    TdMode          `json:"tdMode"`
	Price        decimal.Decimal `json:"px"`
	Currency     string          `json:"ccy"`
	SCode        string          `json:"sCode"`
	SMsg         string          `json:"sMsg"`
}

MovePositionsLegTo is the destination-account side of a moved-position leg.

type MovePositionsService

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

MovePositionsService -- POST /api/v5/account/move-positions (Trade)

Moves positions between the master account and a managed sub-account (block transfer). Each leg pairs a source-account position with its destination.

func (*MovePositionsService) Do

type NonTradableAsset

type NonTradableAsset struct {
	Currency           string          `json:"ccy"`
	Name               string          `json:"name"`
	LogoLink           string          `json:"logoLink"`
	Balance            decimal.Decimal `json:"bal"`
	CanWithdrawal      bool            `json:"canWd"`
	Chain              string          `json:"chain"`
	ContractAddress    string          `json:"ctAddr"`
	Fee                decimal.Decimal `json:"fee"`
	FeeCurrency        string          `json:"feeCcy"`
	MinWithdrawal      decimal.Decimal `json:"minWd"`
	WithdrawalTickSize decimal.Decimal `json:"wdTickSz"`
	WithdrawalAll      bool            `json:"wdAll"`
	NeedTag            bool            `json:"needTag"`
	BurningFeeRate     decimal.Decimal `json:"burningFeeRate"`
}

NonTradableAsset is a single non-tradable asset and its withdrawal rules.

type OKUSDLimits added in v0.20260703.0

type OKUSDLimits struct {
	SubLimit        OKUSDSubLimit    `json:"subLimit"`
	FastRedeemLimit OKUSDRedeemLimit `json:"fastRedeemLimit"`
	StdRedeemLimit  OKUSDRedeemLimit `json:"stdRedeemLimit"`
	Timestamp       time.Time        `json:"ts"`
}

OKUSDLimits is the account's OKUSD subscription/redemption limit snapshot.

type OKUSDRedeemLimit added in v0.20260703.0

type OKUSDRedeemLimit struct {
	PersonalDailyLimit decimal.Decimal `json:"personalDailyLimit"`
	PersonalUsedAmount decimal.Decimal `json:"personalUsedAmt"`
	PlatformDailyLimit decimal.Decimal `json:"platformDailyLimit"`
	PlatformUsedAmount decimal.Decimal `json:"platformUsedAmt"`
	FeeRate            decimal.Decimal `json:"feeRate"`
}

OKUSDRedeemLimit holds a redemption limit tier's figures (OKUSD) and its fee rate.

type OKUSDRedeemType added in v0.20260703.0

type OKUSDRedeemType string

OKUSDRedeemType selects how an OKUSD redemption settles.

const (
	// OKUSDRedeemTypeFast settles in real time.
	OKUSDRedeemTypeFast OKUSDRedeemType = "1"
	// OKUSDRedeemTypeStandard settles in D+5 business days.
	OKUSDRedeemTypeStandard OKUSDRedeemType = "2"
)

type OKUSDRedemption added in v0.20260703.0

type OKUSDRedemption struct {
	OrderID                 string          `json:"ordId"`
	Currency                string          `json:"ccy"`
	Amount                  decimal.Decimal `json:"amt"`
	Fee                     decimal.Decimal `json:"fee"`
	USDTAmount              decimal.Decimal `json:"usdtAmt"`
	RedeemType              OKUSDRedeemType `json:"redeemType"`
	State                   string          `json:"state"`
	EstimatedSettlementTime time.Time       `json:"estSettlementTime"`
	Timestamp               time.Time       `json:"ts"`
}

OKUSDRedemption is the ack of an OKUSD redemption.

type OKUSDSubLimit added in v0.20260703.0

type OKUSDSubLimit struct {
	MaxSubAmount       decimal.Decimal `json:"maxSubAmt"`
	PersonalDailyLimit decimal.Decimal `json:"personalDailyLimit"`
	PersonalUsedAmount decimal.Decimal `json:"personalUsedAmt"`
	PlatformDailyLimit decimal.Decimal `json:"platformDailyLimit"`
	PlatformUsedAmount decimal.Decimal `json:"platformUsedAmt"`
}

OKUSDSubLimit holds the subscription limit figures (USDT).

type OKUSDSubscription added in v0.20260703.0

type OKUSDSubscription struct {
	OrderID     string          `json:"ordId"`
	Currency    string          `json:"ccy"`
	Amount      decimal.Decimal `json:"amt"`
	OKUSDAmount decimal.Decimal `json:"okusdAmt"`
	State       string          `json:"state"`
	Timestamp   time.Time       `json:"ts"`
}

OKUSDSubscription is the ack of an OKUSD subscription.

type OneClickRepayCurrencyList

type OneClickRepayCurrencyList struct {
	DebtType  DebtType             `json:"debtType"`
	DebtData  []OneClickRepayDebt  `json:"debtData"`
	RepayData []OneClickRepayRepay `json:"repayData"`
}

OneClickRepayCurrencyList is the set of repayable debt currencies and the currencies available to repay them, grouped by debt type.

type OneClickRepayCurrencyListV2

type OneClickRepayCurrencyListV2 struct {
	DebtData  []OneClickRepayDebt  `json:"debtData"`
	RepayData []OneClickRepayRepay `json:"repayData"`
}

OneClickRepayCurrencyListV2 is the set of repayable debt currencies and the currencies available to repay them (v2).

type OneClickRepayDebt

type OneClickRepayDebt struct {
	DebtCurrency string          `json:"debtCcy"`
	DebtAmount   decimal.Decimal `json:"debtAmt"`
}

OneClickRepayDebt is a single debt currency and its outstanding amount.

type OneClickRepayHistory

type OneClickRepayHistory struct {
	DebtCurrency  string          `json:"debtCcy"`
	FillDebtSize  decimal.Decimal `json:"fillDebtSz"`
	RepayCurrency string          `json:"repayCcy"`
	FillRepaySize decimal.Decimal `json:"fillRepaySz"`
	Status        ConvertStatus   `json:"status"`
	UpdateTime    time.Time       `json:"uTime"`
}

OneClickRepayHistory is a single past one-click repay order.

type OneClickRepayHistoryV2

type OneClickRepayHistoryV2 struct {
	DebtCurrency      string                  `json:"debtCcy"`
	RepayCurrencyList []string                `json:"repayCcyList"`
	FillDebtSize      decimal.Decimal         `json:"fillDebtSz"`
	Status            ConvertStatus           `json:"status"`
	OrderIDInfo       []OneClickRepayOrderRef `json:"ordIdInfo"`
	Timestamp         time.Time               `json:"ts"`
}

OneClickRepayHistoryV2 is a single past one-click repay (v2) order.

type OneClickRepayOrderRef

type OneClickRepayOrderRef struct {
	OrderID      string          `json:"ordId"`
	InstrumentID string          `json:"instId"`
	OrderType    OrdType         `json:"ordType"`
	Side         Side            `json:"side"`
	Price        decimal.Decimal `json:"px"`
	Size         decimal.Decimal `json:"sz"`
	FillPrice    decimal.Decimal `json:"fillPx"`
	FillSize     decimal.Decimal `json:"fillSz"`
	State        OrdState        `json:"state"`
	CreationTime time.Time       `json:"cTime"`
}

OneClickRepayOrderRef is a single underlying order placed to execute a one-click repay (v2).

type OneClickRepayRepay

type OneClickRepayRepay struct {
	RepayCurrency string          `json:"repayCcy"`
	RepayAmount   decimal.Decimal `json:"repayAmt"`
}

OneClickRepayRepay is a single currency available to repay debt and its available balance.

type OneClickRepayResult

type OneClickRepayResult struct {
	Status        ConvertStatus   `json:"status"`
	DebtCurrency  string          `json:"debtCcy"`
	RepayCurrency string          `json:"repayCcy"`
	FillDebtSize  decimal.Decimal `json:"fillDebtSz"`
	FillRepaySize decimal.Decimal `json:"fillRepaySz"`
	UpdateTime    time.Time       `json:"uTime"`
}

OneClickRepayResult is the acknowledgement for a one-click repay order.

type OneClickRepayResultV2

type OneClickRepayResultV2 struct {
	DebtCurrency      string    `json:"debtCcy"`
	RepayCurrencyList []string  `json:"repayCcyList"`
	Timestamp         time.Time `json:"ts"`
}

OneClickRepayResultV2 is the acknowledgement for a one-click repay (v2) order.

type OpenInterest

type OpenInterest struct {
	InstrumentType       InstType        `json:"instType"`
	InstrumentID         string          `json:"instId"`
	OpenInterest         decimal.Decimal `json:"oi"`
	OpenInterestCurrency decimal.Decimal `json:"oiCcy"`
	OpenInterestUSD      decimal.Decimal `json:"oiUsd"`
	Timestamp            time.Time       `json:"ts"`
}

OpenInterest is an instrument's open interest.

type OptSummary

type OptSummary struct {
	InstrumentType     InstType        `json:"instType"`
	InstrumentID       string          `json:"instId"`
	Underlying         string          `json:"uly"`
	Delta              decimal.Decimal `json:"delta"`
	Gamma              decimal.Decimal `json:"gamma"`
	Theta              decimal.Decimal `json:"theta"`
	Vega               decimal.Decimal `json:"vega"`
	DeltaBS            decimal.Decimal `json:"deltaBS"`
	GammaBS            decimal.Decimal `json:"gammaBS"`
	ThetaBS            decimal.Decimal `json:"thetaBS"`
	VegaBS             decimal.Decimal `json:"vegaBS"`
	RealizedVolatility decimal.Decimal `json:"realVol"`
	BidVolatility      decimal.Decimal `json:"bidVol"`
	AskVolatility      decimal.Decimal `json:"askVol"`
	MarkVolatility     decimal.Decimal `json:"markVol"`
	Leverage           decimal.Decimal `json:"lever"`
	VolatilityLevel    decimal.Decimal `json:"volLv"`
	ForwardPrice       decimal.Decimal `json:"fwdPx"`
	Distance           decimal.Decimal `json:"distance"`
	BuyAPR             decimal.Decimal `json:"buyApr"`
	SellAPR            decimal.Decimal `json:"sellApr"`
	Timestamp          time.Time       `json:"ts"`
}

OptSummary is the greeks/IV summary of a single option instrument.

type OptType

type OptType string

OptType is an option type (call or put).

const (
	OptTypeCall OptType = "C"
	OptTypePut  OptType = "P"
)

type OptionFamilyInfo

type OptionFamilyInfo struct {
	InstrumentID string          `json:"instId"`
	TradeID      string          `json:"tradeId"`
	Price        decimal.Decimal `json:"px"`
	Size         decimal.Decimal `json:"sz"`
	Side         Side            `json:"side"`
	Timestamp    time.Time       `json:"ts"`
}

OptionFamilyInfo is one trade within an option instrument family.

type OptionFamilyTrades

type OptionFamilyTrades struct {
	OptionType OptType            `json:"optType"`
	Volume24h  decimal.Decimal    `json:"vol24h"`
	TradeInfo  []OptionFamilyInfo `json:"tradeInfo"`
}

OptionFamilyTrades groups recent option trades by option type and underlying 24h volume.

type OrdState

type OrdState string

OrdState is the lifecycle state of an order.

const (
	OrdStateLive            OrdState = "live"
	OrdStatePartiallyFilled OrdState = "partially_filled"
	OrdStateFilled          OrdState = "filled"
	OrdStateCanceled        OrdState = "canceled"
	OrdStateMMPCanceled     OrdState = "mmp_canceled"
)

type OrdType

type OrdType string

OrdType is an order type. It doubles as the time-in-force selector OKX folds into the order type (fok / ioc / post_only).

const (
	OrdTypeMarket          OrdType = "market"
	OrdTypeLimit           OrdType = "limit"
	OrdTypePostOnly        OrdType = "post_only"
	OrdTypeFOK             OrdType = "fok"
	OrdTypeIOC             OrdType = "ioc"
	OrdTypeOptimalLimitIOC OrdType = "optimal_limit_ioc"
	OrdTypeMMP             OrdType = "mmp"
	OrdTypeMMPAndPostOnly  OrdType = "mmp_and_post_only"
)

type Order

type Order struct {
	InstrumentType             InstType        `json:"instType"`
	InstrumentID               string          `json:"instId"`
	TargetCurrency             TgtCcy          `json:"tgtCcy"`
	Currency                   string          `json:"ccy"`
	OrderID                    string          `json:"ordId"`
	ClientOrderID              string          `json:"clOrdId"`
	Tag                        string          `json:"tag"`
	Price                      decimal.Decimal `json:"px"`
	PriceUSD                   decimal.Decimal `json:"pxUsd"`
	PriceVolatility            decimal.Decimal `json:"pxVol"`
	PriceType                  string          `json:"pxType"`
	Size                       decimal.Decimal `json:"sz"`
	Pnl                        decimal.Decimal `json:"pnl"`
	OrderType                  OrdType         `json:"ordType"`
	Side                       Side            `json:"side"`
	PositionSide               PosSide         `json:"posSide"`
	TradeMode                  TdMode          `json:"tdMode"`
	AccumulatedFillSize        decimal.Decimal `json:"accFillSz"`
	FillPrice                  decimal.Decimal `json:"fillPx"`
	TradeID                    string          `json:"tradeId"`
	FillSize                   decimal.Decimal `json:"fillSz"`
	FillTime                   time.Time       `json:"fillTime"`
	AveragePrice               decimal.Decimal `json:"avgPx"`
	State                      OrdState        `json:"state"`
	Leverage                   decimal.Decimal `json:"lever"`
	AttachAlgoClientOrderID    string          `json:"attachAlgoClOrdId"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx"`
	AttachAlgoOrders           []AttachAlgoOrd `json:"attachAlgoOrds"`
	STPID                      string          `json:"stpId"`
	STPMode                    string          `json:"stpMode"`
	FeeCurrency                string          `json:"feeCcy"`
	Fee                        decimal.Decimal `json:"fee"`
	RebateCurrency             string          `json:"rebateCcy"`
	Rebate                     decimal.Decimal `json:"rebate"`
	Source                     string          `json:"source"`
	Category                   string          `json:"category"`
	ReduceOnly                 string          `json:"reduceOnly"` // OKX sends a quoted "true"/"false"
	CancelSource               string          `json:"cancelSource"`
	CancelSourceReason         string          `json:"cancelSourceReason"`
	QuickMarginType            string          `json:"quickMgnType"`
	AlgoClientOrderID          string          `json:"algoClOrdId"`
	AlgoID                     string          `json:"algoId"`
	IsTakeProfitLimit          string          `json:"isTpLimit"`
	Outcome                    string          `json:"outcome"`
	LinkedAlgoOrder            OrderLinkedAlgo `json:"linkedAlgoOrd"`
	UpdateTime                 time.Time       `json:"uTime"`
	CreationTime               time.Time       `json:"cTime"`
	TradeQuoteCurrency         string          `json:"tradeQuoteCcy"`
}

Order is a single order record returned by the order / orders-pending / orders-history(-archive) endpoints. The validating account had no order history, so the field set is modeled from the OKX doc field table.

type OrderArg

type OrderArg struct {
	InstrumentID               string          `json:"instId"`
	TradeMode                  TdMode          `json:"tdMode"`
	Side                       Side            `json:"side"`
	OrderType                  OrdType         `json:"ordType"`
	Size                       decimal.Decimal `json:"sz"`
	Currency                   string          `json:"ccy,omitempty"`
	ClientOrderID              string          `json:"clOrdId,omitempty"`
	Tag                        string          `json:"tag,omitempty"`
	PositionSide               PosSide         `json:"posSide,omitempty"`
	Price                      decimal.Decimal `json:"px,omitzero"`
	PriceUSD                   decimal.Decimal `json:"pxUsd,omitzero"`
	PriceVolatility            decimal.Decimal `json:"pxVol,omitzero"`
	ReduceOnly                 bool            `json:"reduceOnly,omitempty"`
	TargetCurrency             TgtCcy          `json:"tgtCcy,omitempty"`
	BanAmend                   bool            `json:"banAmend,omitempty"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx,omitzero"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx,omitzero"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx,omitzero"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx,omitzero"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType,omitempty"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType,omitempty"`
	QuickMarginType            string          `json:"quickMgnType,omitempty"`
	STPID                      string          `json:"stpId,omitempty"`
	STPMode                    string          `json:"stpMode,omitempty"`
	AttachAlgoOrders           []AttachAlgoOrd `json:"attachAlgoOrds,omitempty"`
}

OrderArg is one order leg of a batch place-orders request body. It mirrors the single place-order body and is used by NewBatchOrdersService and NewPlaceOrderService.

type OrderBook

type OrderBook struct {
	Asks       [][]string `json:"asks"`
	Bids       [][]string `json:"bids"`
	Timestamp  time.Time  `json:"ts"`
	SequenceID int64      `json:"seqId"`
}

OrderBook is an order book snapshot. Each ask/bid level is [price, size, deprecated("0"), numOrders] for /books and [price, size, numOrders] for /books-full.

type OrderLinkedAlgo

type OrderLinkedAlgo struct {
	AlgoID string `json:"algoId"`
}

OrderLinkedAlgo is the algo order linked to a regular order (returned by order-info as a nested object).

type OrderPrecheck

type OrderPrecheck struct {
	AdjustedEquity            decimal.Decimal `json:"adjEq"`
	AdjustedEquityChange      decimal.Decimal `json:"adjEqChg"`
	AvailableBalance          decimal.Decimal `json:"availBal"`
	AvailableBalanceChange    decimal.Decimal `json:"availBalChg"`
	IMR                       decimal.Decimal `json:"imr"`
	IMRChange                 decimal.Decimal `json:"imrChg"`
	Borrowed                  decimal.Decimal `json:"borrowed"`
	Liability                 decimal.Decimal `json:"liab"`
	LiabilityChange           decimal.Decimal `json:"liabChg"`
	LiabilityChangeCurrency   string          `json:"liabChgCcy"`
	LiquidationPrice          decimal.Decimal `json:"liqPx"`
	LiquidationPriceDiff      decimal.Decimal `json:"liqPxDiff"`
	LiquidationPriceDiffRatio decimal.Decimal `json:"liqPxDiffRatio"`
	Margin                    decimal.Decimal `json:"mgn"`
	MarginRatio               decimal.Decimal `json:"mgnRatio"`
	MarginRatioChange         decimal.Decimal `json:"mgnRatioChg"`
	MMR                       decimal.Decimal `json:"mmr"`
	MMRChange                 decimal.Decimal `json:"mmrChg"`
	PositionBalance           decimal.Decimal `json:"posBal"`
	PositionBalanceChange     decimal.Decimal `json:"posBalChg"`
	Type                      string          `json:"type"`
}

OrderPrecheck is the estimated account impact of a hypothetical order.

type OrderPrecheckService

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

OrderPrecheckService -- POST /api/v5/trade/order-precheck (Trade)

Pre-checks the account-level impact (estimated margin, available balance, liquidation price) of placing an order without actually placing it.

func (*OrderPrecheckService) Do

func (*OrderPrecheckService) SetAttachAlgoOrds

func (s *OrderPrecheckService) SetAttachAlgoOrds(orders []AttachAlgoOrd) *OrderPrecheckService

SetAttachAlgoOrds attaches take-profit / stop-loss algo orders for the check.

func (*OrderPrecheckService) SetPosSide

func (s *OrderPrecheckService) SetPosSide(posSide PosSide) *OrderPrecheckService

SetPosSide sets the position side (long/short/net).

func (*OrderPrecheckService) SetPx

SetPx sets the order price (required for limit-type orders).

func (*OrderPrecheckService) SetReduceOnly

func (s *OrderPrecheckService) SetReduceOnly(reduceOnly bool) *OrderPrecheckService

SetReduceOnly toggles reduce-only.

func (*OrderPrecheckService) SetTgtCcy

func (s *OrderPrecheckService) SetTgtCcy(tgtCcy TgtCcy) *OrderPrecheckService

SetTgtCcy selects the unit of a spot market order's size (base_ccy/quote_ccy).

type OrderResult

type OrderResult struct {
	OrderID       string    `json:"ordId"`
	ClientOrderID string    `json:"clOrdId"`
	Tag           string    `json:"tag"`
	Timestamp     time.Time `json:"ts"`
	SCode         string    `json:"sCode"`
	SMsg          string    `json:"sMsg"`
}

OrderResult is the ack returned by the place / batch-place / cancel / batch-cancel order endpoints. The real per-item status lives in sCode/sMsg.

func (OrderResult) Err added in v0.20260623.1

func (r OrderResult) Err() error

Err returns the per-item API error each batch result carries, or nil when that item succeeded.

type PlaceAlgoOrderService

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

PlaceAlgoOrderService -- POST /api/v5/trade/order-algo (Trade)

Places a single algo (trigger / advanced) order: conditional, oco, trigger, move_order_stop (trailing), twap, iceberg or chase. The required body fields (instId, tdMode, side, ordType, sz) are constructor args; the many type-specific fields are optional setters.

func (*PlaceAlgoOrderService) Do

func (*PlaceAlgoOrderService) SetActivePx

SetActivePx sets the activation price (move_order_stop).

func (*PlaceAlgoOrderService) SetAdvChaseParams added in v0.20260723.0

func (s *PlaceAlgoOrderService) SetAdvChaseParams(params []AdvChaseParam) *PlaceAlgoOrderService

SetAdvChaseParams sets the chase parameters carried by a trigger order whose advanceOrdType is "chase" (FUTURES/SWAP).

func (*PlaceAlgoOrderService) SetAdvanceOrdType added in v0.20260723.0

func (s *PlaceAlgoOrderService) SetAdvanceOrdType(advanceOrdType string) *PlaceAlgoOrderService

SetAdvanceOrdType sets the order type spawned when a FUTURES/SWAP trigger order fires. Value "chase" makes the triggered order a chase limit order; ordPx is then not required and the chase parameters come from SetAdvChaseParams.

func (*PlaceAlgoOrderService) SetAlgoClOrdId

func (s *PlaceAlgoOrderService) SetAlgoClOrdId(algoClOrdId string) *PlaceAlgoOrderService

SetAlgoClOrdId sets a client-supplied algo order id.

func (*PlaceAlgoOrderService) SetAttachAlgoOrds

func (s *PlaceAlgoOrderService) SetAttachAlgoOrds(ords []AlgoAttachOrd) *PlaceAlgoOrderService

SetAttachAlgoOrds attaches a list of TP/SL orders to a trigger order.

func (*PlaceAlgoOrderService) SetCallbackRatio

func (s *PlaceAlgoOrderService) SetCallbackRatio(ratio decimal.Decimal) *PlaceAlgoOrderService

SetCallbackRatio sets the trailing callback ratio (move_order_stop).

func (*PlaceAlgoOrderService) SetCallbackSpread

func (s *PlaceAlgoOrderService) SetCallbackSpread(spread decimal.Decimal) *PlaceAlgoOrderService

SetCallbackSpread sets the trailing callback spread (move_order_stop).

func (*PlaceAlgoOrderService) SetCcy

SetCcy sets the margin currency (single-currency margin only).

func (*PlaceAlgoOrderService) SetChaseType

func (s *PlaceAlgoOrderService) SetChaseType(chaseType string) *PlaceAlgoOrderService

SetChaseType sets the chase distance type (distance / ratio).

func (*PlaceAlgoOrderService) SetChaseVal

SetChaseVal sets the chase distance value (chase).

func (*PlaceAlgoOrderService) SetClOrdId

func (s *PlaceAlgoOrderService) SetClOrdId(clOrdId string) *PlaceAlgoOrderService

SetClOrdId sets a client-supplied order id for the resulting order.

func (*PlaceAlgoOrderService) SetCxlOnClosePos

func (s *PlaceAlgoOrderService) SetCxlOnClosePos(cxl bool) *PlaceAlgoOrderService

SetCxlOnClosePos toggles whether the algo order is canceled when the position is fully closed (only for TP/SL orders bound to a position).

func (*PlaceAlgoOrderService) SetMaxChaseType

func (s *PlaceAlgoOrderService) SetMaxChaseType(maxChaseType string) *PlaceAlgoOrderService

SetMaxChaseType sets the max-chase distance type (distance / ratio).

func (*PlaceAlgoOrderService) SetMaxChaseVal

SetMaxChaseVal sets the max-chase distance value (chase).

func (*PlaceAlgoOrderService) SetOrdPx

SetOrdPx sets the order price for trigger/iceberg/twap ("-1" for market).

func (*PlaceAlgoOrderService) SetPosSide

func (s *PlaceAlgoOrderService) SetPosSide(posSide PosSide) *PlaceAlgoOrderService

SetPosSide sets the position side (long/short/net).

func (*PlaceAlgoOrderService) SetPxLimit

SetPxLimit sets the price limit per child order (iceberg/twap).

func (*PlaceAlgoOrderService) SetPxSpread

func (s *PlaceAlgoOrderService) SetPxSpread(pxSpread decimal.Decimal) *PlaceAlgoOrderService

SetPxSpread sets the price variance per child order (iceberg/twap, absolute).

func (*PlaceAlgoOrderService) SetPxVar

SetPxVar sets the price ratio versus the latest price (iceberg/twap, % offset).

func (*PlaceAlgoOrderService) SetQuickMgnType

func (s *PlaceAlgoOrderService) SetQuickMgnType(quickMgnType string) *PlaceAlgoOrderService

SetQuickMgnType sets the quick-margin borrow type (manual/auto_borrow/auto_borrow_repay).

func (*PlaceAlgoOrderService) SetReduceOnly

func (s *PlaceAlgoOrderService) SetReduceOnly(reduceOnly bool) *PlaceAlgoOrderService

SetReduceOnly toggles reduce-only (MARGIN/FUTURES/SWAP).

func (*PlaceAlgoOrderService) SetSlOrdPx

SetSlOrdPx sets the stop-loss order price ("-1" for market).

func (*PlaceAlgoOrderService) SetSlTriggerPx

SetSlTriggerPx sets the stop-loss trigger price (conditional/oco).

func (*PlaceAlgoOrderService) SetSlTriggerPxType

func (s *PlaceAlgoOrderService) SetSlTriggerPxType(pxType string) *PlaceAlgoOrderService

SetSlTriggerPxType sets the stop-loss trigger price type (last/index/mark).

func (*PlaceAlgoOrderService) SetSzLimit

SetSzLimit sets the average amount per child order (iceberg/twap).

func (*PlaceAlgoOrderService) SetTag

SetTag sets an order tag.

func (*PlaceAlgoOrderService) SetTgtCcy

func (s *PlaceAlgoOrderService) SetTgtCcy(tgtCcy TgtCcy) *PlaceAlgoOrderService

SetTgtCcy sets the spot market size unit (base_ccy / quote_ccy).

func (*PlaceAlgoOrderService) SetTimeInterval

func (s *PlaceAlgoOrderService) SetTimeInterval(seconds int) *PlaceAlgoOrderService

SetTimeInterval sets the interval in seconds between child orders (twap).

func (*PlaceAlgoOrderService) SetTpOrdKind

func (s *PlaceAlgoOrderService) SetTpOrdKind(kind string) *PlaceAlgoOrderService

SetTpOrdKind sets the take-profit order kind (condition / limit).

func (*PlaceAlgoOrderService) SetTpOrdPx

SetTpOrdPx sets the take-profit order price ("-1" for market).

func (*PlaceAlgoOrderService) SetTpTriggerPx

SetTpTriggerPx sets the take-profit trigger price (conditional/oco).

func (*PlaceAlgoOrderService) SetTpTriggerPxType

func (s *PlaceAlgoOrderService) SetTpTriggerPxType(pxType string) *PlaceAlgoOrderService

SetTpTriggerPxType sets the take-profit trigger price type (last/index/mark).

func (*PlaceAlgoOrderService) SetTriggerPx

SetTriggerPx sets the trigger price (trigger ordType).

func (*PlaceAlgoOrderService) SetTriggerPxType

func (s *PlaceAlgoOrderService) SetTriggerPxType(pxType string) *PlaceAlgoOrderService

SetTriggerPxType sets the trigger price type (last/index/mark).

type PlaceCopyLeadStopOrderService

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

PlaceCopyLeadStopOrderService -- POST /api/v5/copytrading/place-lead-stop-order (Trade)

Places a take-profit / stop-loss order against a lead trader's sub-position.

func (*PlaceCopyLeadStopOrderService) Do

func (*PlaceCopyLeadStopOrderService) SetSlTriggerPx

SetSlTriggerPx sets the stop-loss trigger price.

func (*PlaceCopyLeadStopOrderService) SetSlTriggerPxType

SetSlTriggerPxType sets the stop-loss trigger price type (last/index/mark).

func (*PlaceCopyLeadStopOrderService) SetTpTriggerPx

SetTpTriggerPx sets the take-profit trigger price.

func (*PlaceCopyLeadStopOrderService) SetTpTriggerPxType

SetTpTriggerPxType sets the take-profit trigger price type (last/index/mark).

type PlaceEasyConvertService

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

PlaceEasyConvertService -- POST /api/v5/trade/easy-convert (Trade)

Converts up to five small-balance ("dust") currencies into a single mainstream currency. State-changing: implemented but never executed by tests.

func (*PlaceEasyConvertService) Do

func (*PlaceEasyConvertService) SetSource

SetSource sets the funding source: "1" (trading account, default) or "2" (funding account).

type PlaceFixedLoanLendingOrderService

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

PlaceFixedLoanLendingOrderService -- POST /api/v5/finance/fixed-loan/lending-order (Trade)

Places a fixed-loan lending order. State-changing: implemented but never executed by the test suite. The acknowledgement shape is modeled from the OKX doc field table.

func (*PlaceFixedLoanLendingOrderService) Do

func (*PlaceFixedLoanLendingOrderService) SetAutoRenewal

SetAutoRenewal enables auto-renewal of the lending order on maturity.

type PlaceGridAlgoOrderService

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

PlaceGridAlgoOrderService -- POST /api/v5/tradingBot/grid/order-algo (Trade)

Places a new spot/margin grid ("grid") or contract grid ("contract_grid") algo order. IMPLEMENT-ONLY: never executed during validation (real account).

func (*PlaceGridAlgoOrderService) Do

func (*PlaceGridAlgoOrderService) SetAlgoClOrdId

func (s *PlaceGridAlgoOrderService) SetAlgoClOrdId(algoClOrdId string) *PlaceGridAlgoOrderService

SetAlgoClOrdId sets a client-supplied algo order id.

func (*PlaceGridAlgoOrderService) SetBasePos

SetBasePos toggles whether to open a base position immediately (contract grid).

func (*PlaceGridAlgoOrderService) SetBaseSz

SetBaseSz sets the invested amount in the base currency (spot grid).

func (*PlaceGridAlgoOrderService) SetCcy

SetCcy sets the margin currency (margin grid).

func (*PlaceGridAlgoOrderService) SetDirection

SetDirection sets the contract grid direction (long/short/neutral).

func (*PlaceGridAlgoOrderService) SetLever

SetLever sets the leverage (contract grid).

func (*PlaceGridAlgoOrderService) SetProfitSharingRatio

func (s *PlaceGridAlgoOrderService) SetProfitSharingRatio(ratio decimal.Decimal) *PlaceGridAlgoOrderService

SetProfitSharingRatio sets the profit-sharing ratio (copy-trading leaders).

func (*PlaceGridAlgoOrderService) SetQuoteSz

SetQuoteSz sets the invested amount in the quote currency (spot grid).

func (*PlaceGridAlgoOrderService) SetRunType

SetRunType sets the grid spacing mode ("1" arithmetic, "2" geometric).

func (*PlaceGridAlgoOrderService) SetSlRatio

SetSlRatio sets the stop-loss ratio (contract grid).

func (*PlaceGridAlgoOrderService) SetSlTriggerPx

SetSlTriggerPx sets the stop-loss trigger price (spot grid).

func (*PlaceGridAlgoOrderService) SetSz

SetSz sets the invested margin amount (contract grid).

func (*PlaceGridAlgoOrderService) SetTag

SetTag sets an order tag.

func (*PlaceGridAlgoOrderService) SetTdMode

SetTdMode sets the trade mode (cross/isolated for margin grid; cash for spot).

func (*PlaceGridAlgoOrderService) SetTpRatio

SetTpRatio sets the take-profit ratio (contract grid).

func (*PlaceGridAlgoOrderService) SetTpTriggerPx

SetTpTriggerPx sets the take-profit trigger price (spot grid).

type PlaceOrderService

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

PlaceOrderService -- POST /api/v5/trade/order (Trade)

Places a single order. OKX may report failure with a top-level code "1" and the real reason in data[0].sCode, so the ack is read via DoListPartial and the first (only) element is returned, preserving sCode/sMsg.

func (*PlaceOrderService) Do

func (*PlaceOrderService) SetAttachAlgoOrds

func (s *PlaceOrderService) SetAttachAlgoOrds(orders []AttachAlgoOrd) *PlaceOrderService

SetAttachAlgoOrds attaches take-profit / stop-loss algo orders.

func (*PlaceOrderService) SetBanAmend

func (s *PlaceOrderService) SetBanAmend(banAmend bool) *PlaceOrderService

SetBanAmend forbids the order from being amended by the system on self-fill.

func (*PlaceOrderService) SetCcy

func (s *PlaceOrderService) SetCcy(ccy string) *PlaceOrderService

SetCcy sets the margin currency (single-currency margin mode only).

func (*PlaceOrderService) SetClOrdId

func (s *PlaceOrderService) SetClOrdId(clOrdId string) *PlaceOrderService

SetClOrdId sets the client-supplied order id.

func (*PlaceOrderService) SetPosSide

func (s *PlaceOrderService) SetPosSide(posSide PosSide) *PlaceOrderService

SetPosSide sets the position side (long/short/net).

func (*PlaceOrderService) SetPx

SetPx sets the limit price (required for limit-type orders).

func (*PlaceOrderService) SetQuickMgnType

func (s *PlaceOrderService) SetQuickMgnType(quickMgnType string) *PlaceOrderService

SetQuickMgnType sets the quick-margin type (manual/auto_borrow/auto_borrow_repay).

func (*PlaceOrderService) SetReduceOnly

func (s *PlaceOrderService) SetReduceOnly(reduceOnly bool) *PlaceOrderService

SetReduceOnly toggles reduce-only (cross MARGIN / FUTURES / SWAP).

func (*PlaceOrderService) SetSlOrdPx

SetSlOrdPx sets the stop-loss order price ("-1" for market).

func (*PlaceOrderService) SetSlTriggerPx

func (s *PlaceOrderService) SetSlTriggerPx(px decimal.Decimal) *PlaceOrderService

SetSlTriggerPx sets the stop-loss trigger price.

func (*PlaceOrderService) SetSlTriggerPxType

func (s *PlaceOrderService) SetSlTriggerPxType(pxType string) *PlaceOrderService

SetSlTriggerPxType sets the stop-loss trigger price type (last/index/mark).

func (*PlaceOrderService) SetStpId

func (s *PlaceOrderService) SetStpId(stpId string) *PlaceOrderService

SetStpId sets the self-trade-prevention id.

func (*PlaceOrderService) SetStpMode

func (s *PlaceOrderService) SetStpMode(stpMode string) *PlaceOrderService

SetStpMode sets the self-trade-prevention mode (cancel_maker/cancel_taker/cancel_both).

func (*PlaceOrderService) SetTag

func (s *PlaceOrderService) SetTag(tag string) *PlaceOrderService

SetTag sets the order tag.

func (*PlaceOrderService) SetTgtCcy

func (s *PlaceOrderService) SetTgtCcy(tgtCcy TgtCcy) *PlaceOrderService

SetTgtCcy selects the unit of a spot market order's size (base_ccy/quote_ccy).

func (*PlaceOrderService) SetTpOrdPx

SetTpOrdPx sets the take-profit order price ("-1" for market).

func (*PlaceOrderService) SetTpTriggerPx

func (s *PlaceOrderService) SetTpTriggerPx(px decimal.Decimal) *PlaceOrderService

SetTpTriggerPx sets the take-profit trigger price.

func (*PlaceOrderService) SetTpTriggerPxType

func (s *PlaceOrderService) SetTpTriggerPxType(pxType string) *PlaceOrderService

SetTpTriggerPxType sets the take-profit trigger price type (last/index/mark).

type PlaceRecurringOrderService

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

PlaceRecurringOrderService -- POST /api/v5/tradingBot/recurring/order-algo (Trade)

Creates a recurring-buy (DCA) strategy that invests amt of investmentCcy across recurringList on the configured period/day/time.

func (*PlaceRecurringOrderService) Do

func (*PlaceRecurringOrderService) SetAlgoClOrdId

func (s *PlaceRecurringOrderService) SetAlgoClOrdId(algoClOrdId string) *PlaceRecurringOrderService

SetAlgoClOrdId sets a client-supplied strategy id.

func (*PlaceRecurringOrderService) SetRecurringDay

func (s *PlaceRecurringOrderService) SetRecurringDay(recurringDay string) *PlaceRecurringOrderService

SetRecurringDay sets the day of the recurring buy. Required when period is "weekly" (1-7) or "monthly" (1-28).

func (*PlaceRecurringOrderService) SetRecurringHour

func (s *PlaceRecurringOrderService) SetRecurringHour(recurringHour string) *PlaceRecurringOrderService

SetRecurringHour sets the hour of the recurring buy ("0"/"6"/"12"/"18"), required when period is "hourly".

func (*PlaceRecurringOrderService) SetTag

SetTag sets an order tag for the strategy.

type PlaceSprdOrderAlgoService

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

PlaceSprdOrderAlgoService -- POST /api/v5/sprd/order-algo (Trade)

Places a spread algo (e.g. TWAP) order. sprdId, side, ordType and sz are required; the remaining params depend on the algo order type.

func (*PlaceSprdOrderAlgoService) Do

func (*PlaceSprdOrderAlgoService) SetAlgoClOrdId

func (s *PlaceSprdOrderAlgoService) SetAlgoClOrdId(algoClOrdId string) *PlaceSprdOrderAlgoService

SetAlgoClOrdId sets a client-supplied algo order id.

func (*PlaceSprdOrderAlgoService) SetPxLimit

SetPxLimit sets the limit price (TWAP).

func (*PlaceSprdOrderAlgoService) SetPxSpread

SetPxSpread sets the price spread (TWAP).

func (*PlaceSprdOrderAlgoService) SetPxVar

SetPxVar sets the price variance (TWAP).

func (*PlaceSprdOrderAlgoService) SetSzLimit

SetSzLimit sets the per-interval size limit (TWAP).

func (*PlaceSprdOrderAlgoService) SetTag

SetTag sets an order tag.

func (*PlaceSprdOrderAlgoService) SetTimeInterval

func (s *PlaceSprdOrderAlgoService) SetTimeInterval(timeInterval string) *PlaceSprdOrderAlgoService

SetTimeInterval sets the order interval in seconds (TWAP).

type PlaceSprdOrderService

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

PlaceSprdOrderService -- POST /api/v5/sprd/order (Trade)

Places a spread order. sprdId, side, ordType and sz are required; px is required for limit / post_only / ioc orders.

func (*PlaceSprdOrderService) Do

func (*PlaceSprdOrderService) SetClOrdId

func (s *PlaceSprdOrderService) SetClOrdId(clOrdId string) *PlaceSprdOrderService

SetClOrdId sets a client-supplied order id.

func (*PlaceSprdOrderService) SetPx

SetPx sets the order price (required for limit / post_only / ioc).

func (*PlaceSprdOrderService) SetTag

SetTag sets an order tag.

type Platform24Volume

type Platform24Volume struct {
	VolumeUSD decimal.Decimal `json:"volUsd"`
	VolumeCNY decimal.Decimal `json:"volCny"`
	Timestamp time.Time       `json:"ts"`
}

Platform24Volume is the platform-wide 24h trading volume in CNY and USD.

type PosMode

type PosMode string

PosMode is the account-wide position mode (long/short hedging vs net).

const (
	PosModeLongShort PosMode = "long_short_mode"
	PosModeNet       PosMode = "net_mode"
)

type PosSide

type PosSide string

PosSide is a position side. "net" is used in net mode; "long"/"short" in long/short mode.

const (
	PosSideLong  PosSide = "long"
	PosSideShort PosSide = "short"
	PosSideNet   PosSide = "net"
)

type Position

type Position struct {
	InstrumentType                  InstType                 `json:"instType"`
	MarginMode                      MgnMode                  `json:"mgnMode"`
	PositionID                      string                   `json:"posId"`
	PositionSide                    PosSide                  `json:"posSide"`
	Position                        decimal.Decimal          `json:"pos"`
	BaseBalance                     decimal.Decimal          `json:"baseBal"`
	QuoteBalance                    decimal.Decimal          `json:"quoteBal"`
	BaseBorrowed                    decimal.Decimal          `json:"baseBorrowed"`
	BaseInterest                    decimal.Decimal          `json:"baseInterest"`
	QuoteBorrowed                   decimal.Decimal          `json:"quoteBorrowed"`
	QuoteInterest                   decimal.Decimal          `json:"quoteInterest"`
	PositionCurrency                string                   `json:"posCcy"`
	AvailablePosition               decimal.Decimal          `json:"availPos"`
	AveragePrice                    decimal.Decimal          `json:"avgPx"`
	NonSettleAveragePrice           decimal.Decimal          `json:"nonSettleAvgPx"`
	MarkPrice                       decimal.Decimal          `json:"markPx"`
	UPL                             decimal.Decimal          `json:"upl"`
	UPLRatio                        decimal.Decimal          `json:"uplRatio"`
	UPLLastPrice                    decimal.Decimal          `json:"uplLastPx"`
	UPLRatioLastPrice               decimal.Decimal          `json:"uplRatioLastPx"`
	InstrumentID                    string                   `json:"instId"`
	Leverage                        decimal.Decimal          `json:"lever"`
	LiquidationPrice                decimal.Decimal          `json:"liqPx"`
	IMR                             decimal.Decimal          `json:"imr"`
	Margin                          decimal.Decimal          `json:"margin"`
	MarginRatio                     decimal.Decimal          `json:"mgnRatio"`
	MMR                             decimal.Decimal          `json:"mmr"`
	Liability                       decimal.Decimal          `json:"liab"`
	LiabilityCurrency               string                   `json:"liabCcy"`
	Interest                        decimal.Decimal          `json:"interest"`
	TradeID                         string                   `json:"tradeId"`
	OptionValue                     decimal.Decimal          `json:"optVal"`
	PendingCloseOrderLiabilityValue decimal.Decimal          `json:"pendingCloseOrdLiabVal"`
	NotionalUSD                     decimal.Decimal          `json:"notionalUsd"`
	ADL                             decimal.Decimal          `json:"adl"`
	Currency                        string                   `json:"ccy"`
	Last                            decimal.Decimal          `json:"last"`
	IndexPrice                      decimal.Decimal          `json:"idxPx"`
	USDPrice                        decimal.Decimal          `json:"usdPx"`
	BreakEvenPrice                  decimal.Decimal          `json:"bePx"`
	DeltaBS                         decimal.Decimal          `json:"deltaBS"`
	DeltaPA                         decimal.Decimal          `json:"deltaPA"`
	GammaBS                         decimal.Decimal          `json:"gammaBS"`
	GammaPA                         decimal.Decimal          `json:"gammaPA"`
	ThetaBS                         decimal.Decimal          `json:"thetaBS"`
	ThetaPA                         decimal.Decimal          `json:"thetaPA"`
	VegaBS                          decimal.Decimal          `json:"vegaBS"`
	VegaPA                          decimal.Decimal          `json:"vegaPA"`
	SpotInUseAmount                 decimal.Decimal          `json:"spotInUseAmt"`
	SpotInUseCurrency               string                   `json:"spotInUseCcy"`
	ClientSpotInUseAmount           decimal.Decimal          `json:"clSpotInUseAmt"`
	MaxSpotInUseAmount              decimal.Decimal          `json:"maxSpotInUseAmt"`
	RealizedPnl                     decimal.Decimal          `json:"realizedPnl"`
	SettledPnl                      decimal.Decimal          `json:"settledPnl"`
	Pnl                             decimal.Decimal          `json:"pnl"`
	Fee                             decimal.Decimal          `json:"fee"`
	FundingFee                      decimal.Decimal          `json:"fundingFee"`
	LiquidationPenalty              decimal.Decimal          `json:"liqPenalty"`
	CloseOrderAlgo                  []PositionCloseOrderAlgo `json:"closeOrderAlgo"`
	CreationTime                    time.Time                `json:"cTime"`
	UpdateTime                      time.Time                `json:"uTime"`
	BusinessReferenceID             string                   `json:"bizRefId"`
	BusinessReferenceType           string                   `json:"bizRefType"`
}

Position is a single open position. The account used to validate this SDK had no open positions, so the field set is modeled from the OKX doc field table.

type PositionBuilder

type PositionBuilder struct {
	Equity          decimal.Decimal           `json:"eq"`
	TotalMMR        decimal.Decimal           `json:"totalMmr"`
	TotalIMR        decimal.Decimal           `json:"totalImr"`
	BorrowMMR       decimal.Decimal           `json:"borrowMmr"`
	DerivativesMMR  decimal.Decimal           `json:"derivMmr"`
	MarginRatio     decimal.Decimal           `json:"marginRatio"`
	UPL             decimal.Decimal           `json:"upl"`
	AccountLeverage decimal.Decimal           `json:"acctLever"`
	Timestamp       time.Time                 `json:"ts"`
	Assets          []PositionBuilderAsset    `json:"assets"`
	RiskUnitData    []PositionBuilderRiskUnit `json:"riskUnitData"`
	Positions       []PositionBuilderPosition `json:"positions"`
}

PositionBuilder is the result of a portfolio-margin simulation.

type PositionBuilderAsset

type PositionBuilderAsset struct {
	Currency        string          `json:"ccy"`
	AvailableEquity decimal.Decimal `json:"availEq"`
	SpotInUse       decimal.Decimal `json:"spotInUse"`
	BorrowMMR       decimal.Decimal `json:"borrowMmr"`
	BorrowIMR       decimal.Decimal `json:"borrowImr"`
}

PositionBuilderAsset is one asset row of a position-builder simulation.

type PositionBuilderMr1Scenarios

type PositionBuilderMr1Scenarios struct {
	VolatilityShockDown map[string]string `json:"volShockDown"`
	VolatilitySame      map[string]string `json:"volSame"`
	VolatilityShockUp   map[string]string `json:"volShockUp"`
}

PositionBuilderMr1Scenarios holds the MR1 stress-test P&L grids keyed by price volatility ratio (a "change" -> "value" map per volatility shock direction).

type PositionBuilderMr6FinalResult

type PositionBuilderMr6FinalResult struct {
	Pnl       decimal.Decimal `json:"pnl"`
	SpotShock decimal.Decimal `json:"spotShock"`
}

PositionBuilderMr6FinalResult is the worst-case MR6 scenario.

type PositionBuilderMrFinalResult

type PositionBuilderMrFinalResult struct {
	Pnl             decimal.Decimal `json:"pnl"`
	SpotShock       decimal.Decimal `json:"spotShock"`
	VolatilityShock string          `json:"volShock"`
}

PositionBuilderMrFinalResult is the worst-case MR1 scenario.

type PositionBuilderPortfolio

type PositionBuilderPortfolio struct {
	InstrumentID    string          `json:"instId"`
	InstrumentType  InstType        `json:"instType"`
	Amount          decimal.Decimal `json:"amt"`
	PositionSide    PosSide         `json:"posSide"`
	AveragePrice    decimal.Decimal `json:"avgPx"`
	MarkPriceBefore decimal.Decimal `json:"markPxBf"`
	MarkPrice       decimal.Decimal `json:"markPx"`
	FloatPnl        decimal.Decimal `json:"floatPnl"`
	NotionalUSD     decimal.Decimal `json:"notionalUsd"`
	Delta           decimal.Decimal `json:"delta"`
	Gamma           decimal.Decimal `json:"gamma"`
	Theta           decimal.Decimal `json:"theta"`
	Vega            decimal.Decimal `json:"vega"`
	IsRealPosition  bool            `json:"isRealPos"`
}

PositionBuilderPortfolio is one instrument within a risk unit (portfolio margin only).

type PositionBuilderPosition

type PositionBuilderPosition struct {
	InstrumentID    string          `json:"instId"`
	InstrumentType  InstType        `json:"instType"`
	Amount          decimal.Decimal `json:"amt"`
	PositionSide    PosSide         `json:"posSide"`
	AveragePrice    decimal.Decimal `json:"avgPx"`
	MarkPriceBefore decimal.Decimal `json:"markPxBf"`
	MarkPrice       decimal.Decimal `json:"markPx"`
	FloatPnl        decimal.Decimal `json:"floatPnl"`
	IMRBefore       decimal.Decimal `json:"imrBf"`
	IMR             decimal.Decimal `json:"imr"`
	MarginRatio     decimal.Decimal `json:"mgnRatio"`
	Leverage        decimal.Decimal `json:"lever"`
	NotionalUSD     decimal.Decimal `json:"notionalUsd"`
	IsRealPosition  bool            `json:"isRealPos"`
}

PositionBuilderPosition is one position row (multi-currency margin only).

type PositionBuilderRiskUnit

type PositionBuilderRiskUnit struct {
	RiskUnit       string                        `json:"riskUnit"`
	MMRBefore      decimal.Decimal               `json:"mmrBf"`
	MMR            decimal.Decimal               `json:"mmr"`
	IMRBefore      decimal.Decimal               `json:"imrBf"`
	IMR            decimal.Decimal               `json:"imr"`
	UPL            decimal.Decimal               `json:"upl"`
	Mr1            decimal.Decimal               `json:"mr1"`
	Mr2            decimal.Decimal               `json:"mr2"`
	Mr3            decimal.Decimal               `json:"mr3"`
	Mr4            decimal.Decimal               `json:"mr4"`
	Mr5            decimal.Decimal               `json:"mr5"`
	Mr6            decimal.Decimal               `json:"mr6"`
	Mr7            decimal.Decimal               `json:"mr7"`
	Mr8            decimal.Decimal               `json:"mr8"`
	Mr9            decimal.Decimal               `json:"mr9"`
	Mr1Scenarios   PositionBuilderMr1Scenarios   `json:"mr1Scenarios"`
	Mr1FinalResult PositionBuilderMrFinalResult  `json:"mr1FinalResult"`
	Mr6FinalResult PositionBuilderMr6FinalResult `json:"mr6FinalResult"`
	Delta          decimal.Decimal               `json:"delta"`
	Gamma          decimal.Decimal               `json:"gamma"`
	Theta          decimal.Decimal               `json:"theta"`
	Vega           decimal.Decimal               `json:"vega"`
	Portfolios     []PositionBuilderPortfolio    `json:"portfolios"`
}

PositionBuilderRiskUnit is one risk-unit row of a position-builder simulation.

type PositionBuilderService

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

PositionBuilderService -- POST /api/v5/account/position-builder (Read)

Simulates portfolio-margin risk for a hypothetical set of positions and assets, returning the resulting margin requirements and greeks. This is a read-only simulation that does not change account state.

func (*PositionBuilderService) Do

func (*PositionBuilderService) SetAcctLv

SetAcctLv sets the simulated account mode.

func (*PositionBuilderService) SetGreeksType

func (s *PositionBuilderService) SetGreeksType(greeksType GreeksType) *PositionBuilderService

SetGreeksType sets the greeks display type.

func (*PositionBuilderService) SetIdxVol

SetIdxVol sets the index volatility used for the stress-test scenarios.

func (*PositionBuilderService) SetInclRealPosAndEq

func (s *PositionBuilderService) SetInclRealPosAndEq(incl bool) *PositionBuilderService

SetInclRealPosAndEq includes the account's real positions and equity in the simulation.

func (*PositionBuilderService) SetLever

SetLever sets the simulated leverage.

func (*PositionBuilderService) SetSimAsset

SetSimAsset sets the simulated assets.

func (*PositionBuilderService) SetSimPos

SetSimPos sets the simulated positions.

type PositionBuilderSimAsset

type PositionBuilderSimAsset struct {
	Currency string `json:"ccy"`
	Amount   string `json:"amt"`
}

PositionBuilderSimAsset is a simulated asset fed to the position builder.

type PositionBuilderSimPos

type PositionBuilderSimPos struct {
	InstrumentID string `json:"instId"`
	Position     string `json:"pos"`
	AveragePrice string `json:"avgPx,omitempty"`
	Leverage     string `json:"lever,omitempty"`
}

PositionBuilderSimPos is a simulated position fed to the position builder.

type PositionCloseOrderAlgo

type PositionCloseOrderAlgo struct {
	AlgoID                     string          `json:"algoId"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType"`
	CloseFraction              decimal.Decimal `json:"closeFraction"`
}

PositionCloseOrderAlgo is a take-profit / stop-loss algo order attached to a position.

type PositionHistory

type PositionHistory struct {
	InstrumentType        InstType        `json:"instType"`
	InstrumentID          string          `json:"instId"`
	MarginMode            MgnMode         `json:"mgnMode"`
	Type                  string          `json:"type"`
	Currency              string          `json:"ccy"`
	PositionID            string          `json:"posId"`
	PositionSide          PosSide         `json:"posSide"`
	Direction             string          `json:"direction"`
	Leverage              decimal.Decimal `json:"lever"`
	OpenAveragePrice      decimal.Decimal `json:"openAvgPx"`
	CloseAveragePrice     decimal.Decimal `json:"closeAvgPx"`
	NonSettleAveragePrice decimal.Decimal `json:"nonSettleAvgPx"`
	OpenMaxPosition       decimal.Decimal `json:"openMaxPos"`
	CloseTotalPosition    decimal.Decimal `json:"closeTotalPos"`
	Pnl                   decimal.Decimal `json:"pnl"`
	PnlRatio              decimal.Decimal `json:"pnlRatio"`
	RealizedPnl           decimal.Decimal `json:"realizedPnl"`
	SettledPnl            decimal.Decimal `json:"settledPnl"`
	Fee                   decimal.Decimal `json:"fee"`
	FundingFee            decimal.Decimal `json:"fundingFee"`
	LiquidationPenalty    decimal.Decimal `json:"liqPenalty"`
	TriggerPrice          decimal.Decimal `json:"triggerPx"`
	Underlying            string          `json:"uly"`
	CreationTime          time.Time       `json:"cTime"`
	UpdateTime            time.Time       `json:"uTime"`
}

PositionHistory is one closed-position record.

type PositionMode

type PositionMode struct {
	PositionMode PosMode `json:"posMode"`
}

PositionMode is the set-position-mode acknowledgement.

type PositionTier

type PositionTier struct {
	Underlying         string          `json:"uly"`
	InstrumentFamily   string          `json:"instFamily"`
	InstrumentID       string          `json:"instId"`
	Tier               string          `json:"tier"`
	MinSize            decimal.Decimal `json:"minSz"`
	MaxSize            decimal.Decimal `json:"maxSz"`
	MMR                decimal.Decimal `json:"mmr"`
	IMR                decimal.Decimal `json:"imr"`
	MaxLeverage        decimal.Decimal `json:"maxLever"`
	OptionMarginFactor decimal.Decimal `json:"optMgnFactor"`
	QuoteMaxLoan       decimal.Decimal `json:"quoteMaxLoan"`
	BaseMaxLoan        decimal.Decimal `json:"baseMaxLoan"`
}

PositionTier is one row of the position-tier schedule.

type PremiumHistory

type PremiumHistory struct {
	InstrumentID string          `json:"instId"`
	Premium      decimal.Decimal `json:"premium"`
	Timestamp    time.Time       `json:"ts"`
}

PremiumHistory is one premium-index record.

type PriceLimit

type PriceLimit struct {
	InstrumentType InstType        `json:"instType"`
	InstrumentID   string          `json:"instId"`
	BuyLimit       decimal.Decimal `json:"buyLmt"`
	SellLimit      decimal.Decimal `json:"sellLmt"`
	Enabled        bool            `json:"enabled"`
	Timestamp      time.Time       `json:"ts"`
}

PriceLimit is an instrument's buy/sell price limits.

type PurchaseEthStakingService

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

PurchaseEthStakingService -- POST /api/v5/finance/staking-defi/eth/purchase (Trade)

Stakes ETH (receiving BETH). State-changing: implement-only.

func (*PurchaseEthStakingService) Do

type PurchaseSolStakingService

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

PurchaseSolStakingService -- POST /api/v5/finance/staking-defi/sol/purchase (Trade)

Stakes SOL (receiving OKSOL). State-changing: implement-only.

func (*PurchaseSolStakingService) Do

type PurchaseStakingService

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

PurchaseStakingService -- POST /api/v5/finance/staking-defi/purchase (Trade)

Subscribes to an on-chain earn offer. State-changing: implement-only, never executed by the SDK's test suite.

func (*PurchaseStakingService) Do

func (*PurchaseStakingService) SetTag

SetTag sets an order tag (brokerId-issued label).

func (*PurchaseStakingService) SetTerm

SetTerm sets the protocol term (required for fixed-term protocols).

type RecurringItem

type RecurringItem struct {
	Currency string          `json:"ccy"`
	Ratio    decimal.Decimal `json:"ratio"`
}

RecurringItem is one currency allocation within a recurring-buy strategy (used in both the create body and the strategy detail response).

type RecurringOrder

type RecurringOrder struct {
	AlgoID               string          `json:"algoId"`
	AlgoClientOrderID    string          `json:"algoClOrdId"`
	InstrumentType       InstType        `json:"instType"`
	Cycles               string          `json:"cycles"`
	StrategyName         string          `json:"stgyName"`
	State                RecurringState  `json:"state"`
	Period               RecurringPeriod `json:"period"`
	RecurringDay         string          `json:"recurringDay"`
	RecurringHour        string          `json:"recurringHour"`
	RecurringTime        string          `json:"recurringTime"`
	TimeZone             string          `json:"timeZone"`
	Amount               decimal.Decimal `json:"amt"`
	InvestmentCurrency   string          `json:"investmentCcy"`
	InvestmentAmount     decimal.Decimal `json:"investmentAmt"`
	TotalPnl             decimal.Decimal `json:"totalPnl"`
	TotalAnnualRate      decimal.Decimal `json:"totalAnnRate"`
	PnlRatio             decimal.Decimal `json:"pnlRatio"`
	MarketCapitalization decimal.Decimal `json:"mktCap"`
	TradeMode            TdMode          `json:"tdMode"`
	Tag                  string          `json:"tag"`
	RecurringList        []RecurringItem `json:"recurringList"`
	CreationTime         time.Time       `json:"cTime"`
	UpdateTime           time.Time       `json:"uTime"`
}

RecurringOrder is a recurring-buy (DCA) strategy bot.

type RecurringPeriod

type RecurringPeriod string

RecurringPeriod is the cadence at which a recurring-buy strategy invests.

const (
	RecurringPeriodMonthly RecurringPeriod = "monthly"
	RecurringPeriodWeekly  RecurringPeriod = "weekly"
	RecurringPeriodDaily   RecurringPeriod = "daily"
	RecurringPeriodHourly  RecurringPeriod = "hourly"
)

type RecurringResult

type RecurringResult struct {
	AlgoID            string `json:"algoId"`
	AlgoClientOrderID string `json:"algoClOrdId"`
	SCode             string `json:"sCode"`
	SMsg              string `json:"sMsg"`
	Tag               string `json:"tag"`
}

RecurringResult is the per-item ack of a recurring-buy create/stop op. OKX may set the top-level code to "1" with the real reason in sCode/sMsg.

func (RecurringResult) Err added in v0.20260623.1

func (r RecurringResult) Err() error

type RecurringState

type RecurringState string

RecurringState is the lifecycle state of a recurring-buy strategy bot.

const (
	RecurringStateStarting   RecurringState = "starting"
	RecurringStateRunning    RecurringState = "running"
	RecurringStateStopping   RecurringState = "stopping"
	RecurringStateNotStarted RecurringState = "not_started"
	RecurringStateStopped    RecurringState = "stopped"
	RecurringStatePause      RecurringState = "pause"
)

type RecurringSubOrder

type RecurringSubOrder struct {
	AlgoID              string          `json:"algoId"`
	AlgoClientOrderID   string          `json:"algoClOrdId"`
	InstrumentType      InstType        `json:"instType"`
	BotID               string          `json:"botId"`
	InstrumentID        string          `json:"instId"`
	OrderID             string          `json:"ordId"`
	ClientOrderID       string          `json:"clOrdId"`
	OrderType           OrdType         `json:"ordType"`
	Side                Side            `json:"side"`
	Price               decimal.Decimal `json:"px"`
	Size                decimal.Decimal `json:"sz"`
	State               OrdState        `json:"state"`
	AccumulatedFillSize decimal.Decimal `json:"accFillSz"`
	AveragePrice        decimal.Decimal `json:"avgPx"`
	Fee                 decimal.Decimal `json:"fee"`
	FeeCurrency         string          `json:"feeCcy"`
	Tag                 string          `json:"tag"`
	CreationTime        time.Time       `json:"cTime"`
	UpdateTime          time.Time       `json:"uTime"`
}

RecurringSubOrder is a single underlying order executed by a recurring-buy strategy.

type RedeemEthStakingService

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

RedeemEthStakingService -- POST /api/v5/finance/staking-defi/eth/redeem (Trade)

Redeems BETH back to ETH. State-changing: implement-only.

func (*RedeemEthStakingService) Do

type RedeemSolStakingService

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

RedeemSolStakingService -- POST /api/v5/finance/staking-defi/sol/redeem (Trade)

Redeems OKSOL back to SOL. State-changing: implement-only.

func (*RedeemSolStakingService) Do

type RedeemStakingService

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

RedeemStakingService -- POST /api/v5/finance/staking-defi/redeem (Trade)

Redeems an active on-chain earn order. State-changing: implement-only.

func (*RedeemStakingService) Do

func (*RedeemStakingService) SetAllowEarlyRedeem

func (s *RedeemStakingService) SetAllowEarlyRedeem(allow bool) *RedeemStakingService

SetAllowEarlyRedeem permits early redemption (incurring any applicable cost).

type ResetMMPService

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

ResetMMPService -- POST /api/v5/account/mmp-reset (Trade)

Resets the Market Maker Protection frozen state of an option instrument family, allowing quoting to resume.

func (*ResetMMPService) Do

func (s *ResetMMPService) Do(ctx context.Context) (*MMPReset, error)

func (*ResetMMPService) SetInstType

func (s *ResetMMPService) SetInstType(instType InstType) *ResetMMPService

SetInstType sets the instrument type (optional).

type ResetRfqMmpService

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

ResetRfqMmpService -- POST /api/v5/rfq/mmp-reset (Trade)

Resets (unfreezes) the maker's MMP state.

func (*ResetRfqMmpService) Do

type Rfq

type Rfq struct {
	CreateTime     time.Time `json:"cTime"`
	UpdateTime     time.Time `json:"uTime"`
	TraderCode     string    `json:"traderCode"`
	RFQID          string    `json:"rfqId"`
	ClientRFQID    string    `json:"clRfqId"`
	State          RfqState  `json:"state"`
	ValidUntil     time.Time `json:"validUntil"`
	Counterparties []string  `json:"counterparties"`
	Legs           []RfqLeg  `json:"legs"`
	AllowPartial   bool      `json:"allowPartialExecution"`
}

Rfq is one RFQ record. The validating account has no RFQ history, so the field set is modeled from the OKX doc field table.

type RfqBlockTicker

type RfqBlockTicker struct {
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	VolumeCurrency24h decimal.Decimal `json:"volCcy24h"`
	Volume24h         decimal.Decimal `json:"vol24h"`
	Timestamp         time.Time       `json:"ts"`
}

RfqBlockTicker is the 24h block-trade volume snapshot for an instrument.

type RfqCancelAck

type RfqCancelAck struct {
	RFQID       string `json:"rfqId"`
	ClientRFQID string `json:"clRfqId"`
	SCode       string `json:"sCode"`
	SMsg        string `json:"sMsg"`
}

RfqCancelAck is the per-item ack of an RFQ cancel.

func (RfqCancelAck) Err added in v0.20260623.1

func (r RfqCancelAck) Err() error

type RfqCancelAllAfter

type RfqCancelAllAfter struct {
	TriggerTime time.Time `json:"triggerTime"`
	Timestamp   time.Time `json:"ts"`
}

RfqCancelAllAfter is the ack of a cancel-all-after action.

type RfqCounterparty

type RfqCounterparty struct {
	TraderName string `json:"traderName"`
	TraderCode string `json:"traderCode"`
	Type       string `json:"type"`
}

RfqCounterparty is one available RFQ counterparty (maker).

type RfqCreateLeg

type RfqCreateLeg struct {
	InstrumentID   string          `json:"instId"`
	Size           decimal.Decimal `json:"sz"`
	Side           Side            `json:"side"`
	TargetCurrency TgtCcy          `json:"tgtCcy,omitempty"`
	PositionSide   PosSide         `json:"posSide,omitempty"`
}

RfqCreateLeg is one leg supplied when creating an RFQ.

type RfqExecuteLeg

type RfqExecuteLeg struct {
	InstrumentID string          `json:"instId"`
	Size         decimal.Decimal `json:"sz"`
}

RfqExecuteLeg is one leg supplied when executing a quote.

type RfqLeg

type RfqLeg struct {
	InstrumentID   string          `json:"instId"`
	Size           decimal.Decimal `json:"sz"`
	Side           Side            `json:"side"`
	TargetCurrency TgtCcy          `json:"tgtCcy"`
	PositionSide   PosSide         `json:"posSide"`
}

RfqLeg is one leg of an RFQ.

type RfqMakerInstrumentSetting

type RfqMakerInstrumentSetting struct {
	InstrumentType InstType                        `json:"instType"`
	IncludeALL     bool                            `json:"includeALL"`
	Data           []RfqMakerInstrumentSettingData `json:"data"`
}

RfqMakerInstrumentSetting is the maker's quoting configuration for one instrument type. The validating account lacks maker permission (50030), so the field set is modeled from the OKX doc field table.

type RfqMakerInstrumentSettingData

type RfqMakerInstrumentSettingData struct {
	InstrumentFamily string          `json:"instFamily"`
	InstrumentID     string          `json:"instId"`
	MaxBlockSize     decimal.Decimal `json:"maxBlockSz"`
	MakerPriceBand   decimal.Decimal `json:"makerPxBand"`
}

RfqMakerInstrumentSettingData is one instrument-family/underlying entry within a maker's quoting configuration.

type RfqMmpConfig

type RfqMmpConfig struct {
	TimeInterval   decimal.Decimal `json:"timeInterval"`
	FrozenInterval decimal.Decimal `json:"frozenInterval"`
	CountLimit     decimal.Decimal `json:"countLimit"`
	MMPFrozen      bool            `json:"mmpFrozen"`
	MMPFrozenUntil time.Time       `json:"mmpFrozenUntil"`
}

RfqMmpConfig is the maker's MMP configuration. The validating account lacks maker permission (50030), so the field set is modeled from the OKX doc field table.

type RfqMmpReset

type RfqMmpReset struct {
	Result bool `json:"result"`
}

RfqMmpReset is the ack of an MMP reset.

type RfqPublicTrade

type RfqPublicTrade struct {
	BlockTradeID string              `json:"blockTdId"`
	GroupID      string              `json:"groupId"`
	Strategy     string              `json:"strategy"`
	Inverse      bool                `json:"inverse"`
	CreateTime   time.Time           `json:"cTime"`
	Legs         []RfqPublicTradeLeg `json:"legs"`
}

RfqPublicTrade is one public block trade.

type RfqPublicTradeLeg

type RfqPublicTradeLeg struct {
	InstrumentID string          `json:"instId"`
	Side         Side            `json:"side"`
	Size         decimal.Decimal `json:"sz"`
	Price        decimal.Decimal `json:"px"`
	TradeID      string          `json:"tradeId"`
}

RfqPublicTradeLeg is one leg of a public block trade.

type RfqQuote

type RfqQuote struct {
	CreateTime    time.Time     `json:"cTime"`
	UpdateTime    time.Time     `json:"uTime"`
	TraderCode    string        `json:"traderCode"`
	RFQID         string        `json:"rfqId"`
	ClientRFQID   string        `json:"clRfqId"`
	QuoteID       string        `json:"quoteId"`
	ClientQuoteID string        `json:"clQuoteId"`
	State         RfqQuoteState `json:"state"`
	ValidUntil    time.Time     `json:"validUntil"`
	QuoteSide     RfqQuoteSide  `json:"quoteSide"`
	Legs          []RfqQuoteLeg `json:"legs"`
}

RfqQuote is one quote record. The validating account has no quote history, so the field set is modeled from the OKX doc field table.

type RfqQuoteCancelAck

type RfqQuoteCancelAck struct {
	QuoteID       string `json:"quoteId"`
	ClientQuoteID string `json:"clQuoteId"`
	SCode         string `json:"sCode"`
	SMsg          string `json:"sMsg"`
}

RfqQuoteCancelAck is the per-item ack of a quote cancel.

func (RfqQuoteCancelAck) Err added in v0.20260623.1

func (r RfqQuoteCancelAck) Err() error

type RfqQuoteCreateLeg

type RfqQuoteCreateLeg struct {
	InstrumentID   string          `json:"instId"`
	Size           decimal.Decimal `json:"sz"`
	Price          decimal.Decimal `json:"px"`
	Side           Side            `json:"side"`
	TargetCurrency TgtCcy          `json:"tgtCcy,omitempty"`
	PositionSide   PosSide         `json:"posSide,omitempty"`
}

RfqQuoteCreateLeg is one leg supplied when creating a quote.

type RfqQuoteLeg

type RfqQuoteLeg struct {
	InstrumentID   string          `json:"instId"`
	Size           decimal.Decimal `json:"sz"`
	Price          decimal.Decimal `json:"px"`
	Side           Side            `json:"side"`
	TargetCurrency TgtCcy          `json:"tgtCcy"`
	PositionSide   PosSide         `json:"posSide"`
}

RfqQuoteLeg is one leg of a quote.

type RfqQuoteProduct

type RfqQuoteProduct struct {
	InstrumentType InstType              `json:"instType"`
	IncludeALL     bool                  `json:"includeALL"`
	Data           []RfqQuoteProductData `json:"data"`
}

RfqQuoteProduct is one quote-product configuration. The validating account lacks maker permission, so the field set is modeled from the OKX doc field table.

type RfqQuoteProductData

type RfqQuoteProductData struct {
	Underlying       string          `json:"underlying"`
	InstrumentFamily string          `json:"instFamily"`
	InstrumentID     string          `json:"instId"`
	MaxBlockSize     decimal.Decimal `json:"maxBlockSz"`
	MakerPriceBand   decimal.Decimal `json:"makerPxBand"`
}

RfqQuoteProductData is one instrument entry within a quote product.

type RfqQuoteSide

type RfqQuoteSide string

RfqQuoteSide is the side a maker quotes an RFQ on.

const (
	RfqQuoteSideBuy  RfqQuoteSide = "buy"
	RfqQuoteSideSell RfqQuoteSide = "sell"
)

type RfqQuoteState

type RfqQuoteState string

RfqQuoteState is the lifecycle state of a quote.

const (
	RfqQuoteStateActive   RfqQuoteState = "active"
	RfqQuoteStateCanceled RfqQuoteState = "canceled"
	RfqQuoteStatePendFill RfqQuoteState = "pending_fill"
	RfqQuoteStateFilled   RfqQuoteState = "filled"
	RfqQuoteStateExpired  RfqQuoteState = "expired"
	RfqQuoteStateFailed   RfqQuoteState = "failed"
)

type RfqState

type RfqState string

RfqState is the lifecycle state of an RFQ.

const (
	RfqStateActive   RfqState = "active"
	RfqStateCanceled RfqState = "canceled"
	RfqStatePendFill RfqState = "pending_fill"
	RfqStateFilled   RfqState = "filled"
	RfqStateExpired  RfqState = "expired"
	RfqStateTraded   RfqState = "traded_away"
	RfqStateFailed   RfqState = "failed"
)

type RfqTimestampAck

type RfqTimestampAck struct {
	Timestamp time.Time `json:"ts"`
}

RfqTimestampAck is the ack of a bulk cancel/reset action, carrying the server timestamp at which the action took effect.

type RfqTrade

type RfqTrade struct {
	CreateTime      time.Time     `json:"cTime"`
	RFQID           string        `json:"rfqId"`
	ClientRFQID     string        `json:"clRfqId"`
	QuoteID         string        `json:"quoteId"`
	ClientQuoteID   string        `json:"clQuoteId"`
	BlockTradeID    string        `json:"blockTdId"`
	TakerTraderCode string        `json:"tTraderCode"`
	MakerTraderCode string        `json:"mTraderCode"`
	Tag             string        `json:"tag"`
	Legs            []RfqTradeLeg `json:"legs"`
}

RfqTrade is one executed block trade. The validating account has no block-trade history, so the field set is modeled from the OKX doc field table.

type RfqTradeLeg

type RfqTradeLeg struct {
	InstrumentID   string          `json:"instId"`
	Side           Side            `json:"side"`
	Size           decimal.Decimal `json:"sz"`
	Price          decimal.Decimal `json:"px"`
	TradeID        string          `json:"tradeId"`
	Fee            decimal.Decimal `json:"fee"`
	FeeCurrency    string          `json:"feeCcy"`
	TargetCurrency TgtCcy          `json:"tgtCcy"`
	PositionSide   PosSide         `json:"posSide"`
}

RfqTradeLeg is one leg of an executed block trade.

type RiskState

type RiskState struct {
	AtRisk       bool      `json:"atRisk"`
	AtRiskIndex  []string  `json:"atRiskIdx"`
	AtRiskMargin []string  `json:"atRiskMgn"`
	Timestamp    time.Time `json:"ts"`
}

RiskState is the portfolio-margin account's risk-offset state. The validating account is not in portfolio-margin mode (the endpoint returns 51010), so the field set is modeled from the OKX doc field table.

type RubikOpenInterestHistory

type RubikOpenInterestHistory struct {
	Timestamp            time.Time       `json:"ts"`
	OpenInterest         decimal.Decimal `json:"oi"`
	OpenInterestCurrency decimal.Decimal `json:"oiCcy"`
	OpenInterestUSD      decimal.Decimal `json:"oiUsd"`
}

RubikOpenInterestHistory is one open-interest-history bar: [ts, oi (contracts), oiCcy (base ccy), oiUsd].

type RubikOpenInterestVolume

type RubikOpenInterestVolume struct {
	Timestamp    time.Time       `json:"ts"`
	OpenInterest decimal.Decimal `json:"oi"`
	Volume       decimal.Decimal `json:"vol"`
}

RubikOpenInterestVolume is one [ts, oi, vol] bar shared by the contract and option open-interest-volume endpoints.

type RubikOpenInterestVolumeExpiry

type RubikOpenInterestVolumeExpiry struct {
	Timestamp        time.Time       `json:"ts"`
	ExpiryTime       string          `json:"expTime"`
	CallOpenInterest decimal.Decimal `json:"callOI"`
	PutOpenInterest  decimal.Decimal `json:"putOI"`
	CallVolume       decimal.Decimal `json:"callVol"`
	PutVolume        decimal.Decimal `json:"putVol"`
}

RubikOpenInterestVolumeExpiry is one option-by-expiry bar: [ts, expTime, callOI, putOI, callVol, putVol]. ExpTime is the expiry date in YYYYMMDD form.

type RubikOpenInterestVolumeStrike

type RubikOpenInterestVolumeStrike struct {
	Timestamp        time.Time       `json:"ts"`
	Strike           decimal.Decimal `json:"strike"`
	CallOpenInterest decimal.Decimal `json:"callOI"`
	PutOpenInterest  decimal.Decimal `json:"putOI"`
	CallVolume       decimal.Decimal `json:"callVol"`
	PutVolume        decimal.Decimal `json:"putVol"`
}

RubikOpenInterestVolumeStrike is one option-by-strike bar: [ts, strike, callOI, putOI, callVol, putVol].

type RubikOptionTakerBlockVolume

type RubikOptionTakerBlockVolume struct {
	Timestamp       time.Time       `json:"ts"`
	CallBuyVolume   decimal.Decimal `json:"callBuyVol"`
	CallSellVolume  decimal.Decimal `json:"callSellVol"`
	PutBuyVolume    decimal.Decimal `json:"putBuyVol"`
	PutSellVolume   decimal.Decimal `json:"putSellVol"`
	CallBlockVolume decimal.Decimal `json:"callBlockVol"`
	PutBlockVolume  decimal.Decimal `json:"putBlockVol"`
}

RubikOptionTakerBlockVolume is the option taker/block-volume snapshot: [ts, callBuyVol, callSellVol, putBuyVol, putSellVol, callBlockVol, putBlockVol].

type RubikRatio

type RubikRatio struct {
	Timestamp time.Time       `json:"ts"`
	Ratio     decimal.Decimal `json:"ratio"`
}

RubikRatio is one [ts, ratio] bar shared by the loan-ratio and the long/short account/position ratio endpoints.

type RubikStatPeriod

type RubikStatPeriod string

RubikStatPeriod is the bar/aggregation window accepted by the rubik trading-statistics endpoints (e.g. "5m", "1H", "1D"). Each endpoint documents the subset it supports; values are passed through verbatim.

const (
	RubikStatPeriod5m RubikStatPeriod = "5m"
	RubikStatPeriod1H RubikStatPeriod = "1H"
	RubikStatPeriod1D RubikStatPeriod = "1D"
)

type RubikSupportCoin

type RubikSupportCoin struct {
	Contract []string `json:"contract"`
	Option   []string `json:"option"`
	Spot     []string `json:"spot"`
}

RubikSupportCoin lists the currencies covered by the trading-statistics endpoints, split by product line.

type RubikTakerVolume

type RubikTakerVolume struct {
	Timestamp  time.Time       `json:"ts"`
	SellVolume decimal.Decimal `json:"sellVol"`
	BuyVolume  decimal.Decimal `json:"buyVol"`
}

RubikTakerVolume is one taker-volume bar: [ts, sellVol, buyVol].

type SavingsBalance

type SavingsBalance struct {
	Currency         string          `json:"ccy"`
	Amount           decimal.Decimal `json:"amt"`
	Earnings         decimal.Decimal `json:"earnings"`
	Rate             decimal.Decimal `json:"rate"`
	LoanAmount       decimal.Decimal `json:"loanAmt"`
	PendingAmount    decimal.Decimal `json:"pendingAmt"`
	RedemptionAmount decimal.Decimal `json:"redemptAmt"`
}

SavingsBalance is one currency's savings balance. The validating account holds no savings (the endpoint returns an empty data array), so the field set is modeled from the OKX doc field table.

type SavingsLendingHistory

type SavingsLendingHistory struct {
	Currency  string          `json:"ccy"`
	Amount    decimal.Decimal `json:"amt"`
	Earnings  decimal.Decimal `json:"earnings"`
	Rate      decimal.Decimal `json:"rate"`
	Timestamp time.Time       `json:"ts"`
}

SavingsLendingHistory is one savings lending record. The validating account has no lending history (the endpoint returns an empty data array), so the field set is modeled from the OKX doc field table.

type SavingsLendingRate

type SavingsLendingRate struct {
	Currency string          `json:"ccy"`
	Rate     decimal.Decimal `json:"rate"`
}

SavingsLendingRate is the ack of a set-lending-rate action.

type SavingsLendingRateHistory

type SavingsLendingRateHistory struct {
	Currency    string          `json:"ccy"`
	Amount      decimal.Decimal `json:"amt"`
	LendingRate decimal.Decimal `json:"lendingRate"`
	Rate        decimal.Decimal `json:"rate"`
	Timestamp   time.Time       `json:"ts"`
}

SavingsLendingRateHistory is one historical lending-rate record.

type SavingsLendingRateSummary

type SavingsLendingRateSummary struct {
	Currency         string          `json:"ccy"`
	AverageAmount    decimal.Decimal `json:"avgAmt"`
	AverageAmountUSD decimal.Decimal `json:"avgAmtUsd"`
	AverageRate      decimal.Decimal `json:"avgRate"`
	PreRate          decimal.Decimal `json:"preRate"`
	EstimatedRate    decimal.Decimal `json:"estRate"`
}

SavingsLendingRateSummary is one currency's lending-rate summary.

type SavingsPurchaseRedemption

type SavingsPurchaseRedemption struct {
	Currency string          `json:"ccy"`
	Amount   decimal.Decimal `json:"amt"`
	Side     SavingsSide     `json:"side"`
	Rate     decimal.Decimal `json:"rate"`
}

SavingsPurchaseRedemption is the ack of a savings purchase/redemption action.

type SavingsSide

type SavingsSide string

SavingsSide selects whether a Simple Earn Flexible (savings) purchase / redemption order is a subscribe (purchase) or a redeem (redempt).

const (
	SavingsSidePurchase SavingsSide = "purchase"
	SavingsSideRedempt  SavingsSide = "redempt"
)

type SetAccountLevelService

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

SetAccountLevelService -- POST /api/v5/account/set-account-level (Trade)

Sets the account mode (acctLv: "1" spot, "2" spot&futures, "3" multi-currency margin, "4" portfolio margin). DANGEROUS: this changes the whole account's trading mode.

func (*SetAccountLevelService) Do

type SetAutoLoanService

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

SetAutoLoanService -- POST /api/v5/account/set-auto-loan (Trade)

Enables or disables automatic margin borrowing for the account.

func (*SetAutoLoanService) Do

type SetAutoRepayService

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

SetAutoRepayService -- POST /api/v5/account/set-auto-repay (Trade)

Enables or disables automatic repayment of spot borrowings.

State-changing: NOT exercised by the test suite.

func (*SetAutoRepayService) Do

type SetBorrowRepayService

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

SetBorrowRepayService -- POST /api/v5/account/borrow-repay (Trade)

Borrows or repays a VIP loan.

State-changing: NOT exercised by the test suite.

func (*SetBorrowRepayService) Do

func (*SetBorrowRepayService) SetOrdId

SetOrdId targets an existing VIP loan order (required when repaying).

type SetCollateralAssetsService

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

SetCollateralAssetsService -- POST /api/v5/account/set-collateral-assets (Trade)

Enables or disables assets as collateral, either for all currencies (type "all") or for a custom currency list (type "custom", then set CcyList).

func (*SetCollateralAssetsService) Do

func (*SetCollateralAssetsService) SetCcyList

SetCcyList sets the currency list (required when type is "custom").

type SetCopyLeverageService

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

SetCopyLeverageService -- POST /api/v5/copytrading/set-leverage (Trade)

Sets the leverage a lead trader uses for one or more instruments.

func (*SetCopyLeverageService) Do

func (*SetCopyLeverageService) SetInstId

SetInstId sets the comma-separated instruments to set leverage on.

type SetGreeksService

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

SetGreeksService -- POST /api/v5/account/set-greeks (Trade)

Sets the display type of option greeks ("PA" in coins or "BS" in dollars).

func (*SetGreeksService) Do

type SetIsolatedModeService

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

SetIsolatedModeService -- POST /api/v5/account/set-isolated-mode (Trade)

Sets the isolated-margin transfer behaviour (automatic vs autonomy) for the given instrument type (MARGIN or CONTRACTS).

func (*SetIsolatedModeService) Do

type SetLeverageService

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

SetLeverageService -- POST /api/v5/account/set-leverage (Trade)

Sets the leverage of an instrument or currency. Either instId or ccy is required (instId for an instrument's leverage; ccy for cross-margin currency leverage in Futures mode).

func (*SetLeverageService) Do

func (*SetLeverageService) SetCcy

SetCcy sets the currency whose cross-margin leverage is changed (Futures mode).

func (*SetLeverageService) SetInstId

func (s *SetLeverageService) SetInstId(instId string) *SetLeverageService

SetInstId sets the instrument whose leverage is changed.

func (*SetLeverageService) SetPosSide

func (s *SetLeverageService) SetPosSide(posSide PosSide) *SetLeverageService

SetPosSide sets the position side (long/short) for isolated long/short mode.

type SetMMPConfigService

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

SetMMPConfigService -- POST /api/v5/account/mmp-config (Trade)

Sets the Market Maker Protection configuration of an option instrument family.

func (*SetMMPConfigService) Do

type SetMarginBalanceService

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

SetMarginBalanceService -- POST /api/v5/account/position/margin-balance (Trade)

Increases or decreases the margin of an isolated position.

func (*SetMarginBalanceService) Do

func (*SetMarginBalanceService) SetAuto

SetAuto enables automatic loan transfer when reducing margin.

func (*SetMarginBalanceService) SetCcy

SetCcy sets the currency (applicable to isolated MARGIN positions).

type SetOKUSDRedeemService added in v0.20260703.0

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

SetOKUSDRedeemService -- POST /api/v5/finance/okusd/redeem (Trade)

Redeems OKUSD back to USDT, either fast (real-time) or standard (D+5).

State-changing: NOT exercised by the test suite.

func (*SetOKUSDRedeemService) Do added in v0.20260703.0

type SetOKUSDSubscribeService added in v0.20260703.0

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

SetOKUSDSubscribeService -- POST /api/v5/finance/okusd/subscribe (Trade)

Subscribes USDT to receive OKUSD at a 1:1 rate.

State-changing: NOT exercised by the test suite.

func (*SetOKUSDSubscribeService) Do added in v0.20260703.0

type SetPositionModeService

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

SetPositionModeService -- POST /api/v5/account/set-position-mode (Trade)

Sets the account-wide position mode (long/short hedging or net) for derivatives. Single-currency margin accounts only.

func (*SetPositionModeService) Do

type SetRfqMakerInstrumentSettingsService

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

SetRfqMakerInstrumentSettingsService -- POST /api/v5/rfq/maker-instrument-settings (Trade)

Sets the maker's per-instrument-type quoting settings.

func (*SetRfqMakerInstrumentSettingsService) Do

type SetRfqMmpService

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

SetRfqMmpService -- POST /api/v5/rfq/set-mmp (Trade)

Sets the maker's MMP (market-maker protection) configuration.

func (*SetRfqMmpService) Do

type SetRfqQuoteProductsService

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

SetRfqQuoteProductsService -- POST /api/v5/rfq/set-quote-products (Trade)

Sets the maker's quote products.

func (*SetRfqQuoteProductsService) Do

type SetSavingsLendingRateService

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

SetSavingsLendingRateService -- POST /api/v5/finance/savings/set-lending-rate (Trade)

Sets the minimum lending rate the account is willing to accept for a savings currency.

State-changing: NOT exercised by the test suite.

func (*SetSavingsLendingRateService) Do

type SetSavingsPurchaseRedemptionService

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

SetSavingsPurchaseRedemptionService -- POST /api/v5/finance/savings/purchase-redemption (Trade)

Subscribes to (purchase) or redeems (redempt) a currency in Simple Earn Flexible savings.

State-changing: NOT exercised by the test suite.

func (*SetSavingsPurchaseRedemptionService) Do

func (*SetSavingsPurchaseRedemptionService) SetRate

SetRate sets the lending rate (between 0.01 and 3.65, only applicable when subscribing).

type SetSpotManualBorrowRepayService

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

SetSpotManualBorrowRepayService -- POST /api/v5/account/spot-manual-borrow-repay (Trade)

Manually borrows or repays spot in the cross-margin account.

State-changing: NOT exercised by the test suite.

func (*SetSpotManualBorrowRepayService) Do

type SetSubAccountTransferOutService

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

SetSubAccountTransferOutService -- POST /api/v5/users/subaccount/set-transfer-out (Trade)

Sets whether a sub-account is permitted to transfer funds out (master account). Implement-only: never executed by the live test suite.

func (*SetSubAccountTransferOutService) Do

type SettlementHistory

type SettlementHistory struct {
	Timestamp time.Time                 `json:"ts"`
	Details   []SettlementHistoryDetail `json:"details"`
}

SettlementHistory is one settlement event and its per-instrument prices.

type SettlementHistoryDetail

type SettlementHistoryDetail struct {
	InstrumentID string          `json:"instId"`
	SettlePrice  decimal.Decimal `json:"settlePx"`
}

SettlementHistoryDetail is a single instrument's settlement price.

type Side

type Side string

Side is an order side.

const (
	SideBuy  Side = "buy"
	SideSell Side = "sell"
)

type SolStakingAck

type SolStakingAck struct{}

SolStakingAck is the (empty) acknowledgement returned by SOL purchase/redeem.

type SolStakingBalance

type SolStakingBalance struct {
	Currency              string          `json:"ccy"`
	Amount                decimal.Decimal `json:"amt"`
	LatestInterestAccrual decimal.Decimal `json:"latestInterestAccrual"`
	TotalInterestAccrual  decimal.Decimal `json:"totalInterestAccrual"`
	Timestamp             time.Time       `json:"ts"`
}

SolStakingBalance is the OKSOL balance and accrued interest.

type SolStakingHistory

type SolStakingHistory struct {
	Type                   string          `json:"type"`
	Amount                 decimal.Decimal `json:"amt"`
	Status                 string          `json:"status"`
	RequestTime            time.Time       `json:"requestTime"`
	CompletedTime          time.Time       `json:"completedTime"`
	EstimatedCompletedTime time.Time       `json:"estCompletedTime"`
}

SolStakingHistory is one SOL staking purchase/redemption record. The validating account has no SOL staking history, so the field set is modeled from the OKX doc field table.

type SolStakingProductInfo

type SolStakingProductInfo struct {
	FastRedemptionAvailable  decimal.Decimal `json:"fastRedemptionAvail"`
	FastRedemptionDailyLimit decimal.Decimal `json:"fastRedemptionDailyLimit"`
	MinAmount                decimal.Decimal `json:"minAmt"`
	Rate                     decimal.Decimal `json:"rate"`
	RedemptionDays           decimal.Decimal `json:"redemptDays"`
}

SolStakingProductInfo is the SOL staking product configuration.

type SpotBorrowRepayHistory

type SpotBorrowRepayHistory struct {
	Currency            string          `json:"ccy"`
	Type                string          `json:"type"`
	Amount              decimal.Decimal `json:"amt"`
	AccumulatedBorrowed decimal.Decimal `json:"accBorrowed"`
	Timestamp           time.Time       `json:"ts"`
}

SpotBorrowRepayHistory is one spot borrow/repay event.

type SpotManualBorrowRepay

type SpotManualBorrowRepay struct {
	Currency string          `json:"ccy"`
	Side     BorrowRepayType `json:"side"`
	Amount   decimal.Decimal `json:"amt"`
}

SpotManualBorrowRepay is the ack of a manual spot borrow/repay action.

type SprdAlgoAck

type SprdAlgoAck struct {
	AlgoID            string `json:"algoId"`
	AlgoClientOrderID string `json:"algoClOrdId"`
	SCode             string `json:"sCode"`
	SMsg              string `json:"sMsg"`
}

SprdAlgoAck is the acknowledgement of a place / cancel spread algo order.

func (SprdAlgoAck) Err added in v0.20260623.1

func (r SprdAlgoAck) Err() error

type SprdAlgoOrder

type SprdAlgoOrder struct {
	SpreadID          string          `json:"sprdId"`
	AlgoID            string          `json:"algoId"`
	AlgoClientOrderID string          `json:"algoClOrdId"`
	OrderType         string          `json:"ordType"`
	Side              Side            `json:"side"`
	Size              decimal.Decimal `json:"sz"`
	SizeLimit         decimal.Decimal `json:"szLimit"`
	PriceVariation    decimal.Decimal `json:"pxVar"`
	PriceSpread       decimal.Decimal `json:"pxSpread"`
	PriceLimit        decimal.Decimal `json:"pxLimit"`
	TimeInterval      string          `json:"timeInterval"`
	State             string          `json:"state"`
	Tag               string          `json:"tag"`
	UpdateTime        time.Time       `json:"uTime"`
	CreationTime      time.Time       `json:"cTime"`
}

SprdAlgoOrder is a single spread algo order's state.

type SprdAmendAck

type SprdAmendAck struct {
	OrderID       string `json:"ordId"`
	ClientOrderID string `json:"clOrdId"`
	RequestID     string `json:"reqId"`
	SCode         string `json:"sCode"`
	SMsg          string `json:"sMsg"`
}

SprdAmendAck is the acknowledgement of an amend spread order request.

func (SprdAmendAck) Err added in v0.20260623.1

func (r SprdAmendAck) Err() error

type SprdCancelAllAck

type SprdCancelAllAck struct {
	TriggerTime time.Time `json:"triggerTime"`
	Timestamp   time.Time `json:"ts"`
}

SprdCancelAllAck is the acknowledgement of a cancel-all spread orders request.

type SprdCancelAllAfterAck

type SprdCancelAllAfterAck struct {
	TriggerTime time.Time `json:"triggerTime"`
	Timestamp   time.Time `json:"ts"`
}

SprdCancelAllAfterAck is the acknowledgement of a cancel-all-after request.

type SprdCancelAllAfterService

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

SprdCancelAllAfterService -- POST /api/v5/sprd/cancel-all-after (Trade)

Arms or disarms the dead-man's-switch: all pending spread orders are canceled timeOut seconds after the last heartbeat. timeOut of 0 cancels the timer.

func (*SprdCancelAllAfterService) Do

type SprdCandle

type SprdCandle struct {
	Timestamp time.Time
	Open      decimal.Decimal
	High      decimal.Decimal
	Low       decimal.Decimal
	Close     decimal.Decimal
	Volume    decimal.Decimal
	Confirm   string
}

SprdCandle is one OHLCV candlestick for a spread. The raw response is an array-of-arrays with 7 columns: [ts, o, h, l, c, vol, confirm].

type SprdLeg

type SprdLeg struct {
	InstrumentID string `json:"instId"`
	Side         Side   `json:"side"`
}

SprdLeg is one leg of a spread.

type SprdMassCancelAck

type SprdMassCancelAck struct {
	Result bool `json:"result"`
}

SprdMassCancelAck is the acknowledgement of a mass-cancel spread orders request.

type SprdMassCancelOrdersService

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

SprdMassCancelOrdersService -- POST /api/v5/sprd/mass-cancel (Trade)

Cancels all pending spread orders (mass cancel), optionally scoped to one spread.

func (*SprdMassCancelOrdersService) Do

func (*SprdMassCancelOrdersService) SetSprdId

SetSprdId scopes the mass cancel to a single spread.

type SprdOrdState

type SprdOrdState string

SprdOrdState is the lifecycle state of a spread order.

const (
	SprdOrdStateLive            SprdOrdState = "live"
	SprdOrdStatePartiallyFilled SprdOrdState = "partially_filled"
	SprdOrdStateFilled          SprdOrdState = "filled"
	SprdOrdStateCanceled        SprdOrdState = "canceled"
)

type SprdOrdType

type SprdOrdType string

SprdOrdType is a spread order type.

const (
	SprdOrdTypeLimit    SprdOrdType = "limit"
	SprdOrdTypeMarket   SprdOrdType = "market"
	SprdOrdTypePostOnly SprdOrdType = "post_only"
	SprdOrdTypeIOC      SprdOrdType = "ioc"
)

type SprdOrder

type SprdOrder struct {
	SpreadID            string          `json:"sprdId"`
	OrderID             string          `json:"ordId"`
	ClientOrderID       string          `json:"clOrdId"`
	Tag                 string          `json:"tag"`
	Price               decimal.Decimal `json:"px"`
	Size                decimal.Decimal `json:"sz"`
	OrderType           SprdOrdType     `json:"ordType"`
	Side                Side            `json:"side"`
	FillSize            decimal.Decimal `json:"fillSz"`
	FillPrice           decimal.Decimal `json:"fillPx"`
	TradeID             string          `json:"tradeId"`
	AccumulatedFillSize decimal.Decimal `json:"accFillSz"`
	PendingFillSize     decimal.Decimal `json:"pendingFillSz"`
	PendingSettleSize   decimal.Decimal `json:"pendingSettleSz"`
	CanceledSize        decimal.Decimal `json:"canceledSz"`
	State               SprdOrdState    `json:"state"`
	AveragePrice        decimal.Decimal `json:"avgPx"`
	CancelSource        string          `json:"cancelSource"`
	UpdateTime          time.Time       `json:"uTime"`
	CreationTime        time.Time       `json:"cTime"`
}

SprdOrder is a single spread order's full state.

type SprdOrderAck

type SprdOrderAck struct {
	OrderID       string `json:"ordId"`
	ClientOrderID string `json:"clOrdId"`
	Tag           string `json:"tag"`
	SCode         string `json:"sCode"`
	SMsg          string `json:"sMsg"`
}

SprdOrderAck is the acknowledgement of a place / amend / cancel spread order.

func (SprdOrderAck) Err added in v0.20260623.1

func (r SprdOrderAck) Err() error

type SprdOrderBook

type SprdOrderBook struct {
	Asks      [][]string `json:"asks"`
	Bids      [][]string `json:"bids"`
	Timestamp time.Time  `json:"ts"`
}

SprdOrderBook is a spread's order book snapshot. Each ask/bid level is [price, size, numOrders].

type SprdPublicTrade

type SprdPublicTrade struct {
	SpreadID  string          `json:"sprdId"`
	TradeID   string          `json:"tradeId"`
	Price     decimal.Decimal `json:"px"`
	Size      decimal.Decimal `json:"sz"`
	Side      Side            `json:"side"`
	Timestamp time.Time       `json:"ts"`
}

SprdPublicTrade is a single public trade (taker fill) on a spread.

type SprdSpread

type SprdSpread struct {
	SpreadID      string          `json:"sprdId"`
	SpreadType    SprdType        `json:"sprdType"`
	State         SprdState       `json:"state"`
	BaseCurrency  string          `json:"baseCcy"`
	SizeCurrency  string          `json:"szCcy"`
	QuoteCurrency string          `json:"quoteCcy"`
	TickSize      decimal.Decimal `json:"tickSz"`
	MinSize       decimal.Decimal `json:"minSz"`
	LotSize       decimal.Decimal `json:"lotSz"`
	ListTime      time.Time       `json:"listTime"`
	Legs          []SprdLeg       `json:"legs"`
	ExpiryTime    time.Time       `json:"expTime"`
	UpdateTime    time.Time       `json:"uTime"`
}

SprdSpread is a single tradable spread and its legs.

type SprdState

type SprdState string

SprdState is the listing state of a spread.

const (
	SprdStateLive    SprdState = "live"
	SprdStateExpired SprdState = "expired"
	SprdStateSuspend SprdState = "suspend"
	SprdStatePreOpen SprdState = "preopen"
)

type SprdTicker

type SprdTicker struct {
	SpreadID  string          `json:"sprdId"`
	Last      decimal.Decimal `json:"last"`
	LastSize  decimal.Decimal `json:"lastSz"`
	AskPrice  decimal.Decimal `json:"askPx"`
	AskSize   decimal.Decimal `json:"askSz"`
	BidPrice  decimal.Decimal `json:"bidPx"`
	BidSize   decimal.Decimal `json:"bidSz"`
	Timestamp time.Time       `json:"ts"`
}

SprdTicker is the latest market snapshot for a spread.

type SprdTrade

type SprdTrade struct {
	SpreadID      string          `json:"sprdId"`
	TradeID       string          `json:"tradeId"`
	OrderID       string          `json:"ordId"`
	ClientOrderID string          `json:"clOrdId"`
	Tag           string          `json:"tag"`
	FillPrice     decimal.Decimal `json:"fillPx"`
	FillSize      decimal.Decimal `json:"fillSz"`
	Side          Side            `json:"side"`
	State         string          `json:"state"`
	ExecutionType ExecType        `json:"execType"`
	Timestamp     time.Time       `json:"ts"`
	Legs          []SprdTradeLeg  `json:"legs"`
	Code          string          `json:"code"`
	Message       string          `json:"msg"`
}

SprdTrade is a single account spread fill, including its per-leg fills.

type SprdTradeLeg

type SprdTradeLeg struct {
	InstrumentID string          `json:"instId"`
	Price        decimal.Decimal `json:"px"`
	Size         decimal.Decimal `json:"sz"`
	SizeContract decimal.Decimal `json:"szCont"`
	Side         Side            `json:"side"`
	Fee          decimal.Decimal `json:"fee"`
	FeeCurrency  string          `json:"feeCcy"`
	TradeID      string          `json:"tradeId"`
}

SprdTradeLeg is one leg fill within a spread trade.

type SprdType

type SprdType string

SprdType is a spread's pricing type (linear vs inverse legs).

const (
	SprdTypeLinear   SprdType = "linear"
	SprdTypeInverse  SprdType = "inverse"
	SprdTypeHybrid   SprdType = "hybrid"
	SprdTypeFundRate SprdType = "fund_rate"
)

type StakingActiveOrder

type StakingActiveOrder struct {
	OrderID                  string                  `json:"ordId"`
	Currency                 string                  `json:"ccy"`
	ProductID                string                  `json:"productId"`
	State                    StakingOrderState       `json:"state"`
	Protocol                 string                  `json:"protocol"`
	ProtocolType             StakingProtocolType     `json:"protocolType"`
	Term                     string                  `json:"term"`
	APY                      decimal.Decimal         `json:"apy"`
	InvestmentData           []StakingOrderInvest    `json:"investData"`
	EarningData              []StakingOrderEarn      `json:"earningData"`
	PurchasedTime            time.Time               `json:"purchasedTime"`
	EstimatedSettlementTime  time.Time               `json:"estSettlementTime"`
	CancelRedemptionDeadline time.Time               `json:"cancelRedemptionDeadline"`
	FastRedemptionData       []StakingFastRedemption `json:"fastRedemptionData"`
	Tag                      string                  `json:"tag"`
}

StakingActiveOrder is one active on-chain earn order. The validating account holds no on-chain earn orders, so the field set is modeled from the OKX doc field table.

type StakingApyHistory

type StakingApyHistory struct {
	Rate      decimal.Decimal `json:"rate"`
	Timestamp time.Time       `json:"ts"`
}

StakingApyHistory is one daily APY point of the ETH/SOL staking APY history.

type StakingEarningData

type StakingEarningData struct {
	Currency    string `json:"ccy"`
	EarningType string `json:"earningType"`
}

StakingEarningData is one asset earned by an offer and how it is earned.

type StakingFastRedemption

type StakingFastRedemption struct {
	Currency                string          `json:"ccy"`
	RedeemingAmount         decimal.Decimal `json:"redeemingAmt"`
	FastRedemptionAvailable decimal.Decimal `json:"fastRedemptionAvail"`
}

StakingFastRedemption is the fast-redemption availability of an order.

type StakingHistoryOrder

type StakingHistoryOrder struct {
	OrderID        string               `json:"ordId"`
	Currency       string               `json:"ccy"`
	ProductID      string               `json:"productId"`
	State          StakingOrderState    `json:"state"`
	Protocol       string               `json:"protocol"`
	ProtocolType   StakingProtocolType  `json:"protocolType"`
	Term           string               `json:"term"`
	APY            decimal.Decimal      `json:"apy"`
	InvestmentData []StakingOrderInvest `json:"investData"`
	EarningData    []StakingOrderEarn   `json:"earningData"`
	PurchasedTime  time.Time            `json:"purchasedTime"`
	RedeemedTime   time.Time            `json:"redeemedTime"`
	Tag            string               `json:"tag"`
}

StakingHistoryOrder is one completed on-chain earn order. The validating account holds no order history, so the field set is modeled from the OKX doc field table.

type StakingInvestData

type StakingInvestData struct {
	Balance   decimal.Decimal `json:"bal"`
	Currency  string          `json:"ccy"`
	MaxAmount decimal.Decimal `json:"maxAmt"`
	MinAmount decimal.Decimal `json:"minAmt"`
}

StakingInvestData is one investable currency's balance and amount limits within an offer.

type StakingOffer

type StakingOffer struct {
	Currency                 string               `json:"ccy"`
	ProductID                string               `json:"productId"`
	Protocol                 string               `json:"protocol"`
	ProtocolType             StakingProtocolType  `json:"protocolType"`
	Term                     string               `json:"term"`
	APY                      decimal.Decimal      `json:"apy"`
	EarlyRedeem              bool                 `json:"earlyRedeem"`
	State                    StakingOfferState    `json:"state"`
	InvestmentData           []StakingInvestData  `json:"investData"`
	EarningData              []StakingEarningData `json:"earningData"`
	FastRedemptionDailyLimit decimal.Decimal      `json:"fastRedemptionDailyLimit"`
	ProjectDisplayName       string               `json:"projectDisplayName"`
	RedeemPeriod             []string             `json:"redeemPeriod"`
}

StakingOffer is a single on-chain earn offer.

type StakingOfferState

type StakingOfferState string

StakingOfferState is the purchasability state of an on-chain earn offer.

const (
	StakingOfferStatePurchasable StakingOfferState = "purchasable"
	StakingOfferStateSoldOut     StakingOfferState = "sold_out"
	StakingOfferStateStop        StakingOfferState = "stop"
)

type StakingOrderAck

type StakingOrderAck struct {
	OrderID string `json:"ordId"`
	Tag     string `json:"tag"`
}

StakingOrderAck is the acknowledgement returned by purchase/redeem/cancel.

type StakingOrderEarn

type StakingOrderEarn struct {
	Currency         string          `json:"ccy"`
	Earnings         decimal.Decimal `json:"earnings"`
	EarningType      string          `json:"earningType"`
	RealizedEarnings decimal.Decimal `json:"realizedEarnings"`
}

StakingOrderEarn is one earned-asset line of an on-chain earn order.

type StakingOrderInvest

type StakingOrderInvest struct {
	Currency string          `json:"ccy"`
	Amount   decimal.Decimal `json:"amt"`
}

StakingOrderInvest is one invested currency line of an on-chain earn order.

type StakingOrderState

type StakingOrderState string

StakingOrderState is the lifecycle state of an on-chain earn order.

const (
	StakingOrderState8  StakingOrderState = "8"  // pending
	StakingOrderState13 StakingOrderState = "13" // cancelling
	StakingOrderState9  StakingOrderState = "9"  // onchain
	StakingOrderState1  StakingOrderState = "1"  // earning
	StakingOrderState2  StakingOrderState = "2"  // redeeming
	StakingOrderState3  StakingOrderState = "3"  // expired
)

type StakingProtocolType

type StakingProtocolType string

StakingProtocolType is the on-chain earn protocol category (e.g. "defi").

const (
	StakingProtocolTypeDefi    StakingProtocolType = "defi"
	StakingProtocolTypeStaking StakingProtocolType = "staking"
)

type StakingPurchaseInvest

type StakingPurchaseInvest struct {
	Currency string `json:"ccy"`
	Amount   string `json:"amt"`
}

StakingPurchaseInvest is one currency+amount line of a purchase request.

type StopCopyCopyTradingService

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

StopCopyCopyTradingService -- POST /api/v5/copytrading/stop-copy-trading (Trade)

Stops copying a lead trader and (per subPosCloseType) closes or keeps the mirrored positions.

func (*StopCopyCopyTradingService) Do

func (*StopCopyCopyTradingService) SetInstType

SetInstType sets the product line (SWAP).

type StopCopyLeadTradingService

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

StopCopyLeadTradingService -- POST /api/v5/copytrading/stop-lead-trading (Trade)

Stops being a lead trader (closes lead positions per platform rules).

func (*StopCopyLeadTradingService) Do

func (*StopCopyLeadTradingService) SetInstType

SetInstType sets the product line (SWAP).

type StopGridAlgoOrderService

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

StopGridAlgoOrderService -- POST /api/v5/tradingBot/grid/stop-order-algo (Trade)

Stops one or more running grid algo orders. The request body is an ARRAY. IMPLEMENT-ONLY.

func (*StopGridAlgoOrderService) Do

type StopRecurringOrderService

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

StopRecurringOrderService -- POST /api/v5/tradingBot/recurring/stop-order-algo (Trade)

Stops one or more recurring-buy strategies. The request body is an ARRAY of {algoId} objects (max 10).

func (*StopRecurringOrderService) Do

type SubAccount

type SubAccount struct {
	Type           subAccountType `json:"type"`
	Enable         bool           `json:"enable"`
	SubAccount     string         `json:"subAcct"`
	UID            string         `json:"uid"`
	Label          string         `json:"label"`
	Mobile         string         `json:"mobile"`
	GoogleAuth     bool           `json:"gAuth"`
	Frozen         bool           `json:"frozen"`
	CanTransferOut bool           `json:"canTransOut"`
	FrozenFunc     []string       `json:"frozenFunc"`
	Timestamp      time.Time      `json:"ts"`
}

SubAccount is a single sub-account.

type SubAccountApiKey

type SubAccountApiKey struct {
	SubAccount string    `json:"subAcct"`
	Label      string    `json:"label"`
	APIKey     string    `json:"apiKey"`
	SecretKey  string    `json:"secretKey"`
	Perm       string    `json:"perm"`
	IP         string    `json:"ip"`
	Timestamp  time.Time `json:"ts"`
}

SubAccountApiKey is a sub-account API key and its permissions.

type SubAccountBill

type SubAccountBill struct {
	BillID     string          `json:"billId"`
	Currency   string          `json:"ccy"`
	Amount     decimal.Decimal `json:"amt"`
	Type       string          `json:"type"`
	SubAccount string          `json:"subAcct"`
	Timestamp  time.Time       `json:"ts"`
}

SubAccountBill is one master<->sub funding transfer record.

type SubAccountFundingBalance

type SubAccountFundingBalance struct {
	Currency         string          `json:"ccy"`
	Balance          decimal.Decimal `json:"bal"`
	FrozenBalance    decimal.Decimal `json:"frozenBal"`
	AvailableBalance decimal.Decimal `json:"availBal"`
}

SubAccountFundingBalance is one currency's funding-account balance within a sub-account.

type SubAccountMaxWithdrawal

type SubAccountMaxWithdrawal struct {
	Currency                string          `json:"ccy"`
	MaxWithdrawal           decimal.Decimal `json:"maxWd"`
	MaxWdEx                 decimal.Decimal `json:"maxWdEx"`
	SpotOffsetMaxWithdrawal decimal.Decimal `json:"spotOffsetMaxWd"`
	SpotOffsetMaxWdEx       decimal.Decimal `json:"spotOffsetMaxWdEx"`
}

SubAccountMaxWithdrawal is a currency's maximum withdrawal amounts for a sub-account.

type SubAccountTradingBalance

type SubAccountTradingBalance struct {
	AdjustedEquity decimal.Decimal               `json:"adjEq"`
	BorrowFrozen   decimal.Decimal               `json:"borrowFroz"`
	IMR            decimal.Decimal               `json:"imr"`
	IsolatedEquity decimal.Decimal               `json:"isoEq"`
	MarginRatio    decimal.Decimal               `json:"mgnRatio"`
	MMR            decimal.Decimal               `json:"mmr"`
	NotionalUSD    decimal.Decimal               `json:"notionalUsd"`
	OrderFrozen    decimal.Decimal               `json:"ordFroz"`
	TotalEquity    decimal.Decimal               `json:"totalEq"`
	UpdateTime     time.Time                     `json:"uTime"`
	Details        []SubAccountTradingBalanceCcy `json:"details"`
}

SubAccountTradingBalance is a sub-account's trading-account balance summary.

type SubAccountTradingBalanceCcy

type SubAccountTradingBalanceCcy struct {
	Currency            string          `json:"ccy"`
	Equity              decimal.Decimal `json:"eq"`
	CashBalance         decimal.Decimal `json:"cashBal"`
	UpdateTime          time.Time       `json:"uTime"`
	IsolatedEquity      decimal.Decimal `json:"isoEq"`
	AvailableEquity     decimal.Decimal `json:"availEq"`
	DiscountEquity      decimal.Decimal `json:"disEq"`
	AvailableBalance    decimal.Decimal `json:"availBal"`
	FrozenBalance       decimal.Decimal `json:"frozenBal"`
	OrderFrozen         decimal.Decimal `json:"ordFrozen"`
	Liability           decimal.Decimal `json:"liab"`
	UPL                 decimal.Decimal `json:"upl"`
	UPLLiability        decimal.Decimal `json:"uplLiab"`
	CrossLiability      decimal.Decimal `json:"crossLiab"`
	IsolatedLiability   decimal.Decimal `json:"isoLiab"`
	MarginRatio         decimal.Decimal `json:"mgnRatio"`
	Interest            decimal.Decimal `json:"interest"`
	TWAP                decimal.Decimal `json:"twap"`
	MaxLoan             decimal.Decimal `json:"maxLoan"`
	EquityUSD           decimal.Decimal `json:"eqUsd"`
	NotionalLeverage    decimal.Decimal `json:"notionalLever"`
	StrategyEquity      decimal.Decimal `json:"stgyEq"`
	IsolatedUPL         decimal.Decimal `json:"isoUpl"`
	SpotInUseAmount     decimal.Decimal `json:"spotInUseAmt"`
	SpotIsolatedBalance decimal.Decimal `json:"spotIsoBal"`
	IMR                 decimal.Decimal `json:"imr"`
	MMR                 decimal.Decimal `json:"mmr"`
	SmtSyncEquity       decimal.Decimal `json:"smtSyncEq"`
}

SubAccountTradingBalanceCcy is one currency's balance within a sub-account's trading account.

type SubAccountTransfer

type SubAccountTransfer struct {
	TransferID string `json:"transId"`
}

SubAccountTransfer is the sub-account transfer acknowledgement.

type SubAccountTransferOut

type SubAccountTransferOut struct {
	SubAccount     string `json:"subAcct"`
	CanTransferOut bool   `json:"canTransOut"`
}

SubAccountTransferOut is the set-transfer-out acknowledgement.

type SubAccountTransferService

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

SubAccountTransferService -- POST /api/v5/asset/subaccount/transfer (Trade)

Transfers funds between the master account and a sub-account, or between two sub-accounts (master account). Implement-only: never executed by the live test suite.

func (*SubAccountTransferService) Do

func (*SubAccountTransferService) SetLoanTrans

func (s *SubAccountTransferService) SetLoanTrans(loanTrans bool) *SubAccountTransferService

SetLoanTrans sets whether borrowing/repayment is allowed during the transfer.

func (*SubAccountTransferService) SetOmitPosRisk

func (s *SubAccountTransferService) SetOmitPosRisk(omitPosRisk string) *SubAccountTransferService

SetOmitPosRisk sets whether to ignore position risk ("true"/"false").

type SubscribeAccountGreeksService

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

SubscribeAccountGreeksService -- "account-greeks" channel (private; login).

Pushes the account's per-currency option greeks on change. Activity-driven (empty when the account holds no options).

func (*SubscribeAccountGreeksService) Do

func (s *SubscribeAccountGreeksService) Do(ctx context.Context, cb WsHandler[WsAccountGreeks]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeAccountGreeksService) SetCcy

SetCcy limits the push to a single currency.

type SubscribeAccountService

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

SubscribeAccountService -- "account" channel (private; login).

Pushes the trading-account equity snapshot on login, then on balance change.

func (*SubscribeAccountService) Do

func (s *SubscribeAccountService) Do(ctx context.Context, cb WsHandler[WsAccount]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeAccountService) SetCcy

SetCcy limits the push to a single settlement currency.

func (*SubscribeAccountService) SetExtraParams

func (s *SubscribeAccountService) SetExtraParams(extraParams string) *SubscribeAccountService

SetExtraParams sets the channel's extraParams JSON (e.g. `{"updateInterval":"0"}` to push on every change rather than on the default interval).

type SubscribeAlgoAdvanceService

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

SubscribeAlgoAdvanceService -- "algo-advance" channel (business; login).

Streams the account's advanced algo (iceberg / twap) orders for a product line. InstId narrows the subscription.

func (*SubscribeAlgoAdvanceService) Do

func (s *SubscribeAlgoAdvanceService) Do(ctx context.Context, cb WsHandler[WsAdvanceAlgoOrder]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeAlgoAdvanceService) SetInstId

SetInstId narrows the subscription to a single instrument.

type SubscribeBalanceAndPositionService

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

SubscribeBalanceAndPositionService -- "balance_and_position" channel (private; login).

Pushes a combined balance + position snapshot on login, then incremental updates (with the originating trades) on every balance/position change.

func (*SubscribeBalanceAndPositionService) Do

func (s *SubscribeBalanceAndPositionService) Do(ctx context.Context, cb WsHandler[WsBalanceAndPosition]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeBboTbtService

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

SubscribeBboTbtService -- "bbo-tbt" channel (public; no login). Tick-by-tick best bid/offer (1-level book), pushed at ~10ms.

func (*SubscribeBboTbtService) Do

func (s *SubscribeBboTbtService) Do(ctx context.Context, cb WsHandler[WsOrderBook]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeBooks5Service

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

SubscribeBooks5Service -- "books5" channel (public; no login). 5-level snapshots pushed at ~100ms.

func (*SubscribeBooks5Service) Do

func (s *SubscribeBooks5Service) Do(ctx context.Context, cb WsHandler[WsOrderBook]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeBooks50L2TbtService

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

SubscribeBooks50L2TbtService -- "books50-l2-tbt" channel (public gateway; login required). Tick-by-tick 50-level book, gated behind a VIP fee tier; without it the subscribe returns code 64003. Action is "snapshot"/"update".

func (*SubscribeBooks50L2TbtService) Do

func (s *SubscribeBooks50L2TbtService) Do(ctx context.Context, cb WsHandler[WsOrderBook]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeBooksL2TbtService

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

SubscribeBooksL2TbtService -- "books-l2-tbt" channel (public gateway; login required). Tick-by-tick 400-level book, gated behind a VIP fee tier; without it the subscribe returns code 64003. Action is "snapshot"/"update".

func (*SubscribeBooksL2TbtService) Do

func (s *SubscribeBooksL2TbtService) Do(ctx context.Context, cb WsHandler[WsOrderBook]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeBooksService

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

SubscribeBooksService -- "books" channel (public; no login). 400-level book: the first push is a "snapshot" (push.Action), subsequent pushes are "update".

func (*SubscribeBooksService) Do

func (s *SubscribeBooksService) Do(ctx context.Context, cb WsHandler[WsOrderBook]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeCandleService

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

SubscribeCandleService -- "candle{bar}" channel (business; public).

Streams the instrument's candlesticks at the given bar (e.g. "1m", "1H", "1D", "1Dutc"). The channel name is "candle"+bar; the payload is an array-of-arrays, delivered as parsed WsCandle rows.

func (*SubscribeCandleService) Do

func (s *SubscribeCandleService) Do(ctx context.Context, cb WsCandleHandler) (chan<- struct{}, <-chan struct{}, error)

type SubscribeEconomicCalendarService

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

SubscribeEconomicCalendarService -- "economic-calendar" channel (business; login).

Streams macro-economic calendar event updates. Access requires a sufficient trading-fee tier (OKX rejects lower tiers with code 64003).

func (*SubscribeEconomicCalendarService) Do

func (s *SubscribeEconomicCalendarService) Do(ctx context.Context, cb WsHandler[WsEconomicCalendar]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeFundingRateService

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

SubscribeFundingRateService -- "funding-rate" channel (public; no login).

func (*SubscribeFundingRateService) Do

func (s *SubscribeFundingRateService) Do(ctx context.Context, cb WsHandler[WsFundingRate]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeGridOrdersContractService

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

SubscribeGridOrdersContractService -- "grid-orders-contract" channel (business; login).

Streams the account's contract grid algo orders for a product line. InstId narrows the subscription.

func (*SubscribeGridOrdersContractService) Do

func (s *SubscribeGridOrdersContractService) Do(ctx context.Context, cb WsHandler[WsGridOrder]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeGridOrdersContractService) SetInstId

SetInstId narrows the subscription to a single instrument.

type SubscribeGridOrdersMoonService

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

SubscribeGridOrdersMoonService -- "grid-orders-moon" channel (business; login).

Streams the account's moon grid algo orders for a product line. InstId narrows the subscription.

func (*SubscribeGridOrdersMoonService) Do

func (s *SubscribeGridOrdersMoonService) Do(ctx context.Context, cb WsHandler[WsGridOrder]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeGridOrdersMoonService) SetInstId

SetInstId narrows the subscription to a single instrument.

type SubscribeGridOrdersSpotService

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

SubscribeGridOrdersSpotService -- "grid-orders-spot" channel (business; login).

Streams the account's spot grid algo orders for a product line. InstId narrows the subscription.

func (*SubscribeGridOrdersSpotService) Do

func (s *SubscribeGridOrdersSpotService) Do(ctx context.Context, cb WsHandler[WsGridOrder]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeGridOrdersSpotService) SetInstId

SetInstId narrows the subscription to a single instrument.

type SubscribeGridPositionsService

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

SubscribeGridPositionsService -- "grid-positions" channel (business; login).

Streams the open positions of a contract grid algo order, keyed by algoId.

func (*SubscribeGridPositionsService) Do

func (s *SubscribeGridPositionsService) Do(ctx context.Context, cb WsHandler[WsGridPosition]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeGridSubOrdersService

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

SubscribeGridSubOrdersService -- "grid-sub-orders" channel (business; login).

Streams the sub-orders (working legs) of a grid algo order, keyed by algoId.

func (*SubscribeGridSubOrdersService) Do

func (s *SubscribeGridSubOrdersService) Do(ctx context.Context, cb WsHandler[WsGridSubOrder]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeIndexCandleService

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

SubscribeIndexCandleService -- "index-candle{bar}" channel (business; public).

Streams the index's candlesticks at the given bar. The channel name is "index-candle"+bar; the payload is a 6-column array-of-arrays, delivered as parsed WsIndexCandle rows.

func (*SubscribeIndexCandleService) Do

func (s *SubscribeIndexCandleService) Do(ctx context.Context, cb WsIndexCandleHandler) (chan<- struct{}, <-chan struct{}, error)

type SubscribeIndexTickersService

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

SubscribeIndexTickersService -- "index-tickers" channel (public; no login).

func (*SubscribeIndexTickersService) Do

func (s *SubscribeIndexTickersService) Do(ctx context.Context, cb WsHandler[WsIndexTicker]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeInstrumentsService

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

SubscribeInstrumentsService -- "instruments" channel (public; no login).

func (*SubscribeInstrumentsService) Do

func (s *SubscribeInstrumentsService) Do(ctx context.Context, cb WsHandler[WsInstrument]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeLiquidationOrdersService

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

SubscribeLiquidationOrdersService -- "liquidation-orders" channel (public; no login). Forced-liquidation fills for a product line; infrequent.

func (*SubscribeLiquidationOrdersService) Do

func (s *SubscribeLiquidationOrdersService) Do(ctx context.Context, cb WsHandler[WsLiquidationOrder]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeLiquidationWarningService

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

SubscribeLiquidationWarningService -- "liquidation-warning" channel (private; login).

Pushes when a position approaches liquidation. instType is required. Activity-driven (no snapshot unless a position is at risk).

func (*SubscribeLiquidationWarningService) Do

func (s *SubscribeLiquidationWarningService) Do(ctx context.Context, cb WsHandler[WsLiquidationWarning]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeLiquidationWarningService) SetInstFamily

SetInstFamily narrows the push to one instrument family.

func (*SubscribeLiquidationWarningService) SetInstId

SetInstId narrows the push to one instrument.

type SubscribeMarkPriceCandleService

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

SubscribeMarkPriceCandleService -- "mark-price-candle{bar}" channel (business; public).

Streams the instrument's mark-price candlesticks at the given bar. The channel name is "mark-price-candle"+bar; the payload is a 6-column array-of-arrays, delivered as parsed WsIndexCandle rows.

func (*SubscribeMarkPriceCandleService) Do

func (s *SubscribeMarkPriceCandleService) Do(ctx context.Context, cb WsIndexCandleHandler) (chan<- struct{}, <-chan struct{}, error)

type SubscribeMarkPriceService

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

SubscribeMarkPriceService -- "mark-price" channel (public; no login).

func (*SubscribeMarkPriceService) Do

func (s *SubscribeMarkPriceService) Do(ctx context.Context, cb WsHandler[WsMarkPrice]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeOpenInterestService

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

SubscribeOpenInterestService -- "open-interest" channel (public; no login).

func (*SubscribeOpenInterestService) Do

func (s *SubscribeOpenInterestService) Do(ctx context.Context, cb WsHandler[WsOpenInterest]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeOrdersAlgoService

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

SubscribeOrdersAlgoService -- "orders-algo" channel (business; login).

Streams the account's conditional / oco / trigger / move_order_stop algo orders for a product line. InstFamily/InstId narrow the subscription.

func (*SubscribeOrdersAlgoService) Do

func (s *SubscribeOrdersAlgoService) Do(ctx context.Context, cb WsHandler[WsAlgoOrder]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeOrdersAlgoService) SetInstFamily

func (s *SubscribeOrdersAlgoService) SetInstFamily(instFamily string) *SubscribeOrdersAlgoService

SetInstFamily narrows the subscription to an instrument family.

func (*SubscribeOrdersAlgoService) SetInstId

SetInstId narrows the subscription to a single instrument.

type SubscribeOrdersService

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

SubscribeOrdersService -- "orders" channel (private; login).

Pushes on order create / amend / fill / cancel. Activity-driven (no snapshot).

func (*SubscribeOrdersService) Do

func (s *SubscribeOrdersService) Do(ctx context.Context, cb WsHandler[WsOrder]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribeOrdersService) SetInstFamily

func (s *SubscribeOrdersService) SetInstFamily(instFamily string) *SubscribeOrdersService

SetInstFamily narrows the push to one instrument family.

func (*SubscribeOrdersService) SetInstId

SetInstId narrows the push to one instrument.

type SubscribePositionsService

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

SubscribePositionsService -- "positions" channel (private; login).

Pushes the open-positions snapshot on login (empty array when none), then on every position change. instType is required; pass InstTypeAny for all.

func (*SubscribePositionsService) Do

func (s *SubscribePositionsService) Do(ctx context.Context, cb WsHandler[WsPosition]) (chan<- struct{}, <-chan struct{}, error)

func (*SubscribePositionsService) SetInstFamily

func (s *SubscribePositionsService) SetInstFamily(instFamily string) *SubscribePositionsService

SetInstFamily narrows the push to one instrument family.

func (*SubscribePositionsService) SetInstId

SetInstId narrows the push to one instrument.

type SubscribePriceLimitService

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

SubscribePriceLimitService -- "price-limit" channel (public; no login).

func (*SubscribePriceLimitService) Do

func (s *SubscribePriceLimitService) Do(ctx context.Context, cb WsHandler[WsPriceLimit]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeSprdBooks5Service

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

SubscribeSprdBooks5Service -- "sprd-books5" channel (business; public).

func (*SubscribeSprdBooks5Service) Do

func (s *SubscribeSprdBooks5Service) Do(ctx context.Context, cb WsHandler[WsSprdBooks]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeSprdCandleService

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

SubscribeSprdCandleService -- "sprd-candle{bar}" channel (business; public).

Streams a spread's candlesticks at the given bar. The channel name is "sprd-candle"+bar; the payload is a 7-column array-of-arrays, delivered as parsed WsSprdCandle rows.

func (*SubscribeSprdCandleService) Do

func (s *SubscribeSprdCandleService) Do(ctx context.Context, cb WsSprdCandleHandler) (chan<- struct{}, <-chan struct{}, error)

type SubscribeSprdPublicTradesService

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

SubscribeSprdPublicTradesService -- "sprd-public-trades" channel (business; public).

func (*SubscribeSprdPublicTradesService) Do

func (s *SubscribeSprdPublicTradesService) Do(ctx context.Context, cb WsHandler[WsSprdPublicTrade]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeSprdTickersService

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

SubscribeSprdTickersService -- "sprd-tickers" channel (business; public).

func (*SubscribeSprdTickersService) Do

func (s *SubscribeSprdTickersService) Do(ctx context.Context, cb WsHandler[WsSprdTicker]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeStatusService

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

SubscribeStatusService -- "status" channel (public; no login). System maintenance announcements; pushes only around maintenance windows.

func (*SubscribeStatusService) Do

func (s *SubscribeStatusService) Do(ctx context.Context, cb WsHandler[WsStatus]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeTickersService

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

SubscribeTickersService -- "tickers" channel (public; no login).

func (*SubscribeTickersService) Do

func (s *SubscribeTickersService) Do(ctx context.Context, cb WsHandler[WsTicker]) (chan<- struct{}, <-chan struct{}, error)

type SubscribeTradesService

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

SubscribeTradesService -- "trades" channel (public; no login).

func (*SubscribeTradesService) Do

func (s *SubscribeTradesService) Do(ctx context.Context, cb WsHandler[WsTrade]) (chan<- struct{}, <-chan struct{}, error)

type SurplusLmtDetails

type SurplusLmtDetails struct {
	AllAccountRemainingQuota     decimal.Decimal `json:"allAcctRemainingQuota"`
	CurrentAccountRemainingQuota decimal.Decimal `json:"curAcctRemainingQuota"`
	PlatformRemainingQuota       decimal.Decimal `json:"platRemainingQuota"`
}

SurplusLmtDetails breaks the surplus borrowing limit down by its binding constraint. OKX returns it as an empty object when no limit is currently constraining the currency.

type SystemStatus

type SystemStatus struct {
	Title               string            `json:"title"`
	State               SystemStatusState `json:"state"`
	Begin               time.Time         `json:"begin"`
	End                 time.Time         `json:"end"`
	PreOpenBegin        time.Time         `json:"preOpenBegin"`
	Href                string            `json:"href"`
	ServiceType         string            `json:"serviceType"`
	System              string            `json:"system"`
	ScheduleDescription string            `json:"scheDesc"`
	MaintenanceType     string            `json:"maintType"`
	Env                 string            `json:"env"`
}

SystemStatus is one OKX system maintenance window.

type SystemStatusState

type SystemStatusState string

SystemStatusState is the lifecycle state of a system maintenance window.

const (
	SystemStatusStateScheduled SystemStatusState = "scheduled"
	SystemStatusStateOngoing   SystemStatusState = "ongoing"
	SystemStatusStatePreOpen   SystemStatusState = "pre_open"
	SystemStatusStateCompleted SystemStatusState = "completed"
	SystemStatusStateCanceled  SystemStatusState = "canceled"
)

type SystemTime

type SystemTime struct {
	Timestamp time.Time `json:"ts"`
}

SystemTime is the OKX server time.

type TdMode

type TdMode string

TdMode is the trade (margin) mode of an order.

const (
	TdModeCash         TdMode = "cash"
	TdModeIsolated     TdMode = "isolated"
	TdModeCross        TdMode = "cross"
	TdModeSpotIsolated TdMode = "spot_isolated"
)

type TgtCcy

type TgtCcy string

TgtCcy selects whether a spot market order's size is denominated in the base or the quote currency.

const (
	TgtCcyBase  TgtCcy = "base_ccy"
	TgtCcyQuote TgtCcy = "quote_ccy"
)

type TickBand

type TickBand struct {
	MinPrice decimal.Decimal `json:"minPx"`
	MaxPrice decimal.Decimal `json:"maxPx"`
	TickSize decimal.Decimal `json:"tickSz"`
}

TickBand is one price range and its applicable tick size.

type Ticker

type Ticker struct {
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	Last              decimal.Decimal `json:"last"`
	LastSize          decimal.Decimal `json:"lastSz"`
	AskPrice          decimal.Decimal `json:"askPx"`
	AskSize           decimal.Decimal `json:"askSz"`
	BidPrice          decimal.Decimal `json:"bidPx"`
	BidSize           decimal.Decimal `json:"bidSz"`
	Open24h           decimal.Decimal `json:"open24h"`
	High24h           decimal.Decimal `json:"high24h"`
	Low24h            decimal.Decimal `json:"low24h"`
	VolumeCurrency24h decimal.Decimal `json:"volCcy24h"`
	Volume24h         decimal.Decimal `json:"vol24h"`
	StartOfDayUTC0    decimal.Decimal `json:"sodUtc0"`
	StartOfDayUTC8    decimal.Decimal `json:"sodUtc8"`
	Timestamp         time.Time       `json:"ts"`
}

Ticker is the latest market snapshot for an instrument.

type Trade

type Trade struct {
	InstrumentID string          `json:"instId"`
	TradeID      string          `json:"tradeId"`
	Price        decimal.Decimal `json:"px"`
	Size         decimal.Decimal `json:"sz"`
	Side         Side            `json:"side"`
	// Source is the trade source. "1": RPI (Retail Price Improvement) order —
	// previously documented as ELP order; the returned value itself is
	// unchanged by the ELP->RPI rebranding.
	Source    string    `json:"source"`
	Timestamp time.Time `json:"ts"`
}

Trade is a single public trade (taker fill) on an instrument.

type TradeFee

type TradeFee struct {
	InstrumentType InstType        `json:"instType"`
	Level          string          `json:"level"`
	Taker          decimal.Decimal `json:"taker"`
	Maker          decimal.Decimal `json:"maker"`
	TakerUSDT      decimal.Decimal `json:"takerU"`
	MakerUSDT      decimal.Decimal `json:"makerU"`
	TakerUSDC      decimal.Decimal `json:"takerUSDC"`
	MakerUSDC      decimal.Decimal `json:"makerUSDC"`
	Delivery       decimal.Decimal `json:"delivery"`
	Exercise       decimal.Decimal `json:"exercise"`
	Settle         decimal.Decimal `json:"settle"`
	Category       string          `json:"category"`
	RuleType       string          `json:"ruleType"`
	FeeGroup       []TradeFeeGroup `json:"feeGroup"`
	Fiat           []TradeFeeFiat  `json:"fiat"`
	Timestamp      time.Time       `json:"ts"`
}

TradeFee is the account's fee schedule for a product line.

type TradeFeeFiat

type TradeFeeFiat struct {
	Currency string          `json:"ccy"`
	Maker    decimal.Decimal `json:"maker"`
	Taker    decimal.Decimal `json:"taker"`
}

TradeFeeFiat is one fiat currency's maker/taker rates.

type TradeFeeGroup

type TradeFeeGroup struct {
	GroupID string          `json:"groupId"`
	Maker   decimal.Decimal `json:"maker"`
	Taker   decimal.Decimal `json:"taker"`
	// ElpMaker is the ELP (Enhanced Liquidity Program) maker fee rate. OKX is
	// rebranding ELP to RPI (Retail Price Improvement); the json key stays
	// "elpMaker" until the old names retire on 2026-10-31, when it becomes
	// "rpiMaker".
	ElpMaker decimal.Decimal `json:"elpMaker"`
}

TradeFeeGroup is one fee group's maker/taker rates.

type TradeOneClickRepayService

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

TradeOneClickRepayService -- POST /api/v5/trade/one-click-repay (Trade)

Repays up to five debt currencies using a single repay currency. State-changing: implemented but never executed by tests.

func (*TradeOneClickRepayService) Do

type TradeOneClickRepayV2Service

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

TradeOneClickRepayV2Service -- POST /api/v5/trade/one-click-repay-v2 (Trade)

Repays a single debt currency using a prioritized list of repay currencies. State-changing: implemented but never executed by tests.

func (*TradeOneClickRepayV2Service) Do

type TransferState

type TransferState struct {
	TransferID     string            `json:"transId"`
	ClientID       string            `json:"clientId"`
	Currency       string            `json:"ccy"`
	Amount         decimal.Decimal   `json:"amt"`
	Type           AssetTransferType `json:"type"`
	From           AssetAcctType     `json:"from"`
	To             AssetAcctType     `json:"to"`
	SubAccount     string            `json:"subAcct"`
	InstrumentID   string            `json:"instId"`
	ToInstrumentID string            `json:"toInstId"`
	State          string            `json:"state"`
}

TransferState is the status of a funds transfer.

type VipInterestAccrued

type VipInterestAccrued struct {
	OrderID      string          `json:"ordId"`
	Currency     string          `json:"ccy"`
	Interest     decimal.Decimal `json:"interest"`
	InterestRate decimal.Decimal `json:"interestRate"`
	Liability    decimal.Decimal `json:"liab"`
	Timestamp    time.Time       `json:"ts"`
}

VipInterestAccrued is one VIP-loan accrued-interest record.

type VipInterestDeducted

type VipInterestDeducted struct {
	OrderID      string          `json:"ordId"`
	Currency     string          `json:"ccy"`
	Interest     decimal.Decimal `json:"interest"`
	InterestRate decimal.Decimal `json:"interestRate"`
	Liability    decimal.Decimal `json:"liab"`
	Timestamp    time.Time       `json:"ts"`
}

VipInterestDeducted is one VIP-loan interest-deduction record.

type VipLoanOrder

type VipLoanOrder struct {
	OrderID      string          `json:"ordId"`
	State        VipLoanState    `json:"state"`
	Currency     string          `json:"ccy"`
	BorrowAmount decimal.Decimal `json:"borrowAmt"`
	CurrentRate  decimal.Decimal `json:"curRate"`
	DueAmount    decimal.Decimal `json:"dueAmt"`
	RepayAmount  decimal.Decimal `json:"repayAmt"`
	Interest     decimal.Decimal `json:"interest"`
	Timestamp    time.Time       `json:"ts"`
}

VipLoanOrder is one VIP loan order summary.

type VipLoanOrderDetail

type VipLoanOrderDetail struct {
	Currency         string                    `json:"ccy"`
	CurrentRate      decimal.Decimal           `json:"curRate"`
	DueAmount        decimal.Decimal           `json:"dueAmt"`
	TotalRepayAmount decimal.Decimal           `json:"totalRepayAmt"`
	TotalInterest    decimal.Decimal           `json:"totalInterest"`
	Timestamp        time.Time                 `json:"ts"`
	BorrowAmount     decimal.Decimal           `json:"borrowAmt"`
	RepayAmount      decimal.Decimal           `json:"repayAmt"`
	List             []VipLoanOrderDetailEvent `json:"list"`
}

VipLoanOrderDetail is the per-event detail of a VIP loan order.

type VipLoanOrderDetailEvent

type VipLoanOrderDetailEvent struct {
	Type      BorrowRepayType `json:"type"`
	Amount    decimal.Decimal `json:"amt"`
	Currency  string          `json:"ccy"`
	Timestamp time.Time       `json:"ts"`
}

VipLoanOrderDetailEvent is one borrow/repay/interest event within a VIP loan order's history.

type VipLoanState

type VipLoanState string

VipLoanState is the lifecycle state of a VIP loan order.

const (
	VipLoanStateBorrowing       VipLoanState = "1"
	VipLoanStateBorrowed        VipLoanState = "2"
	VipLoanStatePartiallyRepaid VipLoanState = "3"
	VipLoanStateRepaid          VipLoanState = "4"
	VipLoanStateRepaying        VipLoanState = "5"
)

type WebSocketClient

type WebSocketClient struct {
	*client.WebSocketClient
}

WebSocketClient streams OKX v5 public, private and business channels. Public channels need no credentials; private and (private) business channels require WithWebSocketAuth and log in automatically.

func NewWebSocketClient

func NewWebSocketClient(options ...client.WebSocketOptions) *WebSocketClient

NewWebSocketClient constructs an OKX v5 WebSocket client.

func (*WebSocketClient) DialTrade

func (c *WebSocketClient) DialTrade(ctx context.Context) (*WsTradeConn, error)

DialTrade dials the private gateway, logs in, and returns a ready order-entry connection. The caller must Close it.

func (*WebSocketClient) NewSubscribeAccountGreeksService

func (c *WebSocketClient) NewSubscribeAccountGreeksService() *SubscribeAccountGreeksService

func (*WebSocketClient) NewSubscribeAccountService

func (c *WebSocketClient) NewSubscribeAccountService() *SubscribeAccountService

func (*WebSocketClient) NewSubscribeAlgoAdvanceService

func (c *WebSocketClient) NewSubscribeAlgoAdvanceService(instType InstType) *SubscribeAlgoAdvanceService

func (*WebSocketClient) NewSubscribeBalanceAndPositionService

func (c *WebSocketClient) NewSubscribeBalanceAndPositionService() *SubscribeBalanceAndPositionService

func (*WebSocketClient) NewSubscribeBboTbtService

func (c *WebSocketClient) NewSubscribeBboTbtService(instId string) *SubscribeBboTbtService

func (*WebSocketClient) NewSubscribeBooks5Service

func (c *WebSocketClient) NewSubscribeBooks5Service(instId string) *SubscribeBooks5Service

func (*WebSocketClient) NewSubscribeBooks50L2TbtService

func (c *WebSocketClient) NewSubscribeBooks50L2TbtService(instId string) *SubscribeBooks50L2TbtService

func (*WebSocketClient) NewSubscribeBooksL2TbtService

func (c *WebSocketClient) NewSubscribeBooksL2TbtService(instId string) *SubscribeBooksL2TbtService

func (*WebSocketClient) NewSubscribeBooksService

func (c *WebSocketClient) NewSubscribeBooksService(instId string) *SubscribeBooksService

func (*WebSocketClient) NewSubscribeCandleService

func (c *WebSocketClient) NewSubscribeCandleService(instId, bar string) *SubscribeCandleService

func (*WebSocketClient) NewSubscribeEconomicCalendarService

func (c *WebSocketClient) NewSubscribeEconomicCalendarService() *SubscribeEconomicCalendarService

func (*WebSocketClient) NewSubscribeFundingRateService

func (c *WebSocketClient) NewSubscribeFundingRateService(instId string) *SubscribeFundingRateService

func (*WebSocketClient) NewSubscribeGridOrdersContractService

func (c *WebSocketClient) NewSubscribeGridOrdersContractService(instType InstType) *SubscribeGridOrdersContractService

func (*WebSocketClient) NewSubscribeGridOrdersMoonService

func (c *WebSocketClient) NewSubscribeGridOrdersMoonService(instType InstType) *SubscribeGridOrdersMoonService

func (*WebSocketClient) NewSubscribeGridOrdersSpotService

func (c *WebSocketClient) NewSubscribeGridOrdersSpotService(instType InstType) *SubscribeGridOrdersSpotService

func (*WebSocketClient) NewSubscribeGridPositionsService

func (c *WebSocketClient) NewSubscribeGridPositionsService(algoId string) *SubscribeGridPositionsService

func (*WebSocketClient) NewSubscribeGridSubOrdersService

func (c *WebSocketClient) NewSubscribeGridSubOrdersService(algoId string) *SubscribeGridSubOrdersService

func (*WebSocketClient) NewSubscribeIndexCandleService

func (c *WebSocketClient) NewSubscribeIndexCandleService(instId, bar string) *SubscribeIndexCandleService

func (*WebSocketClient) NewSubscribeIndexTickersService

func (c *WebSocketClient) NewSubscribeIndexTickersService(instId string) *SubscribeIndexTickersService

func (*WebSocketClient) NewSubscribeInstrumentsService

func (c *WebSocketClient) NewSubscribeInstrumentsService(instType InstType) *SubscribeInstrumentsService

func (*WebSocketClient) NewSubscribeLiquidationOrdersService

func (c *WebSocketClient) NewSubscribeLiquidationOrdersService(instType InstType) *SubscribeLiquidationOrdersService

func (*WebSocketClient) NewSubscribeLiquidationWarningService

func (c *WebSocketClient) NewSubscribeLiquidationWarningService(instType InstType) *SubscribeLiquidationWarningService

func (*WebSocketClient) NewSubscribeMarkPriceCandleService

func (c *WebSocketClient) NewSubscribeMarkPriceCandleService(instId, bar string) *SubscribeMarkPriceCandleService

func (*WebSocketClient) NewSubscribeMarkPriceService

func (c *WebSocketClient) NewSubscribeMarkPriceService(instId string) *SubscribeMarkPriceService

func (*WebSocketClient) NewSubscribeOpenInterestService

func (c *WebSocketClient) NewSubscribeOpenInterestService(instId string) *SubscribeOpenInterestService

func (*WebSocketClient) NewSubscribeOrdersAlgoService

func (c *WebSocketClient) NewSubscribeOrdersAlgoService(instType InstType) *SubscribeOrdersAlgoService

func (*WebSocketClient) NewSubscribeOrdersService

func (c *WebSocketClient) NewSubscribeOrdersService(instType InstType) *SubscribeOrdersService

func (*WebSocketClient) NewSubscribePositionsService

func (c *WebSocketClient) NewSubscribePositionsService(instType InstType) *SubscribePositionsService

func (*WebSocketClient) NewSubscribePriceLimitService

func (c *WebSocketClient) NewSubscribePriceLimitService(instId string) *SubscribePriceLimitService

func (*WebSocketClient) NewSubscribeSprdBooks5Service

func (c *WebSocketClient) NewSubscribeSprdBooks5Service(sprdId string) *SubscribeSprdBooks5Service

func (*WebSocketClient) NewSubscribeSprdCandleService

func (c *WebSocketClient) NewSubscribeSprdCandleService(sprdId, bar string) *SubscribeSprdCandleService

func (*WebSocketClient) NewSubscribeSprdPublicTradesService

func (c *WebSocketClient) NewSubscribeSprdPublicTradesService(sprdId string) *SubscribeSprdPublicTradesService

func (*WebSocketClient) NewSubscribeSprdTickersService

func (c *WebSocketClient) NewSubscribeSprdTickersService(sprdId string) *SubscribeSprdTickersService

func (*WebSocketClient) NewSubscribeStatusService

func (c *WebSocketClient) NewSubscribeStatusService() *SubscribeStatusService

func (*WebSocketClient) NewSubscribeTickersService

func (c *WebSocketClient) NewSubscribeTickersService(instId string) *SubscribeTickersService

func (*WebSocketClient) NewSubscribeTradesService

func (c *WebSocketClient) NewSubscribeTradesService(instId string) *SubscribeTradesService

func (*WebSocketClient) Subscribe

func (c *WebSocketClient) Subscribe(ctx context.Context, gateway request.Gateway, private bool, arg request.WsArg, cb func([]byte, error)) (chan<- struct{}, <-chan struct{}, error)

Subscribe is the low-level escape hatch: it subscribes to an arbitrary channel on the given gateway (request.GatewayPublic / GatewayPrivate / GatewayBusiness) and delivers each data push's raw bytes. Prefer the typed NewSubscribe* services; use this for channels the SDK does not yet wrap.

type WithdrawGridIncomeService

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

WithdrawGridIncomeService -- POST /api/v5/tradingBot/grid/withdraw-income (Trade)

Withdraws the realized grid profit of a spot grid to the trading account. IMPLEMENT-ONLY.

func (*WithdrawGridIncomeService) Do

type Withdrawal

type Withdrawal struct {
	Currency     string          `json:"ccy"`
	Chain        string          `json:"chain"`
	Amount       decimal.Decimal `json:"amt"`
	WithdrawalID string          `json:"wdId"`
	ClientID     string          `json:"clientId"`
}

Withdrawal is the acknowledgement of a submitted withdrawal.

type WithdrawalHistory

type WithdrawalHistory struct {
	Currency         string          `json:"ccy"`
	Chain            string          `json:"chain"`
	NonTradableAsset bool            `json:"nonTradableAsset"`
	Amount           decimal.Decimal `json:"amt"`
	Timestamp        time.Time       `json:"ts"`
	From             string          `json:"from"`
	AreaCodeFrom     string          `json:"areaCodeFrom"`
	To               string          `json:"to"`
	AreaCodeTo       string          `json:"areaCodeTo"`
	Memo             string          `json:"memo"`
	ToAddressType    string          `json:"toAddrType"`
	TransactionID    string          `json:"txId"`
	Fee              decimal.Decimal `json:"fee"`
	FeeCurrency      string          `json:"feeCcy"`
	State            string          `json:"state"`
	WithdrawalID     string          `json:"wdId"`
	ClientID         string          `json:"clientId"`
	Note             string          `json:"note"`
}

WithdrawalHistory is one withdrawal record.

type WithdrawalService

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

WithdrawalService -- POST /api/v5/asset/withdrawal (private)

Submits a withdrawal (on-chain or internal). IMPLEMENT-ONLY: this withdraws real funds and must NEVER be executed.

func (*WithdrawalService) Do

func (*WithdrawalService) SetAreaCode

func (s *WithdrawalService) SetAreaCode(areaCode string) *WithdrawalService

SetAreaCode sets the mobile area code (required for some internal withdrawals).

func (*WithdrawalService) SetChain

func (s *WithdrawalService) SetChain(chain string) *WithdrawalService

SetChain sets the chain (e.g. "USDT-ERC20"); required for on-chain withdrawals of multi-chain currencies.

func (*WithdrawalService) SetClientId

func (s *WithdrawalService) SetClientId(clientId string) *WithdrawalService

SetClientId sets a client-supplied withdrawal id.

func (*WithdrawalService) SetFee

SetFee sets the network fee (on-chain only).

func (*WithdrawalService) SetRcvrInfo

func (s *WithdrawalService) SetRcvrInfo(rcvrInfo any) *WithdrawalService

SetRcvrInfo sets the recipient information (required by some jurisdictions).

type WsAccount

type WsAccount struct {
	UpdateTime            time.Time         `json:"uTime"`
	TotalEquity           decimal.Decimal   `json:"totalEq"`
	IsolatedEquity        decimal.Decimal   `json:"isoEq"`
	AdjustedEquity        decimal.Decimal   `json:"adjEq"`
	AvailableEquity       decimal.Decimal   `json:"availEq"`
	OrderFrozen           decimal.Decimal   `json:"ordFroz"`
	IMR                   decimal.Decimal   `json:"imr"`
	MMR                   decimal.Decimal   `json:"mmr"`
	BorrowFrozen          decimal.Decimal   `json:"borrowFroz"`
	MarginRatio           decimal.Decimal   `json:"mgnRatio"`
	NotionalUSD           decimal.Decimal   `json:"notionalUsd"`
	NotionalUSDForBorrow  decimal.Decimal   `json:"notionalUsdForBorrow"`
	NotionalUSDForSwap    decimal.Decimal   `json:"notionalUsdForSwap"`
	NotionalUSDForFutures decimal.Decimal   `json:"notionalUsdForFutures"`
	NotionalUSDForOption  decimal.Decimal   `json:"notionalUsdForOption"`
	UPL                   decimal.Decimal   `json:"upl"`
	Delta                 decimal.Decimal   `json:"delta"`
	DeltaLeverage         decimal.Decimal   `json:"deltaLever"`
	DeltaNeutralStatus    string            `json:"deltaNeutralStatus"`
	Details               []WsAccountDetail `json:"details"`
}

WsAccount is one "account" channel push: account-level equity plus per-currency details. It mirrors the REST Balance but is the WebSocket variant (it adds coinUsdPrice/frpType per detail and omits some REST-only fields).

type WsAccountDetail

type WsAccountDetail struct {
	Currency                       string          `json:"ccy"`
	Equity                         decimal.Decimal `json:"eq"`
	CashBalance                    decimal.Decimal `json:"cashBal"`
	UpdateTime                     time.Time       `json:"uTime"`
	IsolatedEquity                 decimal.Decimal `json:"isoEq"`
	AvailableEquity                decimal.Decimal `json:"availEq"`
	DiscountEquity                 decimal.Decimal `json:"disEq"`
	FixedBalance                   decimal.Decimal `json:"fixedBal"`
	AvailableBalance               decimal.Decimal `json:"availBal"`
	FrozenBalance                  decimal.Decimal `json:"frozenBal"`
	OrderFrozen                    decimal.Decimal `json:"ordFrozen"`
	Liability                      decimal.Decimal `json:"liab"`
	UPL                            decimal.Decimal `json:"upl"`
	UPLLiability                   decimal.Decimal `json:"uplLiab"`
	CrossLiability                 decimal.Decimal `json:"crossLiab"`
	IsolatedLiability              decimal.Decimal `json:"isoLiab"`
	RewardBalance                  decimal.Decimal `json:"rewardBal"`
	MarginRatio                    decimal.Decimal `json:"mgnRatio"`
	IMR                            decimal.Decimal `json:"imr"`
	MMR                            decimal.Decimal `json:"mmr"`
	Interest                       decimal.Decimal `json:"interest"`
	TWAP                           decimal.Decimal `json:"twap"`
	MaxLoan                        decimal.Decimal `json:"maxLoan"`
	EquityUSD                      decimal.Decimal `json:"eqUsd"`
	CoinUSDPrice                   decimal.Decimal `json:"coinUsdPrice"`
	BorrowFrozen                   decimal.Decimal `json:"borrowFroz"`
	NotionalLeverage               decimal.Decimal `json:"notionalLever"`
	StrategyEquity                 decimal.Decimal `json:"stgyEq"`
	IsolatedUPL                    decimal.Decimal `json:"isoUpl"`
	SpotInUseAmount                decimal.Decimal `json:"spotInUseAmt"`
	ClientSpotInUseAmount          decimal.Decimal `json:"clSpotInUseAmt"`
	MaxSpotInUseAmount             decimal.Decimal `json:"maxSpotInUseAmt"`
	SpotIsolatedBalance            decimal.Decimal `json:"spotIsoBal"`
	SmtSyncEquity                  decimal.Decimal `json:"smtSyncEq"`
	SpotCopyTradingEquity          decimal.Decimal `json:"spotCopyTradingEq"`
	SpotBalance                    decimal.Decimal `json:"spotBal"`
	OpenAveragePrice               decimal.Decimal `json:"openAvgPx"`
	AccumulatedAveragePrice        decimal.Decimal `json:"accAvgPx"`
	SpotUPL                        decimal.Decimal `json:"spotUpl"`
	SpotUPLRatio                   decimal.Decimal `json:"spotUplRatio"`
	TotalPnl                       decimal.Decimal `json:"totalPnl"`
	TotalPnlRatio                  decimal.Decimal `json:"totalPnlRatio"`
	CollateralEnabled              bool            `json:"collateralEnabled"`
	CollateralRestrict             bool            `json:"collateralRestrict"`
	CollateralBorrowAutoConversion decimal.Decimal `json:"colBorrAutoConversion"`
	ColRes                         string          `json:"colRes"`
	AutoLendStatus                 string          `json:"autoLendStatus"`
	AutoLendAmount                 decimal.Decimal `json:"autoLendAmt"`
	AutoLendMatchedAmount          decimal.Decimal `json:"autoLendMtAmt"`
	AutoStakingStatus              string          `json:"autoStakingStatus"`
	FrpType                        string          `json:"frpType"`
}

WsAccountDetail is one currency's balance within an "account" push.

type WsAccountGreeks

type WsAccountGreeks struct {
	Currency  string          `json:"ccy"`
	DeltaBS   decimal.Decimal `json:"deltaBS"`
	DeltaPA   decimal.Decimal `json:"deltaPA"`
	GammaBS   decimal.Decimal `json:"gammaBS"`
	GammaPA   decimal.Decimal `json:"gammaPA"`
	ThetaBS   decimal.Decimal `json:"thetaBS"`
	ThetaPA   decimal.Decimal `json:"thetaPA"`
	VegaBS    decimal.Decimal `json:"vegaBS"`
	VegaPA    decimal.Decimal `json:"vegaPA"`
	Timestamp time.Time       `json:"ts"`
}

WsAccountGreeks is one currency's aggregated option greeks from the "account-greeks" channel. The validating account held no options, so the field set is modeled from the OKX channel field table.

type WsAdvanceAlgoOrder

type WsAdvanceAlgoOrder struct {
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	Currency          string          `json:"ccy"`
	OrderID           string          `json:"ordId"`
	AlgoID            string          `json:"algoId"`
	ClientOrderID     string          `json:"clOrdId"`
	AlgoClientOrderID string          `json:"algoClOrdId"`
	Size              decimal.Decimal `json:"sz"`
	OrderType         AlgoOrdType     `json:"ordType"`
	Side              Side            `json:"side"`
	PositionSide      PosSide         `json:"posSide"`
	TradeMode         TdMode          `json:"tdMode"`
	TargetCurrency    TgtCcy          `json:"tgtCcy"`
	State             AlgoState       `json:"state"`
	Leverage          decimal.Decimal `json:"lever"`
	PriceVariation    decimal.Decimal `json:"pxVar"`
	PriceSpread       decimal.Decimal `json:"pxSpread"`
	PriceLimit        decimal.Decimal `json:"pxLimit"`
	SizeLimit         decimal.Decimal `json:"szLimit"`
	TimeInterval      string          `json:"timeInterval"`
	TriggerPrice      decimal.Decimal `json:"triggerPx"`
	OrderPrice        decimal.Decimal `json:"ordPx"`
	ActualSize        decimal.Decimal `json:"actualSz"`
	ActualPrice       decimal.Decimal `json:"actualPx"`
	ActualSide        string          `json:"actualSide"`
	NotionalUSD       decimal.Decimal `json:"notionalUsd"`
	TriggerTime       time.Time       `json:"triggerTime"`
	Tag               string          `json:"tag"`
	Count             string          `json:"count"`
	Last              decimal.Decimal `json:"last"`
	FailCode          string          `json:"failCode"`
	AmendResult       string          `json:"amendResult"`
	RequestID         string          `json:"reqId"`
	CreationTime      time.Time       `json:"cTime"`
	UpdateTime        time.Time       `json:"uTime"`
}

WsAdvanceAlgoOrder is a single advanced algo (iceberg / twap / grid) order pushed by the "algo-advance" channel. The validating account had no advanced algo orders, so the field set is modeled from the OKX WS doc field table for the algo-advance channel.

type WsAlgoOrder

type WsAlgoOrder struct {
	InstrumentType             InstType        `json:"instType"`
	InstrumentID               string          `json:"instId"`
	Currency                   string          `json:"ccy"`
	OrderID                    string          `json:"ordId"`
	AlgoID                     string          `json:"algoId"`
	ClientOrderID              string          `json:"clOrdId"`
	AlgoClientOrderID          string          `json:"algoClOrdId"`
	Size                       decimal.Decimal `json:"sz"`
	OrderType                  AlgoOrdType     `json:"ordType"`
	Side                       Side            `json:"side"`
	PositionSide               PosSide         `json:"posSide"`
	TradeMode                  TdMode          `json:"tdMode"`
	TargetCurrency             TgtCcy          `json:"tgtCcy"`
	NotionalUSD                decimal.Decimal `json:"notionalUsd"`
	OrderPrice                 decimal.Decimal `json:"ordPx"`
	Price                      decimal.Decimal `json:"px"`
	State                      AlgoState       `json:"state"`
	Leverage                   decimal.Decimal `json:"lever"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx"`
	TriggerPrice               decimal.Decimal `json:"triggerPx"`
	TriggerPriceType           string          `json:"triggerPxType"`
	OrderPriceType             string          `json:"ordPxType"`
	ActualSize                 decimal.Decimal `json:"actualSz"`
	ActualPrice                decimal.Decimal `json:"actualPx"`
	ActualSide                 string          `json:"actualSide"`
	TriggerTime                time.Time       `json:"triggerTime"`
	Tag                        string          `json:"tag"`
	ReduceOnly                 string          `json:"reduceOnly"`
	Last                       decimal.Decimal `json:"last"`
	FailCode                   string          `json:"failCode"`
	AmendResult                string          `json:"amendResult"`
	RequestID                  string          `json:"reqId"`
	AmendPriceOnTriggerType    string          `json:"amendPxOnTriggerType"`
	CreationTime               time.Time       `json:"cTime"`
	UpdateTime                 time.Time       `json:"uTime"`
}

WsAlgoOrder is a single algo (conditional / oco / trigger / move_order_stop) order pushed by the "orders-algo" channel. The validating account had no algo orders, so the field set is a union modeled from the OKX WS doc field table for the orders-algo channel.

type WsBalData

type WsBalData struct {
	Currency    string          `json:"ccy"`
	CashBalance decimal.Decimal `json:"cashBal"`
	UpdateTime  time.Time       `json:"uTime"`
}

WsBalData is one currency's balance change within a "balance_and_position" push.

type WsBalPosTrade

type WsBalPosTrade struct {
	InstrumentID string `json:"instId"`
	TradeID      string `json:"tradeId"`
}

WsBalPosTrade is one trade that triggered a "balance_and_position" update. The validating account had no live trades, so the field set is modeled from the OKX channel field table.

type WsBalanceAndPosition

type WsBalanceAndPosition struct {
	PushTime     time.Time       `json:"pTime"`
	EventType    string          `json:"eventType"`
	BalanceData  []WsBalData     `json:"balData"`
	PositionData []WsPosition    `json:"posData"`
	Trades       []WsBalPosTrade `json:"trades"`
}

WsBalanceAndPosition is one "balance_and_position" push: the publish time, the event type ("snapshot"/"delivered"/"exercised"/"transferred"/"filled"/...), the changed balances, the changed positions and the triggering trades.

type WsCandle

type WsCandle struct {
	Timestamp           time.Time
	Open                decimal.Decimal
	High                decimal.Decimal
	Low                 decimal.Decimal
	Close               decimal.Decimal
	Volume              decimal.Decimal
	VolumeCurrency      decimal.Decimal
	VolumeCurrencyQuote decimal.Decimal
	Confirm             string
}

WsCandle is one OHLCV candlestick pushed by the "candle{bar}" channel. The raw data frame is an array-of-arrays with 9 columns: [ts, o, h, l, c, vol, volCcy, volCcyQuote, confirm].

type WsCandleHandler

type WsCandleHandler func([]WsCandle, error)

WsCandleHandler is invoked for every "candle{bar}" push (or error). The push's data array is parsed into typed WsCandle rows.

type WsEconomicCalendar

type WsEconomicCalendar struct {
	CalendarID      string                     `json:"calendarId"`
	Date            time.Time                  `json:"date"`
	Region          string                     `json:"region"`
	Category        string                     `json:"category"`
	Event           string                     `json:"event"`
	ReferenceDate   time.Time                  `json:"refDate"`
	Actual          string                     `json:"actual"`
	Previous        string                     `json:"previous"`
	Forecast        string                     `json:"forecast"`
	DateSpan        string                     `json:"dateSpan"`
	Importance      EconomicCalendarImportance `json:"importance"`
	UpdateTime      time.Time                  `json:"uTime"`
	PreviousInitial string                     `json:"prevInitial"`
	Currency        string                     `json:"ccy"`
	Unit            string                     `json:"unit"`
}

WsEconomicCalendar is one macro-economic calendar event pushed by the "economic-calendar" channel. Access requires a sufficient trading-fee tier; the field set matches the REST economic-calendar response.

type WsFundingRate

type WsFundingRate struct {
	InstrumentType        InstType        `json:"instType"`
	InstrumentID          string          `json:"instId"`
	Method                string          `json:"method"`
	FormulaType           string          `json:"formulaType"`
	FundingRate           decimal.Decimal `json:"fundingRate"`
	NextFundingRate       decimal.Decimal `json:"nextFundingRate"`
	FundingTime           time.Time       `json:"fundingTime"`
	NextFundingTime       time.Time       `json:"nextFundingTime"`
	MinFundingRate        decimal.Decimal `json:"minFundingRate"`
	MaxFundingRate        decimal.Decimal `json:"maxFundingRate"`
	InterestRate          decimal.Decimal `json:"interestRate"`
	ImpactValue           decimal.Decimal `json:"impactValue"`
	SettlementState       string          `json:"settState"`
	SettlementFundingRate decimal.Decimal `json:"settFundingRate"`
	Premium               decimal.Decimal `json:"premium"`
	PreviousFundingTime   time.Time       `json:"prevFundingTime"`
	Timestamp             time.Time       `json:"ts"`
}

WsFundingRate is a perpetual swap's funding rate pushed on the "funding-rate" channel.

type WsGridOrder

type WsGridOrder struct {
	AlgoID                 string             `json:"algoId"`
	AlgoClientOrderID      string             `json:"algoClOrdId"`
	AlgoOrderType          GridAlgoOrdType    `json:"algoOrdType"`
	InstrumentType         InstType           `json:"instType"`
	InstrumentID           string             `json:"instId"`
	CancelType             string             `json:"cancelType"`
	State                  string             `json:"state"`
	RunType                GridRunType        `json:"runType"`
	GridNumber             decimal.Decimal    `json:"gridNum"`
	MaxPrice               decimal.Decimal    `json:"maxPx"`
	MinPrice               decimal.Decimal    `json:"minPx"`
	GridProfit             decimal.Decimal    `json:"gridProfit"`
	TotalPnl               decimal.Decimal    `json:"totalPnl"`
	PnlRatio               decimal.Decimal    `json:"pnlRatio"`
	FloatProfit            decimal.Decimal    `json:"floatProfit"`
	TotalAnnualizedRate    decimal.Decimal    `json:"totalAnnualizedRate"`
	AnnualizedRate         decimal.Decimal    `json:"annualizedRate"`
	Investment             decimal.Decimal    `json:"investment"`
	TakeProfitTriggerPrice decimal.Decimal    `json:"tpTriggerPx"`
	StopLossTriggerPrice   decimal.Decimal    `json:"slTriggerPx"`
	TriggerPrice           decimal.Decimal    `json:"triggerPx"`
	StopType               string             `json:"stopType"`
	StopResult             string             `json:"stopResult"`
	ActiveOrderNumber      decimal.Decimal    `json:"activeOrdNum"`
	Tag                    string             `json:"tag"`
	ProfitSharingRatio     decimal.Decimal    `json:"profitSharingRatio"`
	CopyType               string             `json:"copyType"`
	Fee                    decimal.Decimal    `json:"fee"`
	FundingFee             decimal.Decimal    `json:"fundingFee"`
	RebateTransfer         []GridRebateTrans  `json:"rebateTrans"`
	TriggerParams          []GridTriggerParam `json:"triggerParams"`
	TriggerTime            time.Time          `json:"triggerTime"`
	CreationTime           time.Time          `json:"cTime"`
	UpdateTime             time.Time          `json:"uTime"`

	// --- spot/moon grid ("grid"/"moon_grid") ---
	BaseSize                decimal.Decimal `json:"baseSz"`
	QuoteSize               decimal.Decimal `json:"quoteSz"`
	BaseCurrency            string          `json:"baseCcy"`
	QuoteCurrency           string          `json:"quoteCcy"`
	TradeMode               TdMode          `json:"tdMode"`
	ProfitAndLoss           decimal.Decimal `json:"profitAndLoss"`
	GridArithmeticGeometric string          `json:"gridArithGeo"`
	MinTradeFeeRate         decimal.Decimal `json:"minTradeFeeRate"`

	// --- contract grid ("contract_grid") ---
	Direction          GridDirection   `json:"direction"`
	BasePosition       bool            `json:"basePos"`
	Size               decimal.Decimal `json:"sz"`
	Currency           string          `json:"ccy"`
	Equity             decimal.Decimal `json:"eq"`
	Underlying         string          `json:"uly"`
	InstrumentFamily   string          `json:"instFamily"`
	Leverage           decimal.Decimal `json:"lever"`
	TakeProfitRatio    decimal.Decimal `json:"tpRatio"`
	StopLossRatio      decimal.Decimal `json:"slRatio"`
	AvailableEquity    decimal.Decimal `json:"availEq"`
	LiquidationPrice   decimal.Decimal `json:"liqPx"`
	UPLRatio           decimal.Decimal `json:"uplRatio"`
	UPL                decimal.Decimal `json:"upl"`
	TotalInvestment    decimal.Decimal `json:"totalInvestment"`
	GridInvestment     decimal.Decimal `json:"gridInvestment"`
	MarginRatio        decimal.Decimal `json:"marginRatio"`
	Arbitrage          decimal.Decimal `json:"arbitrage"`
	SingleAmount       decimal.Decimal `json:"singleAmt"`
	PerMaxProfitRate   decimal.Decimal `json:"perMaxProfitRate"`
	PerMinProfitRate   decimal.Decimal `json:"perMinProfitRate"`
	OrderFrozen        decimal.Decimal `json:"ordFrozen"`
	ActualLeverage     decimal.Decimal `json:"actualLever"`
	InvestmentCurrency string          `json:"investmentCcy"`
}

WsGridOrder is a single grid algo order pushed by the "grid-orders-spot", "grid-orders-contract" and "grid-orders-moon" channels. The validating account had no grid orders, so the field set is a union modeled from the OKX WS doc field tables for those channels (spot / contract / moon grid).

type WsGridPosition

type WsGridPosition struct {
	AlgoID            string          `json:"algoId"`
	AlgoClientOrderID string          `json:"algoClOrdId"`
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	Currency          string          `json:"ccy"`
	PositionSide      PosSide         `json:"posSide"`
	MarginMode        MgnMode         `json:"mgnMode"`
	Position          decimal.Decimal `json:"pos"`
	AveragePrice      decimal.Decimal `json:"avgPx"`
	LiquidationPrice  decimal.Decimal `json:"liqPx"`
	MarkPrice         decimal.Decimal `json:"markPx"`
	Leverage          decimal.Decimal `json:"lever"`
	IMR               decimal.Decimal `json:"imr"`
	MMR               decimal.Decimal `json:"mmr"`
	MarginRatio       decimal.Decimal `json:"mgnRatio"`
	Margin            decimal.Decimal `json:"margin"`
	NotionalUSD       decimal.Decimal `json:"notionalUsd"`
	Last              decimal.Decimal `json:"last"`
	UPL               decimal.Decimal `json:"upl"`
	UPLRatio          decimal.Decimal `json:"uplRatio"`
	CreationTime      time.Time       `json:"cTime"`
	UpdateTime        time.Time       `json:"uTime"`
}

WsGridPosition is the position held by a contract grid algo order pushed by the "grid-positions" channel. The validating account had no grid orders, so the field set is modeled from the OKX WS doc field table.

type WsGridSubOrder

type WsGridSubOrder struct {
	AlgoID              string          `json:"algoId"`
	AlgoClientOrderID   string          `json:"algoClOrdId"`
	AlgoOrderType       GridAlgoOrdType `json:"algoOrdType"`
	InstrumentType      InstType        `json:"instType"`
	InstrumentID        string          `json:"instId"`
	GroupID             string          `json:"groupId"`
	OrderID             string          `json:"ordId"`
	ClientOrderID       string          `json:"clOrdId"`
	Tag                 string          `json:"tag"`
	OrderType           OrdType         `json:"ordType"`
	Side                Side            `json:"side"`
	PositionSide        PosSide         `json:"posSide"`
	TradeMode           TdMode          `json:"tdMode"`
	Currency            string          `json:"ccy"`
	Price               decimal.Decimal `json:"px"`
	Size                decimal.Decimal `json:"sz"`
	State               OrdState        `json:"state"`
	AccumulatedFillSize decimal.Decimal `json:"accFillSz"`
	AveragePrice        decimal.Decimal `json:"avgPx"`
	Leverage            decimal.Decimal `json:"lever"`
	Fee                 decimal.Decimal `json:"fee"`
	FeeCurrency         string          `json:"feeCcy"`
	Rebate              decimal.Decimal `json:"rebate"`
	RebateCurrency      string          `json:"rebateCcy"`
	Pnl                 decimal.Decimal `json:"pnl"`
	CreationTime        time.Time       `json:"cTime"`
	UpdateTime          time.Time       `json:"uTime"`
}

WsGridSubOrder is one sub-order (working leg) of a grid algo order pushed by the "grid-sub-orders" channel. The validating account had no grid orders, so the field set is modeled from the OKX WS doc field table.

type WsHandler

type WsHandler[T any] func(*request.WsPush[[]T], error)

WsHandler is invoked for every push (or error) on a subscription. The push's Data field is already decoded into the channel's typed slice.

type WsIndexCandle

type WsIndexCandle struct {
	Timestamp time.Time
	Open      decimal.Decimal
	High      decimal.Decimal
	Low       decimal.Decimal
	Close     decimal.Decimal
	Confirm   string
}

WsIndexCandle is one OHLC candlestick pushed by the "mark-price-candle{bar}" and "index-candle{bar}" channels. The raw data frame is an array-of-arrays with 6 columns: [ts, o, h, l, c, confirm] (no volume).

type WsIndexCandleHandler

type WsIndexCandleHandler func([]WsIndexCandle, error)

WsIndexCandleHandler is invoked for every mark-price-candle / index-candle push (or error).

type WsIndexTicker

type WsIndexTicker struct {
	InstrumentID   string          `json:"instId"`
	IndexPrice     decimal.Decimal `json:"idxPx"`
	Open24h        decimal.Decimal `json:"open24h"`
	High24h        decimal.Decimal `json:"high24h"`
	Low24h         decimal.Decimal `json:"low24h"`
	StartOfDayUTC0 decimal.Decimal `json:"sodUtc0"`
	StartOfDayUTC8 decimal.Decimal `json:"sodUtc8"`
	Timestamp      time.Time       `json:"ts"`
}

WsIndexTicker is an index's latest snapshot pushed on the "index-tickers" channel. idxPx is the index price; there is no last-trade or volume.

type WsInstrument

type WsInstrument struct {
	InstrumentType            InstType        `json:"instType"`
	InstrumentID              string          `json:"instId"`
	InstrumentIDCode          int64           `json:"instIdCode"`
	Underlying                string          `json:"uly"`
	InstrumentFamily          string          `json:"instFamily"`
	InstrumentCategory        string          `json:"instCategory"`
	BaseCurrency              string          `json:"baseCcy"`
	QuoteCurrency             string          `json:"quoteCcy"`
	SettleCurrency            string          `json:"settleCcy"`
	ContractValue             decimal.Decimal `json:"ctVal"`
	ContractMultiplier        decimal.Decimal `json:"ctMult"`
	ContractValueCurrency     string          `json:"ctValCcy"`
	OptionType                OptType         `json:"optType"`
	Strike                    decimal.Decimal `json:"stk"`
	ListTime                  time.Time       `json:"listTime"`
	AuctionEndTime            time.Time       `json:"auctionEndTime"`
	ContinuousTradeSwitchTime time.Time       `json:"contTdSwTime"`
	OpenType                  string          `json:"openType"`
	ExpiryTime                time.Time       `json:"expTime"`
	Leverage                  decimal.Decimal `json:"lever"`
	TickSize                  decimal.Decimal `json:"tickSz"`
	LotSize                   decimal.Decimal `json:"lotSz"`
	MinSize                   decimal.Decimal `json:"minSz"`
	ContractType              CtType          `json:"ctType"`
	Alias                     string          `json:"alias"`
	State                     InstState       `json:"state"`
	// RuleType is the trading rule type: "normal", "pre_market" (including
	// pre-market X-Perp FUTURES), "rebase_contract" and "xperp" (a pre-market
	// X-Perp changes from "pre_market" to "xperp" after converting to a normal
	// X-Perp).
	RuleType                         string          `json:"ruleType"`
	MaxLimitSize                     decimal.Decimal `json:"maxLmtSz"`
	MaxMarketSize                    decimal.Decimal `json:"maxMktSz"`
	MaxLimitAmount                   decimal.Decimal `json:"maxLmtAmt"`
	MaxMarketAmount                  decimal.Decimal `json:"maxMktAmt"`
	MaxTWAPSize                      decimal.Decimal `json:"maxTwapSz"`
	MaxIcebergSize                   decimal.Decimal `json:"maxIcebergSz"`
	MaxTriggerSize                   decimal.Decimal `json:"maxTriggerSz"`
	MaxStopSize                      decimal.Decimal `json:"maxStopSz"`
	MaxPlatformOpenInterestLimit     decimal.Decimal `json:"maxPlatOILmt"`
	MaxPlatformOpenInterestCoinLimit decimal.Decimal `json:"maxPlatOICoinLmt"`
	FutureSettlement                 bool            `json:"futureSettlement"`
	TradeQuoteCurrencyList           []string        `json:"tradeQuoteCcyList"`
	GroupID                          string          `json:"groupId"`
	PositionLimitAmount              decimal.Decimal `json:"posLmtAmt"`
	PositionLimitPercent             decimal.Decimal `json:"posLmtPct"`
	// PreMarketSwitchTime is the time a pre-market instrument switched to normal
	// trading. Applicable to pre-market SWAP and pre-market X-Perp FUTURES.
	PreMarketSwitchTime time.Time `json:"preMktSwTime"`
	// Elp is the ELP (Enhanced Liquidity Program) maker permission (values
	// "0"/"1"/"2"; see Instrument.Elp). OKX is rebranding ELP to RPI (Retail
	// Price Improvement); the json key stays "elp" until the old names retire on
	// 2026-10-31, after which it becomes "rpi".
	Elp string `json:"elp"`
}

WsInstrument is an instrument definition pushed on the "instruments" channel (on a listing/rule change). It mirrors the REST Instrument's pushed subset.

type WsLiquidationOrder

type WsLiquidationOrder struct {
	InstrumentType   InstType                   `json:"instType"`
	InstrumentID     string                     `json:"instId"`
	InstrumentFamily string                     `json:"instFamily"`
	Underlying       string                     `json:"uly"`
	Details          []WsLiquidationOrderDetail `json:"details"`
}

WsLiquidationOrder groups an instrument's recent forced-liquidation fills pushed on the "liquidation-orders" channel.

type WsLiquidationOrderDetail

type WsLiquidationOrderDetail struct {
	Side            Side            `json:"side"`
	PositionSide    PosSide         `json:"posSide"`
	BankruptcyPrice decimal.Decimal `json:"bkPx"`
	Size            decimal.Decimal `json:"sz"`
	BankruptcyLoss  decimal.Decimal `json:"bkLoss"`
	Currency        string          `json:"ccy"`
	Timestamp       time.Time       `json:"ts"`
}

WsLiquidationOrderDetail is one forced-liquidation fill.

type WsLiquidationWarning

type WsLiquidationWarning = WsPosition

WsLiquidationWarning is one at-risk position from the "liquidation-warning" channel. It carries the same per-position fields as the positions channel; the validating account had no at-risk positions, so the field set is modeled from the OKX channel field table.

type WsMarkPrice

type WsMarkPrice struct {
	InstrumentType InstType        `json:"instType"`
	InstrumentID   string          `json:"instId"`
	MarkPrice      decimal.Decimal `json:"markPx"`
	Timestamp      time.Time       `json:"ts"`
}

WsMarkPrice is an instrument's mark price pushed on the "mark-price" channel.

type WsOpenInterest

type WsOpenInterest struct {
	InstrumentType       InstType        `json:"instType"`
	InstrumentID         string          `json:"instId"`
	OpenInterest         decimal.Decimal `json:"oi"`
	OpenInterestCurrency decimal.Decimal `json:"oiCcy"`
	OpenInterestUSD      decimal.Decimal `json:"oiUsd"`
	Timestamp            time.Time       `json:"ts"`
}

WsOpenInterest is an instrument's open interest pushed on the "open-interest" channel.

type WsOrder

type WsOrder struct {
	InstrumentType             InstType        `json:"instType"`
	InstrumentID               string          `json:"instId"`
	TargetCurrency             TgtCcy          `json:"tgtCcy"`
	Currency                   string          `json:"ccy"`
	OrderID                    string          `json:"ordId"`
	ClientOrderID              string          `json:"clOrdId"`
	Tag                        string          `json:"tag"`
	Price                      decimal.Decimal `json:"px"`
	PriceUSD                   decimal.Decimal `json:"pxUsd"`
	PriceVolatility            decimal.Decimal `json:"pxVol"`
	PriceType                  string          `json:"pxType"`
	Size                       decimal.Decimal `json:"sz"`
	NotionalUSD                decimal.Decimal `json:"notionalUsd"`
	OrderType                  OrdType         `json:"ordType"`
	Side                       Side            `json:"side"`
	PositionSide               PosSide         `json:"posSide"`
	TradeMode                  TdMode          `json:"tdMode"`
	FillPrice                  decimal.Decimal `json:"fillPx"`
	TradeID                    string          `json:"tradeId"`
	FillSize                   decimal.Decimal `json:"fillSz"`
	FillPnl                    decimal.Decimal `json:"fillPnl"`
	FillTime                   time.Time       `json:"fillTime"`
	FillFee                    decimal.Decimal `json:"fillFee"`
	FillFeeCurrency            string          `json:"fillFeeCcy"`
	FillPriceVolatility        decimal.Decimal `json:"fillPxVol"`
	FillPriceUSD               decimal.Decimal `json:"fillPxUsd"`
	FillMarkVolatility         decimal.Decimal `json:"fillMarkVol"`
	FillForwardPrice           decimal.Decimal `json:"fillFwdPx"`
	FillMarkPrice              decimal.Decimal `json:"fillMarkPx"`
	ExecutionType              ExecType        `json:"execType"`
	AccumulatedFillSize        decimal.Decimal `json:"accFillSz"`
	FillNotionalUSD            decimal.Decimal `json:"fillNotionalUsd"`
	AveragePrice               decimal.Decimal `json:"avgPx"`
	State                      OrdState        `json:"state"`
	Leverage                   decimal.Decimal `json:"lever"`
	AttachAlgoClientOrderID    string          `json:"attachAlgoClOrdId"`
	TakeProfitTriggerPrice     decimal.Decimal `json:"tpTriggerPx"`
	TakeProfitTriggerPriceType string          `json:"tpTriggerPxType"`
	TakeProfitOrderPrice       decimal.Decimal `json:"tpOrdPx"`
	StopLossTriggerPrice       decimal.Decimal `json:"slTriggerPx"`
	StopLossTriggerPriceType   string          `json:"slTriggerPxType"`
	StopLossOrderPrice         decimal.Decimal `json:"slOrdPx"`
	AttachAlgoOrders           []AttachAlgoOrd `json:"attachAlgoOrds"`
	STPID                      string          `json:"stpId"`
	STPMode                    string          `json:"stpMode"`
	FeeCurrency                string          `json:"feeCcy"`
	Fee                        decimal.Decimal `json:"fee"`
	RebateCurrency             string          `json:"rebateCcy"`
	Rebate                     decimal.Decimal `json:"rebate"`
	Pnl                        decimal.Decimal `json:"pnl"`
	Source                     string          `json:"source"`
	Category                   string          `json:"category"`
	ReduceOnly                 string          `json:"reduceOnly"` // OKX sends a quoted "true"/"false"
	CancelSource               string          `json:"cancelSource"`
	CancelSourceReason         string          `json:"cancelSourceReason"`
	QuickMarginType            string          `json:"quickMgnType"`
	AlgoClientOrderID          string          `json:"algoClOrdId"`
	AlgoID                     string          `json:"algoId"`
	IsTakeProfitLimit          string          `json:"isTpLimit"`
	LastPrice                  decimal.Decimal `json:"lastPx"`
	UpdateTime                 time.Time       `json:"uTime"`
	CreationTime               time.Time       `json:"cTime"`
	RequestID                  string          `json:"reqId"`
	AmendResult                string          `json:"amendResult"`
	// AmendSource gains value "6" with the ELP->RPI rebranding rollout: order
	// price adjusted (rounded) by the system to satisfy the RPI maker spacing
	// rule.
	AmendSource        string `json:"amendSource"`
	Code               string `json:"code"`
	Message            string `json:"msg"`
	TradeQuoteCurrency string `json:"tradeQuoteCcy"`
}

WsOrder is one order update from the "orders" channel. The validating account had no order activity, so the field set is modeled from the OKX "orders" channel field table (it mirrors the REST Order shape plus the WS-only fill / notify fields).

type WsOrderBook

type WsOrderBook struct {
	Asks               [][]string `json:"asks"`
	Bids               [][]string `json:"bids"`
	InstrumentID       string     `json:"instId,omitempty"`
	Timestamp          time.Time  `json:"ts"`
	Checksum           int64      `json:"checksum,omitempty"`
	PreviousSequenceID int64      `json:"prevSeqId,omitempty"`
	SequenceID         int64      `json:"seqId"`
}

WsOrderBook is an order-book frame. It is the superset shape across the order-book channels: "books" carries asks/bids/ts/checksum/seqId/prevSeqId (with Action "snapshot"/"update" on the push); "books5" carries asks/bids/instId/ts/seqId; "bbo-tbt" carries asks/bids/ts/seqId; the VIP "*-l2-tbt" channels carry the same as "books". Each level is [price, size, deprecated("0"), numOrders] as strings.

type WsPosition

type WsPosition struct {
	InstrumentType                  InstType                 `json:"instType"`
	MarginMode                      MgnMode                  `json:"mgnMode"`
	PositionID                      string                   `json:"posId"`
	PositionSide                    PosSide                  `json:"posSide"`
	Position                        decimal.Decimal          `json:"pos"`
	BaseBalance                     decimal.Decimal          `json:"baseBal"`
	QuoteBalance                    decimal.Decimal          `json:"quoteBal"`
	BaseBorrowed                    decimal.Decimal          `json:"baseBorrowed"`
	BaseInterest                    decimal.Decimal          `json:"baseInterest"`
	QuoteBorrowed                   decimal.Decimal          `json:"quoteBorrowed"`
	QuoteInterest                   decimal.Decimal          `json:"quoteInterest"`
	PositionCurrency                string                   `json:"posCcy"`
	AvailablePosition               decimal.Decimal          `json:"availPos"`
	AveragePrice                    decimal.Decimal          `json:"avgPx"`
	NonSettleAveragePrice           decimal.Decimal          `json:"nonSettleAvgPx"`
	MarkPrice                       decimal.Decimal          `json:"markPx"`
	UPL                             decimal.Decimal          `json:"upl"`
	UPLRatio                        decimal.Decimal          `json:"uplRatio"`
	UPLLastPrice                    decimal.Decimal          `json:"uplLastPx"`
	UPLRatioLastPrice               decimal.Decimal          `json:"uplRatioLastPx"`
	InstrumentID                    string                   `json:"instId"`
	Leverage                        decimal.Decimal          `json:"lever"`
	LiquidationPrice                decimal.Decimal          `json:"liqPx"`
	IMR                             decimal.Decimal          `json:"imr"`
	Margin                          decimal.Decimal          `json:"margin"`
	MarginRatio                     decimal.Decimal          `json:"mgnRatio"`
	MMR                             decimal.Decimal          `json:"mmr"`
	Liability                       decimal.Decimal          `json:"liab"`
	LiabilityCurrency               string                   `json:"liabCcy"`
	Interest                        decimal.Decimal          `json:"interest"`
	TradeID                         string                   `json:"tradeId"`
	OptionValue                     decimal.Decimal          `json:"optVal"`
	PendingCloseOrderLiabilityValue decimal.Decimal          `json:"pendingCloseOrdLiabVal"`
	NotionalUSD                     decimal.Decimal          `json:"notionalUsd"`
	ADL                             decimal.Decimal          `json:"adl"`
	Currency                        string                   `json:"ccy"`
	Last                            decimal.Decimal          `json:"last"`
	IndexPrice                      decimal.Decimal          `json:"idxPx"`
	USDPrice                        decimal.Decimal          `json:"usdPx"`
	BreakEvenPrice                  decimal.Decimal          `json:"bePx"`
	DeltaBS                         decimal.Decimal          `json:"deltaBS"`
	DeltaPA                         decimal.Decimal          `json:"deltaPA"`
	GammaBS                         decimal.Decimal          `json:"gammaBS"`
	GammaPA                         decimal.Decimal          `json:"gammaPA"`
	ThetaBS                         decimal.Decimal          `json:"thetaBS"`
	ThetaPA                         decimal.Decimal          `json:"thetaPA"`
	VegaBS                          decimal.Decimal          `json:"vegaBS"`
	VegaPA                          decimal.Decimal          `json:"vegaPA"`
	SpotInUseAmount                 decimal.Decimal          `json:"spotInUseAmt"`
	SpotInUseCurrency               string                   `json:"spotInUseCcy"`
	ClientSpotInUseAmount           decimal.Decimal          `json:"clSpotInUseAmt"`
	MaxSpotInUseAmount              decimal.Decimal          `json:"maxSpotInUseAmt"`
	RealizedPnl                     decimal.Decimal          `json:"realizedPnl"`
	SettledPnl                      decimal.Decimal          `json:"settledPnl"`
	Pnl                             decimal.Decimal          `json:"pnl"`
	Fee                             decimal.Decimal          `json:"fee"`
	FundingFee                      decimal.Decimal          `json:"fundingFee"`
	LiquidationPenalty              decimal.Decimal          `json:"liqPenalty"`
	CloseOrderAlgo                  []PositionCloseOrderAlgo `json:"closeOrderAlgo"`
	CreationTime                    time.Time                `json:"cTime"`
	UpdateTime                      time.Time                `json:"uTime"`
	PushTime                        time.Time                `json:"pTime"`
	BusinessReferenceID             string                   `json:"bizRefId"`
	BusinessReferenceType           string                   `json:"bizRefType"`
}

WsPosition is one open position from the "positions" channel. The validating account had no open positions, so the field set is modeled from the OKX "positions" channel field table (it mirrors the REST Position shape).

type WsPriceLimit

type WsPriceLimit struct {
	InstrumentType InstType        `json:"instType"`
	InstrumentID   string          `json:"instId"`
	BuyLimit       decimal.Decimal `json:"buyLmt"`
	SellLimit      decimal.Decimal `json:"sellLmt"`
	Enabled        bool            `json:"enabled"`
	Timestamp      time.Time       `json:"ts"`
}

WsPriceLimit is an instrument's buy/sell price limits pushed on the "price-limit" channel.

type WsSprdBooks

type WsSprdBooks struct {
	Asks       [][]string `json:"asks"`
	Bids       [][]string `json:"bids"`
	Timestamp  time.Time  `json:"ts"`
	SequenceID int64      `json:"seqId"`
}

WsSprdBooks is a spread's 5-level order book snapshot/update pushed by the "sprd-books5" channel. Each ask/bid level is [price, size, numOrders].

type WsSprdCandle

type WsSprdCandle struct {
	Timestamp time.Time
	Open      decimal.Decimal
	High      decimal.Decimal
	Low       decimal.Decimal
	Close     decimal.Decimal
	Volume    decimal.Decimal
	Confirm   string
}

WsSprdCandle is one OHLCV candlestick pushed by the "sprd-candle{bar}" channel. The raw data frame is an array-of-arrays with 7 columns: [ts, o, h, l, c, vol, confirm].

type WsSprdCandleHandler

type WsSprdCandleHandler func([]WsSprdCandle, error)

WsSprdCandleHandler is invoked for every "sprd-candle{bar}" push (or error).

type WsSprdPublicTrade

type WsSprdPublicTrade struct {
	SpreadID  string          `json:"sprdId"`
	TradeID   string          `json:"tradeId"`
	Price     decimal.Decimal `json:"px"`
	Size      decimal.Decimal `json:"sz"`
	Side      Side            `json:"side"`
	Timestamp time.Time       `json:"ts"`
}

WsSprdPublicTrade is a single public trade (taker fill) on a spread pushed by the "sprd-public-trades" channel.

type WsSprdTicker

type WsSprdTicker struct {
	SpreadID  string          `json:"sprdId"`
	Last      decimal.Decimal `json:"last"`
	LastSize  decimal.Decimal `json:"lastSz"`
	AskPrice  decimal.Decimal `json:"askPx"`
	AskSize   decimal.Decimal `json:"askSz"`
	BidPrice  decimal.Decimal `json:"bidPx"`
	BidSize   decimal.Decimal `json:"bidSz"`
	Open24h   decimal.Decimal `json:"open24h"`
	High24h   decimal.Decimal `json:"high24h"`
	Low24h    decimal.Decimal `json:"low24h"`
	Volume24h decimal.Decimal `json:"vol24h"`
	Timestamp time.Time       `json:"ts"`
}

WsSprdTicker is the latest market snapshot for a spread pushed by the "sprd-tickers" channel.

type WsStatus

type WsStatus struct {
	Title               string    `json:"title"`
	State               string    `json:"state"`
	Begin               time.Time `json:"begin"`
	End                 time.Time `json:"end"`
	PreOpenBegin        time.Time `json:"preOpenBegin"`
	Href                string    `json:"href"`
	ServiceType         string    `json:"serviceType"`
	System              string    `json:"system"`
	ScheduleDescription string    `json:"scheDesc"`
	MaintenanceType     string    `json:"maintType"`
	Env                 string    `json:"env"`
	Timestamp           time.Time `json:"ts"`
}

WsStatus is a system maintenance event pushed on the "status" channel.

type WsTicker

type WsTicker struct {
	InstrumentType    InstType        `json:"instType"`
	InstrumentID      string          `json:"instId"`
	Last              decimal.Decimal `json:"last"`
	LastSize          decimal.Decimal `json:"lastSz"`
	AskPrice          decimal.Decimal `json:"askPx"`
	AskSize           decimal.Decimal `json:"askSz"`
	BidPrice          decimal.Decimal `json:"bidPx"`
	BidSize           decimal.Decimal `json:"bidSz"`
	Open24h           decimal.Decimal `json:"open24h"`
	High24h           decimal.Decimal `json:"high24h"`
	Low24h            decimal.Decimal `json:"low24h"`
	VolumeCurrency24h decimal.Decimal `json:"volCcy24h"`
	Volume24h         decimal.Decimal `json:"vol24h"`
	StartOfDayUTC0    decimal.Decimal `json:"sodUtc0"`
	StartOfDayUTC8    decimal.Decimal `json:"sodUtc8"`
	Timestamp         time.Time       `json:"ts"`
}

WsTicker is the latest market snapshot pushed on the "tickers" channel. It is a subset of the REST Ticker (no SodUtc fields differ, but it omits the REST-only extras).

type WsTrade

type WsTrade struct {
	InstrumentID string          `json:"instId"`
	TradeID      string          `json:"tradeId"`
	Price        decimal.Decimal `json:"px"`
	Size         decimal.Decimal `json:"sz"`
	Side         Side            `json:"side"`
	Count        string          `json:"count"`
	// Source is the trade source ("1": RPI order, previously ELP order; see
	// Trade.Source).
	Source     string    `json:"source"`
	SequenceID int64     `json:"seqId"`
	Timestamp  time.Time `json:"ts"`
}

WsTrade is a single public taker fill pushed on the "trades" channel.

type WsTradeConn

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

WsTradeConn is a persistent, logged-in WebSocket connection for order entry — a low-latency alternative to the REST trade endpoints. OKX correlates each request with its response by a client-supplied "id"; this type assigns ids, matches responses, and exposes one method per order operation.

Obtain one via (*WebSocketClient).DialTrade and Close it when done. All methods are safe for concurrent use.

func (*WsTradeConn) AmendOrder

func (tc *WsTradeConn) AmendOrder(ctx context.Context, arg AmendOrderArg) (*AmendResult, error)

AmendOrder amends a single order.

func (*WsTradeConn) BatchAmendOrders

func (tc *WsTradeConn) BatchAmendOrders(ctx context.Context, args []AmendOrderArg) ([]AmendResult, error)

BatchAmendOrders amends up to 20 orders in one request.

func (*WsTradeConn) BatchCancelOrders

func (tc *WsTradeConn) BatchCancelOrders(ctx context.Context, args []CancelOrderArg) ([]OrderResult, error)

BatchCancelOrders cancels up to 20 orders in one request.

func (*WsTradeConn) BatchPlaceOrders

func (tc *WsTradeConn) BatchPlaceOrders(ctx context.Context, args []OrderArg) ([]OrderResult, error)

BatchPlaceOrders places up to 20 orders in one request.

func (*WsTradeConn) CancelOrder

func (tc *WsTradeConn) CancelOrder(ctx context.Context, arg CancelOrderArg) (*OrderResult, error)

CancelOrder cancels a single order.

func (*WsTradeConn) Close

func (tc *WsTradeConn) Close() error

Close terminates the connection and fails any in-flight requests.

func (*WsTradeConn) MassCancel

func (tc *WsTradeConn) MassCancel(ctx context.Context, instType InstType, instFamily string) (*MassCancelResult, error)

MassCancel cancels all pending orders for an option instrument family.

func (*WsTradeConn) PlaceOrder

func (tc *WsTradeConn) PlaceOrder(ctx context.Context, arg OrderArg) (*OrderResult, error)

PlaceOrder places a single order over the trade connection. The per-order result carries sCode/sMsg for the order-level outcome.

Directories

Path Synopsis
cmd
okxraw command
Command okxraw signs and executes a single OKX v5 REST call and pretty prints the raw response.
Command okxraw signs and executes a single OKX v5 REST call and pretty prints the raw response.
pkg
log

Jump to

Keyboard shortcuts

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