mybybitapi

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 23 Imported by: 2

README

mybybitapi

Go 1.19.0 Contributor Victor

Table of Contents

Require

require (
	github.com/json-iterator/go v1.1.12
	github.com/shopspring/decimal v1.4.0
	github.com/sirupsen/logrus v1.9.3
)

Installation

go get github.com/Hongssd/mybybitapi

Public Rest Examples

Kline

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PublicRestClient()
res, err := client.NewMarketKline().Category("spot").Interval("1").Symbol("BTCUSDT").Limit(10).Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

OrderBook

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PublicRestClient()
res, err := client.NewMarketOrderBook().Category("spot").Symbol("BTCUSDT").Limit(20).Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Private Rest Examples

Wallet Balance

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PrivateRestClient()
res, err := client.NewAccountWalletBalance().AccountType("UNIFIED").Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Order Create

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PrivateRestClient()
res, err := client.NewOrderCreate().
	Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("10000").
	Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Batch Order Create

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PrivateRestClient()
res, err := client.NewOrderCreateBatch().
        AddNewOrderCreateReq(client.NewOrderCreate().
			Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("10000")).
        AddNewOrderCreateReq(client.NewOrderCreate().
			Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("11000")).
        Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Public Websocket Examples

Subscribe Kline

wsclient := mybybitapi.NewPublicSpotWsStreamClient()
//Open Websocket Connect
err := wsclient.OpenConn()
if err != nil {
    panic(err)
}
//Subscribe Kline
sub, err := wsclient.SubscribeKlineMultiple([]string{"BTCUSDT", "ETHUSDT"}, []string{"1", "5", "30"})
if err != nil {
    panic(err)
}


//Listen for klines 
for {
    select {
    case err := <-sub.ErrChan():
        panic(err)
    case result := <-sub.ResultChan():
        fmt.Println(result)
    case <-sub.CloseChan():
        fmt.Println("subscribe closed")
    }
}

Private Websocket Examples

Subscribe Order

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY")
wsclient := mybybitapi.NewPrivateWsStreamClient()

//Open Websocket Connect
err := wsclient.OpenConn()
if err != nil {
    panic(err)
}

//Auth To Bybit
err = wsclient.Auth(client)
if err != nil {
    panic(err)
}


//Subscribe All-In-One Topic: order
sub, err := wsclient.SubscribeOrder("all")
if err != nil {
    panic(err)
}


//Listen for orders 
for {
    select {
    case err := <-sub.ErrChan():
        panic(err)
    case result := <-sub.ResultChan():
        fmt.Println(result)
    case <-sub.CloseChan():
        fmt.Println("subscribe closed")
    }
}

Trade Websocket Examples

Create Order

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY")
privateClient := client.PrivateRestClient()
wsclient := mybybitapi.NewTradeWsStreamClient()
//Open Websocket Connect
err := wsclient.OpenConn()
if err != nil {
    panic(err)
}

//Auth To Bybit
err = wsclient.Auth(client)
if err != nil {
    panic(err)
}

//Websocket order create
orderCreateRes, err := wsclient.CreateOrder(
    privateClient.NewOrderCreate().
    Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("10000"))
if err != nil {
    panic(err)
}
fmt.Println(orderCreateRes)

Documentation

Index

Constants

View Source
const (
	BIT_BASE_10 = 10
	BIT_SIZE_64 = 64
	BIT_SIZE_32 = 32
)

test

View Source
const (
	GET    = "GET"
	POST   = "POST"
	DELETE = "DELETE"
	PUT    = "PUT"
)
View Source
const (
	BYBIT_API_HTTP           = "api.bybit.com"
	BYBIT_API_WEBSOCKET      = "stream.bybit.com"
	BYBIT_API_HTTP_AWS       = "api.bytick.com"
	BYBIT_API_WEBSOCKET_AWS  = "stream.bytick.com"
	BYBIT_API_HTTP_TEST      = "api-testnet.bybit.com"
	BYBIT_API_WEBSOCKET_TEST = "stream-testnet.bybit.com"
	IS_GZIP                  = true
)
View Source
const (
	BYBIT_API_WS_PUBLIC_SPOT    = "/v5/public/spot"    //现货公共频道
	BYBIT_API_WS_PUBLIC_LINEAR  = "/v5/public/linear"  //合约公共频道
	BYBIT_API_WS_PUBLIC_INVERSE = "/v5/public/inverse" //反向合约公共频道
	BYBIT_API_WS_PUBLIC_OPTION  = "/v5/public/option"  //期权公共频道
	BYBIT_API_WS_PRIVATE        = "/v5/private"        //私有频道
	BYBIT_API_WS_TRADE          = "/v5/trade"          //ws下单交易频道
)
View Source
const (
	AUTH         = "auth"         //鉴权
	SUBSCRIBE    = "subscribe"    //订阅
	UNSUBSCRIBE  = "unsubscribe"  //取消订阅
	ORDER_CREATE = "order.create" //下单
	ORDER_AMEND  = "order.amend"  //撤单
	ORDER_CANCEL = "order.cancel" //批量撤单
)

Variables

View Source
var (
	WebsocketTimeout        = time.Second * 10
	WebsocketKeepalive      = true
	SUBSCRIBE_INTERVAL_TIME = 500 * time.Millisecond //订阅间隔
)
View Source
var NIL_REQBODY = []byte{}
View Source
var PrivateRestAPIMap = map[PrivateRestAPI]string{
	AccountInfo:                     "/v5/account/info",
	AccountWalletBalance:            "/v5/account/wallet-balance",
	AccountFeeRate:                  "/v5/account/fee-rate",
	AccountUpgradeToUta:             "/v5/account/upgrade-to-uta",
	AccountSetMarginMode:            "/v5/account/set-margin-mode",
	AccountWithdrawal:               "/v5/account/withdrawal",
	AccountSetCollateralSwitch:      "/v5/account/set-collateral-switch",
	AccountSetCollateralSwitchBatch: "/v5/account/set-collateral-switch-batch",
	AccountCollateralInfo:           "/v5/account/collateral-info",

	PositionList:           "/v5/position/list",
	PositionSetLeverage:    "/v5/position/set-leverage",
	PositionSwitchIsolated: "/v5/position/switch-isolated",
	PositionSwitchMode:     "/v5/position/switch-mode",

	OrderCreate:        "/v5/order/create",
	OrderCreateBatch:   "/v5/order/create-batch",
	OrderAmend:         "/v5/order/amend",
	OrderAmendBatch:    "/v5/order/amend-batch",
	OrderCancel:        "/v5/order/cancel",
	OrderCancelBatch:   "/v5/order/cancel-batch",
	OrderCancelAll:     "/v5/order/cancel-all",
	OrderRealtime:      "/v5/order/realtime",
	OrderHistory:       "/v5/order/history",
	OrderExecutionList: "/v5/execution/list",

	AssetTransferQueryInterTransferList:   "/v5/asset/transfer/query-inter-transfer-list",
	AssetTransferQueryTransferCoinList:    "/v5/asset/transfer/query-transfer-coin-list",
	AssetTransferInterTransfer:            "/v5/asset/transfer/inter-transfer",
	AssetTransferQueryAccountCoinsBalance: "/v5/asset/transfer/query-account-coins-balance",
	AssetTransferQueryAccountCoinBalance:  "/v5/asset/transfer/query-account-coin-balance",
	AssetTithdrawWithdrawableAmount:       "/v5/asset/withdraw/withdrawable-amount",

	SpotMarginTradeSetLeverage: "/v5/spot-margin-trade/set-leverage",
	SpotMarginTradeState:       "/v5/spot-margin-trade/state",
}
View Source
var PublicRestAPIMap = map[PublicRestAPI]string{

	MarketInstrumentsInfo: "/v5/market/instruments-info",
	MarketTime:            "/v5/market/time",
	MarketKline:           "/v5/market/kline",
	MarketOrderBook:       "/v5/market/orderbook",
	MarketTickers:         "/v5/market/tickers",
	MarketRecentTrade:     "/v5/market/recent-trade",
}
View Source
var SERVER_TYPE = BASE
View Source
var UseProxy = false
View Source
var WsUseProxy = false

Functions

func BybitGetRestHostByAPIType

func BybitGetRestHostByAPIType(apiType APIType) string

func GetPointer

func GetPointer[T any](v T) *T

func HmacSha256

func HmacSha256(secret, data string) []byte

func Request

func Request(url string, reqBody []byte, method string, isGzip bool) ([]byte, int, error)

Request 发送请求

func RequestWithHeader

func RequestWithHeader(urlStr string, reqBody []byte, method string, headerMap map[string]string, isGzip bool) ([]byte, int, error)

func SetLogger

func SetLogger(logger *logrus.Logger)

func SetServerType

func SetServerType(serverType ServerType)

func SetUseProxy added in v0.1.7

func SetUseProxy(useProxy bool, proxyUrls ...string)

func SetWsUseProxy added in v0.1.7

func SetWsUseProxy(useProxy bool) error

Types

type APIType

type APIType int
const (
	REST APIType = iota
	WS_PUBLIC_SPOT
	WS_PUBLIC_LINEAR
	WS_PUBLIC_INVERSE
	WS_PUBLIC_OPTION
	WS_PRIVATE
	WS_TRADE
)

type AccountCollateralInfoAPI added in v0.1.7

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

func (*AccountCollateralInfoAPI) Currency added in v0.1.7

func (api *AccountCollateralInfoAPI) Currency(currency string) *AccountCollateralInfoAPI

currency string false 目前所有抵押品的資產幣種

func (*AccountCollateralInfoAPI) Do added in v0.1.7

type AccountCollateralInfoReq added in v0.1.7

type AccountCollateralInfoReq struct {
	Currency *string `json:"currency"` //string false 目前所有抵押品的資產幣種
}

type AccountCollateralInfoRes added in v0.1.7

type AccountCollateralInfoRes struct {
	List []AccountCollateralInfoResRow `json:"list"`
}

type AccountCollateralInfoResRow added in v0.1.7

type AccountCollateralInfoResRow struct {
	Currency            string `json:"currency"`            //目前所有抵押品的資產幣種
	HourlyBorrowRate    string `json:"hourlyBorrowRate"`    //每小時藉款利率
	MaxBorrowingAmount  string `json:"maxBorrowingAmount"`  //最大可藉貸額度. 該值由母子帳號共享
	FreeBorrowingLimit  string `json:"freeBorrowingLimit"`  //免息借款額上限
	FreeBorrowAmount    string `json:"freeBorrowAmount"`    //借款總額中免息部分的借款金額
	BorrowAmount        string `json:"borrowAmount"`        //已用借貸額度
	OtherBorrowAmount   string `json:"otherBorrowAmount"`   //其他帳戶的已借貸總額(同一個母帳戶下)
	AvailableToBorrow   string `json:"availableToBorrow"`   //用戶剩餘可藉額度. 該值由母子帳號共享
	Borrowable          bool   `json:"borrowable"`          //是否是可藉貸的幣種, true: 是. false: 否
	FreeBorrowingAmount string `json:"freeBorrowingAmount"` //廢棄字段, 總是返回空字符串, 請參考freeBorrowingLimit
	BorrowUsageRate     string `json:"borrowUsageRate"`     //借貸資金使用率: 母子帳戶加起來的borrowAmount/maxBorrowingAmount. 這是一個真實值, 0.5则表示50%
	MarginCollateral    bool   `json:"marginCollateral"`    //是否可作為保證金抵押幣種(平台維度), true: 是. false: 否
	CollateralSwitch    bool   `json:"collateralSwitch"`    //用戶是否開啟保證金幣種抵押(用戶維度), true: 是. false: 否
	CollateralRatio     string `json:"collateralRatio"`     //由於新的階梯價值率邏輯, 該字段從2025年2月19日開始不再準確。請使用查詢階梯價值率
}

type AccountFeeRateAPI

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

func (*AccountFeeRateAPI) BaseCoin

func (api *AccountFeeRateAPI) BaseCoin(baseCoin string) *AccountFeeRateAPI

baseCoin string false 交易幣種. SOL, BTC, ETH.僅option有效

func (*AccountFeeRateAPI) Category

func (api *AccountFeeRateAPI) Category(category string) *AccountFeeRateAPI

category string true 產品類型. spot, linear, inverse, option

func (*AccountFeeRateAPI) Do

func (*AccountFeeRateAPI) Symbol

func (api *AccountFeeRateAPI) Symbol(symbol string) *AccountFeeRateAPI

symbol string false 合約名稱. 僅spot, linear, inverse有效

type AccountFeeRateReq

type AccountFeeRateReq struct {
	Category *string `json:"category"` //string	true	產品類型. spot, linear, inverse, option
	Symbol   *string `json:"symbol"`   //string	false	合約名稱. 僅spot, linear, inverse有效
	BaseCoin *string `json:"baseCoin"` //string	false	交易幣種. SOL, BTC, ETH.僅option有效
}

type AccountFeeRateRes

type AccountFeeRateRes struct {
	Category string                 `json:"category"` //產品類型. spot, option. 期貨不返回該字段
	List     []AccountFeeRateResRow `json:"list"`
}

type AccountFeeRateResRow

type AccountFeeRateResRow struct {
	Symbol       string `json:"symbol"`       //合約名稱. 期權總是為""
	BaseCoin     string `json:"baseCoin"`     //交易幣種. SOL, BTC, ETH 期貨不返回該字段 現貨總是返回""
	TakerFeeRate string `json:"takerFeeRate"` //吃單手續費率
	MakerFeeRate string `json:"makerFeeRate"` //掛單手續費率
}

type AccountInfoAPI added in v0.0.9

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

func (*AccountInfoAPI) Do added in v0.0.9

type AccountInfoReq added in v0.0.9

type AccountInfoReq struct {
}

type AccountInfoRes added in v0.0.9

type AccountInfoRes struct {
	MarginMode          string `json:"marginMode"`
	UpdatedTime         string `json:"updatedTime"`
	UnifiedMarginStatus int    `json:"unifiedMarginStatus"`
	DcpStatus           string `json:"dcpStatus"`
	TimeWindow          int    `json:"timeWindow"`
	SmpGroup            int    `json:"smpGroup"`
	IsMasterTrader      bool   `json:"isMasterTrader"`
	SpotHedgingStatus   string `json:"spotHedgingStatus"`
}

type AccountSetCollateralSwitchAPI added in v0.1.7

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

func (*AccountSetCollateralSwitchAPI) Coin added in v0.1.7

coin string true 幣種名稱

func (*AccountSetCollateralSwitchAPI) CollateralSwitch added in v0.1.7

func (api *AccountSetCollateralSwitchAPI) CollateralSwitch(collateralSwitch string) *AccountSetCollateralSwitchAPI

collateralSwitch string true ON: 開啟抵押, OFF: 關閉抵押

func (*AccountSetCollateralSwitchAPI) Do added in v0.1.7

type AccountSetCollateralSwitchBatchAPI added in v0.1.7

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

func (*AccountSetCollateralSwitchBatchAPI) AddNewSetCollateralSwitchReq added in v0.1.7

func (api *AccountSetCollateralSwitchBatchAPI) AddNewSetCollateralSwitchReq(coin string, collateralSwitch string) *AccountSetCollateralSwitchBatchAPI

func (*AccountSetCollateralSwitchBatchAPI) Do added in v0.1.7

func (*AccountSetCollateralSwitchBatchAPI) SetSetCollateralSwitchReqList added in v0.1.7

func (api *AccountSetCollateralSwitchBatchAPI) SetSetCollateralSwitchReqList(setCollateralSwitchReqList []AccountSetCollateralSwitchReq) *AccountSetCollateralSwitchBatchAPI

type AccountSetCollateralSwitchBatchReq added in v0.1.7

type AccountSetCollateralSwitchBatchReq struct {
	Request []AccountSetCollateralSwitchReq `json:"request"`
}

type AccountSetCollateralSwitchBatchRes added in v0.1.7

type AccountSetCollateralSwitchBatchRes struct {
	List []AccountSetCollateralSwitchBatchResRow `json:"list"`
}

type AccountSetCollateralSwitchBatchResRow added in v0.1.7

type AccountSetCollateralSwitchBatchResRow struct {
	Coin             string `json:"coin"`             //幣種名稱
	CollateralSwitch string `json:"collateralSwitch"` //ON: 開啟抵押, OFF: 關閉抵押
}

type AccountSetCollateralSwitchReq added in v0.1.7

type AccountSetCollateralSwitchReq struct {
	Coin             *string `json:"coin"`             //string	true	幣種名稱
	CollateralSwitch *string `json:"collateralSwitch"` //string	true	ON: 開啟抵押, OFF: 關閉抵押
}

type AccountSetCollateralSwitchRes added in v0.1.7

type AccountSetCollateralSwitchRes struct{}

type AccountSetMarginModeAPI added in v0.1.0

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

func (*AccountSetMarginModeAPI) Do added in v0.1.0

func (*AccountSetMarginModeAPI) SetMarginMode added in v0.1.0

func (api *AccountSetMarginModeAPI) SetMarginMode(setMarginMode string) *AccountSetMarginModeAPI

setMarginMode true string ISOLATED_MARGIN(逐倉保證金模式), REGULAR_MARGIN(全倉保證金模式)PORTFOLIO_MARGIN(組合保證金模式)默認常規,傳常規則返回設置成功

type AccountSetMarginModeReq added in v0.1.0

type AccountSetMarginModeReq struct {
	SetMarginMode *string `json:"setMarginMode"` //true	ISOLATED_MARGIN(逐倉保證金模式), REGULAR_MARGIN(全倉保證金模式)PORTFOLIO_MARGIN(組合保證金模式)默認常規,傳常規則返回設置成功
}

setMarginMode true string ISOLATED_MARGIN(逐倉保證金模式), REGULAR_MARGIN(全倉保證金模式)PORTFOLIO_MARGIN(組合保證金模式)默認常規,傳常規則返回設置成功

type AccountSetMarginModeRes added in v0.1.0

type AccountSetMarginModeRes struct {
	Reasons []struct {
		ReasonCode string `json:"reasonCode"`
		ReasonMsg  string `json:"reasonMsg"`
	} `json:"reasons"`
}

type AccountType

type AccountType string
const (
	// CONTRACT合約帳戶
	// SPOT現貨帳戶
	// OPTION USDC合約帳戶
	// FUND資金帳戶
	// UNIFIED統一帳戶
	ACCT_CONTRACT AccountType = "CONTRACT"
	ACCT_SPOT     AccountType = "SPOT"
	ACCT_OPTION   AccountType = "OPTION"
	ACCT_FUND     AccountType = "FUND"
	ACCT_UNIFIED  AccountType = "UNIFIED"
)

func (AccountType) String

func (c AccountType) String() string

type AccountUpgradeToUtaAPI added in v0.0.9

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

func (*AccountUpgradeToUtaAPI) Do added in v0.0.9

type AccountUpgradeToUtaReq added in v0.0.9

type AccountUpgradeToUtaReq struct {
}

type AccountUpgradeToUtaRes added in v0.0.9

type AccountUpgradeToUtaRes struct {
	UnifiedUpdateStatus string `json:"unifiedUpdateStatus"`
	UnifiedUpdateMsg    struct {
		Msg []string `json:"msg"`
	} `json:"unifiedUpdateMsg"`
}

type AccountWalletBalanceAPI

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

func (*AccountWalletBalanceAPI) AccountType

func (api *AccountWalletBalanceAPI) AccountType(accountType string) *AccountWalletBalanceAPI

accountType string true 帳戶類型. 統一帳戶: UNIFIED(現貨/USDT和USDC永續/期權), CONTRACT(反向) 經典帳戶: CONTRACT(期貨), SPOT(現貨)

func (*AccountWalletBalanceAPI) Coin

coin string false 幣種名稱 不傳則返回非零資產信息 可以傳多個幣進行查詢,以逗號分隔, USDT,USDC

func (*AccountWalletBalanceAPI) Do

type AccountWalletBalanceReq

type AccountWalletBalanceReq struct {
	AccountType *string `json:"accountType"` //string	true	帳戶類型. 統一帳戶: UNIFIED(現貨/USDT和USDC永續/期權), CONTRACT(反向) 經典帳戶: CONTRACT(期貨), SPOT(現貨)
	Coin        *string `json:"coin"`        //string	false	幣種名稱 不傳則返回非零資產信息 可以傳多個幣進行查詢,以逗號分隔, USDT,USDC
}

type AccountWalletBalanceRes

type AccountWalletBalanceRes struct {
	List []AccountWalletBalanceResRow `json:"list"`
}

type AccountWalletBalanceResRow

type AccountWalletBalanceResRow struct {
	AccountType            string                           `json:"accountType"`            //帳戶類型
	AccountLTV             string                           `json:"accountLTV"`             //字段廢棄
	AccountIMRate          string                           `json:"accountIMRate"`          //帳戶初始保證金率  Account Total Initial Margin Base Coin / Account Margin Balance Base Coin. 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
	AccountMMRate          string                           `json:"accountMMRate"`          //帳戶維持保證金率 Account Total Maintenance Margin Base Coin / Account Margin Balance Base Coin。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
	TotalEquity            string                           `json:"totalEquity"`            //總凈值為賬戶中每個幣種資產凈值的法幣估值之和。。非統一保證金模式以及統一帳戶(反向)下,該字段返回為空。
	TotalWalletBalance     string                           `json:"totalWalletBalance"`     //賬戶維度換算成usd的產錢包餘額:∑ Asset Wallet Balance By USD value of each asset。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
	TotalMarginBalance     string                           `json:"totalMarginBalance"`     //賬戶維度換算成usd的保證金餘額:totalWalletBalance + totalPerpUPL。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
	TotalAvailableBalance  string                           `json:"totalAvailableBalance"`  //賬戶維度換算成usd的可用餘額:RM:totalMarginBalance - totalInitialMargin。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
	TotalPerpUPL           string                           `json:"totalPerpUPL"`           //賬戶維度換算成usd的永續和USDC交割合約的浮動盈虧:∑ Each perp and USDC Futures upl by base coin。非統一保證金模式以及統一帳戶(反向)下,該字段返回為空。
	TotalInitialMargin     string                           `json:"totalInitialMargin"`     //賬戶維度換算成usd的總初始保證金:∑ Asset Total Initial Margin Base Coin。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
	TotalMaintenanceMargin string                           `json:"totalMaintenanceMargin"` //賬戶維度換算成usd的總維持保證金: ∑ Asset Total Maintenance Margin Base Coin。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
	Coin                   []AccountWalletBalanceResRowCoin `json:"coin"`                   //幣種列表

}

type AccountWalletBalanceResRowCoin

type AccountWalletBalanceResRowCoin struct {
	Coin                string `json:"coin"`                //幣種名稱,例如 BTC,ETH,USDT,USDC
	Equity              string `json:"equity"`              //當前幣種的資產淨值
	UsdValue            string `json:"usdValue"`            //當前幣種折算成 usd 的價值
	WalletBalance       string `json:"walletBalance"`       //當前幣種的錢包餘額
	Free                string `json:"free"`                //經典帳戶現貨錢包的可用餘額. 經典帳戶現貨錢包的獨有字段
	Locked              string `json:"locked"`              //現貨掛單凍結金額
	SpotHedgingQty      string `json:"spotHedgingQty"`      //用於組合保證金(PM)現貨對衝的數量, 截斷至8為小數, 默認為0 統一帳戶的獨有字段
	BorrowAmount        string `json:"borrowAmount"`        //當前幣種的已用借貸額度
	AvailableToWithdraw string `json:"availableToWithdraw"` //當前幣種的可劃轉提現金額
	AccruedInterest     string `json:"accruedInterest"`     //當前幣種的預計要在下一個利息週期收取的利息金額
	TotalOrderIM        string `json:"totalOrderIM"`        //以當前幣種結算的訂單委託預佔用保證金. 組合保證金模式下,該字段返回空字符串
	TotalPositionIM     string `json:"totalPositionIM"`     //以當前幣種結算的所有倉位起始保證金求和 + 所有倉位的預佔用平倉手續費. 組合保證金模式下,該字段返回空字符串
	TotalPositionMM     string `json:"totalPositionMM"`     //以當前幣種結算的所有倉位維持保證金求和. 組合保證金模式下,該字段返回空字符串
	UnrealisedPnl       string `json:"unrealisedPnl"`       //以當前幣種結算的所有倉位的未結盈虧之和
	CumRealisedPnl      string `json:"cumRealisedPnl"`      //以當前幣種結算的所有倉位的累計已結盈虧之和
	Bonus               string `json:"bonus"`               //體驗金. UNIFIED帳戶的獨有字段
	MarginCollateral    bool   `json:"marginCollateral"`    //是否可作為保證金抵押幣種(平台維度), true: 是. false: 否
	CollateralSwitch    bool   `json:"collateralSwitch"`    //用戶是否開啟保證金幣種抵押(用戶維度), true: 是. false: 否
}

type AccountWithdrawalAPI added in v0.1.5

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

func (*AccountWithdrawalAPI) CoinName added in v0.1.5

func (api *AccountWithdrawalAPI) CoinName(coinName string) *AccountWithdrawalAPI

coinName string true 幣種名稱, 僅大寫. 支持最多20個幣種批量查詢, 用逗號分隔. BTC,SOL,USDT,USDC

func (*AccountWithdrawalAPI) Do added in v0.1.5

type AccountWithdrawalReq added in v0.1.5

type AccountWithdrawalReq struct {
	CoinName *string `json:"coinName"` //string	true	幣種名稱, 僅大寫. 支持最多20個幣種批量查詢, 用逗號分隔. BTC,SOL,USDT,USDC
}

coinName true string 幣種名稱, 僅大寫. 支持最多20個幣種批量查詢, 用逗號分隔. BTC,SOL,USDT,USDC

type AccountWithdrawalRes added in v0.1.5

type AccountWithdrawalRes struct {
	AvailableWithdrawal    string            `json:"availableWithdrawal"`
	AvailableWithdrawalMap map[string]string `json:"availableWithdrawalMap"`
}

availableWithdrawal string 請求中第一個幣種的可劃轉餘額 availableWithdrawalMap Object 每個請求幣種的可劃轉餘額的對象。在映射中,鍵是請求的幣種,值是相應的金額(字符串) 例如, "availableWithdrawalMap":{"BTC":"4.54549050","SOL":"33.16713007","XRP":"10805.54548970","ETH":"17.76451865"}

type AssetTithdrawWithdrawableAmountAPI added in v0.1.1

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

func (*AssetTithdrawWithdrawableAmountAPI) Coin added in v0.1.1

func (*AssetTithdrawWithdrawableAmountAPI) Do added in v0.1.1

type AssetTithdrawWithdrawableAmountReq added in v0.1.1

type AssetTithdrawWithdrawableAmountReq struct {
	Coin *string `json:"coin"` //String	true	string	幣種敏誠
}

AssetTithdrawWithdrawableAmount: PrivateRest接口 //GET 查詢延遲提幣凍結金額

type AssetTithdrawWithdrawableAmountRes added in v0.1.1

type AssetTithdrawWithdrawableAmountRes struct {
	LimitAmountUsd     string `json:"limitAmountUsd"` //string	延遲提幣凍結金額 (USD)
	WithdrawableAmount struct {
		SPOT struct {
			Coin               string `json:"coin"`               //string	幣種名稱
			WithdrawableAmount string `json:"withdrawableAmount"` //string	可提現金額
			AvailableBalance   string `json:"availableBalance"`   //string	可用餘額
		} `json:"SPOT"`
		FUND struct {
			Coin               string `json:"coin"`               //string	幣種名稱
			WithdrawableAmount string `json:"withdrawableAmount"` //string	可提現金額
			AvailableBalance   string `json:"availableBalance"`   //string	可用餘額
		} `json:"FUND"`
	} `json:"withdrawableAmount"`
}

AssetTithdrawWithdrawableAmount: PrivateRest接口 //GET 查詢延遲提幣凍結金額

type AssetTransferInterTransferAPI added in v0.1.1

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

func (*AssetTransferInterTransferAPI) Amount added in v0.1.1

func (*AssetTransferInterTransferAPI) Coin added in v0.1.1

func (*AssetTransferInterTransferAPI) Do added in v0.1.1

func (*AssetTransferInterTransferAPI) FromAccountType added in v0.1.1

func (api *AssetTransferInterTransferAPI) FromAccountType(fromAccountType string) *AssetTransferInterTransferAPI

func (*AssetTransferInterTransferAPI) ToAccountType added in v0.1.1

func (api *AssetTransferInterTransferAPI) ToAccountType(toAccountType string) *AssetTransferInterTransferAPI

func (*AssetTransferInterTransferAPI) TransferId added in v0.1.1

type AssetTransferInterTransferReq added in v0.1.1

type AssetTransferInterTransferReq struct {
	TransferId      *string `json:"transferId"`      //String	true	string	UUID. 請自行手動生成UUID
	Coin            *string `json:"coin"`            //String	true	string	幣種
	Amount          *string `json:"amount"`          //String	true	string	劃入數量
	FromAccountType *string `json:"fromAccountType"` //String	true	string	轉出賬戶類型
	ToAccountType   *string `json:"toAccountType"`   //String	true	string	轉入賬戶類型
}

AssetTransferInterTransfer: PrivateRest接口 //POST 劃轉 (單帳號內)

type AssetTransferInterTransferRes added in v0.1.1

type AssetTransferInterTransferRes struct {
	TransferId string `json:"transferId"` //string	UUID
	Status     string `json:"status"`     //string	劃轉狀態  STATUS_UNKNOWN  SUCCESS  PENDING   FAILED
}

AssetTransferInterTransfer: PrivateRest接口 //POST 劃轉 (單帳號內)

type AssetTransferQueryAccountCoinBalanceAPI added in v0.1.1

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

func (*AssetTransferQueryAccountCoinBalanceAPI) AccountType added in v0.1.1

func (*AssetTransferQueryAccountCoinBalanceAPI) Coin added in v0.1.1

func (*AssetTransferQueryAccountCoinBalanceAPI) Do added in v0.1.1

func (*AssetTransferQueryAccountCoinBalanceAPI) MemberId added in v0.1.1

func (*AssetTransferQueryAccountCoinBalanceAPI) ToMemberId added in v0.1.1

func (*AssetTransferQueryAccountCoinBalanceAPI) WithBonus added in v0.1.1

func (*AssetTransferQueryAccountCoinBalanceAPI) WithLtvTransferSafeAmount added in v0.1.1

func (api *AssetTransferQueryAccountCoinBalanceAPI) WithLtvTransferSafeAmount(withLtvTransferSafeAmount int) *AssetTransferQueryAccountCoinBalanceAPI

func (*AssetTransferQueryAccountCoinBalanceAPI) WithTransferSafeAmount added in v0.1.1

func (api *AssetTransferQueryAccountCoinBalanceAPI) WithTransferSafeAmount(withTransferSafeAmount int) *AssetTransferQueryAccountCoinBalanceAPI

type AssetTransferQueryAccountCoinBalanceReq added in v0.1.1

type AssetTransferQueryAccountCoinBalanceReq struct {
	MemberId                  *string `json:"memberId"`                  //String	false	string	用戶ID. 當使用母帳號api key查詢子帳戶的幣種餘額時,該字段必傳
	ToMemberId                *string `json:"toMemberId"`                //String	false	string	劃入帳戶UID. 當查詢不同uid間劃轉時, 該字段必傳
	AccountType               *string `json:"accountType"`               //String	true	string	帳戶類型
	Coin                      *string `json:"coin"`                      //String	true	string	幣種
	WithBonus                 *int    `json:"withBonus"`                 //String	false	integer	是否查詢體驗金. 0(默認): 不查詢,1: 查詢.
	WithTransferSafeAmount    *int    `json:"withTransferSafeAmount"`    //String	false	integer	是否查詢延遲提幣安全限額  // 0(默認):否, 1:是// 什麼是延遲提幣?
	WithLtvTransferSafeAmount *int    `json:"withLtvTransferSafeAmount"` //String	false	integer	特別用於機構借貸用戶, 可以查詢風險水平內的可劃轉餘額0(default):false, 1:true  此時toAccountType字段必傳
}

AssetTransferQueryAccountCoinBalance: PrivateRest接口 //GET 查詢帳戶單個幣種餘額

type AssetTransferQueryAccountCoinBalanceRes added in v0.1.1

type AssetTransferQueryAccountCoinBalanceRes struct {
	AccountType string `json:"accountType"` //string	賬戶類型
	BizType     int    `json:"bizType"`     //integer	帳戶業務子類型
	AccountId   string `json:"accountId"`   //string	賬戶ID
	MemberId    string `json:"memberId"`    //string	用戶ID
	Balance     struct {
		Coin                  string `json:"coin"`                  //string	幣種類型
		WalletBalance         string `json:"walletBalance"`         //string	錢包余額
		TransferBalance       string `json:"transferBalance"`       //string	可划余額
		Bonus                 string `json:"bonus"`                 //string	可用金額中包含的体验金
		TransferSafeAmount    string `json:"transferSafeAmount"`    //string	可劃轉的安全限額. 若不查詢,則返回""
		LtvTransferSafeAmount string `json:"ltvTransferSafeAmount"` //string	機構借貸用戶的可劃轉餘額. 若不查詢,則返回""
	} `json:"balance"`
}

AssetTransferQueryAccountCoinBalance: PrivateRest接口 //GET 查詢帳戶單個幣種餘額

type AssetTransferQueryAccountCoinsBalanceAPI added in v0.1.1

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

func (*AssetTransferQueryAccountCoinsBalanceAPI) AccountType added in v0.1.1

func (*AssetTransferQueryAccountCoinsBalanceAPI) Coin added in v0.1.1

func (*AssetTransferQueryAccountCoinsBalanceAPI) Do added in v0.1.1

func (*AssetTransferQueryAccountCoinsBalanceAPI) MemberId added in v0.1.1

func (*AssetTransferQueryAccountCoinsBalanceAPI) WithBonus added in v0.1.1

type AssetTransferQueryAccountCoinsBalanceReq added in v0.1.1

type AssetTransferQueryAccountCoinsBalanceReq struct {
	MemberId    *string `json:"memberId"`    //String	false	string	用戶ID. 當使用母帳號api key查詢子帳戶的幣種餘額時,該字段必傳
	AccountType *string `json:"accountType"` //String	true	string	賬戶類型
	Coin        *string `json:"coin"`        //String	false	string	幣種類型
	WithBonus   *int    `json:"withBonus"`   //String	false	integer	是否查詢體驗金. 0(默認):不查詢; 1:查詢
}

AssetTransferQueryAccountCoinsBalance: PrivateRest接口 //GET 查詢賬戶所有幣種餘額

type AssetTransferQueryAccountCoinsBalanceRes added in v0.1.1

type AssetTransferQueryAccountCoinsBalanceRes struct {
	AccountType string `json:"accountType"` //string	賬戶類型
	MemberId    string `json:"memberId"`    //string	用戶ID
	Balance     []struct {
		Coin            string `json:"coin"`            //string	幣種類型
		WalletBalance   string `json:"walletBalance"`   //string	錢包余額
		TransferBalance string `json:"transferBalance"` //string	可划余額
		Bonus           string `json:"bonus"`           //string	体验金
	} `json:"balance"`
}

AssetTransferQueryAccountCoinsBalance: PrivateRest接口 //GET 查詢賬戶所有幣種餘額

type AssetTransferQueryInterTransferListAPI added in v0.1.1

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

func (*AssetTransferQueryInterTransferListAPI) Coin added in v0.1.1

func (*AssetTransferQueryInterTransferListAPI) Cursor added in v0.1.1

func (*AssetTransferQueryInterTransferListAPI) Do added in v0.1.1

func (*AssetTransferQueryInterTransferListAPI) EndTime added in v0.1.1

func (*AssetTransferQueryInterTransferListAPI) Limit added in v0.1.1

func (*AssetTransferQueryInterTransferListAPI) StartTime added in v0.1.1

func (*AssetTransferQueryInterTransferListAPI) Status added in v0.1.1

func (*AssetTransferQueryInterTransferListAPI) TransferId added in v0.1.1

type AssetTransferQueryInterTransferListReq added in v0.1.1

type AssetTransferQueryInterTransferListReq struct {
	TransferId *string `json:"transferId,omitempty"` //String	false	string	UUID. 使用創建劃轉時用的UUID
	Coin       *string `json:"coin,omitempty"`       //String	false	string	幣種
	Status     *string `json:"status,omitempty"`     //String	false	string	劃轉狀態
	StartTime  *int64  `json:"startTime,omitempty"`  //String	false	integer	開始時間戳 (毫秒) 注意: 實際查詢時是秒級維度生效	當startTime & endTime都不傳入時, API默認返回30天的數據
	EndTime    *int64  `json:"endTime,omitempty"`    //String	false	integer	結束時間戳 (毫秒) 注意: 實際查詢時是秒級維度生效
	Limit      *int    `json:"limit,omitempty"`      //String	false	integer	每頁數量限制. [1, 50]. 默認: 20
	Cursor     *string `json:"cursor,omitempty"`     //String	false	string	游標,用於翻頁
}

AssetTransferQueryInterTransferList: PrivateRest接口 //GET 查詢劃轉紀錄 (單帳號內)

type AssetTransferQueryInterTransferListRes added in v0.1.1

type AssetTransferQueryInterTransferListRes struct {
	List           []AssetTransferQueryInterTransferListResRow `json:"list"`
	NextPageCursor string                                      `json:"nextPageCursor"` //string	游標,用於翻頁
}

AssetTransferQueryInterTransferList: PrivateRest接口 //GET 查詢劃轉紀錄 (單帳號內)

type AssetTransferQueryInterTransferListResRow added in v0.1.1

type AssetTransferQueryInterTransferListResRow struct {
	TransferId      string `json:"transferId"`      //劃轉Id
	Coin            string `json:"coin"`            //劃轉幣種
	Amount          string `json:"amount"`          //劃轉金額
	FromAccountType string `json:"fromAccountType"` //劃出賬戶類型
	ToAccountType   string `json:"toAccountType"`   //劃入賬戶類型
	Timestamp       string `json:"timestamp"`       //劃轉創建時間戳 (毫秒)
	Status          string `json:"status"`          //劃轉狀態
}

type AssetTransferQueryTransferCoinListAPI added in v0.1.1

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

func (*AssetTransferQueryTransferCoinListAPI) Do added in v0.1.1

func (*AssetTransferQueryTransferCoinListAPI) FromAccountType added in v0.1.1

func (*AssetTransferQueryTransferCoinListAPI) ToAccountType added in v0.1.1

type AssetTransferQueryTransferCoinListReq added in v0.1.1

type AssetTransferQueryTransferCoinListReq struct {
	FromAccountType *string `json:"fromAccountType"` //String	true	string	劃出帳戶類型
	ToAccountType   *string `json:"toAccountType"`   //String	true	string	劃入帳戶類型
}

AssetTransferQueryTransferCoinList: PrivateRest接口 //GET 帳戶類型間可劃轉的幣種

type AssetTransferQueryTransferCoinListRes added in v0.1.1

type AssetTransferQueryTransferCoinListRes struct {
	List []string `json:"list"` //array	幣種數組
}

AssetTransferQueryTransferCoinList: PrivateRest接口 //GET 帳戶類型間可劃轉的幣種

type Books

type Books struct {
	Price    string `json:"price"`    //价格
	Quantity string `json:"quantity"` //合约张数或交易币的数量
}

func (*Books) DecimalResult added in v0.0.2

func (b *Books) DecimalResult() (decimal.Decimal, decimal.Decimal)

func (*Books) Float64Result added in v0.0.2

func (b *Books) Float64Result() (float64, float64)

type BooksMiddle

type BooksMiddle [2]interface{}

type BybitErrorRes

type BybitErrorRes struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
}

type BybitRestRes

type BybitRestRes[T any] struct {
	BybitErrorRes             //错误信息
	BybitTimeRes              //时间戳
	RetExtInfo    interface{} `json:"retExtInfo"`
	Result        T           `json:"result"` //请求结果
}

type BybitTimeRes

type BybitTimeRes struct {
	Time int64 `json:"time"` //REST网关接收请求时的时间戳,Unix时间戳的微秒数格式,如 1597026383085123返回的时间是请求验证后的时间
}

type Category

type Category string

spot 現貨 linear USDT永續, USDC永續, USDC交割 inverse 反向合約,包含反向永續, 反向交割 option 期權

const (
	CAT_ALL     Category = "all"
	CAT_SPOT    Category = "spot"
	CAT_LINEAR  Category = "linear"
	CAT_INVERSE Category = "inverse"
	CAT_OPTION  Category = "option"
)

func (Category) String

func (c Category) String() string

type Client

type Client struct {
	APIKey     string
	SecretKey  string
	Referer    string
	RecvWindow string
}

type CommonWsRes added in v0.0.2

type CommonWsRes struct {
	Topic string `json:"topic"` //Topic名
	Ts    int64  `json:"ts"`    //行情服務生成數據的時間戳 (毫秒)
	Type  string `json:"type"`  //數據類型. snapshot,delta
}

type InstrumentsInfoResRow

type InstrumentsInfoResRow struct {
	Symbol        string        `json:"symbol"`        // 合約名稱
	BaseCoin      string        `json:"baseCoin"`      // 交易幣種
	QuoteCoin     string        `json:"quoteCoin"`     // 報價幣種
	SettleCoin    string        `json:"settleCoin"`    // 結算幣種
	Status        string        `json:"status"`        // 合約狀態
	LotSizeFilter LotSizeFilter `json:"lotSizeFilter"` // 數量屬性
	PriceFilter   PriceFilter   `json:"priceFilter"`   // 價格屬性
	LinearDetails
	OptionsDetails
	SpotDetails
}

type LeverageFilter

type LeverageFilter struct {
	MinLeverage  string `json:"minLeverage"`  // 最小槓桿
	MaxLeverage  string `json:"maxLeverage"`  // 最大槓桿
	LeverageStep string `json:"leverageStep"` // 修改槓桿的步長
}

type LinearDetails

type LinearDetails struct {
	UnifiedMarginTrade bool           `json:"unifiedMarginTrade"` // 是否支持統一保證金交易
	FundingInterval    int            `json:"fundingInterval"`    // 資金費率結算週期 (分鐘)
	CopyTrading        string         `json:"copyTrading"`        // 當前交易對是否支持帶單交易
	UpperFundingRate   string         `json:"upperFundingRate"`   // 資金費率上限
	LowerFundingRate   string         `json:"lowerFundingRate"`   // 資金費率下限
	ContractType       string         `json:"contractType"`       // 合約類型
	LaunchTime         string         `json:"launchTime"`         // 發佈時間 (ms)
	DeliveryTime       string         `json:"deliveryTime"`       // 交割時間 (ms). 僅對交割合約有效
	DeliveryFeeRate    string         `json:"deliveryFeeRate"`    // 交割費率. 僅對交割合約有效
	PriceScale         string         `json:"priceScale"`         // 價格精度
	LeverageFilter     LeverageFilter `json:"leverageFilter"`     // 槓桿屬性
}

LinearDetails

type LotSizeFilter

type LotSizeFilter struct {
	MaxOrderQty         string `json:"maxOrderQty"`         // 單筆限價或PostOnly單最大下單量
	MinOrderQty         string `json:"minOrderQty"`         // 單筆訂單最小下單量
	MaxMktOrderQty      string `json:"maxMktOrderQty"`      // 單筆市價單最大下單量
	QtyStep             string `json:"qtyStep"`             // 修改下單量的步長
	PostOnlyMaxOrderQty string `json:"postOnlyMaxOrderQty"` // 廢棄, 請參照maxOrderQty
	MinNotionalValue    string `json:"minNotionalValue"`    // 訂單最小名義價值
	BasePrecision       string `json:"basePrecision"`       // 交易幣種精度
	QuotePrecision      string `json:"quotePrecision"`      // 報價幣種精度
	MinOrderAmt         string `json:"minOrderAmt"`         // 單筆訂單最小訂單額
	MaxOrderAmt         string `json:"maxOrderAmt"`         // 單筆訂單最大訂單額
}

type MarketInstrumentsInfoAPI

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

func (*MarketInstrumentsInfoAPI) BaseCoin

func (api *MarketInstrumentsInfoAPI) BaseCoin(baseCoin string) *MarketInstrumentsInfoAPI

baseCoin false string 交易货币. 仅对期货/期权有效 对于期权, 默认返回baseCoin为BTC的

func (*MarketInstrumentsInfoAPI) Category

func (api *MarketInstrumentsInfoAPI) Category(category string) *MarketInstrumentsInfoAPI

category true string 产品类型. spot,linear,inverse,option

func (*MarketInstrumentsInfoAPI) Cursor

cursor false string 游标,用于翻页

func (*MarketInstrumentsInfoAPI) Do

func (*MarketInstrumentsInfoAPI) Limit

limit false integer 每页数量限制. [1, 1000]. 默认: 500

func (*MarketInstrumentsInfoAPI) Status

status false string 交易对状态筛选 现货/期货 仅有Trading状态

func (*MarketInstrumentsInfoAPI) Symbol

symbol false string 合约名称

type MarketInstrumentsInfoReq

type MarketInstrumentsInfoReq struct {
	Category *string `json:"category"` //String	true	string	产品类型. spot,linear,inverse,option
	Symbol   *string `json:"symbol"`   //String	false	string	合约名称
	Status   *string `json:"status"`   //String	false	string	交易对状态筛选  现货/期货 仅有Trading状态
	BaseCoin *string `json:"baseCoin"` //String	false	string	交易货币. 仅对期货/期权有效 对于期权, 默认返回baseCoin为BTC的
	Limit    *int    `json:"limit"`    //String	false	integer	每页数量限制. [1, 1000]. 默认: 500
	Cursor   *string `json:"cursor"`   //String	false	string	游标,用于翻页
}

category true string 产品类型. spot,linear,inverse,option symbol false string 合约名称 status false string 交易对状态筛选 现货/期货 仅有Trading状态 baseCoin false string 交易货币. 仅对期货/期权有效 对于期权, 默认返回baseCoin为BTC的 limit false integer 每页数量限制. [1, 1000]. 默认: 500 cursor false string 游标,用于翻页

type MarketInstrumentsInfoRes

type MarketInstrumentsInfoRes struct {
	Category       string                  `json:"category"`       // 產品類型
	NextPageCursor string                  `json:"nextPageCursor"` // 游標,用於翻頁
	List           []InstrumentsInfoResRow `json:"list"`           // 共有参数列表
}

type MarketKlineAPI

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

func (*MarketKlineAPI) Category

func (api *MarketKlineAPI) Category(category string) *MarketKlineAPI

category false string 產品類型. spot,linear,inverse 當category不指定時, 默認是linear

func (*MarketKlineAPI) Do

func (*MarketKlineAPI) End

func (api *MarketKlineAPI) End(end int64) *MarketKlineAPI

end false integer 結束時間戳 (毫秒)

func (*MarketKlineAPI) Interval

func (api *MarketKlineAPI) Interval(interval string) *MarketKlineAPI

interval true string 時間粒度. 1,3,5,15,30,60,120,240,360,720,D,M,W

func (*MarketKlineAPI) Limit

func (api *MarketKlineAPI) Limit(limit int) *MarketKlineAPI

limit false integer 每頁數量限制. [1, 1000]. 默認: 200

func (*MarketKlineAPI) Start

func (api *MarketKlineAPI) Start(start int64) *MarketKlineAPI

start false integer 開始時間戳 (毫秒)

func (*MarketKlineAPI) Symbol

func (api *MarketKlineAPI) Symbol(symbol string) *MarketKlineAPI

symbol true string 合約名稱

type MarketKlineMiddle

type MarketKlineMiddle struct {
	Symbol   string                 `json:"symbol"`
	Category string                 `json:"category"`
	List     []MarketKlineMiddleRow `json:"list"`
}

func (MarketKlineMiddle) ConvertToRes

func (middleRow MarketKlineMiddle) ConvertToRes() MarketKlineRes

type MarketKlineMiddleRow

type MarketKlineMiddleRow [7]interface{}

type MarketKlineReq

type MarketKlineReq struct {
	Category *string `json:"category"` //String	false	string	產品類型. spot,linear,inverse 當category不指定時, 默認是linear
	Symbol   *string `json:"symbol"`   //String	true	string	合約名稱
	Interval *string `json:"interval"` //String	true	string	時間粒度. 1,3,5,15,30,60,120,240,360,720,D,M,W
	Start    *int64  `json:"start"`    //String	false	integer	開始時間戳 (毫秒)
	End      *int64  `json:"end"`      //String	false	integer	結束時間戳 (毫秒)
	Limit    *int    `json:"limit"`    //String	false	integer	每頁數量限制. [1, 1000]. 默認: 200
}

category false string 產品類型. spot,linear,inverse 當category不指定時, 默認是linear symbol true string 合約名稱 interval true string 時間粒度. 1,3,5,15,30,60,120,240,360,720,D,M,W start false integer 開始時間戳 (毫秒) end false integer 結束時間戳 (毫秒) limit false integer 每頁數量限制. [1, 1000]. 默認: 200

type MarketKlineRes

type MarketKlineRes struct {
	Category string              `json:"category"` //產品類型
	Symbol   string              `json:"symbol"`   //合約名稱
	List     []MarketKlineResRow `json:"list"`
}

type MarketKlineResRow

type MarketKlineResRow struct {
	StartTime  string `json:"startTime"`  //蠟燭的開始時間戳 (毫秒)
	OpenPrice  string `json:"openPrice"`  //開始價格
	HighPrice  string `json:"highPrice"`  //最高價格
	LowPrice   string `json:"lowPrice"`   //最低價格
	ClosePrice string `json:"closePrice"` //結束價格. 如果蠟燭尚未結束,則表示為最新成交價格
	Volume     string `json:"volume"`     //交易量. 合約單位: 合約的張數. 現貨單位: 幣種的數量
	Turnover   string `json:"turnover"`   //交易額. 單位: 報價貨幣的數量
}

type MarketOrderBookAPI

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

func (*MarketOrderBookAPI) Category

func (api *MarketOrderBookAPI) Category(category string) *MarketOrderBookAPI

category true string 產品類型. spot, linear, inverse, option

func (*MarketOrderBookAPI) Do

func (*MarketOrderBookAPI) Limit

func (api *MarketOrderBookAPI) Limit(limit int) *MarketOrderBookAPI

limit false integer 深度限制. spot: [1, 200], 默認: 1. linear&inverse: [1, 500],默認: 25. option: [1, 25],默認: 1

func (*MarketOrderBookAPI) Symbol

func (api *MarketOrderBookAPI) Symbol(symbol string) *MarketOrderBookAPI

symbol true string 合約名稱

type MarketOrderBookMiddle

type MarketOrderBookMiddle struct {
	Symbol string        `json:"s"`   //合約名稱
	Bids   []BooksMiddle `json:"b"`   //買方. 按照價格從大到小
	Asks   []BooksMiddle `json:"a"`   //賣方. 按照價格從小到大
	Ts     int64         `json:"ts"`  //行情服務生成數據時間戳(毫秒)
	U      int64         `json:"u"`   //表示數據連續性的id. 對於期貨, 它和wss推送裡的500檔的u對齊 對於現貨, 它和wss推送裡的200檔的u對齊
	Seq    int64         `json:"seq"` //撮合版本號 該字段可以用於關聯不同檔位的orderbook, 如果值越小, 則說明數據生成越早 期權目前不存在此字段
}

func (MarketOrderBookMiddle) ConvertToRes

func (middle MarketOrderBookMiddle) ConvertToRes() MarketOrderBookRes

type MarketOrderBookReq

type MarketOrderBookReq struct {
	Category *string `json:"category"` //String	true	string	產品類型. spot, linear, inverse, option
	Symbol   *string `json:"symbol"`   //String	true	string	合約名稱
	Limit    *int    `json:"limit"`    //String	false	integer	深度限制. spot: [1, 200], 默認: 1. linear&inverse: [1, 500],默認: 25. option: [1, 25],默認: 1.
}

type MarketOrderBookRes

type MarketOrderBookRes struct {
	Symbol string  `json:"s"`   //合約名稱
	Bids   []Books `json:"b"`   //買方. 按照價格從大到小
	Asks   []Books `json:"a"`   //賣方. 按照價格從小到大
	Ts     int64   `json:"ts"`  //行情服務生成數據時間戳(毫秒)
	U      int64   `json:"u"`   //表示數據連續性的id. 對於期貨, 它和wss推送裡的500檔的u對齊 對於現貨, 它和wss推送裡的200檔的u對齊
	Seq    int64   `json:"seq"` //撮合版本號 該字段可以用於關聯不同檔位的orderbook, 如果值越小, 則說明數據生成越早 期權目前不存在此字段
}

type MarketTickersAPI

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

func (*MarketTickersAPI) BaseCoin

func (api *MarketTickersAPI) BaseCoin(baseCoin string) *MarketTickersAPI

baseCoin false string 交易幣種. 僅option有效, baseCoin和symbol必傳其中一個

func (*MarketTickersAPI) Category

func (api *MarketTickersAPI) Category(category string) *MarketTickersAPI

category true string 產品類型. spot,linear,inverse,option

func (*MarketTickersAPI) Do

func (*MarketTickersAPI) ExpDate

func (api *MarketTickersAPI) ExpDate(expDate string) *MarketTickersAPI

expDate false string 到期日. 舉例, 25DEC22. 僅option有效

func (*MarketTickersAPI) Symbol

func (api *MarketTickersAPI) Symbol(symbol string) *MarketTickersAPI

symbol false string 合約名稱

type MarketTickersLinear

type MarketTickersLinear struct {
	IndexPrice             string `json:"indexPrice"`             //指數價格
	MarkPrice              string `json:"markPrice"`              //標記價格
	PrevPrice1H            string `json:"prevPrice1h"`            //1小時前的整點市價
	OpenInterest           string `json:"openInterest"`           //未平倉合約的數量
	OpenInterestValue      string `json:"openInterestValue"`      //未平倉合約的價值
	FundingRate            string `json:"fundingRate"`            //資金費率
	NextFundingTime        string `json:"nextFundingTime"`        //下次結算資金費用的時間 (毫秒)
	PredictedDeliveryPrice string `json:"predictedDeliveryPrice"` //預計交割價格. 交割前30分鐘有值
	BasisRate              string `json:"basisRate"`              //交割合約基差率
	DeliveryFeeRate        string `json:"deliveryFeeRate"`        //交割費率
	DeliveryTime           string `json:"deliveryTime"`           //交割時間戳 (毫秒)
	Basis                  string `json:"basis"`                  //交割合約基差
}

linear 独特参数

type MarketTickersOption

type MarketTickersOption struct {
	Bid1Iv          string `json:"bid1Iv"`          //買1價對應的iv
	Ask1Iv          string `json:"ask1Iv"`          //賣1價對應的iv
	MarkIv          string `json:"markIv"`          //標記價格對應的iv
	UnderlyingPrice string `json:"underlyingPrice"` //底層資產的價格
	TotalVolume     string `json:"totalVolume"`     //總成交量
	TotalTurnover   string `json:"totalTurnover"`   //總成交額
	Delta           string `json:"delta"`           //Delta
	Gamma           string `json:"gamma"`           //Gamma
	Vega            string `json:"vega"`            //Vega
	Theta           string `json:"theta"`           //Theta
	Change24H       string `json:"change24h"`       //過去24小時的變化
}

option 独特参数

type MarketTickersReq

type MarketTickersReq struct {
	Category *string `json:"category"` //String	true	string	產品類型. spot,linear,inverse,option
	Symbol   *string `json:"symbol"`   //String	false	string	合約名稱
	BaseCoin *string `json:"baseCoin"` //String	false	string	交易幣種. 僅option有效, baseCoin和symbol必傳其中一個
	ExpDate  *string `json:"expDate"`  //String	false	string	到期日. 舉例, 25DEC22. 僅option有效
}

category true string 產品類型. spot,linear,inverse,option symbol false string 合約名稱 baseCoin false string 交易幣種. 僅option有效, baseCoin和symbol必傳其中一個 expDate false string 到期日. 舉例, 25DEC22. 僅option有效

type MarketTickersRes

type MarketTickersRes struct {
	Category string                `json:"category"` //產品類型
	List     []MarketTickersResRow `json:"list"`
}

type MarketTickersResRow

type MarketTickersResRow struct {
	//common 公有参数
	Symbol       string `json:"symbol"`       //合約名稱
	Bid1Price    string `json:"bid1Price"`    //買1價
	Bid1Size     string `json:"bid1Size"`     //買1價的數量
	Ask1Price    string `json:"ask1Price"`    //賣1價
	Ask1Size     string `json:"ask1Size"`     //賣1價的數量
	LastPrice    string `json:"lastPrice"`    //最新市場成交價
	PrevPrice24H string `json:"prevPrice24h"` //24小時前的整點市價
	Price24HPcnt string `json:"price24hPcnt"` //市場價格相對24h前變化的百分比
	HighPrice24H string `json:"highPrice24h"` //最近24小時的最高價
	LowPrice24H  string `json:"lowPrice24h"`  //最近24小時的最低價
	Turnover24H  string `json:"turnover24h"`  //最近24小時成交額
	Volume24H    string `json:"volume24h"`    //最近24小時成交量

	MarketTickersLinear
	MarketTickersOption
	MarketTickersSpot
}

type MarketTickersSpot

type MarketTickersSpot struct {
	UsdIndexPrice string `json:"usdIndexPrice"` //USD指數價格 用於計算統一帳戶裡資產折算成USD價值的價格 若幣種不屬於抵押品幣種, 則返回空字符串 只有那些幣對名是"XXX/USDT"或者"XXX/USDC"有值
}

spot 独特参数

type MarketTimeAPI

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

func (*MarketTimeAPI) Do

type MarketTimeReq

type MarketTimeReq struct {
}

type MarketTimeRes

type MarketTimeRes struct {
	TimeSecond string `json:"timeSecond"` //Bybit服務器時間戳 (秒)
	TimeNano   string `json:"timeNano"`   //Bybit 服務器時間戳 (微秒)
}

type MySyncMap

type MySyncMap[K any, V any] struct {
	// contains filtered or unexported fields
}

func NewMySyncMap

func NewMySyncMap[K any, V any]() MySyncMap[K, V]

func (*MySyncMap[K, V]) Delete

func (m *MySyncMap[K, V]) Delete(k K)

func (*MySyncMap[K, V]) Length

func (m *MySyncMap[K, V]) Length() int

func (*MySyncMap[K, V]) Load

func (m *MySyncMap[K, V]) Load(k K) (V, bool)

func (*MySyncMap[K, V]) MapValues

func (m *MySyncMap[K, V]) MapValues(f func(k K, v V) V) *MySyncMap[K, V]

func (*MySyncMap[K, V]) Range

func (m *MySyncMap[K, V]) Range(f func(k K, v V) bool)

func (*MySyncMap[K, V]) Store

func (m *MySyncMap[K, V]) Store(k K, v V)

type OptionsDetails

type OptionsDetails struct {
	OptionsType     string `json:"optionsType"`     // 期權類型. Call,Put
	LaunchTime      string `json:"launchTime"`      // 發佈時間 (ms)
	DeliveryTime    string `json:"deliveryTime"`    // 交割時間 (ms)
	DeliveryFeeRate string `json:"deliveryFeeRate"` // 交割費率
}

OptionsDetails

type OrderAmendAPI

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

func (*OrderAmendAPI) Category

func (api *OrderAmendAPI) Category(category string) *OrderAmendAPI

category string true 產品類型 統一帳戶: linear, inverse, spot, option 經典帳戶: linear, inverse, spot

func (*OrderAmendAPI) Do

func (*OrderAmendAPI) OrderId

func (api *OrderAmendAPI) OrderId(orderId string) *OrderAmendAPI

orderId string false 訂單Id. orderId和orderLinkId必傳其中一個

func (*OrderAmendAPI) OrderIv

func (api *OrderAmendAPI) OrderIv(orderIv string) *OrderAmendAPI

orderIv string false 隱含波動率. 僅option有效. 按照實際值傳入, e.g., 對於10%, 則傳入0.1

func (*OrderAmendAPI) OrderLinkId

func (api *OrderAmendAPI) OrderLinkId(orderLinkId string) *OrderAmendAPI

orderLinkId string false 用戶自定義訂單Id. orderId和orderLinkId必傳其中一個

func (*OrderAmendAPI) Price

func (api *OrderAmendAPI) Price(price string) *OrderAmendAPI

price string false 修改後的訂單價格. 若不修改,請不要傳該字段

func (*OrderAmendAPI) Qty

func (api *OrderAmendAPI) Qty(qty string) *OrderAmendAPI

qty string false 修改後的訂單數量. 若不修改,請不要傳該字段

func (*OrderAmendAPI) SlLimitPrice

func (api *OrderAmendAPI) SlLimitPrice(slLimitPrice string) *OrderAmendAPI

slLimitPrice string false *觸發止損後轉換為限價單的價格. 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 適用於 spot(UTA), linear, inverse

func (*OrderAmendAPI) SlTriggerBy

func (api *OrderAmendAPI) SlTriggerBy(slTriggerBy string) *OrderAmendAPI

slTriggerBy string false 止損價格觸發類型. 若下單時未設置該值,則調用該接口修改止損價格時,該字段必傳

func (*OrderAmendAPI) StopLoss

func (api *OrderAmendAPI) StopLoss(stopLoss string) *OrderAmendAPI

stopLoss string false 修改後的止損價格. 當傳"0"時, 表示取消當前訂單上設置的止損. 若不修改,請不要傳該字段 適用於 spot(UTA), linear, inverse

func (*OrderAmendAPI) Symbol

func (api *OrderAmendAPI) Symbol(symbol string) *OrderAmendAPI

symbol string true 合約名稱

func (*OrderAmendAPI) TakeProfit

func (api *OrderAmendAPI) TakeProfit(takeProfit string) *OrderAmendAPI

takeProfit string false 修改後的止盈價格. 當傳"0"時, 表示取消當前訂單上設置的止盈. 若不修改,請不要傳該字段 適用於 spot(UTA), linear, inverse

func (*OrderAmendAPI) TpLimitPrice

func (api *OrderAmendAPI) TpLimitPrice(tpLimitPrice string) *OrderAmendAPI

tpLimitPrice string false *觸發止盈後轉換為限價單的價格. 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 適用於 spot(UTA), linear, inverse

func (*OrderAmendAPI) TpTriggerBy

func (api *OrderAmendAPI) TpTriggerBy(tpTriggerBy string) *OrderAmendAPI

tpTriggerBy string false 止盈價格觸發類型. 若下單時未設置該值,則調用該接口修改止盈價格時,該字段必傳

func (*OrderAmendAPI) TpslMode

func (api *OrderAmendAPI) TpslMode(tpslMode string) *OrderAmendAPI

tpslMode string false 止盈止損模式 Full: 全部倉位止盈止損. 此時, tpOrderType或者slOrderType必須傳Market Partial: 部分倉位止盈止損. 支持創建限價止盈止損. 注意: 創建限價止盈止損時, tpslMode必傳且為Partial 僅對linear和inverse有效

func (*OrderAmendAPI) TriggerBy

func (api *OrderAmendAPI) TriggerBy(triggerBy string) *OrderAmendAPI

triggerBy string false 觸發價格的觸發類型

func (*OrderAmendAPI) TriggerPrice

func (api *OrderAmendAPI) TriggerPrice(triggerPrice string) *OrderAmendAPI

triggerPrice string false 對於期貨, 是條件單觸發價格參數. 若您希望市場價是要上升後觸發, 確保: triggerPrice > 市場價格 否則, triggerPrice < 市場價格 對於現貨, 這是下止盈止損單或者條件單的觸發價格參數

type OrderAmendBatchAPI

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

func (*OrderAmendBatchAPI) AddNewOrderAmendReq

func (api *OrderAmendBatchAPI) AddNewOrderAmendReq(orderAmendApi *OrderAmendAPI) *OrderAmendBatchAPI

func (*OrderAmendBatchAPI) Do

func (*OrderAmendBatchAPI) SetOrderList

func (api *OrderAmendBatchAPI) SetOrderList(orderAmendApiList []*OrderAmendAPI) *OrderAmendBatchAPI

type OrderAmendBatchReq

type OrderAmendBatchReq struct {
	Category *string         `json:"category"` //string	true	產品類型 統一帳戶: linear, inverse, spot, option 經典帳戶: linear, inverse, spot
	Request  []OrderAmendReq `json:"request"`  //array	true	批量訂單請求
}

type OrderAmendBatchRes

type OrderAmendBatchRes struct {
	List []OrderAmendBatchResRow `json:"list"`
}

type OrderAmendBatchResRow

type OrderAmendBatchResRow struct {
	Category    string `json:"category"`    //產品類型
	Symbol      string `json:"symbol"`      //合約名稱
	OrderId     string `json:"orderId"`     //訂單Id
	OrderLinkId string `json:"orderLinkId"` //用戶自定義訂單Id
}

type OrderAmendReq

type OrderAmendReq struct {
	Category     *string `json:"category"`     //string	true	產品類型 統一帳戶: linear, inverse, spot, option 經典帳戶: linear, inverse, spot
	Symbol       *string `json:"symbol"`       //string	true	合約名稱
	OrderId      *string `json:"orderId"`      //string	false	訂單Id. orderId和orderLinkId必傳其中一個
	OrderLinkId  *string `json:"orderLinkId"`  //string	false	用戶自定義訂單Id. orderId和orderLinkId必傳其中一個
	OrderIv      *string `json:"orderIv"`      //string	false	隱含波動率. 僅option有效. 按照實際值傳入, e.g., 對於10%, 則傳入0.1
	TriggerPrice *string `json:"triggerPrice"` //string	false	對於期貨, 是條件單觸發價格參數. 若您希望市場價是要上升後觸發, 確保: triggerPrice > 市場價格 否則, triggerPrice < 市場價格 對於現貨, 這是下止盈止損單或者條件單的觸發價格參數
	Qty          *string `json:"qty"`          //string	false	修改後的訂單數量. 若不修改,請不要傳該字段
	Price        *string `json:"price"`        //string	false	修改後的訂單價格. 若不修改,請不要傳該字段
	TpslMode     *string `json:"tpslMode"`     //string	false	止盈止損模式 Full: 全部倉位止盈止損. 此時, tpOrderType或者slOrderType必須傳Market Partial: 部分倉位止盈止損. 支持創建限價止盈止損. 注意: 創建限價止盈止損時, tpslMode必傳且為Partial 僅對linear和inverse有效
	TakeProfit   *string `json:"takeProfit"`   //string	false	修改後的止盈價格. 當傳"0"時, 表示取消當前訂單上設置的止盈. 若不修改,請不要傳該字段 適用於 spot(UTA), linear, inverse
	StopLoss     *string `json:"stopLoss"`     //string	false	修改後的止損價格. 當傳"0"時, 表示取消當前訂單上設置的止損. 若不修改,請不要傳該字段 適用於 spot(UTA), linear, inverse
	TpTriggerBy  *string `json:"tpTriggerBy"`  //string	false	止盈價格觸發類型. 若下單時未設置該值,則調用該接口修改止盈價格時,該字段必傳
	SlTriggerBy  *string `json:"slTriggerBy"`  //string	false	止損價格觸發類型. 若下單時未設置該值,則調用該接口修改止損價格時,該字段必傳
	TriggerBy    *string `json:"triggerBy"`    //string	false	觸發價格的觸發類型
	TpLimitPrice *string `json:"tpLimitPrice"` //string	false	*觸發止盈後轉換為限價單的價格. 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 適用於 spot(UTA), linear, inverse
	SlLimitPrice *string `json:"slLimitPrice"` //string	false	*觸發止損後轉換為限價單的價格. 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 適用於 spot(UTA), linear, inverse
}

type OrderAmendRes

type OrderAmendRes OrderCommonRes

type OrderCancelAPI

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

func (*OrderCancelAPI) Category

func (api *OrderCancelAPI) Category(category string) *OrderCancelAPI

category string true 產品類型 統一帳戶: spot, linear, option 經典帳戶: spot, linear, inverse

func (*OrderCancelAPI) Do

func (*OrderCancelAPI) OrderFilter

func (api *OrderCancelAPI) OrderFilter(orderFilter string) *OrderCancelAPI

orderFilter string false 僅spot有效. Order: 普通單,tpslOrder: 止盈止損單,StopOrder: 條件單. 若不傳, 默認是Order

func (*OrderCancelAPI) OrderId

func (api *OrderCancelAPI) OrderId(orderId string) *OrderCancelAPI

orderId string false 訂單Id. orderId和orderLinkId必傳其中一個

func (*OrderCancelAPI) OrderLinkId

func (api *OrderCancelAPI) OrderLinkId(orderLinkId string) *OrderCancelAPI

orderLinkId string false 用戶自定義訂單Id. orderId和orderLinkId必傳其中一個

func (*OrderCancelAPI) Symbol

func (api *OrderCancelAPI) Symbol(symbol string) *OrderCancelAPI

symbol string true 合約名稱

type OrderCancelAllAPI

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

func (*OrderCancelAllAPI) BaseCoin

func (api *OrderCancelAllAPI) BaseCoin(baseCoin string) *OrderCancelAllAPI

baseCoin string false 交易幣種 對於經典帳戶下的linear & inverse: 當通過baseCoin來全部撤單時,會將linear和inverse訂單全部撤掉。若不傳symbol和baseCoin, 則該字段必傳 對於統一帳戶下的linear & inverse: 當通過baseCoin來全部撤單時,會將對應category的訂單全部撤掉。若不傳symbol和baseCoin, 則該字段必傳 對於經典帳戶的現貨: 該字段無效

func (*OrderCancelAllAPI) Category

func (api *OrderCancelAllAPI) Category(category string) *OrderCancelAllAPI

category string true 產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse

func (*OrderCancelAllAPI) Do

func (*OrderCancelAllAPI) OrderFilter

func (api *OrderCancelAllAPI) OrderFilter(orderFilter string) *OrderCancelAllAPI

orderFilter string false 當category=spot, 該字段可以傳Order(普通單), tpslOrder(止盈止損單), StopOrder(條件單), OcoOrder, BidirectionalTpslOrder(現貨雙向止盈止損訂單). 若不傳, 則默認是撤掉Order單 當category=linear 或者 inverse, 該字段可以傳Order(普通單), StopOrder(條件單, 包括止盈止損單和追蹤出場單). 若不傳, 則所有類型的訂單都會被撤掉 當category=option, 該字段可以傳Order, 不管傳與不傳, 都是撤掉所有訂單\

func (*OrderCancelAllAPI) SettleCoin

func (api *OrderCancelAllAPI) SettleCoin(settleCoin string) *OrderCancelAllAPI

settleCoin string false 結算幣種 對於linear & inverse: 該字段必傳, 若不傳symbol和baseCoin 該字段不支持spot

func (*OrderCancelAllAPI) StopOrderType

func (api *OrderCancelAllAPI) StopOrderType(stopOrderType string) *OrderCancelAllAPI

stopOrderType string false 條件單類型, Stop 僅用於當category=linear 或者 inverse以及orderFilter=StopOrder時, 若想僅取消條件單 (不包括止盈止損單和追蹤出場單), 則可以傳入該字段

func (*OrderCancelAllAPI) Symbol

func (api *OrderCancelAllAPI) Symbol(symbol string) *OrderCancelAllAPI

symbol string false 合約名稱. 對於linear & inverse: 若不傳baseCoin和settleCoin, 該字段必傳

type OrderCancelAllReq

type OrderCancelAllReq struct {
	Category      *string `json:"category"`      //string	true	產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse
	Symbol        *string `json:"symbol"`        //string	false	合約名稱. 對於linear & inverse: 若不傳baseCoin和settleCoin, 該字段必傳
	BaseCoin      *string `json:"baseCoin"`      //string	false	交易幣種 對於經典帳戶下的linear & inverse: 當通過baseCoin來全部撤單時,會將linear和inverse訂單全部撤掉。若不傳symbol和baseCoin, 則該字段必傳 對於統一帳戶下的linear & inverse: 當通過baseCoin來全部撤單時,會將對應category的訂單全部撤掉。若不傳symbol和baseCoin, 則該字段必傳 對於經典帳戶的現貨: 該字段無效
	SettleCoin    *string `json:"settleCoin"`    //string	false	結算幣種 對於linear & inverse: 該字段必傳, 若不傳symbol和baseCoin 該字段不支持spot
	OrderFilter   *string `json:"orderFilter"`   //string	false	當category=spot, 該字段可以傳Order(普通單), tpslOrder(止盈止損單), StopOrder(條件單), OcoOrder, BidirectionalTpslOrder(現貨雙向止盈止損訂單). 若不傳, 則默認是撤掉Order單 當category=linear 或者 inverse, 該字段可以傳Order(普通單), StopOrder(條件單, 包括止盈止損單和追蹤出場單). 若不傳, 則所有類型的訂單都會被撤掉 當category=option, 該字段可以傳Order, 不管傳與不傳, 都是撤掉所有訂單
	StopOrderType *string `json:"stopOrderType"` //string	false	條件單類型, Stop 僅用於當category=linear 或者 inverse以及orderFilter=StopOrder時, 若想僅取消條件單 (不包括止盈止損單和追蹤出場單), 則可以傳入該字段
}

type OrderCancelAllRes

type OrderCancelAllRes struct {
	List    []OrderCancelAllResRow `json:"list"`    //array	Object
	Success string                 `json:"success"` //string	"1": 成功, "0": 失敗
}

type OrderCancelAllResRow

type OrderCancelAllResRow struct {
	OrderId     string `json:"orderId"`     //訂單Id
	OrderLinkId string `json:"orderLinkId"` //用戶自定義訂單Id
}

type OrderCancelBatchAPI

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

func (*OrderCancelBatchAPI) AddNewOrderCancelReq

func (api *OrderCancelBatchAPI) AddNewOrderCancelReq(orderCancelApi *OrderCancelAPI) *OrderCancelBatchAPI

func (*OrderCancelBatchAPI) Do

func (*OrderCancelBatchAPI) SetOrderList

func (api *OrderCancelBatchAPI) SetOrderList(orderCancelApiList []*OrderCancelAPI) *OrderCancelBatchAPI

type OrderCancelBatchReq

type OrderCancelBatchReq struct {
	Category *string          `json:"category"` //string	true	產品類型 統一帳戶: spot, linear, option 經典帳戶: spot, linear, inverse
	Request  []OrderCancelReq `json:"request"`  //array	true	批量訂單請求
}

type OrderCancelBatchRes

type OrderCancelBatchRes struct {
	List []OrderCancelBatchResRow `json:"list"`
}

type OrderCancelBatchResRow

type OrderCancelBatchResRow struct {
	Category    string `json:"category"`    //產品類型
	Symbol      string `json:"symbol"`      //合約名稱
	OrderId     string `json:"orderId"`     //訂單Id
	OrderLinkId string `json:"orderLinkId"` //用戶自定義訂單Id
}

type OrderCancelReq

type OrderCancelReq struct {
	Category    *string `json:"category"`    //string	true	產品類型 統一帳戶: spot, linear, option 經典帳戶: spot, linear, inverse
	Symbol      *string `json:"symbol"`      //string	true	合約名稱
	OrderId     *string `json:"orderId"`     //string	false	訂單Id. orderId和orderLinkId必傳其中一個
	OrderLinkId *string `json:"orderLinkId"` //string	false	用戶自定義訂單Id. orderId和orderLinkId必傳其中一個
	OrderFilter *string `json:"orderFilter"` //string	false	僅spot有效. Order: 普通單,tpslOrder: 止盈止損單,StopOrder: 條件單. 若不傳, 默認是Order
}

type OrderCancelRes

type OrderCancelRes OrderCommonRes

type OrderCommonRes

type OrderCommonRes struct {
	OrderId     string `json:"orderId"`     //訂單ID
	OrderLinkId string `json:"orderLinkId"` //用戶自定義訂單ID
}

type OrderCreateAPI

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

func (*OrderCreateAPI) Category

func (api *OrderCreateAPI) Category(category string) *OrderCreateAPI

category string true 產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse

func (*OrderCreateAPI) CloseOnTrigger

func (api *OrderCreateAPI) CloseOnTrigger(closeOnTrigger bool) *OrderCreateAPI

closeOnTrigger boolean false 什麼是觸發後平倉委託?此選項可以確保您的止損單被用於減倉(平倉)而非加倉,並且在可用保證金不足的情況下,取消其他委託,騰出保證金以確保平倉委託的執行. 僅對linear和inverse有效

func (*OrderCreateAPI) Do

func (*OrderCreateAPI) IsLeverage

func (api *OrderCreateAPI) IsLeverage(isLeverage int) *OrderCreateAPI

isLeverage integer false 是否借貸. 僅統一帳戶的現貨交易有效. 0(default): 否,則是幣幣訂單, 1: 是,則是槓桿訂單

func (*OrderCreateAPI) MarketUnit

func (api *OrderCreateAPI) MarketUnit(marketUnit string) *OrderCreateAPI

marketUnit string false 統一帳戶現貨交易創建市價單時給入參qty指定的單位. 当前不支持止盈/止损和条件单 baseCoin: 比如, 買BTCUSDT, 則"qty"的單位是BTC quoteCoin: 比如, 賣BTCUSDT, 則"qty"的單位是USDT

func (*OrderCreateAPI) Mmp

func (api *OrderCreateAPI) Mmp(mmp bool) *OrderCreateAPI

mmp boolean false 做市商保護. 僅option有效. true 表示該訂單是做市商保護訂單. 什麼是做市商保護?

func (*OrderCreateAPI) OrderFilter

func (api *OrderCreateAPI) OrderFilter(orderFilter string) *OrderCreateAPI

orderFilter string false 指定訂單品種. Order: 普通單,tpslOrder: 止盈止損單,StopOrder: 條件單. 若不傳, 默認Order 僅對現貨有效

func (*OrderCreateAPI) OrderIv

func (api *OrderCreateAPI) OrderIv(orderIv string) *OrderCreateAPI

orderIv string false 隱含波動率. 僅option有效. 按照實際值傳入, e.g., 對於10%, 則傳入0.1. orderIv比price有更高的優先級

func (*OrderCreateAPI) OrderLinkId

func (api *OrderCreateAPI) OrderLinkId(orderLinkId string) *OrderCreateAPI

orderLinkId string false 用戶自定義訂單Id. category=option時,該參數必傳

func (*OrderCreateAPI) OrderType

func (api *OrderCreateAPI) OrderType(orderType string) *OrderCreateAPI

orderType string true 訂單類型. Market, Limit

func (*OrderCreateAPI) PositionIdx

func (api *OrderCreateAPI) PositionIdx(positionIdx int) *OrderCreateAPI

positionIdx integer false 倉位標識, 用戶不同倉位模式. 該字段對於雙向持倉模式(僅USDT永續和反向期貨有雙向模式)是必傳: 0: 單向持倉 1: 買側雙向持倉 2: 賣側雙向持倉 僅對linear和inverse有效

func (*OrderCreateAPI) Price

func (api *OrderCreateAPI) Price(price string) *OrderCreateAPI

price string false 訂單價格. 市價單將會忽視該字段 請通過該接口確認最低價格和精度要求 如果有持倉, 確保價格優於強平價格

func (*OrderCreateAPI) Qty

func (api *OrderCreateAPI) Qty(qty string) *OrderCreateAPI

qty string true 訂單數量 統一帳戶 現貨: 可以通過設置marketUnit來表示市價單qty的單位, 市價買單默認是quoteCoin, 市價賣單默認是baseCoin 期貨和期權: 總是以base coin作為qty的單位 經典帳戶 現貨: 市價買單的qty總是以quote coin為單位, 其他情況下, qty都是以base coin為單位 期貨: qty總是以base coin為單位 期貨: 如果傳入qty="0"以及reduceOnly="true", 則可以全部平掉對應合約的倉位

func (*OrderCreateAPI) ReduceOnly

func (api *OrderCreateAPI) ReduceOnly(reduceOnly bool) *OrderCreateAPI

reduceOnly boolean false 什麼是只減倉? true 將這筆訂單設為只減倉 當減倉時, reduceOnly=true必傳 只減倉單的止盈止損不生效 對linear, inverse和option有效

func (*OrderCreateAPI) Side

func (api *OrderCreateAPI) Side(side string) *OrderCreateAPI

side string true Buy, Sell

func (*OrderCreateAPI) SlLimitPrice

func (api *OrderCreateAPI) SlLimitPrice(slLimitPrice string) *OrderCreateAPI

slLimitPrice string false 觸發止損後轉換為限價單的價格 linear & inverse: 僅作用於當tpslMode=Partial以及slOrderType=Limit時 spot(UTA): 參數必傳當創建訂單時帶了stopLoss 和 slOrderType=Limit

func (*OrderCreateAPI) SlOrderType

func (api *OrderCreateAPI) SlOrderType(slOrderType string) *OrderCreateAPI

slOrderType string false 止損觸發後的訂單類型 linear & inverse: Market(默認), Limit. 對於tpslMode=Full, 僅支持slOrderType=Market spot(UTA): Market: 當帶了參數"stopLoss", Limit: 當帶了參數"stopLoss" 和 "slLimitPrice"

func (*OrderCreateAPI) SlTriggerBy

func (api *OrderCreateAPI) SlTriggerBy(slTriggerBy string) *OrderCreateAPI

slTriggerBy string false 觸發止損的價格類型. MarkPrice, IndexPrice, 默認:LastPrice 僅對linear和inverse有效

func (*OrderCreateAPI) SmpType

func (api *OrderCreateAPI) SmpType(smpType string) *OrderCreateAPI

smpType string false Smp執行類型. 什麼是SMP?

func (*OrderCreateAPI) StopLoss

func (api *OrderCreateAPI) StopLoss(stopLoss string) *OrderCreateAPI

stopLoss string false 止損價格 linear & inverse: 支援統一帳戶和經典帳戶 spot: 僅支持統一帳戶, 創建限價單時, 可以附帶市價止盈止損和限價止盈止損

func (*OrderCreateAPI) Symbol

func (api *OrderCreateAPI) Symbol(symbol string) *OrderCreateAPI

symbol string true 合約名稱

func (*OrderCreateAPI) TakeProfit

func (api *OrderCreateAPI) TakeProfit(takeProfit string) *OrderCreateAPI

takeProfit string false 止盈價格 linear & inverse: 支援統一帳戶和經典帳戶 spot: 僅支持統一帳戶, 創建限價單時, 可以附帶市價止盈止損和限價止盈止損

func (*OrderCreateAPI) TimeInForce

func (api *OrderCreateAPI) TimeInForce(timeInForce string) *OrderCreateAPI

timeInForce string false 訂單執行策略 市價單,系統直接使用IOC 若不傳,默認使用GTC

func (*OrderCreateAPI) TpLimitPrice

func (api *OrderCreateAPI) TpLimitPrice(tpLimitPrice string) *OrderCreateAPI

tpLimitPrice string false 觸發止盈後轉換為限價單的價格 linear & inverse: 僅作用於當tpslMode=Partial以及tpOrderType=Limit時 spot(UTA): 參數必傳當創建訂單時帶了takeProfit 和 tpOrderType=Limit

func (*OrderCreateAPI) TpOrderType

func (api *OrderCreateAPI) TpOrderType(tpOrderType string) *OrderCreateAPI

tpOrderType string false 止盈觸發後的訂單類型 linear & inverse: Market(默認), Limit. 對於tpslMode=Full, 僅支持tpOrderType=Market spot(UTA): Market: 當帶了參數"takeProfit", Limit: 當帶了參數"takeProfit" 和 "tpLimitPrice"

func (*OrderCreateAPI) TpTriggerBy

func (api *OrderCreateAPI) TpTriggerBy(tpTriggerBy string) *OrderCreateAPI

tpTriggerBy string false 觸發止盈的價格類型. MarkPrice, IndexPrice, 默認:LastPrice 僅對linear和inverse有效

func (*OrderCreateAPI) TpslMode

func (api *OrderCreateAPI) TpslMode(tpslMode string) *OrderCreateAPI

tpslMode string false 止盈止損模式 Full: 全部倉位止盈止損. 此時, tpOrderType或者slOrderType必須傳Market Partial: 部分倉位止盈止損(下單時沒有size選項, 實際上創建tpsl訂單時, 是按照實際成交的數量來生成止盈止損). 支持創建限價止盈止損. 注意: 創建限價止盈止損時, tpslMode必傳且為Partial 僅對linear和inverse有效

func (*OrderCreateAPI) TriggerBy

func (api *OrderCreateAPI) TriggerBy(triggerBy string) *OrderCreateAPI

triggerBy string false 條件單參數. 觸發價格類型. LastPrice, IndexPrice, MarkPrice 僅對linear和inverse有效

func (*OrderCreateAPI) TriggerDirection

func (api *OrderCreateAPI) TriggerDirection(triggerDirection int) *OrderCreateAPI

triggerDirection integer false 條件單參數. 用於辨別期望的方向. 1: 當市場價上漲到了triggerPrice時觸發條件單 2: 當市場價下跌到了triggerPrice時觸發條件單 對linear和inverse有效

func (*OrderCreateAPI) TriggerPrice

func (api *OrderCreateAPI) TriggerPrice(triggerPrice string) *OrderCreateAPI

triggerPrice string false 對於期貨, 是條件單觸發價格參數. 若您希望市場價是要上升後觸發, 確保: triggerPrice > 市場價格 否則, triggerPrice < 市場價格 對於現貨, 這是下止盈止損單或者條件單的觸發價格參數

type OrderCreateBatchAPI

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

下單時需確保帳戶內有足夠的資金。一旦下單,根據訂單所需資金,您的帳戶資金將在訂單生命週期內凍結相應額度,被凍結的資金額度取決於訂單屬性。 每個請求包含的訂單數最大是: 20筆(期权), 10筆(期貨), 10筆(現貨),返回的數據列表中分成兩個list,訂單創建的列表和創建結果的信息返回,兩個list的訂單的序列是完全保持一致的。

func (*OrderCreateBatchAPI) AddNewOrderCreateReq

func (api *OrderCreateBatchAPI) AddNewOrderCreateReq(orderCreateApi *OrderCreateAPI) *OrderCreateBatchAPI

func (*OrderCreateBatchAPI) Do

func (*OrderCreateBatchAPI) SetOrderList

func (api *OrderCreateBatchAPI) SetOrderList(orderCreateApiList []*OrderCreateAPI) *OrderCreateBatchAPI

type OrderCreateBatchReq

type OrderCreateBatchReq struct {
	Category *string          `json:"category"` //string	true	產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse
	Request  []OrderCreateReq `json:"request"`  //array	true	批量訂單請求
}

type OrderCreateBatchRes

type OrderCreateBatchRes struct {
	List []OrderCreateBatchResRow `json:"list"`
}

type OrderCreateBatchResRow

type OrderCreateBatchResRow struct {
	Category    string `json:"category"`    //產品類型
	Symbol      string `json:"symbol"`      //合約名稱
	OrderId     string `json:"orderId"`     //訂單Id
	OrderLinkId string `json:"orderLinkId"` //用戶自定義訂單Id
	CreateAt    string `json:"createAt"`    //訂單創建時間 (毫秒
}

type OrderCreateReq

type OrderCreateReq struct {
	Category         *string `json:"category"`                   //string	true	產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse
	Symbol           *string `json:"symbol"`                     //string	true	合約名稱
	IsLeverage       *int    `json:"isLeverage,omitempty"`       //integer	false	是否借貸. 僅統一帳戶的現貨交易有效. 0(default): 否,則是幣幣訂單, 1: 是,則是槓桿訂單
	Side             *string `json:"side"`                       //string	true	Buy, Sell
	OrderType        *string `json:"orderType"`                  //string	true	訂單類型. Market, Limit
	Qty              *string `json:"qty"`                        //string	true	訂單數量 統一帳戶 現貨: 可以通過設置marketUnit來表示市價單qty的單位, 市價買單默認是quoteCoin, 市價賣單默認是baseCoin 期貨和期權: 總是以base coin作為qty的單位 經典帳戶 現貨: 市價買單的qty總是以quote coin為單位, 其他情況下, qty都是以base coin為單位 期貨: qty總是以base coin為單位 期貨: 如果傳入qty="0"以及reduceOnly="true", 則可以全部平掉對應合約的倉位
	MarketUnit       *string `json:"marketUnit,omitempty"`       //string	false	統一帳戶現貨交易創建市價單時給入參qty指定的單位. 当前不支持止盈/止损和条件单 baseCoin: 比如, 買BTCUSDT, 則"qty"的單位是BTC quoteCoin: 比如, 賣BTCUSDT, 則"qty"的單位是USDT
	Price            *string `json:"price,omitempty"`            //string	false	訂單價格. 市價單將會忽視該字段 請通過該接口確認最低價格和精度要求 如果有持倉, 確保價格優於強平價格
	TriggerDirection *int    `json:"triggerDirection,omitempty"` //integer	false	條件單參數. 用於辨別期望的方向. 1: 當市場價上漲到了triggerPrice時觸發條件單 2: 當市場價下跌到了triggerPrice時觸發條件單 對linear和inverse有效
	OrderFilter      *string `json:"orderFilter,omitempty"`      //string	false	指定訂單品種. Order: 普通單,tpslOrder: 止盈止損單,StopOrder: 條件單. 若不傳, 默認Order 僅對現貨有效
	TriggerPrice     *string `json:"triggerPrice,omitempty"`     //string	false	對於期貨, 是條件單觸發價格參數. 若您希望市場價是要上升後觸發, 確保: triggerPrice > 市場價格 否則, triggerPrice < 市場價格 對於現貨, 這是下止盈止損單或者條件單的觸發價格參數
	TriggerBy        *string `json:"triggerBy,omitempty"`        //string	false	條件單參數. 觸發價格類型. LastPrice, IndexPrice, MarkPrice 僅對linear和inverse有效
	OrderIv          *string `json:"orderIv,omitempty"`          //string	false	隱含波動率. 僅option有效. 按照實際值傳入, e.g., 對於10%, 則傳入0.1. orderIv比price有更高的優先級
	TimeInForce      *string `json:"timeInForce,omitempty"`      //string	false	訂單執行策略 市價單,系統直接使用IOC 若不傳,默認使用GTC
	PositionIdx      *int    `json:"positionIdx,omitempty"`      //integer	false	倉位標識, 用戶不同倉位模式. 該字段對於雙向持倉模式(僅USDT永續和反向期貨有雙向模式)是必傳: 0: 單向持倉 1: 買側雙向持倉 2: 賣側雙向持倉 僅對linear和inverse有效
	OrderLinkId      *string `json:"orderLinkId,omitempty"`      //string	false	用戶自定義訂單Id. category=option時,該參數必傳
	TakeProfit       *string `json:"takeProfit,omitempty"`       //string	false	止盈價格 linear & inverse: 支援統一帳戶和經典帳戶 spot: 僅支持統一帳戶, 創建限價單時, 可以附帶市價止盈止損和限價止盈止損
	StopLoss         *string `json:"stopLoss,omitempty"`         //string	false	止損價格 linear & inverse: 支援統一帳戶和經典帳戶 spot: 僅支持統一帳戶, 創建限價單時, 可以附帶市價止盈止損和限價止盈止損
	TpTriggerBy      *string `json:"tpTriggerBy,omitempty"`      //string	false	觸發止盈的價格類型. MarkPrice, IndexPrice, 默認:LastPrice 僅對linear和inverse有效
	SlTriggerBy      *string `json:"slTriggerBy,omitempty"`      //string	false	觸發止損的價格類型. MarkPrice, IndexPrice, 默認:LastPrice 僅對linear和inverse有效
	ReduceOnly       *bool   `json:"reduceOnly,omitempty"`       //boolean	false	什麼是只減倉? true 將這筆訂單設為只減倉 當減倉時, reduceOnly=true必傳 只減倉單的止盈止損不生效 對linear, inverse和option有效
	CloseOnTrigger   *bool   `json:"closeOnTrigger,omitempty"`   //boolean	false	什麼是觸發後平倉委託?此選項可以確保您的止損單被用於減倉(平倉)而非加倉,並且在可用保證金不足的情況下,取消其他委託,騰出保證金以確保平倉委託的執行. 僅對linear和inverse有效
	SmpType          *string `json:"smpType,omitempty"`          //string	false	Smp執行類型. 什麼是SMP?
	Mmp              *bool   `json:"mmp,omitempty"`              //boolean	false	做市商保護. 僅option有效. true 表示該訂單是做市商保護訂單. 什麼是做市商保護?
	TpslMode         *string `json:"tpslMode,omitempty"`         //string	false	止盈止損模式 Full: 全部倉位止盈止損. 此時, tpOrderType或者slOrderType必須傳Market Partial: 部分倉位止盈止損(下單時沒有size選項, 實際上創建tpsl訂單時, 是按照實際成交的數量來生成止盈止損). 支持創建限價止盈止損. 注意: 創建限價止盈止損時, tpslMode必傳且為Partial 僅對linear和inverse有效
	TpLimitPrice     *string `json:"tpLimitPrice,omitempty"`     //string	false	觸發止盈後轉換為限價單的價格 linear & inverse: 僅作用於當tpslMode=Partial以及tpOrderType=Limit時 spot(UTA): 參數必傳當創建訂單時帶了takeProfit 和 tpOrderType=Limit
	SlLimitPrice     *string `json:"slLimitPrice,omitempty"`     //string	false	觸發止損後轉換為限價單的價格 linear & inverse: 僅作用於當tpslMode=Partial以及slOrderType=Limit時 spot(UTA): 參數必傳當創建訂單時帶了stopLoss 和 slOrderType=Limit
	TpOrderType      *string `json:"tpOrderType,omitempty"`      //string	false	止盈觸發後的訂單類型 linear & inverse: Market(默認), Limit. 對於tpslMode=Full, 僅支持tpOrderType=Market spot(UTA): Market: 當帶了參數"takeProfit", Limit: 當帶了參數"takeProfit" 和 "tpLimitPrice"
	SlOrderType      *string `json:"slOrderType,omitempty"`      //string	false	止損觸發後的訂單類型 linear & inverse: Market(默認), Limit. 對於tpslMode=Full, 僅支持slOrderType=Market spot(UTA): Market: 當帶了參數"stopLoss", Limit: 當帶了參數"stopLoss" 和 "slLimitPrice"
}

type OrderCreateRes

type OrderCreateRes OrderCommonRes

type OrderExecutionListAPI

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

func (*OrderExecutionListAPI) BaseCoin

func (api *OrderExecutionListAPI) BaseCoin(baseCoin string) *OrderExecutionListAPI

baseCoin string false 交易幣種. 統一帳戶(反向)和經典帳戶不支持該字段查詢

func (*OrderExecutionListAPI) Category

func (api *OrderExecutionListAPI) Category(category string) *OrderExecutionListAPI

category string true 產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse

func (*OrderExecutionListAPI) Cursor

func (api *OrderExecutionListAPI) Cursor(cursor string) *OrderExecutionListAPI

cursor string false 游標,用於翻頁

func (*OrderExecutionListAPI) Do

func (*OrderExecutionListAPI) EndTime

func (api *OrderExecutionListAPI) EndTime(endTime int64) *OrderExecutionListAPI

endTime int false 結束時間戳 (毫秒)

func (*OrderExecutionListAPI) ExecType

func (api *OrderExecutionListAPI) ExecType(execType string) *OrderExecutionListAPI

execType string false 執行類型. 經典帳戶現貨交易無效

func (*OrderExecutionListAPI) Limit

func (api *OrderExecutionListAPI) Limit(limit int) *OrderExecutionListAPI

limit int false 每頁數量限制. [1, 100]. 默認: 50

func (*OrderExecutionListAPI) OrderId

func (api *OrderExecutionListAPI) OrderId(orderId string) *OrderExecutionListAPI

orderId string false 訂單Id

func (*OrderExecutionListAPI) OrderLinkId

func (api *OrderExecutionListAPI) OrderLinkId(orderLinkId string) *OrderExecutionListAPI

orderLinkId string false 用戶自定義訂單id. 經典帳戶不支持該字段查詢

func (*OrderExecutionListAPI) StartTime

func (api *OrderExecutionListAPI) StartTime(startTime int64) *OrderExecutionListAPI

startTime int false 開始時間戳 (毫秒)

func (*OrderExecutionListAPI) Symbol

func (api *OrderExecutionListAPI) Symbol(symbol string) *OrderExecutionListAPI

symbol string false 合約名稱

type OrderExecutionListReq

type OrderExecutionListReq struct {
	Category    *string `json:"category"`    //string	true	產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse
	Symbol      *string `json:"symbol"`      //string	false	合約名稱
	OrderId     *string `json:"orderId"`     //string	false	訂單Id
	OrderLinkId *string `json:"orderLinkId"` //string	false	用戶自定義訂單id. 經典帳戶不支持該字段查詢
	BaseCoin    *string `json:"baseCoin"`    //string	false	交易幣種. 統一帳戶(反向)和經典帳戶不支持該字段查詢
	StartTime   *int64  `json:"startTime"`   //integer	false	開始時間戳 (毫秒)
	EndTime     *int64  `json:"endTime"`     //integer	false	結束時間戳 (毫秒)
	ExecType    *string `json:"execType"`    //string	false	執行類型. 經典帳戶現貨交易無效
	Limit       *int    `json:"limit"`       //integer	false	每頁數量限制. [1, 100]. 默認: 50
	Cursor      *string `json:"cursor"`      //string	false	游標,用於翻頁
}

type OrderExecutionListRes

type OrderExecutionListRes struct {
	Category       string                     `json:"category"`       //產品類型
	NextPageCursor string                     `json:"nextPageCursor"` //游標,用於翻頁
	List           []OrderExecutionListResRow `json:"list"`           //array	Object
}

type OrderExecutionListResRow

type OrderExecutionListResRow struct {
	Symbol          string `json:"symbol"`          //合約名稱
	OrderId         string `json:"orderId"`         //訂單Id
	OrderLinkId     string `json:"orderLinkId"`     //用戶自定義訂單id. 經典帳戶現貨交易不支持
	Side            string `json:"side"`            //訂單方向.買: Buy,賣:Sell
	OrderPrice      string `json:"orderPrice"`      //訂單價格
	OrderQty        string `json:"orderQty"`        //訂單數量
	LeavesQty       string `json:"leavesQty"`       //剩餘委託未成交數量. 經典帳戶現貨交易不支持
	CreateType      string `json:"createType"`      //訂單創建類型
	OrderType       string `json:"orderType"`       //訂單類型. 市價單:Market,限價單:Limit
	StopOrderType   string `json:"stopOrderType"`   //条件单的订单类型。如果该订单不是条件单,则可能返回""或者UNKNOWN. 經典帳戶現貨交易不支持
	ExecFee         string `json:"execFee"`         //交易手續費. 您可以從這裡了解現貨手續費幣種信息
	ExecId          string `json:"execId"`          //成交Id
	ExecPrice       string `json:"execPrice"`       //成交價格
	ExecQty         string `json:"execQty"`         //成交數量
	ExecType        string `json:"execType"`        //交易類型. 經典帳戶現貨交易不支持
	ExecValue       string `json:"execValue"`       //成交價值. 經典帳戶現貨交易不支持
	ExecTime        string `json:"execTime"`        //成交時間(毫秒)
	FeeCurrency     string `json:"feeCurrency"`     //現貨手續費幣種 經典帳戶現貨交易不支持
	IsMaker         bool   `json:"isMaker"`         //是否是 Maker 訂單,true 為 maker 訂單,false 為 taker 訂單
	FeeRate         string `json:"feeRate"`         //手續費率. 經典帳戶現貨交易不支持
	TradeIv         string `json:"tradeIv"`         //隱含波動率,僅期權有效
	MarkIv          string `json:"markIv"`          //標記價格的隱含波動率,僅期權有效
	MarkPrice       string `json:"markPrice"`       //成交執行時,該 symbol 當時的標記價格. 經典帳戶現貨交易不支持
	IndexPrice      string `json:"indexPrice"`      //成交執行時,該 symbol 當時的指數價格,目前僅對期權業務有效
	UnderlyingPrice string `json:"underlyingPrice"` //成交執行時,該 symbol 當時的底層資產價格,僅期權有效
	BlockTradeId    string `json:"blockTradeId"`    //大宗交易的订单 ID ,使用 paradigm 进行大宗交易时生成的 ID
	ClosedSize      string `json:"closedSize"`      //平倉數量
	Seq             int    `json:"seq"`             //序列號, 用於關聯成交和倉位的更新
}

type OrderHistoryAPI

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

func (*OrderHistoryAPI) BaseCoin

func (api *OrderHistoryAPI) BaseCoin(baseCoin string) *OrderHistoryAPI

baseCoin string false 交易幣種. 統一帳戶(反向)以及經典帳戶不支持該字段的查詢

func (*OrderHistoryAPI) Category

func (api *OrderHistoryAPI) Category(category string) *OrderHistoryAPI

category string true 產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse

func (*OrderHistoryAPI) Cursor

func (api *OrderHistoryAPI) Cursor(cursor string) *OrderHistoryAPI

cursor string false 游標,用於翻頁

func (*OrderHistoryAPI) Do

func (*OrderHistoryAPI) EndTime

func (api *OrderHistoryAPI) EndTime(endTime int64) *OrderHistoryAPI

endTime int false 結束時間戳 (毫秒)

func (*OrderHistoryAPI) Limit

func (api *OrderHistoryAPI) Limit(limit int) *OrderHistoryAPI

limit int false 每頁數量限制. [1, 50]. 默認: 20

func (*OrderHistoryAPI) OrderFilter

func (api *OrderHistoryAPI) OrderFilter(orderFilter string) *OrderHistoryAPI

orderFilter string false Order: 普通單, StopOrder: 條件單, 支持現貨和期貨, tpslOrder: 現貨止盈止損單, OcoOrder: OCO訂單, BidirectionalTpslOrder: 現貨(UTA)雙向止盈止損訂單

func (*OrderHistoryAPI) OrderId

func (api *OrderHistoryAPI) OrderId(orderId string) *OrderHistoryAPI

orderId string false 訂單ID

func (*OrderHistoryAPI) OrderLinkId

func (api *OrderHistoryAPI) OrderLinkId(orderLinkId string) *OrderHistoryAPI

orderLinkId string false 用戶自定義訂單ID

func (*OrderHistoryAPI) OrderStatus

func (api *OrderHistoryAPI) OrderStatus(orderStatus string) *OrderHistoryAPI

orderStatus string false 訂單狀態 經典帳戶spot: 該字段無效 UTA(spot, linear, option): 不傳則默認查詢所有終態訂單 UTA(inverse)和經典帳戶: 不傳則默認查詢活動態+終態的訂單

func (*OrderHistoryAPI) SettleCoin

func (api *OrderHistoryAPI) SettleCoin(settleCoin string) *OrderHistoryAPI

settleCoin string false 結算幣種. 統一帳戶(反向)以及經典帳戶不支持該字段的查詢

func (*OrderHistoryAPI) StartTime

func (api *OrderHistoryAPI) StartTime(startTime int64) *OrderHistoryAPI

startTime int false 開始時間戳 (毫秒). 經典帳戶現貨不支持使用startTime和endTime startTime 和 endTime都不傳入, 則默認返回最近7天的數據 startTime 和 endTime都傳入的話, 則確保endTime - startTime <= 7天 若只傳startTime,則查詢startTime和startTime+7天的數據 若只傳endTime,則查詢endTime-7天和endTime的數據

func (*OrderHistoryAPI) Symbol

func (api *OrderHistoryAPI) Symbol(symbol string) *OrderHistoryAPI

symbol string false 合約名稱

type OrderHistoryReq

type OrderHistoryReq struct {
	Category    *string `json:"category"`    //string	true	產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse
	Symbol      *string `json:"symbol"`      //string	false	合約名稱
	BaseCoin    *string `json:"baseCoin"`    //string	false	交易幣種. 統一帳戶(反向)以及經典帳戶不支持該字段的查詢
	SettleCoin  *string `json:"settleCoin"`  //string	false	結算幣種. 統一帳戶(反向)以及經典帳戶不支持該字段的查詢
	OrderId     *string `json:"orderId"`     //string	false	訂單ID
	OrderLinkId *string `json:"orderLinkId"` //string	false	用戶自定義訂單ID
	OrderFilter *string `json:"orderFilter"` //string	false	Order: 普通單, StopOrder: 條件單, 支持現貨和期貨, tpslOrder: 現貨止盈止損單, OcoOrder: OCO訂單, BidirectionalTpslOrder: 現貨(UTA)雙向止盈止損訂單
	OrderStatus *string `json:"orderStatus"` //string	false	訂單狀態 經典帳戶spot: 該字段無效 UTA(spot, linear, option): 不傳則默認查詢所有終態訂單 UTA(inverse)和經典帳戶: 不傳則默認查詢活動態+終態的訂單
	StartTime   *int64  `json:"startTime"`   //integer	false	開始時間戳 (毫秒). 經典帳戶現貨不支持使用startTime和endTime startTime 和 endTime都不傳入, 則默認返回最近7天的數據 startTime 和 endTime都傳入的話, 則確保endTime - startTime <= 7天 若只傳startTime,則查詢startTime和startTime+7天的數據 若只傳endTime,則查詢endTime-7天和endTime的數據
	EndTime     *int64  `json:"endTime"`     //integer	false	結束時間戳 (毫秒)
	Limit       *int    `json:"limit"`       //integer	false	每頁數量限制. [1, 50]. 默認: 20
	Cursor      *string `json:"cursor"`      //string	false	游標,用於翻頁
}

type OrderHistoryRes

type OrderHistoryRes struct {
	Category       string             `json:"category"`       //產品類型
	NextPageCursor string             `json:"nextPageCursor"` //游標,用於翻頁
	List           []OrderQueryCommon `json:"list"`           //array	Object
}

type OrderQueryCommon

type OrderQueryCommon struct {
	OrderId            string `json:"orderId"`            //訂單Id
	OrderLinkId        string `json:"orderLinkId"`        //用戶自定義Id
	BlockTradeId       string `json:"blockTradeId"`       //Paradigm大宗交易Id
	Symbol             string `json:"symbol"`             //合約名稱
	Price              string `json:"price"`              //訂單價格
	Qty                string `json:"qty"`                //訂單數量
	Side               string `json:"side"`               //方向. Buy,Sell
	IsLeverage         string `json:"isLeverage"`         //是否借貸. 僅統一帳戶spot有效. 0: 否, 1: 是. 經典帳戶現貨交易不支持, 總是0
	PositionIdx        int    `json:"positionIdx"`        //倉位標識。用戶不同倉位模式
	OrderStatus        string `json:"orderStatus"`        //訂單狀態
	CreateType         string `json:"createType"`         //訂單創建類型
	CancelType         string `json:"cancelType"`         //訂單被取消類型
	RejectReason       string `json:"rejectReason"`       //拒絕原因. 經典帳戶現貨交易不支持
	AvgPrice           string `json:"avgPrice"`           //訂單平均成交價格
	LeavesQty          string `json:"leavesQty"`          //訂單剩餘未成交的數量. 經典帳戶現貨交易不支持
	LeavesValue        string `json:"leavesValue"`        //訂單剩餘未成交的價值. 經典帳戶現貨交易不支持
	CumExecQty         string `json:"cumExecQty"`         //訂單累計成交數量
	CumExecValue       string `json:"cumExecValue"`       //訂單累計成交價值. 經典帳戶現貨交易不支持
	CumExecFee         string `json:"cumExecFee"`         //訂單累計成交的手續費. 經典帳戶現貨交易不支持
	TimeInForce        string `json:"timeInForce"`        //執行策略
	OrderType          string `json:"orderType"`          //訂單類型. Market,Limit. 對於止盈止損單, 則表示為觸發後的訂單類型
	StopOrderType      string `json:"stopOrderType"`      //條件單類型
	OrderIv            string `json:"orderIv"`            //隱含波動率
	MarketUnit         string `json:"marketUnit"`         //統一帳戶現貨交易時給入參qty選擇的單位. baseCoin, quoteCoin
	TriggerPrice       string `json:"triggerPrice"`       //觸發價格. 若stopOrderType=TrailingStop, 則這是激活價格. 否則, 它是觸發價格
	TakeProfit         string `json:"takeProfit"`         //止盈價格
	StopLoss           string `json:"stopLoss"`           //止損價格
	TpslMode           string `json:"tpslMode"`           //止盈止損模式 Full: 全部倉位止盈止損, Partial: 部分倉位止盈止損. 現貨不返回該字段, 期權總是返回""
	OcoTriggerBy       string `json:"ocoTriggerBy"`       //現貨OCO訂單的觸發類型.OcoTriggerByUnknown, OcoTriggerByTp, OcoTriggerBySl. 經典帳戶現貨不支持該字段
	TpLimitPrice       string `json:"tpLimitPrice"`       //觸發止盈後轉換為限價單的價格
	SlLimitPrice       string `json:"slLimitPrice"`       //觸發止損後轉換為限價單的價格
	TpTriggerBy        string `json:"tpTriggerBy"`        //觸發止盈的價格類型
	SlTriggerBy        string `json:"slTriggerBy"`        //觸發止損的價格類型
	TriggerDirection   int    `json:"triggerDirection"`   //觸發方向. 1: 上漲, 2: 下跌
	TriggerBy          string `json:"triggerBy"`          //觸發價格的觸發類型
	LastPriceOnCreated string `json:"lastPriceOnCreated"` //下單時的市場價格
	ReduceOnly         bool   `json:"reduceOnly"`         //只減倉. true表明這是只減倉單
	CloseOnTrigger     bool   `json:"closeOnTrigger"`     //觸發後平倉委託. 什麼是觸發後平倉委託?
	PlaceType          string `json:"placeType"`          //下單類型, 僅期權使用. iv, price
	SmpType            string `json:"smpType"`            //SMP執行類型
	SmpGroup           int    `json:"smpGroup"`           //所屬Smp組ID. 如果uid不屬於任何組, 則默認為0
	SmpOrderId         string `json:"smpOrderId"`         //觸發此SMP執行的交易對手的 orderID
	CreatedTime        string `json:"createdTime"`        //創建訂單的時間戳 (毫秒)
	UpdatedTime        string `json:"updatedTime"`        //訂單更新的時間戳 (毫秒)
}

type OrderRealtimeAPI

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

func (*OrderRealtimeAPI) BaseCoin

func (api *OrderRealtimeAPI) BaseCoin(baseCoin string) *OrderRealtimeAPI

baseCoin string false 交易幣種. 支持linear, inverse和option. 對於若不傳,則返回期權下所有活動委託單

func (*OrderRealtimeAPI) Category

func (api *OrderRealtimeAPI) Category(category string) *OrderRealtimeAPI

category string true 產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse

func (*OrderRealtimeAPI) Cursor

func (api *OrderRealtimeAPI) Cursor(cursor string) *OrderRealtimeAPI

cursor string false 游標,用於翻頁

func (*OrderRealtimeAPI) Do

func (*OrderRealtimeAPI) Limit

func (api *OrderRealtimeAPI) Limit(limit int) *OrderRealtimeAPI

limit int false 每頁數量限制. [1, 50]. 默認: 20

func (*OrderRealtimeAPI) OpenOnly

func (api *OrderRealtimeAPI) OpenOnly(openOnly int) *OrderRealtimeAPI

openOnly int false 統一帳戶 & 經典帳戶0(默認): 僅查詢活動委託訂單 統一帳戶: 1, 統一帳戶(反向)和經典帳戶: 2

func (*OrderRealtimeAPI) OrderFilter

func (api *OrderRealtimeAPI) OrderFilter(orderFilter string) *OrderRealtimeAPI

orderFilter string false Order: 活動單, StopOrder: 條件單, 支持現貨和期貨, tpslOrder: 止盈止損單, 僅現貨有效, OcoOrder: OCO訂單, BidirectionalTpslOrder: 現貨(UTA)雙向止盈止損訂單

func (*OrderRealtimeAPI) OrderId

func (api *OrderRealtimeAPI) OrderId(orderId string) *OrderRealtimeAPI

orderId string false 訂單Id

func (*OrderRealtimeAPI) OrderLinkId

func (api *OrderRealtimeAPI) OrderLinkId(orderLinkId string) *OrderRealtimeAPI

orderLinkId string false 用戶自定義訂單Id

func (*OrderRealtimeAPI) SettleCoin

func (api *OrderRealtimeAPI) SettleCoin(settleCoin string) *OrderRealtimeAPI

settleCoin string false 結算幣種 linear: symbol 和 settleCoin必傳其中一個 spot: 該字段無效

func (*OrderRealtimeAPI) Symbol

func (api *OrderRealtimeAPI) Symbol(symbol string) *OrderRealtimeAPI

symbol string false 合約名稱. 對於linear, symbol, baseCoin 和 settleCoin必傳其中一個

type OrderRealtimeReq

type OrderRealtimeReq struct {
	Category    *string `json:"category"`    //string	true	產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse
	Symbol      *string `json:"symbol"`      //string	false	合約名稱. 對於linear, symbol, baseCoin 和 settleCoin必傳其中一個
	BaseCoin    *string `json:"baseCoin"`    //string	false	交易幣種. 支持linear, inverse和option. 對於若不傳,則返回期權下所有活動委託單
	SettleCoin  *string `json:"settleCoin"`  //string	false	結算幣種 linear: symbol 和 settleCoin必傳其中一個 spot: 該字段無效
	OrderId     *string `json:"orderId"`     //string	false	訂單Id
	OrderLinkId *string `json:"orderLinkId"` //string	false	用戶自定義訂單Id
	OpenOnly    *int    `json:"openOnly"`    //integer	false	統一帳戶 & 經典帳戶0(默認): 僅查詢活動委託訂單 統一帳戶: 1, 統一帳戶(反向)和經典帳戶: 2
	OrderFilter *string `json:"orderFilter"` //string	false	Order: 活動單, StopOrder: 條件單, 支持現貨和期貨, tpslOrder: 止盈止損單, 僅現貨有效, OcoOrder: OCO訂單, BidirectionalTpslOrder: 現貨(UTA)雙向止盈止損訂單
	Limit       *int    `json:"limit"`       //integer	false	每頁數量限制. [1, 50]. 默認: 20
	Cursor      *string `json:"cursor"`      //string	false	游標,用於翻頁
}

type OrderRealtimeRes

type OrderRealtimeRes struct {
	Category       string             `json:"category"`       //產品類型
	NextPageCursor string             `json:"nextPageCursor"` //游標,用於翻頁
	List           []OrderQueryCommon `json:"list"`           //array	Object
}

type OrderReqType added in v0.0.3

type OrderReqType interface {
	OrderCreateReq | OrderCancelReq | OrderAmendReq
}

type OrderResType added in v0.0.3

type OrderResType interface {
	OrderCreateRes | OrderCancelRes | OrderAmendRes
}

type PositionListAPI

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

func (*PositionListAPI) BaseCoin

func (api *PositionListAPI) BaseCoin(baseCoin string) *PositionListAPI

baseCoin string false 交易幣種. 僅option. 若不傳,則返回期權下所有持倉

func (*PositionListAPI) Category

func (api *PositionListAPI) Category(category string) *PositionListAPI

category string true 統一帳戶: linear,inverse, option 經典帳戶: linear, inverse

func (*PositionListAPI) Cursor

func (api *PositionListAPI) Cursor(cursor string) *PositionListAPI

cursor string false 游標,用於翻頁

func (*PositionListAPI) Do

func (*PositionListAPI) Limit

func (api *PositionListAPI) Limit(limit int) *PositionListAPI

limit integer false 每頁數量限制. [1, 200]. 默認: 20

func (*PositionListAPI) SettleCoin

func (api *PositionListAPI) SettleCoin(settleCoin string) *PositionListAPI

settleCoin string false 結算幣種. 對於USDT和USDC期貨而言,symbol和settleCon必傳其中一個, 若都傳,則symbol有更高的優先級

func (*PositionListAPI) Symbol

func (api *PositionListAPI) Symbol(symbol string) *PositionListAPI

symbol string false 合約名稱 若傳了symbol, 則不管是否有倉位都返回該symbol數據 若symbol不傳但傳了settleCoin, 則僅返回有實際倉位的數據

type PositionListReq

type PositionListReq struct {
	Category   *string `json:"category"`   //string	true	統一帳戶: linear,inverse, option 經典帳戶: linear, inverse
	Symbol     *string `json:"symbol"`     //string	false	合約名稱 若傳了symbol, 則不管是否有倉位都返回該symbol數據 若symbol不傳但傳了settleCoin, 則僅返回有實際倉位的數據
	BaseCoin   *string `json:"baseCoin"`   //string	false	交易幣種. 僅option. 若不傳,則返回期權下所有持倉
	SettleCoin *string `json:"settleCoin"` //string	false	結算幣種. 對於USDT和USDC期貨而言,symbol和settleCon必傳其中一個, 若都傳,則symbol有更高的優先級
	Limit      *int    `json:"limit"`      //integer	false	每頁數量限制. [1, 200]. 默認: 20
	Cursor     *string `json:"cursor"`     //string	false	游標,用於翻頁
}

type PositionListRes

type PositionListRes struct {
	Category       string               `json:"category"` //產品類型
	List           []PositionListResRow `json:"list"`
	NextPageCursor string               `json:"nextPageCursor"` //游標,用於翻頁
}

type PositionListResRow

type PositionListResRow struct {
	PositionIdx            int    `json:"positionIdx"`            //倉位標識符, 用于在不同仓位模式下标识仓位
	RiskId                 int    `json:"riskId"`                 //风险限额ID,參見風險限額接口. 注意:若賬戶為組合保證金模式(PM),該字段返回0,風險限額規則失效
	RiskLimitValue         string `json:"riskLimitValue"`         //當前風險限額ID對應的持倉限制量. 注意:若賬戶為組合保證金模式(PM),該字段返回"",風險限額規則失效
	Symbol                 string `json:"symbol"`                 //合約名称
	Side                   string `json:"side"`                   //持倉方向,Buy:多头;Sell:空头. 經典帳戶的單向模式下和統一帳戶的反向合約: 空倉時返回None. 統一帳戶(正向合約): 單向或對沖模式空的仓位返回空字符串
	Size                   string `json:"size"`                   //當前倉位的合约數量
	AvgPrice               string `json:"avgPrice"`               //當前倉位的平均入場價格 對於8小時結算的USDC合約倉位, 該字段表示的是平均開倉價格, 不隨著結算而改變
	PositionValue          string `json:"positionValue"`          //仓位的價值
	TradeMode              int    `json:"tradeMode"`              //交易模式。 統一帳戶 (反向合約) & 經典帳戶: 0: 全倉, 1: 逐倉 統一帳戶: 廢棄, 總是 0
	AutoAddMargin          int    `json:"autoAddMargin"`          //是否自動追加保證金. 0: 否, 1: 是. 僅當統一帳戶(除反向合約)開啟了帳戶維度的逐倉保證金模式, 該字段才有意義
	PositionStatus         string `json:"positionStatus"`         //倉位状态. Normal,Liq, Adl
	Leverage               string `json:"leverage"`               //當前倉位的槓桿,仅适用于合约. 注意:若賬戶為組合保證金模式(PM),該字段返回空字符串,槓桿規則失效
	MarkPrice              string `json:"markPrice"`              //symbol 的最新標記價格
	LiqPrice               string `json:"liqPrice"`               //倉位強平價格, UTA(反向合約) & 普通账户 & UTA(開啟逐倉保證金模式):是逐倉和全倉持仓的真實價格, 當強平價 <= minPrice或者 強平價 >= maxPrice, 則為""。 統一帳戶(全倉保證金):是全倉持仓的预估价格(因为统一帳戶模式是按照帳戶維度控制风险率), 當強平價 <= minPrice或者 強平價 >= maxPrice, 則為"" 但是對於組合保證金模式,此字段為空,不會提供強平價格
	BustPrice              string `json:"bustPrice"`              //倉位破產價格. 統一保證金模式返回"", 無倉位破產價格 (不包括統一帳戶下的反向交易)
	PositionIM             string `json:"positionIM"`             //倉位起始保證金. 組合保證金模式(PM)下, 該字段返回為空字符串
	PositionMM             string `json:"positionMM"`             //倉位維持保證金. 組合保證金模式(PM)下, 該字段返回為空字符串
	TpslMode               string `json:"tpslMode"`               //該字段廢棄, 無意義, 總是返回"Full". 期權總是返回""
	PositionBalance        string `json:"positionBalance"`        //倉位保證金 統一帳戶(linear): 僅在逐倉保證金模式下有意義
	TakeProfit             string `json:"takeProfit"`             //止盈價格
	StopLoss               string `json:"stopLoss"`               //止損價格
	TrailingStop           string `json:"trailingStop"`           //追蹤止損(與當前價格的距離)
	SessionAvgPrice        string `json:"sessionAvgPrice"`        //USDC合約平均持倉價格, 會隨著8小時結算而變動
	Delta                  string `json:"delta"`                  //Delta, 期權的獨有字段
	Gamma                  string `json:"gamma"`                  //Gamma, 期權的獨有字段
	Vega                   string `json:"vega"`                   //Vega, 期權的獨有字段
	Theta                  string `json:"theta"`                  //Theta, 期權的獨有字段
	UnrealisedPnl          string `json:"unrealisedPnl"`          //未结盈亏
	CurRealisedPnl         string `json:"curRealisedPnl"`         //當前持倉的已結盈虧
	CumRealisedPnl         string `json:"cumRealisedPnl"`         //累计已结盈亏 期貨: 是從第一次開始有持倉加總的已結盈虧 期權: 總是"", 無意義
	AdlRankIndicator       int    `json:"adlRankIndicator"`       //自動減倉燈.
	IsReduceOnly           bool   `json:"isReduceOnly"`           //僅當Bybit需要降低某個Symbol的風險限額時有用 true: 僅允許減倉操作. 您可以考慮一系列的方式, 比如, 降低risk limit檔位, 或者同檔位修改槓桿或減少倉位, 或者增加保證金, 或者撤單, 這些操作做完後, 可以主動調用確認新的風險限額接口 false(默認): 沒有交易限制, 表示您的倉位在系統調整時處於風險水平之下 僅對逐倉和全倉的期貨倉位有意義
	MmrSysUpdatedTime      string `json:"mmrSysUpdatedTime"`      //僅當Bybit需要降低某個Symbol的風險限額時有用 當isReduceOnly=true: 這個時間戳表示系統強制修改MMR的時間 當isReduceOnly=false: 若不為空, 則表示系統已經完成了MMR調整的時間 僅當系統調整才會賦值, 對於主動的調整, 不會在這裡展示時間戳 默認為"", 但如果曾經這個symbol有過系統降檔的操作, 那麼這裡會顯示上一次操作的時間 僅對逐倉和全倉的期貨倉位有意義
	LeverageSysUpdatedTime string `json:"leverageSysUpdatedTime"` //僅當Bybit需要降低某個Symbol的風險限額時有用 當isReduceOnly=true: 這個時間戳表示系統強制修改槓桿的時間 當isReduceOnly=false: 若不為空, 則表示系統已經完成了槓桿調整的時間 僅當系統調整才會賦值, 對於主動的調整, 不會在這裡展示時間戳 默認為"", 但如果曾經這個symbol有過系統降檔的操作, 那麼這裡會顯示上一次操作的時間 僅對逐倉和全倉的期貨倉位有意義
	CreatedTime            string `json:"createdTime"`            //倉位創建時間
	UpdatedTime            string `json:"updatedTime"`            //倉位數據更新時間
	Seq                    int64  `json:"seq"`                    //序列號, 用於關聯成交和倉位的更新 不同的幣對會存在相同seq, 可以使用seq + symbol來做唯一性識別 如果該幣對從未被交易過, 查詢時則會返回"-1" 對於更新槓桿、更新風險限額等非交易行為, 將會返回上一次成交時更新的seq
}

type PositionSetLeverageAPI

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

func (*PositionSetLeverageAPI) BuyLeverage

func (api *PositionSetLeverageAPI) BuyLeverage(buyLeverage string) *PositionSetLeverageAPI

buyLeverage string true [1, 風險限額允許的最大槓桿數] 單倉模式: 經典帳戶和統一帳戶的buyLeverage 必須等於sellLeverage 雙倉模式: 經典帳戶和統一帳戶(逐倉模式)buyLeverage可以與sellLeverage不想等; 統一帳戶(全倉模式)的buyLeverage 必須等於sellLeverage

func (*PositionSetLeverageAPI) Category

func (api *PositionSetLeverageAPI) Category(category string) *PositionSetLeverageAPI

category string true 產品類型 統一帳戶: linear, inverse 經典帳戶: linear, inverse

func (*PositionSetLeverageAPI) Do

func (*PositionSetLeverageAPI) SellLeverage

func (api *PositionSetLeverageAPI) SellLeverage(sellLeverage string) *PositionSetLeverageAPI

sellLeverage string true [1, 風險限額允許的最大槓桿數]

func (*PositionSetLeverageAPI) Symbol

symbol string true 合約名稱

type PositionSetLeverageReq

type PositionSetLeverageReq struct {
	Category     *string `json:"category"`     //string	true	產品類型 統一帳戶: linear, inverse 經典帳戶: linear, inverse
	Symbol       *string `json:"symbol"`       //string	true	合約名稱
	BuyLeverage  *string `json:"buyLeverage"`  //string	true	[1, 風險限額允許的最大槓桿數] 單倉模式: 經典帳戶和統一帳戶的buyLeverage 必須等於sellLeverage 雙倉模式: 經典帳戶和統一帳戶(逐倉模式)buyLeverage可以與sellLeverage不想等; 統一帳戶(全倉模式)的buyLeverage 必須等於sellLeverage
	SellLeverage *string `json:"sellLeverage"` //string	true	[1, 風險限額允許的最大槓桿數]
}

type PositionSetLeverageRes

type PositionSetLeverageRes struct{}

type PositionSwitchIsolatedAPI

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

func (*PositionSwitchIsolatedAPI) BuyLeverage

func (api *PositionSwitchIsolatedAPI) BuyLeverage(buyLeverage string) *PositionSwitchIsolatedAPI

buyLeverage string true 買側槓桿倍數. 必須與sellLeverage的值保持相同

func (*PositionSwitchIsolatedAPI) Category

category string true 產品類型 統一帳戶: inverse 經典帳戶: linear, inverse 這裡category字段不參與業務邏輯,僅做路由使用

func (*PositionSwitchIsolatedAPI) Do

func (*PositionSwitchIsolatedAPI) SellLeverage

func (api *PositionSwitchIsolatedAPI) SellLeverage(sellLeverage string) *PositionSwitchIsolatedAPI

sellLeverage string true 賣側槓桿倍數. 必須與buyLeverage的值保持相同

func (*PositionSwitchIsolatedAPI) Symbol

symbol string true 合約名稱

func (*PositionSwitchIsolatedAPI) TradeMode

func (api *PositionSwitchIsolatedAPI) TradeMode(tradeMode int) *PositionSwitchIsolatedAPI

tradeMode integer true 0: 全倉. 1: 逐倉

type PositionSwitchIsolatedReq

type PositionSwitchIsolatedReq struct {
	Category     *string `json:"category"`     //string	true	產品類型 統一帳戶: inverse 經典帳戶: linear, inverse 這裡category字段不參與業務邏輯,僅做路由使用
	Symbol       *string `json:"symbol"`       //string	true	合約名稱
	TradeMode    *int    `json:"tradeMode"`    //integer	true	0: 全倉. 1: 逐倉
	BuyLeverage  *string `json:"buyLeverage"`  //string	true	買側槓桿倍數. 必須與sellLeverage的值保持相同
	SellLeverage *string `json:"sellLeverage"` //string	true	賣側槓桿倍數. 必須與buyLeverage的值保持相同
}

type PositionSwitchIsolatedRes

type PositionSwitchIsolatedRes struct{}

type PositionSwitchModeAPI

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

func (*PositionSwitchModeAPI) Category

func (api *PositionSwitchModeAPI) Category(category string) *PositionSwitchModeAPI

category string true 產品類型 統一帳戶: linear: USDT永續; inverse: 反向交割 經典帳戶: linear, inverse. 這裡category字段不參與業務邏輯,僅做路由使用

func (*PositionSwitchModeAPI) Coin

coin string false 結算幣種

func (*PositionSwitchModeAPI) Do

func (*PositionSwitchModeAPI) Mode

mode integer true 倉位模式. 0: 單向持倉. 3: 雙向持倉

func (*PositionSwitchModeAPI) Symbol

func (api *PositionSwitchModeAPI) Symbol(symbol string) *PositionSwitchModeAPI

symbol string false 合約名稱. symbol和coin必須傳其中一個. symbol有更高優先級

type PositionSwitchModeReq

type PositionSwitchModeReq struct {
	Category *string `json:"category"` //string	true	產品類型 統一帳戶: linear: USDT永續; inverse: 反向交割 經典帳戶: linear, inverse. 這裡category字段不參與業務邏輯,僅做路由使用
	Symbol   *string `json:"symbol"`   //string	false	合約名稱. symbol和coin必須傳其中一個. symbol有更高優先級
	Coin     *string `json:"coin"`     //string	false	結算幣種
	Mode     *int    `json:"mode"`     //integer	true	倉位模式. 0: 單向持倉. 3: 雙向持倉
}

type PositionSwitchModeRes

type PositionSwitchModeRes struct{}

type PriceFilter

type PriceFilter struct {
	MinPrice string `json:"minPrice"` // 訂單最小價格
	MaxPrice string `json:"maxPrice"` // 訂單最大價格
	TickSize string `json:"tickSize"` // 修改價格的步長
}

type PrivateRestAPI

type PrivateRestAPI int
const (
	//Account
	AccountInfo                     PrivateRestAPI = iota //查詢帳戶信息
	AccountWalletBalance                                  //查詢錢包餘額
	AccountFeeRate                                        //查詢手續費率
	AccountUpgradeToUta                                   //升級至UTA Pro
	AccountSetMarginMode                                  //設置保證金模式(帳戶)
	AccountWithdrawal                                     //查詢可劃轉餘額(统一账户)
	AccountSetCollateralSwitch                            //設置抵押品幣種
	AccountSetCollateralSwitchBatch                       //批量設置抵押品幣種
	AccountCollateralInfo                                 //查詢抵押品幣種

	//Position
	PositionList           //查詢持倉 (實時)
	PositionSetLeverage    //設置槓桿
	PositionSwitchIsolated //切換全倉/逐倉保證金(交易對)
	PositionSwitchMode     //切換持倉模式
	//Order
	OrderCreate        //創建委託單
	OrderCreateBatch   //批量創建委託單
	OrderAmend         //修改委託單
	OrderAmendBatch    //批量修改委託單
	OrderCancel        //撤銷委託單
	OrderCancelBatch   //批量撤銷委託單
	OrderCancelAll     //撤銷所有訂單
	OrderRealtime      //查詢實時委託單
	OrderHistory       //查詢歷史訂單 (2年)
	OrderExecutionList //查詢成交紀錄 (2年)
	//asset
	AssetTransferQueryInterTransferList   //查詢劃轉紀錄 (單帳號內)
	AssetTransferQueryTransferCoinList    //帳戶類型間可劃轉的幣種
	AssetTransferInterTransfer            //劃轉 (單帳號內)
	AssetTransferQueryAccountCoinsBalance //查詢賬戶所有幣種余額
	AssetTransferQueryAccountCoinBalance  //查詢帳戶單個幣種餘額
	AssetTithdrawWithdrawableAmount       //查詢延遲提幣凍結金額

	//margin
	SpotMarginTradeSetLeverage //全倉槓桿設置用戶最大槓桿倍數
	SpotMarginTradeState       //查詢統一帳戶下槓桿交易的開關狀態和槓桿倍數
)

type PrivateRestClient

type PrivateRestClient RestClient

func (*PrivateRestClient) NewAccountCollateralInfo added in v0.1.7

func (client *PrivateRestClient) NewAccountCollateralInfo() *AccountCollateralInfoAPI

bybit AccountCollateralInfo PrivateRest接口 GET 查詢抵押品幣種

func (*PrivateRestClient) NewAccountFeeRate

func (client *PrivateRestClient) NewAccountFeeRate() *AccountFeeRateAPI

bybit AccountFeeRate PrivateRest接口 GET 查詢手續費率

func (*PrivateRestClient) NewAccountInfo added in v0.0.9

func (client *PrivateRestClient) NewAccountInfo() *AccountInfoAPI

bybit AccountInfo PrivateRest接口 GET 查詢帳戶信息

func (*PrivateRestClient) NewAccountSetCollateralSwitch added in v0.1.7

func (client *PrivateRestClient) NewAccountSetCollateralSwitch() *AccountSetCollateralSwitchAPI

bybit AccountSetCollateralSwitch PrivateRest接口 POST 設置抵押品幣種

func (*PrivateRestClient) NewAccountSetCollateralSwitchBatch added in v0.1.7

func (client *PrivateRestClient) NewAccountSetCollateralSwitchBatch() *AccountSetCollateralSwitchBatchAPI

bybit AccountSetCollateralSwitchBatch PrivateRest接口 POST 批量設置抵押品幣種

func (*PrivateRestClient) NewAccountSetMarginMode added in v0.1.0

func (client *PrivateRestClient) NewAccountSetMarginMode() *AccountSetMarginModeAPI

bybit AccountSetMarginMode PrivateRest接口 POST 設置保證金模式(帳戶)

func (*PrivateRestClient) NewAccountUpgradeToUta added in v0.0.9

func (client *PrivateRestClient) NewAccountUpgradeToUta() *AccountUpgradeToUtaAPI

bybit AccountUpgradeToUta PrivateRest接口 POST 升級為UTA帳戶

func (*PrivateRestClient) NewAccountWalletBalance

func (client *PrivateRestClient) NewAccountWalletBalance() *AccountWalletBalanceAPI

bybit AccountWalletBalance PrivateRest接口 GET 查詢錢包餘額

func (*PrivateRestClient) NewAccountWithdrawal added in v0.1.5

func (client *PrivateRestClient) NewAccountWithdrawal() *AccountWithdrawalAPI

bybit AccountWithdrawal PrivateRest接口 GET 查詢可劃轉餘額(统一账户)

func (*PrivateRestClient) NewAssetTithdrawWithdrawableAmount added in v0.1.1

func (client *PrivateRestClient) NewAssetTithdrawWithdrawableAmount() *AssetTithdrawWithdrawableAmountAPI

AssetTithdrawWithdrawableAmount: PrivateRest接口 //GET 查詢延遲提幣凍結金額

func (*PrivateRestClient) NewAssetTransferInterTransfer added in v0.1.1

func (client *PrivateRestClient) NewAssetTransferInterTransfer() *AssetTransferInterTransferAPI

bybit AssetTransferInterTransfer: PrivateRest接口 //POST 劃轉 (單帳號內)

func (*PrivateRestClient) NewAssetTransferQueryAccountCoinBalance added in v0.1.1

func (client *PrivateRestClient) NewAssetTransferQueryAccountCoinBalance() *AssetTransferQueryAccountCoinBalanceAPI

AssetTransferQueryAccountCoinBalance: PrivateRest接口 //GET 查詢帳戶單個幣種餘額

func (*PrivateRestClient) NewAssetTransferQueryAccountCoinsBalance added in v0.1.1

func (client *PrivateRestClient) NewAssetTransferQueryAccountCoinsBalance() *AssetTransferQueryAccountCoinsBalanceAPI

AssetTransferQueryAccountCoinsBalance: PrivateRest接口 //GET 查詢賬戶所有幣種餘額

func (*PrivateRestClient) NewAssetTransferQueryInterTransferList added in v0.1.1

func (client *PrivateRestClient) NewAssetTransferQueryInterTransferList() *AssetTransferQueryInterTransferListAPI

bybit AssetTransferQueryInterTransferList PrivateRest接口 GET 查詢劃轉紀錄 (單帳號內)

func (*PrivateRestClient) NewAssetTransferQueryTransferCoinList added in v0.1.1

func (client *PrivateRestClient) NewAssetTransferQueryTransferCoinList() *AssetTransferQueryTransferCoinListAPI

bybit AssetTransferQueryTransferCoinList: PrivateRest接口 //GET 帳戶類型間可劃轉的幣種

func (*PrivateRestClient) NewOrderAmend

func (client *PrivateRestClient) NewOrderAmend() *OrderAmendAPI

bybit OrderAmend PrivateRest接口 POST 修改委託單

func (*PrivateRestClient) NewOrderAmendBatch

func (client *PrivateRestClient) NewOrderAmendBatch() *OrderAmendBatchAPI

bybit OrderAmendBatch PrivateRest接口 POST 批量修改委託單

func (*PrivateRestClient) NewOrderCancel

func (client *PrivateRestClient) NewOrderCancel() *OrderCancelAPI

bybit OrderCancel PrivateRest接口 POST 撤銷委託單

func (*PrivateRestClient) NewOrderCancelAll

func (client *PrivateRestClient) NewOrderCancelAll() *OrderCancelAllAPI

bybit OrderCancelAll PrivateRest接口 POST 撤銷所有訂單

func (*PrivateRestClient) NewOrderCancelBatch

func (client *PrivateRestClient) NewOrderCancelBatch() *OrderCancelBatchAPI

bybit OrderCancelBatch PrivateRest接口 POST 批量撤銷委託單

func (*PrivateRestClient) NewOrderCreate

func (client *PrivateRestClient) NewOrderCreate() *OrderCreateAPI

bybit OrderCreate PrivateRest接口 POST 創建委託單

func (*PrivateRestClient) NewOrderCreateBatch

func (client *PrivateRestClient) NewOrderCreateBatch() *OrderCreateBatchAPI

bybit OrderCreateBatch PrivateRest接口 POST 批量創建委託單

func (*PrivateRestClient) NewOrderExecutionList

func (client *PrivateRestClient) NewOrderExecutionList() *OrderExecutionListAPI

bybit OrderExecutionList PrivateRest接口 GET 查詢成交紀錄 (2年)

func (*PrivateRestClient) NewOrderHistory

func (client *PrivateRestClient) NewOrderHistory() *OrderHistoryAPI

bybit OrderHistory PrivateRest接口 GET 查詢歷史訂單 (2年)

func (*PrivateRestClient) NewOrderRealtime

func (client *PrivateRestClient) NewOrderRealtime() *OrderRealtimeAPI

bybit OrderRealtime PrivateRest接口 GET 查詢實時委託

func (*PrivateRestClient) NewPositionList

func (client *PrivateRestClient) NewPositionList() *PositionListAPI

bybit PositionList PrivateRest接口 GET 查詢持倉 (實時)

func (*PrivateRestClient) NewPositionSetLeverage

func (client *PrivateRestClient) NewPositionSetLeverage() *PositionSetLeverageAPI

bybit PositionSetLeverage PrivateRest接口 POST 設置持倉槓桿

func (*PrivateRestClient) NewPositionSwitchIsolated

func (client *PrivateRestClient) NewPositionSwitchIsolated() *PositionSwitchIsolatedAPI

bybit PositionSwitchIsolated PrivateRest接口 POST 切換全倉/逐倉保證金(交易對)

func (*PrivateRestClient) NewPositionSwitchMode

func (client *PrivateRestClient) NewPositionSwitchMode() *PositionSwitchModeAPI

bybit PositionSwitchMode PrivateRest接口 POST 切換持倉模式

func (*PrivateRestClient) NewSpotMarginTradeSetLeverage added in v0.1.3

func (client *PrivateRestClient) NewSpotMarginTradeSetLeverage() *SpotMarginTradeSetLeverageAPI

func (*PrivateRestClient) NewSpotMarginTradeState added in v0.1.4

func (client *PrivateRestClient) NewSpotMarginTradeState() *SpotMarginTradeStateAPI

type PrivateWsStreamClient added in v0.0.2

type PrivateWsStreamClient struct {
	WsStreamClient
}

func NewPrivateWsStreamClient added in v0.0.2

func NewPrivateWsStreamClient() *PrivateWsStreamClient

func (*PrivateWsStreamClient) SubscribeExecution added in v0.0.2

func (ws *PrivateWsStreamClient) SubscribeExecution(category string) (*Subscription[WsExecution], error)

订阅单个个人成交推送 如: "spot"

func (*PrivateWsStreamClient) SubscribeExecutionMultiple added in v0.0.2

func (ws *PrivateWsStreamClient) SubscribeExecutionMultiple(categories []string) (*Subscription[WsExecution], error)

批量订阅个人成交推送 如: ["spot","linear"]

func (*PrivateWsStreamClient) SubscribeOrder added in v0.0.2

func (ws *PrivateWsStreamClient) SubscribeOrder(category string) (*Subscription[WsOrder], error)

订阅单个订单推送 如: "spot"

func (*PrivateWsStreamClient) SubscribeOrderMultiple added in v0.0.2

func (ws *PrivateWsStreamClient) SubscribeOrderMultiple(categories []string) (*Subscription[WsOrder], error)

批量订阅订单推送 如: ["spot","linear"]

func (*PrivateWsStreamClient) SubscribePosition added in v0.0.2

func (ws *PrivateWsStreamClient) SubscribePosition(category string) (*Subscription[WsPosition], error)

订阅单个仓位推送 如: "spot"

func (*PrivateWsStreamClient) SubscribePositionMultiple added in v0.0.2

func (ws *PrivateWsStreamClient) SubscribePositionMultiple(categories []string) (*Subscription[WsPosition], error)

批量订阅仓位推送 如: ["spot","linear"]

func (*PrivateWsStreamClient) SubscribeWallet added in v0.0.2

func (ws *PrivateWsStreamClient) SubscribeWallet() (*Subscription[WsWallet], error)

批量订阅钱包推送

func (*PrivateWsStreamClient) UnSubscribeExecution added in v0.0.2

func (ws *PrivateWsStreamClient) UnSubscribeExecution(category string) error

取消订阅单个个人成交推送 如: "spot"

func (*PrivateWsStreamClient) UnSubscribeExecutionMultiple added in v0.0.2

func (ws *PrivateWsStreamClient) UnSubscribeExecutionMultiple(categories []string) error

批量取消订阅个人成交推送 如: ["spot","linear"]

func (*PrivateWsStreamClient) UnSubscribeOrder added in v0.0.2

func (ws *PrivateWsStreamClient) UnSubscribeOrder(category string) error

取消订阅单个订单推送 如: "spot"

func (*PrivateWsStreamClient) UnSubscribeOrderMultiple added in v0.0.2

func (ws *PrivateWsStreamClient) UnSubscribeOrderMultiple(categories []string) error

批量取消订阅订单推送 如: ["spot","linear"]

func (*PrivateWsStreamClient) UnSubscribePosition added in v0.0.2

func (ws *PrivateWsStreamClient) UnSubscribePosition(category string) error

取消订阅单个仓位推送 如: "spot"

func (*PrivateWsStreamClient) UnSubscribePositionMultiple added in v0.0.2

func (ws *PrivateWsStreamClient) UnSubscribePositionMultiple(categories []string) error

批量取消订阅仓位推送 如: ["spot","linear"]

func (*PrivateWsStreamClient) UnSubscribeWallet added in v0.0.2

func (ws *PrivateWsStreamClient) UnSubscribeWallet() error

批量取消订阅钱包推送

type ProxyWeight added in v0.1.7

type ProxyWeight struct {
	RemainWeight int  //剩余可用权重
	IsLimited    bool //是否已被限制
}

type PublicRestAPI

type PublicRestAPI int
const (
	MarketInstrumentsInfo PublicRestAPI = iota //查詢可交易產品的規格信息
	MarketTime                                 //Bybit服務器時間
	MarketKline                                //查詢市場價格K線數據
	MarketOrderBook                            //Order Book (深度)
	MarketTickers                              //查詢最新行情信息
	MarketRecentTrade                          //查詢平台最近成交歷史
)

type PublicRestClient

type PublicRestClient RestClient

func (*PublicRestClient) NewMarketInstrumentsInfo

func (client *PublicRestClient) NewMarketInstrumentsInfo() *MarketInstrumentsInfoAPI

bybit MarketInstrumentsInfo PublicRest接口 GET 查詢可交易產品的規格信息

func (*PublicRestClient) NewMarketKline

func (client *PublicRestClient) NewMarketKline() *MarketKlineAPI

bybit MarketKline PublicRest接口 GET 查詢市場價格K線數據

func (*PublicRestClient) NewMarketOrderBook

func (client *PublicRestClient) NewMarketOrderBook() *MarketOrderBookAPI

bybit MarketOrderBook PublicRest接口 GET Order Book (深度)

func (*PublicRestClient) NewMarketTickers

func (client *PublicRestClient) NewMarketTickers() *MarketTickersAPI

bybit MarketTickers PublicRest接口 GET 查詢最新行情信息

func (*PublicRestClient) NewMarketTime

func (client *PublicRestClient) NewMarketTime() *MarketTimeAPI

bybit MarketTime PublicRest接口 GET Bybit服務器時間

type PublicWsStreamClient added in v0.0.2

type PublicWsStreamClient struct {
	WsStreamClient
}

func NewPublicInverseWsStreamClient added in v0.0.2

func NewPublicInverseWsStreamClient() *PublicWsStreamClient

func NewPublicLinearWsStreamClient added in v0.0.2

func NewPublicLinearWsStreamClient() *PublicWsStreamClient

func NewPublicOptionWsStreamClient added in v0.0.2

func NewPublicOptionWsStreamClient() *PublicWsStreamClient

func NewPublicSpotWsStreamClient added in v0.0.2

func NewPublicSpotWsStreamClient() *PublicWsStreamClient

func (*PublicWsStreamClient) SubscribeDepth added in v0.0.2

func (ws *PublicWsStreamClient) SubscribeDepth(symbol, depth string) (*Subscription[WsDepth], error)

订阅单个深度 如: "BTCUSDT","1"

func (*PublicWsStreamClient) SubscribeDepthMultiple added in v0.0.2

func (ws *PublicWsStreamClient) SubscribeDepthMultiple(symbols []string, depth string) (*Subscription[WsDepth], error)

批量订阅深度 如: ["BTCUSDT","ETHUSDT"],"1"

func (*PublicWsStreamClient) SubscribeKline added in v0.0.2

func (ws *PublicWsStreamClient) SubscribeKline(symbol, interval string) (*Subscription[WsKline], error)

订阅单个K线 如: "BTCUSDT","1"

func (*PublicWsStreamClient) SubscribeKlineMultiple added in v0.0.2

func (ws *PublicWsStreamClient) SubscribeKlineMultiple(symbols []string, intervals []string) (*Subscription[WsKline], error)

批量订阅K线 如: ["BTCUSDT","ETHUSDT"],["1","5"]

func (*PublicWsStreamClient) SubscribeTicker added in v0.1.8

func (ws *PublicWsStreamClient) SubscribeTicker(symbol string) (*Subscription[WsTicker], error)

订阅单个行情 如: "BTCUSDT"

func (*PublicWsStreamClient) SubscribeTickerMultiple added in v0.1.8

func (ws *PublicWsStreamClient) SubscribeTickerMultiple(symbols []string) (*Subscription[WsTicker], error)

批量订阅行情 如: ["BTCUSDT","ETHUSDT"]

func (*PublicWsStreamClient) SubscribeTrade added in v0.0.2

func (ws *PublicWsStreamClient) SubscribeTrade(symbol string) (*Subscription[WsTrade], error)

订阅单个成交 如: "BTCUSDT"

func (*PublicWsStreamClient) SubscribeTradeMultiple added in v0.0.2

func (ws *PublicWsStreamClient) SubscribeTradeMultiple(symbols []string) (*Subscription[WsTrade], error)

批量订阅成交 如: ["BTCUSDT","ETHUSDT"]

func (*PublicWsStreamClient) UnSubscribeDepth added in v0.0.2

func (ws *PublicWsStreamClient) UnSubscribeDepth(symbol, depth string) error

取消订阅单个深度 如: "BTCUSDT","1"

func (*PublicWsStreamClient) UnSubscribeDepthMultiple added in v0.0.2

func (ws *PublicWsStreamClient) UnSubscribeDepthMultiple(symbols []string, depth string) error

批量取消订阅深度 如: ["BTCUSDT","ETHUSDT"],"1"

func (*PublicWsStreamClient) UnSubscribeKline added in v0.0.2

func (ws *PublicWsStreamClient) UnSubscribeKline(symbol, interval string) error

取消订阅单个K线 如: "BTCUSDT","1m"

func (*PublicWsStreamClient) UnSubscribeKlineMultiple added in v0.0.2

func (ws *PublicWsStreamClient) UnSubscribeKlineMultiple(symbols, intervals []string) error

批量取消订阅K线 如: ["BTCUSDT","ETHUSDT"],["1","5"]

func (*PublicWsStreamClient) UnSubscribeTicker added in v0.1.8

func (ws *PublicWsStreamClient) UnSubscribeTicker(symbol string) error

取消订阅单个行情 如: "BTCUSDT"

func (*PublicWsStreamClient) UnSubscribeTickerMultiple added in v0.1.8

func (ws *PublicWsStreamClient) UnSubscribeTickerMultiple(symbols []string) error

批量取消订阅行情 如: ["BTCUSDT","ETHUSDT"]

func (*PublicWsStreamClient) UnSubscribeTrade added in v0.0.2

func (ws *PublicWsStreamClient) UnSubscribeTrade(symbol string) error

取消订阅单个成交 如: "BTCUSDT"

func (*PublicWsStreamClient) UnSubscribeTradeMultiple added in v0.0.2

func (ws *PublicWsStreamClient) UnSubscribeTradeMultiple(symbols []string) error

批量取消订阅成交 如: ["BTCUSDT","ETHUSDT"]

type RequestType

type RequestType string

type RestClient

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

func NewRestClient

func NewRestClient(APIKey, SecretKey string, options ...RestClientOption) *RestClient

func (*RestClient) PrivateRestClient

func (c *RestClient) PrivateRestClient() *PrivateRestClient

func (*RestClient) PublicRestClient

func (c *RestClient) PublicRestClient() *PublicRestClient

type RestClientOption

type RestClientOption func(c *Client)

func WithRecvWindow

func WithRecvWindow(recvWindow int64) RestClientOption

func WithRefer

func WithRefer(referer string) RestClientOption

type RestProxy added in v0.1.7

type RestProxy struct {
	ProxyUrl string //代理的协议IP端口URL
	Weight   ProxyWeight
}

func GetCurrentProxyList added in v0.1.7

func GetCurrentProxyList() []*RestProxy

type RiskParameters

type RiskParameters struct {
	LimitParameter  string `json:"limitParameter"`  // 限價單價格限制
	MarketParameter string `json:"marketParameter"` // 市價單價格限制
}

type ServerType

type ServerType int
const (
	BASE ServerType = iota
	AWS
	TEST
)

type SpotDetails

type SpotDetails struct {
	Innovation     string         `json:"innovation"`     // 是否屬於創新區交易對. `0`: 否, `1`: 是
	MarginTrading  string         `json:"marginTrading"`  // 該幣對是否支持槓桿交易
	RiskParameters RiskParameters `json:"riskParameters"` // 價格限制參數
}

SpotDetails

type SpotMarginTradeSetLeverageAPI added in v0.1.3

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

func (*SpotMarginTradeSetLeverageAPI) Do added in v0.1.3

func (*SpotMarginTradeSetLeverageAPI) Leverage added in v0.1.3

type SpotMarginTradeSetLeverageReq added in v0.1.3

type SpotMarginTradeSetLeverageReq struct {
	Leverage string `json:"leverage"` // 槓桿倍數 (整數), 支持區間 [2, 10]
}

type SpotMarginTradeSetLeverageRes added in v0.1.3

type SpotMarginTradeSetLeverageRes struct {
	RetCode    int      `json:"retCode"`
	RetMsg     string   `json:"retMsg"`
	Result     struct{} `json:"result"`
	RetExtInfo struct{} `json:"retExtInfo"`
	Time       int64    `json:"time"`
}

type SpotMarginTradeStateAPI added in v0.1.4

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

func (*SpotMarginTradeStateAPI) Do added in v0.1.4

type SpotMarginTradeStateReq added in v0.1.4

type SpotMarginTradeStateReq struct{}

type SpotMarginTradeStateRes added in v0.1.4

type SpotMarginTradeStateRes struct {
	SpotLeverage      string `json:"spotLeverage"`      // 槓桿倍數. 如果處於關閉狀態的話, 則返回 ""
	SpotMarginMode    string `json:"spotMarginMode"`    // 開關狀態. 1: 開啟, 0: 關閉
	EffectiveLeverage string `json:"effectiveLeverage"` // 實際借貸槓桿倍數。 精度保留2位小數,向下截取
}

spotLeverage string 槓桿倍數. 如果處於關閉狀態的話, 則返回 "" spotMarginMode string 開關狀態. 1: 開啟, 0: 關閉 effectiveLeverage string 實際借貸槓桿倍數。 精度保留2位小數,向下截取

type Subscription added in v0.0.2

type Subscription[T any] struct {
	SubId int64           //订阅ID
	Ws    *WsStreamClient //订阅的连接
	Op    string          //订阅方法
	Args  []string        //订阅参数
	// contains filtered or unexported fields
}

数据流订阅标准结构体

func (*Subscription[T]) CloseChan added in v0.0.2

func (sub *Subscription[T]) CloseChan() chan struct{}

获取关闭订阅信号

func (*Subscription[T]) ErrChan added in v0.0.2

func (sub *Subscription[T]) ErrChan() chan error

获取错误订阅

func (*Subscription[T]) ResultChan added in v0.0.2

func (sub *Subscription[T]) ResultChan() chan T

获取订阅结果

func (*Subscription[T]) Unsubscribe added in v0.0.2

func (sub *Subscription[T]) Unsubscribe() error

取消订阅

type TradeWsStreamClient added in v0.0.3

type TradeWsStreamClient struct {
	WsStreamClient
}

func NewTradeWsStreamClient added in v0.0.3

func NewTradeWsStreamClient() *TradeWsStreamClient

func (*TradeWsStreamClient) AmendOrder added in v0.0.3

改单

func (*TradeWsStreamClient) CancelOrder added in v0.0.3

撤单

func (*TradeWsStreamClient) CreateOrder added in v0.0.3

下单

type WsActionResult added in v0.0.2

type WsActionResult struct {
	Success bool   `json:"success"`
	RetMsg  string `json:"ret_msg"`
	ConnId  string `json:"conn_id"`
	ReqId   string `json:"req_id"`
	Op      string `json:"op"`
}

登陆及订阅返回结果

type WsAuthArg added in v0.0.2

type WsAuthArg struct {
	ApiKey    string `json:"apiKey"`
	Expire    int64  `json:"expire"`
	Signature string `json:"signature"`
}

授权请求参数

type WsAuthReq added in v0.0.2

type WsAuthReq struct {
	ReqId string         `json:"req_id,omitempty"`
	Op    string         `json:"op"`   //String 是操作
	Args  [3]interface{} `json:"args"` //Array 是请求订阅的频道列表
}

登陆请求相关

type WsAuthResult added in v0.0.3

type WsAuthResult struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Op      string `json:"op"`
	ConnId  string `json:"connId"`
}

单独授权接口返回结果

type WsDepth added in v0.0.2

type WsDepth struct {
	CommonWsRes
	Cts int64 `json:"cts"`
	WsDepthData
}

type WsDepthData added in v0.0.2

type WsDepthData struct {
	Symbol string  `json:"s"`
	U      int64   `json:"u"`
	Seq    int64   `json:"seq"`
	Bids   []Books `json:"b"`
	Asks   []Books `json:"a"`
}

type WsDepthDataMiddle added in v0.0.2

type WsDepthDataMiddle struct {
	Symbol string     `json:"s"`
	U      int64      `json:"u"`
	Seq    int64      `json:"seq"`
	Bids   [][]string `json:"b"`
	Asks   [][]string `json:"a"`
}

type WsDepthMiddle added in v0.0.2

type WsDepthMiddle struct {
	CommonWsRes
	Cts  int64             `json:"cts"`
	Data WsDepthDataMiddle `json:"data"`
}

type WsExecution added in v0.0.2

type WsExecution struct {
	Id           string            `json:"id"`           //消息id
	Topic        string            `json:"topic"`        //Topic名
	CreationTime int64             `json:"creationTime"` //消息數據創建時間
	Data         []WsExecutionData `json:"data"`         //Object
}

id string 消息id topic string Topic名 creationTime number 消息數據創建時間 data array Object > category string 產品類型 統一帳戶: spot, linear, iverse, option 經典帳戶: spot, linear, inverse. > symbol string 合約名稱 > isLeverage string 是否借貸. 僅統一帳戶spot有效. 0: 否, 1: 是. 經典帳戶現貨交易不支持, 總是0 > orderId string 訂單ID > orderLinkId string 用戶自定義訂單ID > side string 訂單方向.買:Buy,賣:Sell > orderPrice string 訂單價格. 經典帳戶現貨交易不支持 > orderQty string 訂單數量. 經典帳戶現貨交易不支持 > leavesQty string 剩餘委託未成交數量. 經典帳戶現貨交易不支持 > createType string 訂單創建類型 統一帳戶: 僅作用於category=linear 或 inverse 經典帳戶: 總是返回"" 現貨、期權不返回該字段 > orderType string 訂單類型. 市價單:Market,限價單:Limit > stopOrderType string 条件单的订单类型。如果该订单不是条件单,则不会返回任何类型. 經典帳戶現貨交易不支持 > execFee string 交易手續費. 您可以從這裡了解現貨手續費幣種信息. 經典帳戶現貨交易不支持 > execId string 成交Id > execPrice string 成交價格 > execQty string 成交數量 > execType string 成交類型. 經典帳戶現貨交易不支持 > execValue string 成交價值. 經典帳戶現貨交易不支持 > execTime string 成交時間(毫秒) > isMaker Bool 是否是 Maker 訂單,true 為 maker 訂單,false 為 taker 訂單 > feeRate string 手續費率. 經典帳戶現貨交易不支持 > tradeIv string 隱含波動率,僅期權有效 > markIv string 標記價格的隱含波動率,僅期權有效 > markPrice string 成交執行時,該 symbol 當時的標記價格. 目前僅對期權業務有效 > indexPrice string 成交執行時,該 symbol 當時的指數價格,目前僅對期權業務有效 > underlyingPrice string 成交執行時,該 symbol 當時的底層資產價格,僅期權有效 > blockTradeId string 大宗交易的订单 ID ,使用 paradigm 进行大宗交易时生成的 ID > closedSize string 平倉數量 > seq long 序列號, 用於關聯成交和倉位的更新 同一時間有多筆成交, seq相同 不同的幣對會存在相同seq, 可以使用seq + symbol來做唯一性識別

type WsExecutionData added in v0.0.2

type WsExecutionData struct {
	Category        string `json:"category"`        //產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse
	Symbol          string `json:"symbol"`          //合約名稱
	IsLeverage      string `json:"isLeverage"`      //是否借貸. 僅統一帳戶spot有效. 0: 否, 1: 是. 經典帳戶現貨交易不支持, 總是0
	OrderId         string `json:"orderId"`         //訂單ID
	OrderLinkId     string `json:"orderLinkId"`     //用戶自定義訂單ID
	Side            string `json:"side"`            //訂單方向.買:Buy,賣:Sell
	OrderPrice      string `json:"orderPrice"`      //訂單價格. 經典帳戶現貨交易不支持
	OrderQty        string `json:"orderQty"`        //訂單數量. 經典帳戶現貨交易不支持
	LeavesQty       string `json:"leavesQty"`       //剩餘委託未成交數量. 經典帳戶現貨交易不支持
	CreateType      string `json:"createType"`      //訂單創建類型 統一帳戶: 僅作用於category=linear 或 inverse 經典帳戶: 總是返回"" 現貨、期權不返回該字段
	OrderType       string `json:"orderType"`       //訂單類型. 市價單:Market,限價單:Limit
	StopOrderType   string `json:"stopOrderType"`   //条件单的订单类型。如果该订单不是条件单,则不会返回任何类型. 經典帳戶現貨交易不支持
	ExecFee         string `json:"execFee"`         //交易手續費. 您可以從這裡了解現貨手續費幣種信息. 經典帳戶現貨交易不支持
	ExecId          string `json:"execId"`          //成交Id
	ExecPrice       string `json:"execPrice"`       //成交價格
	ExecQty         string `json:"execQty"`         //成交數量
	ExecType        string `json:"execType"`        //成交類型. 經典帳戶現貨交易不支持
	ExecValue       string `json:"execValue"`       //成交價值
	ExecTime        string `json:"execTime"`        //成交時間(毫秒)
	IsMaker         bool   `json:"isMaker"`         //是否是 Maker 訂單,true 為 maker 訂單,false 為 taker 訂單
	FeeRate         string `json:"feeRate"`         //手續費率. 經典帳戶現貨交易不支持
	TradeIv         string `json:"tradeIv"`         //隱含波動率,僅期權有效
	MarkIv          string `json:"markIv"`          //標記價格的隱含波動率,僅期權有效
	MarkPrice       string `json:"markPrice"`       //成交執行時,該 symbol 當時的標記價格. 目前僅對期權業務有效
	IndexPrice      string `json:"indexPrice"`      //成交執行時,該 symbol 當時的指數價格,目前僅對期權業務有效
	UnderlyingPrice string `json:"underlyingPrice"` //成交執行時,該 symbol 當時的底層資產價格,僅期權有效
	BlockTradeId    string `json:"blockTradeId"`    //大宗交易的订单 ID ,使用 paradigm 进行大宗交易时生成的 ID
	ClosedSize      string `json:"closedSize"`      //平倉數量
	Seq             int64  `json:"seq"`             //序列號, 用於關聯成交和倉位的更新 同一時間有多筆成交, seq相同 不同的幣對會存在相同seq, 可以使用seq + symbol來做唯一性識別
}

type WsKline added in v0.0.2

type WsKline struct {
	CommonWsRes
	WsKlineData
}

type WsKlineData added in v0.0.2

type WsKlineData struct {
	Start     int64  `json:"start"`     //開始時間戳 (毫秒)
	End       int64  `json:"end"`       //結束時間戳 (毫秒)
	Interval  string `json:"interval"`  //K線粒度
	Open      string `json:"open"`      //開盤價
	Close     string `json:"close"`     //收盤價
	High      string `json:"high"`      //最高價
	Low       string `json:"low"`       //最低價
	Volume    string `json:"volume"`    //交易量
	Turnover  string `json:"turnover"`  //交易額
	Confirm   bool   `json:"confirm"`   //是否確認
	Timestamp int64  `json:"timestamp"` //蠟燭中最後一筆淨值時間戳 (毫秒)
}

type WsKlineMiddle added in v0.0.2

type WsKlineMiddle struct {
	CommonWsRes
	Data []WsKlineData `json:"data"`
}

type WsOrder added in v0.0.2

type WsOrder struct {
	Id           string        `json:"id"`           //消息id
	Topic        string        `json:"topic"`        //Topic名
	CreationTime int64         `json:"creationTime"` //消息數據創建時間
	Data         []WsOrderData `json:"data"`         //Object
}

type WsOrderArg added in v0.0.3

type WsOrderArg[T OrderReqType] struct {
	ReqId  string           `json:"req_id"` //請求reqId, 可作為請求的唯一標識, 若有傳, 則響應會返回該字段 當傳, 需保證唯一, 否則將會拿到錯誤 "20006"
	Header WsOrderReqHeader `json:"header"` //請求頭
	Op     string           `json:"op"`     //Op類型 order.create: 創建訂單 order.amend: 修改訂單 order.cancel: 撤銷訂單
	Args   [1]T             `json:"args"`   //參數數組, 目前僅支持一個元素 order.create: 請參閱創建訂單請求參數 order.amend: 請參閱修改訂單參數 order.cancel: 請參閱撤銷訂單參數
}

ws下单/撤单/改单请求参数

type WsOrderData added in v0.0.2

type WsOrderData struct {
	Category           string `json:"category"`           //產品類型 統一帳戶: spot, linear, inverse, option 經典帳戶: spot, linear, inverse.
	OrderId            string `json:"orderId"`            //訂單ID
	OrderLinkId        string `json:"orderLinkId"`        //用戶自定義ID
	IsLeverage         string `json:"isLeverage"`         //是否借貸. 僅統一帳戶spot有效. 0: 否, 1: 是. 經典帳戶現貨交易不支持, 總是0
	BlockTradeId       string `json:"blockTradeId"`       //大宗交易訂單Id
	Symbol             string `json:"symbol"`             //合約名稱
	Price              string `json:"price"`              //訂單價格
	Qty                string `json:"qty"`                //訂單數量
	Side               string `json:"side"`               //方向. Buy,Sell
	PositionIdx        int    `json:"positionIdx"`        //倉位標識。用戶不同倉位模式
	OrderStatus        string `json:"orderStatus"`        //訂單狀態
	CreateType         string `json:"createType"`         //訂單創建類型 僅作用於category=linear 或 inverse 現貨、期權不返回該字段
	CancelType         string `json:"cancelType"`         //訂單被取消類型. 經典帳戶現貨交易不支持
	RejectReason       string `json:"rejectReason"`       //拒絕原因. 經典帳戶現貨交易不支持
	AvgPrice           string `json:"avgPrice"`           //訂單平均成交價格 不存在avg price場景的訂單返回"", 以及經典帳戶下部分成交但最終被手動取消的訂單 經典帳戶現貨交易: 該字段不支持, 總是""
	LeavesQty          string `json:"leavesQty"`          //訂單剩餘未成交的數量. 經典帳戶現貨交易不支持
	LeavesValue        string `json:"leavesValue"`        //訂單剩餘未成交的價值. 經典帳戶現貨交易不支持
	CumExecQty         string `json:"cumExecQty"`         //訂單累計成交數量
	CumExecValue       string `json:"cumExecValue"`       //訂單累計成交價值
	CumExecFee         string `json:"cumExecFee"`         //訂單累計成交的手續費 經典帳戶spot: 表示的是最近一次成交的手續費. 升級到統一帳戶後, 您可以使用成交頻道中的execFee字段來獲取每次成交的手續費
	FeeCurrency        string `json:"feeCurrency"`        //現貨交易的手續費幣種. 可以從這裡了解現貨交易的手續費幣種規則
	TimeInForce        string `json:"timeInForce"`        //執行策略
	OrderType          string `json:"orderType"`          //訂單類型. Market,Limit. 對於止盈止損單, 則表示為觸發後的訂單類型
	StopOrderType      string `json:"stopOrderType"`      //條件單類型
	OcoTriggerBy       string `json:"ocoTriggerBy"`       //現貨OCO訂單的觸發類型.OcoTriggerByUnknown, OcoTriggerByTp, OcoTriggerBySl. 經典帳戶現貨不支持該字段
	OrderIv            string `json:"orderIv"`            //隱含波動率
	MarketUnit         string `json:"marketUnit"`         //統一帳戶現貨交易時給入參qty選擇的單位. baseCoin, quoteCoin
	TriggerPrice       string `json:"triggerPrice"`       //觸發價格. 若stopOrderType=TrailingStop, 則這是激活價格. 否則, 它是觸發價格
	TakeProfit         string `json:"takeProfit"`         //止盈價格
	StopLoss           string `json:"stopLoss"`           //止損價格
	TpslMode           string `json:"tpslMode"`           //止盈止損模式 Full: 全部倉位止盈止損, Partial: 部分倉位止盈止損. 現貨不返回該字段, 期權總是返回""
	TpLimitPrice       string `json:"tpLimitPrice"`       //觸發止盈後轉換為限價單的價格
	SlLimitPrice       string `json:"slLimitPrice"`       //觸發止損後轉換為限價單的價格
	TpTriggerBy        string `json:"tpTriggerBy"`        //觸發止盈的價格類型
	SlTriggerBy        string `json:"slTriggerBy"`        //觸發止損的價格類型
	TriggerDirection   int    `json:"triggerDirection"`   //觸發方向. 1: 上漲, 2: 下跌
	TriggerBy          string `json:"triggerBy"`          //觸發價格的觸發類型
	LastPriceOnCreated string `json:"lastPriceOnCreated"` //下單時的市場價格
	ReduceOnly         bool   `json:"reduceOnly"`         //只減倉. true表明這是只減倉單
	CloseOnTrigger     bool   `json:"closeOnTrigger"`     //觸發後平倉委託. 什麼是觸發後平倉委託?
	PlaceType          string `json:"placeType"`          //Place type, option used. iv, price
	SmpType            string `json:"smpType"`            //SMP執行類型
	SmpGroup           int    `json:"smpGroup"`           //所屬Smp組ID. 如果uid不屬於任何組, 則默認為0
	SmpOrderId         string `json:"smpOrderId"`         //觸發此SMP執行的交易對手的 orderID
	CreatedTime        string `json:"createdTime"`        //創建訂單的時間戳 (毫秒)
	UpdatedTime        string `json:"updatedTime"`        //訂單更新的時間戳 (毫秒)
}

type WsOrderParamSend added in v0.0.3

type WsOrderParamSend[T OrderReqType, R OrderResType] struct {
	ReqId string          //请求ID
	Ws    *WsStreamClient //订阅的连接
	Op    string          //订阅方法
	Args  WsOrderArg[T]
	// contains filtered or unexported fields
}

ws下单/撤单/改单单次请求

func (*WsOrderParamSend[T, R]) CloseChan added in v0.0.3

func (sub *WsOrderParamSend[T, R]) CloseChan() chan struct{}

获取关闭订阅信号

func (*WsOrderParamSend[T, R]) ErrChan added in v0.0.3

func (sub *WsOrderParamSend[T, R]) ErrChan() chan error

获取错误订阅

func (*WsOrderParamSend[T, R]) ResultChan added in v0.0.3

func (sub *WsOrderParamSend[T, R]) ResultChan() chan WsOrderResult[R]

获取订阅结果

type WsOrderReqHeader added in v0.0.3

type WsOrderReqHeader struct {
	XBapiTimestamp  string `json:"X-BAPI-TIMESTAMP"`
	XBapiRecvWindow string `json:"X-BAPI-RECV-WINDOW"`
	Referer         string `json:"Referer"`
}

type WsOrderResHeader added in v0.0.3

type WsOrderResHeader struct {
	Traceid                  string `json:"Traceid"`                      //Trace ID, 用於追蹤請求鏈路 (內部使用)
	Timenow                  string `json:"Timenow"`                      //當前時間戳
	XBapiLimit               string `json:"X-Bapi-Limit"`                 //該類型請求的帳戶總頻率
	XBapiLimitStatus         string `json:"X-Bapi-Limit-Status"`          //該類型請求的帳戶剩餘可用頻率
	XBapiLimitResetTimestamp string `json:"X-Bapi-Limit-Reset-Timestamp"` //如果您已超過該接口當前窗口頻率限製,該字段表示下個可用時間窗口的時間戳(毫秒)即什麽時候可以恢復訪問;如果您未超過該接口當前窗口頻率限製,該字段表示返回的是當前服務器時間(毫秒).
}

type WsOrderResult added in v0.0.3

type WsOrderResult[T OrderResType] struct {
	ReqId   string           `json:"req_id"`   //若請求有傳, 則響應存在該字段 若請求不傳, 則響應沒有該字段
	RetCode int              `json:"ret_code"` //0: 成功 10404: 1. op類型未找到; 2. category不支持/未找到 10429: 觸發系統級別的頻率保護 20006: reqId重複 10016: 1.內部錯誤; 2. 服務重啟 10019: ws下單服務正在重啟, 拒絕新的請求, 正在處理中的請求不受影響. 您可以重新/新建連接, 會分配到正常的服務上
	RetMsg  string           `json:"ret_msg"`  //OK "" 報錯信息
	Op      string           `json:"op"`       //Op類型
	Data    T                `json:"data"`     //業務數據, 和rest api響應的result字段業務數據一致 order.create: 請參閱創建訂單響應參數 order.amend: 請參閱修改訂單響應參數 order.cancel: 請參閱取消訂單響應參數
	Header  WsOrderResHeader `json:"header"`   //響應頭信息 TraceId string Trace ID, 用於追蹤請求鏈路 (內部使用) Timenow string 當前時間戳 X-Bapi-Limit string 該類型請求的帳戶總頻率 X-Bapi-Limit-Status string 該類型請求的帳戶剩餘可用頻率 X-Bapi-Limit-Reset-Timestamp string 如果您已超過該接口當前窗口頻率限製,該字段表示下個可用時間窗口的時間戳(毫秒)即什麽時候可以恢復訪問;如果您未超過該接口當前窗口頻率限製,該字段表示返回的是當前服務器時間(毫秒).
	ConnId  string           `json:"conn_id"`  //連接的唯一id
}

下单/撤单/改单返回结果

func CatchDoOrderResult added in v0.0.3

func CatchDoOrderResult[T OrderReqType, R OrderResType](ws *WsStreamClient, send *WsOrderParamSend[T, R]) (*WsOrderResult[R], error)

捕获下单/撤单/查单结果

type WsPosition added in v0.0.2

type WsPosition struct {
	Id           string           `json:"id"`           //消息id
	Topic        string           `json:"topic"`        //Topic名
	CreationTime int64            `json:"creationTime"` //消息數據創建時間
	Data         []WsPositionData `json:"data"`         //Object
}

type WsPositionData added in v0.0.2

type WsPositionData struct {
	Category               string `json:"category"`               //產品類型
	Symbol                 string `json:"symbol"`                 //合約名稱
	Side                   string `json:"side"`                   //持倉方向. Buy,Sell
	Size                   string `json:"size"`                   //持倉大小
	PositionIdx            int    `json:"positionIdx"`            //倉位標識
	TradeMode              int    `json:"tradeMode"`              //交易模式 0: 全倉, 1: 逐倉
	PositionValue          string `json:"positionValue"`          //倉位價值
	RiskId                 int    `json:"riskId"`                 //風險限額id 注意: 組合保證金模式下,該字段返回0,風險限額規則失效
	RiskLimitValue         string `json:"riskLimitValue"`         //風險限額id對應的風險限額度 注意: 組合保證金模式下,該字段返回空字符串,風險限額規則失效
	EntryPrice             string `json:"entryPrice"`             //入場價
	MarkPrice              string `json:"markPrice"`              //標記價
	Leverage               string `json:"leverage"`               //槓桿 注意: 組合保證金模式下,該字段返回"",槓桿規則失效
	PositionBalance        string `json:"positionBalance"`        //倉位保證金 注意: 組合保證金模式(PM)下, 該字段返回為空字符串
	AutoAddMargin          int    `json:"autoAddMargin"`          //是否自動追加保證金 0: 否, 1: 是
	PositionMM             string `json:"positionMM"`             //倉位維持保證金 注意: 組合保證金模式下,該字段返回空字符串
	PositionIM             string `json:"positionIM"`             //倉位初始保證金 注意: 組合保證金模式下,該字段返回空字符串
	LiqPrice               string `json:"liqPrice"`               //倉位強平價格
	BustPrice              string `json:"bustPrice"`              //預估破產價
	TpslMode               string `json:"tpslMode"`               //該字段廢棄, 無意義, 總是返回"Full"
	TakeProfit             string `json:"takeProfit"`             //止盈價格
	StopLoss               string `json:"stopLoss"`               //止損價格
	TrailingStop           string `json:"trailingStop"`           //追蹤止損
	UnrealisedPnl          string `json:"unrealisedPnl"`          //未結盈虧
	SessionAvgPrice        string `json:"sessionAvgPrice"`        //USDC合約平均持倉價格
	Delta                  string `json:"delta"`                  //Delta 期權的獨有字段
	Gamma                  string `json:"gamma"`                  //Gamma 期權的獨有字段
	Vega                   string `json:"vega"`                   //Vega 期權的獨有字段
	Theta                  string `json:"theta"`                  //Theta 期權的獨有字段
	CurRealisedPnl         string `json:"curRealisedPnl"`         //當前持倉的已結盈虧
	CumRealisedPnl         string `json:"cumRealisedPnl"`         //累計已结盈亏 期貨: 是從第一次開始有持倉加總的已結盈虧 期權: 它是本次持倉的加總已結盈虧
	PositionStatus         string `json:"positionStatus"`         //倉位狀態 Normal,Liq, Adl
	AdlRankIndicator       int    `json:"adlRankIndicator"`       //自動減倉燈
	IsReduceOnly           bool   `json:"isReduceOnly"`           //僅當Bybit需要降低某個Symbol的風險限額時有用 true: 僅允許減倉操作. false: 沒有交易限制 表示您的倉位在系統調整時處於風險水平之下 僅對逐倉和全倉的期貨倉位有意義
	MmrSysUpdatedTime      string `json:"mmrSysUpdatedTime"`      //僅當Bybit需要降低某個Symbol的風險限額時有用 當isReduceOnly=true: 這個時間戳表示系統強制修改MMR的時間 當isReduceOnly=false: 若不為空, 則表示系統已經完成了MMR調整的時間 僅當系統調整才會賦值, 對於主動的調整, 不會在這裡展示時間戳 默認為"", 但如果曾經這個symbol有過系統降檔的操作, 那麼這裡會顯示上一次操作的時間 僅對逐倉和全倉的期貨倉位有意義
	LeverageSysUpdatedTime string `json:"leverageSysUpdatedTime"` //僅當Bybit需要降低某個Symbol的風險限額時有用 當isReduceOnly=true: 這個時間戳表示系統強制修改槓桿的時間 當isReduceOnly=false: 若不為空, 則表示系統已經完成了槓桿調整的時間 僅當系統調整才會賦值, 對於主動的調整, 不會在這裡展示時間戳 默認為"", 但如果曾經這個symbol有過系統降檔的操作, 那麼這裡會顯示上一次操作的時間 僅對逐倉和全倉的期貨倉位有意義
	CreatedTime            string `json:"createdTime"`            //倉位創建時間戳 (毫秒)
	UpdatedTime            string `json:"updatedTime"`            //倉位數據更新時間戳 (毫秒)
	Seq                    int64  `json:"seq"`                    //序列號, 用於關聯成交和倉位的更新 不同的幣對會存在相同seq, 可以使用seq + symbol來做唯一性識別 如果該幣對從未被交易過, 查詢時則會返回"-1" 對於更新槓桿、更新風險限額等非交易行為, 將會返回上一次成交時更新的seq
}

type WsStreamClient added in v0.0.2

type WsStreamClient struct {
	AutoReConnectTimes int //自动重连次数
	// contains filtered or unexported fields
}

数据流订阅基础客户端

func (*WsStreamClient) Auth added in v0.0.2

func (ws *WsStreamClient) Auth(client *RestClient) error

func (*WsStreamClient) CatchPrivateAuthResult added in v0.0.3

func (ws *WsStreamClient) CatchPrivateAuthResult(sub *Subscription[WsActionResult]) error

捕获鉴权结果

func (*WsStreamClient) CatchTradeAuthResult added in v0.0.3

func (ws *WsStreamClient) CatchTradeAuthResult(sub *Subscription[WsAuthResult]) error

捕获鉴权结果

func (*WsStreamClient) Close added in v0.0.2

func (ws *WsStreamClient) Close() error

func (*WsStreamClient) CurrentSubList added in v0.0.2

func (ws *WsStreamClient) CurrentSubList() []string

func (*WsStreamClient) GetConn added in v0.0.2

func (ws *WsStreamClient) GetConn() *websocket.Conn

func (*WsStreamClient) OpenConn added in v0.0.2

func (ws *WsStreamClient) OpenConn() error

type WsSubscribeReq added in v0.0.2

type WsSubscribeReq struct {
	ReqId string   `json:"req_id"`
	Op    string   `json:"op"`   //String 是操作
	Args  []string `json:"args"` //Array 是请求订阅的频道列表
}

订阅请求相关

type WsTicker added in v0.1.8

type WsTicker struct {
	CommonWsRes
	Cs int64 `json:"cs"` //撮合版本號
	WsTickerData
}

type WsTickerData added in v0.1.8

type WsTickerData struct {
	Symbol                 string `json:"symbol"`                 // 合約名稱
	TickDirection          string `json:"tickDirection"`          // 價格變化方向
	Price24hPcnt           string `json:"price24hPcnt"`           // 市場價格相對24h前變化的百分比
	LastPrice              string `json:"lastPrice"`              // 最新市場成交價
	PrevPrice24h           string `json:"prevPrice24h"`           // 24小時前的整點市價
	HighPrice24h           string `json:"highPrice24h"`           // 最近24小時的最高價
	LowPrice24h            string `json:"lowPrice24h"`            // 最近24小時的最低價
	PrevPrice1h            string `json:"prevPrice1h"`            // 1小時前的整點市價
	MarkPrice              string `json:"markPrice"`              // 標記價格
	IndexPrice             string `json:"indexPrice"`             // 指數價格
	OpenInterest           string `json:"openInterest"`           // 未平倉合約的數量
	OpenInterestValue      string `json:"openInterestValue"`      // 未平倉合約的價值
	Turnover24h            string `json:"turnover24h"`            // 最近24小時成交額
	Volume24h              string `json:"volume24h"`              // 最近24小時成交量
	NextFundingTime        string `json:"nextFundingTime"`        // 下次結算資金費用的時間戳 (毫秒)
	FundingRate            string `json:"fundingRate"`            // 資金費率
	Bid1Price              string `json:"bid1Price"`              // 買1價
	Bid1Size               string `json:"bid1Size"`               // 買1價的數量
	Ask1Price              string `json:"ask1Price"`              // 賣1價
	Ask1Size               string `json:"ask1Size"`               // 賣1價的數量
	DeliveryTime           string `json:"deliveryTime"`           // 交割日期時間 (UTC+0), 僅適用於交割合約
	BasisRate              string `json:"basisRate"`              // 基差率. 反向交割和USDT/USDC交割獨有字段
	DeliveryFeeRate        string `json:"deliveryFeeRate"`        // 交割費率. 反向交割和USDT/USDC交割獨有字段
	PredictedDeliveryPrice string `json:"predictedDeliveryPrice"` // 預估交割價格. 反向交割和USDT/USDC交割獨有字段
	PreOpenPrice           string `json:"preOpenPrice"`           // 盤前合約預估開盤價格
	PreQty                 string `json:"preQty"`                 // 盤前合約預估開盤數量
	CurPreListingPhase     string `json:"curPreListingPhase"`     // 當前盤前交易階段

	// Option 特有字段
	BidPrice        string `json:"bidPrice"`        // 買1價 (期權)
	BidSize         string `json:"bidSize"`         // 買1價的數量 (期權)
	BidIv           string `json:"bidIv"`           // 買1價對應的iv
	AskPrice        string `json:"askPrice"`        // 賣1價 (期權)
	AskSize         string `json:"askSize"`         // 賣1價的數量 (期權)
	AskIv           string `json:"askIv"`           // 賣1價對應的iv
	MarkPriceIv     string `json:"markPriceIv"`     // 標記價格對應的iv
	UnderlyingPrice string `json:"underlyingPrice"` // 底層資產的價格
	TotalVolume     string `json:"totalVolume"`     // 總成交量
	TotalTurnover   string `json:"totalTurnover"`   // 總成交額
	Delta           string `json:"delta"`           // Delta
	Gamma           string `json:"gamma"`           // Gamma
	Vega            string `json:"vega"`            // Vega
	Theta           string `json:"theta"`           // Theta
	Change24h       string `json:"change24h"`       // 過去24小時的變化

	// Spot 特有字段
	UsdIndexPrice string `json:"usdIndexPrice"` // USD指數價格
}

Ticker 数据结构体 - 支持所有交易类型的字段

type WsTickerMiddle added in v0.1.8

type WsTickerMiddle struct {
	CommonWsRes
	Cs   int64        `json:"cs"`   //撮合版本號
	Data WsTickerData `json:"data"` //Ticker数据
}

Ticker WebSocket 数据结构定义

type WsTrade added in v0.0.2

type WsTrade struct {
	CommonWsRes
	Data []WsTradeData `json:"data"`
}

type WsTradeData added in v0.0.2

type WsTradeData struct {
	Timestamp  int64  `json:"T"`   //成交時間戳 (毫秒)
	Symbol     string `json:"s"`   //合約名稱
	Side       string `json:"S"`   //吃單方向. Buy,Sell
	Volume     string `json:"v"`   //成交數量
	Price      string `json:"p"`   //成交價格
	LastChange string `json:"L"`   //價格變化的方向. 期權沒有該字段
	TradeId    string `json:"i"`   //成交Id
	BlockTrade bool   `json:"BT"`  //成交類型是否為大宗交易
	MarkPrice  string `json:"mP"`  //標記價格, 期權的特有字段
	IndexPrice string `json:"iP"`  //指數價格, 期權的特有字段
	MarkIv     string `json:"mIv"` //標記iv, 期權的特有字段
	Iv         string `json:"iv"`  //iv, 期權的特有字段
}

type WsWallet added in v0.0.2

type WsWallet struct {
	Id           string         `json:"id"`           //消息id
	Topic        string         `json:"topic"`        //Topic名
	CreationTime int64          `json:"creationTime"` //消息數據創建時間
	Data         []WsWalletData `json:"data"`         //Object
}

type WsWalletData added in v0.0.2

type WsWalletData struct {
	AccountType            string             `json:"accountType"`            //帳戶類型 統一帳戶: UNIFIED(現貨/USDT和USDC永續/期權), CONTRACT(反向合約) 經典帳戶: CONTRACT, SPOT
	AccountLTV             string             `json:"accountLTV"`             //帳戶LTV account total borrowed size / (account total equity + account total borrowed size 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	AccountIMRate          string             `json:"accountIMRate"`          //帳戶初始保證金率 Account Total Initial Margin Base Coin / Account Margin Balance Base Coin 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	AccountMMRate          string             `json:"accountMMRate"`          //帳戶維持保證金率 Account Total Maintenance Margin Base Coin / Account Margin Balance Base Coin 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	TotalEquity            string             `json:"totalEquity"`            //賬戶維度換算成usd的資產淨值 Account Margin Balance Base Coin + Account Option Value Base Coin 非統一保證金模式和統一帳戶(反向)下,該字段返回為空
	TotalWalletBalance     string             `json:"totalWalletBalance"`     //賬戶維度換算成usd的產錢包餘額 ∑ Asset Wallet Balance By USD value of each asset 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	TotalMarginBalance     string             `json:"totalMarginBalance"`     //賬戶維度換算成usd的保證金餘額 totalWalletBalance + totalPerpUPL 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	TotalAvailableBalance  string             `json:"totalAvailableBalance"`  //賬戶維度換算成usd的可用餘額 RM:totalMarginBalance - totalInitialMargin 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	TotalPerpUPL           string             `json:"totalPerpUPL"`           //賬戶維度換算成usd的永續和USDC交割合約的浮動盈虧 ∑ Each perp and USDC Futures upl by base coin 非統一保證金模式以及統一帳戶(反向)下,該字段返回為空
	TotalInitialMargin     string             `json:"totalInitialMargin"`     //賬戶維度換算成usd的總初始保證金 ∑ Asset Total Initial Margin Base Coin 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	TotalMaintenanceMargin string             `json:"totalMaintenanceMargin"` //賬戶維度換算成usd的總維持保證金 ∑ Asset Total Maintenance Margin Base Coin 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空
	Coin                   []WsWalletDataCoin `json:"coin"`                   //Object. 幣種列表
}

type WsWalletDataCoin added in v0.0.2

type WsWalletDataCoin struct {
	Coin                string `json:"coin"`                //幣種名稱,例如 BTC,ETH,USDT,USDC
	Equity              string `json:"equity"`              //當前幣種的資產淨值
	UsdValue            string `json:"usdValue"`            //當前幣種折算成 usd 的價值,如果該幣種不能作為保證金的抵押品,則該數值為0
	WalletBalance       string `json:"walletBalance"`       //當前幣種的錢包餘額
	Free                string `json:"free"`                //經典帳戶現貨錢包的可用餘額. 經典帳戶現貨錢包的獨有字段
	Locked              string `json:"locked"`              //現貨掛單凍結金額
	SpotHedgingQty      string `json:"spotHedgingQty"`      //用於組合保證金(PM)現貨對衝的數量, 截斷至8為小數, 默認為0 統一帳戶的獨有字段
	BorrowAmount        string `json:"borrowAmount"`        //當前幣種的已用借貸額度
	AvailableToBorrow   string `json:"availableToBorrow"`   //由於母子共享借貸限額, 該字段已廢棄, 總是返回"". 請通過查詢抵押品信息接口查詢availableToBorrow
	AvailableToWithdraw string `json:"availableToWithdraw"` //當前幣種的可劃轉提現金額
	AccruedInterest     string `json:"accruedInterest"`     //當前幣種的預計要在下一個利息週期收取的利息金額
	TotalOrderIM        string `json:"totalOrderIM"`        //以當前幣種結算的訂單委託預佔用保證金. 組合保證金模式下,該字段返回空字符串
	TotalPositionIM     string `json:"totalPositionIM"`     //以當前幣種結算的所有倉位起始保證金求和 + 所有倉位的預佔用平倉手續費. 組合保證金模式下,該字段返回空字符串
	TotalPositionMM     string `json:"totalPositionMM"`     //以當前幣種結算的所有倉位維持保證金求和. 組合保證金模式下,該字段返回空字符串
	UnrealisedPnl       string `json:"unrealisedPnl"`       //以當前幣種結算的所有倉位的未結盈虧之和
	CumRealisedPnl      string `json:"cumRealisedPnl"`      //以當前幣種結算的所有倉位的累計已結盈虧之和
	Bonus               string `json:"bonus"`               //體驗金. UNIFIED帳戶的獨有字段
	MarginCollateral    bool   `json:"marginCollateral"`    //是否可作為保證金抵押幣種(平台維度), true: 是. false: 否 當marginCollateral=false時, 則collateralSwitch無意義
	CollateralSwitch    bool   `json:"collateralSwitch"`    //用戶是否開啟保證金幣種抵押(用戶維度), true: 是. false: 否 僅當marginCollateral=true時, 才能主動選擇開關抵押
}

Jump to

Keyboard shortcuts

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