Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAPIV1Params(requestPath string, params map[string]string, config Config) string
- func BuildOrderParams(params map[string]string) string
- func BuildParams(requestPath string, params map[string]string) string
- func EpochTime() string
- func FlateUnCompress(data []byte) ([]byte, error)
- func FmtPrintln(flag string, info interface{})
- func GetCurrencyUri(uri, currency string) string
- func GetInstrumentIdOrdersUri(uri, instrumentId string, orderId string) string
- func GetInstrumentIdUri(uri, instrumentId string) string
- func GetResponseDataJsonString(response *http.Response) string
- func GetResponsePageJsonString(response *http.Response) string
- func GetUnderlyingUri(uri, underlying string) string
- func Headers(request *http.Request, config Config, timestamp string, sign string)
- func HmacSha256Base64Signer(message string, secretKey string) (string, error)
- func Int2String(arg int) string
- func Int642String(arg int64) string
- func Int64ToString(arg int64) string
- func IntToString(arg int) string
- func IsoTime() string
- func IsoToTime(iso string) (time.Time, error)
- func JsonBytes2Struct(jsonBytes []byte, result interface{}) error
- func JsonString2Struct(jsonString string, result interface{}) error
- func LongTimeToUTC8(longTime int64) time.Time
- func LongTimeToUTC8Format(longTime int64) string
- func Md5Signer(message string) string
- func NewParams() map[string]string
- func ParseProxy(proxyURL string) (res func(*http.Request) (*url.URL, error), err error)
- func ParseRequestParams(params interface{}) (string, *bytes.Reader, error)
- func PreHashString(timestamp string, method string, requestPath string, body string) string
- func StringToInt(arg string) int
- func StringToInt64(arg string) int64
- func Struct2JsonString(structt interface{}) (jsonString string, err error)
- func T3O(condition bool, trueValue, falseValue interface{}) interface{}
- func T3Ox(err error, value interface{}) (interface{}, error)
- type ApiMessage
- type BaseCandleInfo
- type BaseFillInfo
- type BaseHistoricalFundingRate
- type BaseInstrumentAmount
- type BaseInstrumentInfo
- type BaseLedgerInfo
- type BaseLiquidationInfo
- type BaseOp
- type BaseOrderInfo
- type BasePlaceOrderInfo
- type BaseSwapOrderResult
- type BaseTickerInfo
- type BaseTradeInfo
- type BizWarmTips
- type Client
- func (client *Client) BatchCancelFuturesInstrumentOrders(InstrumentId, orderIds string) ([]byte, FuturesBatchCancelInstrumentOrdersResult, error)
- func (client *Client) CancelFuturesInstrumentOrder(InstrumentId string, orderId string) ([]byte, FuturesCancelInstrumentOrderResult, error)
- func (client *Client) FuturesOrder(newOrderParams FuturesNewOrderParams) ([]byte, FuturesNewOrderResult, error)
- func (client *Client) FuturesOrders(batchNewOrder FuturesBatchNewOrderParams) ([]byte, FuturesBatchNewOrderResult, error)
- func (client *Client) GetAccountCurrencies() (*[]map[string]interface{}, error)
- func (client *Client) GetAccountDepositAddress(currency string) (*[]map[string]interface{}, error)
- func (client *Client) GetAccountDepositHistory() (*[]map[string]interface{}, error)
- func (client *Client) GetAccountDepositHistoryByCurrency(currency string) (*[]map[string]interface{}, error)
- func (client *Client) GetAccountLeger(optionalParams *map[string]string) (*[]map[string]interface{}, error)
- func (client *Client) GetAccountWallet() (*[]map[string]interface{}, error)
- func (client *Client) GetAccountWalletByCurrency(currency string) (*[]map[string]interface{}, error)
- func (client *Client) GetAccountWithdrawalFeeByCurrency(currency *string) (*[]map[string]interface{}, error)
- func (client *Client) GetAccountWithdrawalHistory() (*[]map[string]interface{}, error)
- func (client *Client) GetAccountWithdrawalHistoryByCurrency(currency string) (*[]map[string]interface{}, error)
- func (client *Client) GetFinancialRates() (FinancialRatesResult, error)
- func (client *Client) GetFuturesAccounts() (GetFuturesAccountsResult, error)
- func (client *Client) GetFuturesAccountsByCurrency(currency string) (result FuturesCurrencyAccount, err error)
- func (client *Client) GetFuturesAccountsHoldsByInstrumentId(InstrumentId string) (FuturesAccountsHolds, error)
- func (client *Client) GetFuturesAccountsLedgerByCurrency(currency string, from, to, limit int) ([]FuturesCurrencyLedger, error)
- func (client *Client) GetFuturesAccountsLeverage(currency string) (map[string]interface{}, error)
- func (client *Client) GetFuturesExchangeRate() (ExchangeRate, error)
- func (client *Client) GetFuturesFills(InstrumentId string, orderId int64, optionalParams map[string]int) ([]FuturesFillResult, error)
- func (client *Client) GetFuturesInstrumentAllTicker() ([]FuturesInstrumentTickerResult, error)
- func (client *Client) GetFuturesInstrumentBook(InstrumentId string, optionalParams map[string]string) (FuturesInstrumentBookResult, error)
- func (client *Client) GetFuturesInstrumentCandles(InstrumentId string, optionalParams map[string]string) ([][]string, error)
- func (client *Client) GetFuturesInstrumentCurrencies() ([]FuturesInstrumentCurrenciesResult, error)
- func (client *Client) GetFuturesInstrumentEstimatedPrice(InstrumentId string) (FuturesInstrumentEstimatedPriceResult, error)
- func (client *Client) GetFuturesInstrumentIndex(InstrumentId string) (FuturesInstrumentIndexResult, error)
- func (client *Client) GetFuturesInstrumentLiquidation(InstrumentId string, status, from, to, limit int) (FuturesInstrumentLiquidationListResult, error)
- func (client *Client) GetFuturesInstrumentOpenInterest(InstrumentId string) (FuturesInstrumentOpenInterestResult, error)
- func (client *Client) GetFuturesInstrumentPosition(InstrumentId string) (FuturesPosition, error)
- func (client *Client) GetFuturesInstrumentPriceLimit(InstrumentId string) (FuturesInstrumentPriceLimitResult, error)
- func (client *Client) GetFuturesInstrumentTicker(InstrumentId string) (FuturesInstrumentTickerResult, error)
- func (client *Client) GetFuturesInstrumentTrades(InstrumentId string) ([]FuturesInstrumentTradesResult, error)
- func (client *Client) GetFuturesInstruments() ([]FuturesInstrumentsResult, error)
- func (client *Client) GetFuturesOrder(InstrumentId string, orderId string) (FuturesGetOrderResult, error)
- func (client *Client) GetFuturesOrders(InstrumentId string, status int, after string, before string, limit int) (FuturesGetOrdersResult, error)
- func (client *Client) GetFuturesPositions() (FuturesPosition, error)
- func (client *Client) GetIndexConstituents(instrumentID string) (IndexConstituentsResult, error)
- func (client *Client) GetInstrumentMarkPrice(instrumentId string) (*FuturesMarkdown, error)
- func (client *Client) GetMarginAccounts() (GetMarginAccountsResult, error)
- func (client *Client) GetMarginAccountsAvailability() (*[]map[string]interface{}, error)
- func (client *Client) GetMarginAccountsAvailabilityByInstrumentId(instrumentId string) (GetMarginAccountsAvailabilityByInstrumentIdResult, error)
- func (client *Client) GetMarginAccountsBorrowed(optionalParams *map[string]string) (*[]map[string]interface{}, error)
- func (client *Client) GetMarginAccountsBorrowedByInstrumentId(instrumentId string, optionalParams *map[string]string) (GetMarginAccountsBorrowedByInstrumentIdResult, error)
- func (client *Client) GetMarginAccountsByInstrument(instrumentId string) (GetMarginAccountsByInstrumentResult, error)
- func (client *Client) GetMarginAccountsLegerByInstrument(instrumentId string, optionalParams *map[string]string) (*[]map[string]interface{}, error)
- func (client *Client) GetMarginFills(instrumentId, orderId string, optionalParams map[string]string) ([]FillItem, error)
- func (client *Client) GetMarginOrders(instrumentId string, optionalParams map[string]string) ([]map[string]interface{}, error)
- func (client *Client) GetMarginOrdersById(instrumentId, orderOrClientId string) (MarginGetOrderResult, error)
- func (client *Client) GetMarginOrdersPending(optionalParams map[string]string) ([]map[string]interface{}, error)
- func (client *Client) GetServerTime() (ServerTime, error)
- func (client *Client) GetSpotAccounts() (GetSpotAccountsResult, error)
- func (client *Client) GetSpotAccountsCurrency(currency string) (GetSpotAccountsCurrencyResult, error)
- func (client *Client) GetSpotAccountsCurrencyLeger(currency string, optionalParams *map[string]string) (*[]map[string]interface{}, error)
- func (client *Client) GetSpotFills(order_id, instrument_id string, options *map[string]string) (*[]map[string]interface{}, error)
- func (client *Client) GetSpotInstrumentBook(instrumentId string, optionalParams map[string]string) (SpotInstrumentBookResult, error)
- func (client *Client) GetSpotInstrumentCandles(instrumentID string, options *map[string]string) ([]byte, *[]interface{}, error)
- func (client *Client) GetSpotInstrumentTicker(instrument_id string) (*map[string]interface{}, error)
- func (client *Client) GetSpotInstrumentTrade(instrument_id string, options *map[string]string) ([]byte, *[]map[string]interface{}, error)
- func (client *Client) GetSpotInstruments() (*[]map[string]interface{}, error)
- func (client *Client) GetSpotInstrumentsTicker() (*[]map[string]interface{}, error)
- func (client *Client) GetSpotOrders(status, instrument_id string, options *map[string]string) (*[]map[string]interface{}, error)
- func (client *Client) GetSpotOrdersById(instrumentId, orderOrClientId string) (SpotGetOrderResult, error)
- func (client *Client) GetSpotOrdersPending(options *map[string]string) (*[]map[string]interface{}, error)
- func (client *Client) GetSwapAccount(instrumentId string) (SwapAccount, error)
- func (client *Client) GetSwapAccountLedger(instrumentId string, optionalParams map[string]string) (*SwapAccountsLedgerList, error)
- func (client *Client) GetSwapAccounts() (SwapAccounts, error)
- func (client *Client) GetSwapAccountsHoldsByInstrument(instrumentId string) (*SwapAccountHolds, error)
- func (client *Client) GetSwapAccountsSettingsByInstrument(instrumentId string) (SwapAccountsSetting, error)
- func (client *Client) GetSwapCandlesByInstrument(instrumentId string, optionalParams map[string]string) (*SwapCandleList, error)
- func (client *Client) GetSwapDepthByInstrumentId(instrumentId string, optionalParams map[string]string) (SwapInstrumentDepth, error)
- func (client *Client) GetSwapFills(instrumentId string, orderId string, options map[string]string) (interface{}, error)
- func (client *Client) GetSwapFundingTimeByInstrument(instrumentId string) (*SwapFundingTime, error)
- func (client *Client) GetSwapHistoricalFundingRateByInstrument(instrumentId string, optionalParams map[string]string) (*SwapHistoricalFundingRateList, error)
- func (client *Client) GetSwapIndexByInstrument(instrumentId string) (*SwapIndexInfo, error)
- func (client *Client) GetSwapInstruments() (SwapInstrumentList, error)
- func (client *Client) GetSwapInstrumentsTicker() (*SwapTickerList, error)
- func (client *Client) GetSwapLiquidationByInstrument(instrumentId string, status string, optionalParams map[string]string) (*SwapLiquidationList, error)
- func (client *Client) GetSwapMarkPriceByInstrument(instrumentId string) (*SwapMarkPrice, error)
- func (client *Client) GetSwapOpenInterestByInstrument(instrumentId string) (*SwapOpenInterest, error)
- func (client *Client) GetSwapOrderById(instrumentId, orderOrClientId string) (BaseOrderInfo, error)
- func (client *Client) GetSwapOrderByInstrumentId(instrumentId string, paramMap map[string]string) (*SwapOrdersInfo, error)
- func (client *Client) GetSwapOrderByOrderId(instrumentId string, orderId string) (BaseOrderInfo, error)
- func (client *Client) GetSwapPositionByInstrument(instrumentId string) (SwapPosition, error)
- func (client *Client) GetSwapPositions() (*SwapPositionList, error)
- func (client *Client) GetSwapPriceLimitByInstrument(instrumentId string) (*SwapPriceLimit, error)
- func (client *Client) GetSwapRate() (*SwapRate, error)
- func (client *Client) GetSwapTickerByInstrument(instrumentId string) (*BaseTickerInfo, error)
- func (client *Client) GetSwapTradesByInstrument(instrumentId string, optionalParams map[string]string) (*SwapTradeList, error)
- func (client *Client) PostAccountTransfer(currency string, from, to int32, amount float32, ...) ([]byte, *map[string]interface{}, error)
- func (client *Client) PostAccountWithdrawal(currency, to_address, trade_pwd string, destination int32, amount, fee float32) ([]byte, *map[string]interface{}, error)
- func (client *Client) PostFuturesAccountsLeverage(currency string, leverage int, optionalParams map[string]string) (map[string]interface{}, error)
- func (client *Client) PostFuturesAccountsMarginNode(underlying string, marginMode string) (map[string]interface{}, error)
- func (client *Client) PostMarginAccountsBorrow(instrumentId, currency, amount string) ([]byte, PostMarginAccountsBorrowResult, error)
- func (client *Client) PostMarginAccountsRepayment(instrumentId, currency, amount string, optionalBorrowId *string) ([]byte, PostMarginAccountsRepaymentResult, error)
- func (client *Client) PostMarginBatchOrders(orderInfos *[]map[string]string) ([]byte, *map[string]interface{}, error)
- func (client *Client) PostMarginCancelBatchOrders(orderInfos *[]map[string]string) ([]byte, *map[string]interface{}, error)
- func (client *Client) PostMarginCancelOrdersById(instrumentId, orderOrClientId string) ([]byte, MarginNewOrderResult, error)
- func (client *Client) PostMarginOrders(side, instrument_id string, optionalOrderInfo map[string]string) ([]byte, MarginNewOrderResult, error)
- func (client *Client) PostSpotBatchOrders(orderInfos *[]map[string]string) ([]byte, *map[string]interface{}, error)
- func (client *Client) PostSpotCancelBatchOrders(orderInfos *[]map[string]interface{}) ([]byte, *map[string]interface{}, error)
- func (client *Client) PostSpotCancelOrders(instrumentId, orderOrClientId string) ([]byte, *map[string]interface{}, error)
- func (client *Client) PostSpotOrders(side, instrumentID string, optionalOrderInfo *map[string]string) (respBody []byte, result SpotNewOrderResult, err error)
- func (client *Client) PostSwapAccountsLeverage(instrumentId string, leverage string, side string) ([]byte, SwapAccountsSetting, error)
- func (client *Client) PostSwapBatchCancelOrders(instrumentId string, orderIds []string) ([]byte, *SwapCancelOrderResult, error)
- func (client *Client) PostSwapCancelOrder(instrumentId string, orderId string) ([]byte, SwapCancelOrderResult, error)
- func (client *Client) PostSwapOrder(instrumentId string, order BasePlaceOrderInfo) ([]byte, SwapOrderResult, error)
- func (client *Client) PostSwapOrders(instrumentId string, orders []*BasePlaceOrderInfo) ([]byte, *SwapOrdersResult, error)
- func (client *Client) Request(method string, requestPath string, params, result interface{}) (respBody []byte, response *http.Response, err error)
- type ClosePositionData
- type ClosePositionInfo
- type CodeMessage
- type Config
- type Constituent
- type CursorPage
- type DepthOrderBook
- type ExchangeRate
- type FillItem
- type FinancialRate
- type FinancialRates
- type FinancialRatesResult
- type FuturesAccount
- type FuturesAccountsContract
- type FuturesAccountsHolds
- type FuturesBatchCancelInstrumentOrdersResult
- type FuturesBatchNewOrderItem
- type FuturesBatchNewOrderParams
- type FuturesBatchNewOrderResult
- type FuturesCancelInstrumentOrderResult
- type FuturesClosePositionParams
- type FuturesClosePositionResult
- type FuturesCrossAccount
- type FuturesCrossAccountInfo
- type FuturesCrossPosition
- type FuturesCrossPositionHolding
- type FuturesCurrencyAccount
- type FuturesCurrencyAccountV0
- type FuturesCurrencyLedger
- type FuturesCurrencyLedgerDetails
- type FuturesFillResult
- type FuturesFillsParams
- type FuturesFixedAccount
- type FuturesFixedAccountContracts
- type FuturesFixedAccountInfo
- type FuturesFixedPosition
- type FuturesFixedPositionHolding
- type FuturesGetOrderResult
- type FuturesGetOrdersResult
- type FuturesInstrumentBookResult
- type FuturesInstrumentCurrenciesResult
- type FuturesInstrumentEstimatedPriceResult
- type FuturesInstrumentIndexResult
- type FuturesInstrumentLiquidationListResult
- type FuturesInstrumentLiquidationResult
- type FuturesInstrumentOpenInterestResult
- type FuturesInstrumentPriceLimitResult
- type FuturesInstrumentTickerResult
- type FuturesInstrumentTradesResult
- type FuturesInstrumentsResult
- type FuturesMarkdown
- type FuturesNewOrderParams
- type FuturesNewOrderResult
- type FuturesOrdersParams
- type FuturesPosition
- type FuturesPositionBase
- type FuturesUsersSelfTrailingVolumeResult
- type FuturesUsersSelfTrailingVolumesResult
- type FuturesWS
- func (ws *FuturesWS) Login() error
- func (ws *FuturesWS) SetAccountCallback(callback func(accounts []WSAccount))
- func (ws *FuturesWS) SetDepth20SnapshotCallback(callback func(ob *OrderBook))
- func (ws *FuturesWS) SetDepthL2TbtCallback(callback func(action string, data []WSDepthL2Tbt))
- func (ws *FuturesWS) SetOrderCallback(callback func(orders []WSOrder))
- func (ws *FuturesWS) SetPositionCallback(callback func(positions []WSFuturesPosition))
- func (ws *FuturesWS) SetProxy(proxyURL string) (err error)
- func (ws *FuturesWS) SetTickerCallback(callback func(tickers []WSTicker))
- func (ws *FuturesWS) SetTradeCallback(callback func(trades []WSTrade))
- func (ws *FuturesWS) Start()
- func (ws *FuturesWS) Subscribe(id string, args []string) error
- func (ws *FuturesWS) SubscribeAccount(id string, symbol string) error
- func (ws *FuturesWS) SubscribeDepthL2Tbt(id string, symbol string) error
- func (ws *FuturesWS) SubscribeOrder(id string, symbol string) error
- func (ws *FuturesWS) SubscribePosition(id string, symbol string) error
- func (ws *FuturesWS) SubscribeTicker(id string, symbol string) error
- func (ws *FuturesWS) SubscribeTrade(id string, symbol string) error
- func (ws *FuturesWS) Unsubscribe(id string) error
- type GetFuturesAccountsResult
- type GetMarginAccountsAvailabilityByInstrumentIdItem
- type GetMarginAccountsAvailabilityByInstrumentIdResult
- type GetMarginAccountsBorrowedByInstrumentIdItem
- type GetMarginAccountsBorrowedByInstrumentIdResult
- type GetMarginAccountsByInstrumentItem
- type GetMarginAccountsByInstrumentResult
- type GetMarginAccountsItem
- type GetMarginAccountsResult
- type GetSpotAccountsCurrencyResult
- type GetSpotAccountsResult
- type GetSpotAccountsResultItem
- type IndexConstituents
- type IndexConstituentsResult
- type Item
- type MarginCurrency
- type MarginGetOrderResult
- type MarginNewOrderResult
- type OrderBook
- type OrderInfo
- type PageResult
- type PlaceOrderInfo
- type PlaceOrdersInfo
- type PostMarginAccountsBorrowResult
- type PostMarginAccountsRepaymentResult
- type ReceivedDataCallback
- type Result
- type ServerTime
- type SpotGetOrderResult
- type SpotInstrumentBookResult
- type SpotNewOrderResult
- type SubscriptionTopic
- type SwapAccount
- type SwapAccountHolds
- type SwapAccountInfo
- type SwapAccounts
- type SwapAccountsLedgerList
- type SwapAccountsSetting
- type SwapBatchCancelOrderResult
- type SwapCancelOrderResult
- type SwapCandleList
- type SwapFillsInfo
- type SwapFundingTime
- type SwapHistoricalFundingRateList
- type SwapIndexInfo
- type SwapInstrumentDepth
- type SwapInstrumentList
- type SwapLiquidationList
- type SwapMarkPrice
- type SwapOpenInterest
- type SwapOrderResult
- type SwapOrdersInfo
- type SwapOrdersResult
- type SwapPosition
- type SwapPositionHolding
- type SwapPositionList
- type SwapPriceLimit
- type SwapRate
- type SwapTickerList
- type SwapTradeList
- type SwapWS
- func (ws *SwapWS) Login() error
- func (ws *SwapWS) SetAccountCallback(callback func(accounts []WSAccount))
- func (ws *SwapWS) SetDepth20SnapshotCallback(callback func(ob *OrderBook))
- func (ws *SwapWS) SetDepthL2TbtCallback(callback func(action string, data []WSDepthL2Tbt))
- func (ws *SwapWS) SetOrderCallback(callback func(orders []WSOrder))
- func (ws *SwapWS) SetPositionCallback(callback func(position []WSSwapPositionData))
- func (ws *SwapWS) SetProxy(proxyURL string) (err error)
- func (ws *SwapWS) SetTickerCallback(callback func(tickers []WSTicker))
- func (ws *SwapWS) SetTradeCallback(callback func(trades []WSTrade))
- func (ws *SwapWS) Start()
- func (ws *SwapWS) Subscribe(id string, args []string) error
- func (ws *SwapWS) SubscribeAccount(id string, symbol string) error
- func (ws *SwapWS) SubscribeDepthL2Tbt(id string, symbol string) error
- func (ws *SwapWS) SubscribeOrder(id string, symbol string) error
- func (ws *SwapWS) SubscribePosition(id string, symbol string) error
- func (ws *SwapWS) SubscribeTicker(id string, symbol string) error
- func (ws *SwapWS) SubscribeTrade(id string, symbol string) error
- func (ws *SwapWS) Unsubscribe(id string) error
- type WSAccount
- type WSAccountData
- type WSAccountResult
- type WSDepthItem
- type WSDepthL2Tbt
- type WSDepthL2TbtResult
- type WSDepthTableResponse
- type WSErrorResponse
- type WSEventResponse
- type WSFuturesPosition
- type WSFuturesPositionResult
- type WSHotDepths
- type WSOrder
- type WSOrderResult
- type WSSwapPositionData
- type WSSwapPositionHolding
- type WSSwapPositionResult
- type WSTableResponse
- type WSTicker
- type WSTickerResult
- type WSTrade
- type WSTradeResult
Constants ¶
const ( /* http headers */ OK_ACCESS_KEY = "OK-ACCESS-KEY" OK_ACCESS_SIGN = "OK-ACCESS-SIGN" OK_ACCESS_TIMESTAMP = "OK-ACCESS-TIMESTAMP" OK_ACCESS_PASSPHRASE = "OK-ACCESS-PASSPHRASE" /** paging params */ OK_FROM = "OK-FROM" OK_TO = "OK-TO" OK_LIMIT = "OK-LIMIT" CONTENT_TYPE = "Content-Type" ACCEPT = "Accept" COOKIE = "Cookie" LOCALE = "locale=" APPLICATION_JSON = "application/json" APPLICATION_JSON_UTF8 = "application/json; charset=UTF-8" /* i18n: internationalization */ ENGLISH = "en_US" SIMPLIFIED_CHINESE = "zh_CN" //zh_TW || zh_HK TRADITIONAL_CHINESE = "zh_HK" /* http methods */ GET = "GET" POST = "POST" DELETE = "DELETE" /* others */ ResultDataJsonString = "resultDataJsonString" ResultPageJsonString = "resultPageJsonString" )
const ( /* currencies */ BTC = 0 LTC = 1 ETH = 2 ETC = 4 BCH = 5 XRP = 15 EOS = 20 BTG = 10 /* transaction type */ OPEN_LONG = 1 OPEN_SHORT = 2 CLOSE_LONG = 3 CLOSE_SHORT = 4 /* margin mode */ CROSS = 1 FIXED = 2 /* candles bin size */ CANDLES_1MIN = 60 CANDLES_3MIN = 180 CANDLES_5MIN = 300 CANDLES_15MIN = 900 CANDLES_30MIN = 1800 CANDLES_1HOUR = 3600 CANDLES_2HOUR = 7200 CANDLES_4HOUR = 14400 CANDLES_6HOUR = 21600 CANDLES_12HOUR = 43200 CANDLES_1DAY = 86400 CANDLES_1WEEK = 604800 )
const ( TableFuturesTicker = "futures/ticker" // 公共-Ticker频道 TableFuturesTrade = "futures/trade" // 公共-交易频道 TableFuturesDepthL2Tbt = "futures/depth_l2_tbt" // 公共-400档增量数据频道 TableFuturesPosition = "futures/position" // 用户持仓频道 TableFuturesAccount = "futures/account" // 用户账户频道 TableFuturesOrder = "futures/order" // 用户交易频道 )
const ( ActionDepthL2Partial = "partial" ActionDepthL2Update = "update" )
const ( TableSwapTicker = "swap/ticker" // 公共-Ticker频道 TableSwapTrade = "swap/trade" // 公共-交易频道 TableSwapDepthL2Tbt = "swap/depth_l2_tbt" // 公共-400档增量数据频道 TableSwapPosition = "swap/position" // 用户持仓频道 TableSwapAccount = "swap/account" // 用户账户频道 TableSwapOrder = "swap/order" // 用户交易频道 )
const ( OKEX_TIME_URI = "/api/general/v3/time" ACCOUNT_CURRENCIES = "/api/account/v3/currencies" ACCOUNT_DEPOSIT_ADDRESS = "/api/account/v3/deposit/address" ACCOUNT_DEPOSIT_HISTORY = "/api/account/v3/deposit/history" ACCOUNT_DEPOSIT_HISTORY_CURRENCY = "/api/account/v3/deposit/history/{currency}" ACCOUNT_LEDGER = "/api/account/v3/ledger" ACCOUNT_WALLET = "/api/account/v3/wallet" ACCOUNT_WALLET_CURRENCY = "/api/account/v3/wallet/{currency}" ACCOUNT_WITHRAWAL = "/api/account/v3/withdrawal" ACCOUNT_WITHRAWAL_FEE = "/api/account/v3/withdrawal/fee" ACCOUNT_WITHRAWAL_HISTORY = "/api/account/v3/withdrawal/history" ACCOUNT_WITHRAWAL_HISTORY_CURRENCY = "/api/account/v3/withdrawal/history/{currency}" ACCOUNT_TRANSFER = "/api/account/v3/transfer" FUTURES_RATE = "/api/futures/v3/rate" FUTURES_INSTRUMENTS = "/api/futures/v3/instruments" FUTURES_CURRENCIES = "/api/futures/v3/instruments/currencies" FUTURES_INSTRUMENT_BOOK = "/api/futures/v3/instruments/{instrument_id}/book" FUTURES_TICKERS = "/api/futures/v3/instruments/ticker" FUTURES_INSTRUMENT_TICKER = "/api/futures/v3/instruments/{instrument_id}/ticker" FUTURES_INSTRUMENT_TRADES = "/api/futures/v3/instruments/{instrument_id}/trades" FUTURES_INSTRUMENT_CANDLES = "/api/futures/v3/instruments/{instrument_id}/candles" FUTURES_INSTRUMENT_MARK_PRICE = "/api/futures/v3/instruments/{instrument_id}/mark_price" FUTURES_INSTRUMENT_INDEX = "/api/futures/v3/instruments/{instrument_id}/index" FUTURES_INSTRUMENT_ESTIMATED_PRICE = "/api/futures/v3/instruments/{instrument_id}/estimated_price" FUTURES_INSTRUMENT_OPEN_INTEREST = "/api/futures/v3/instruments/{instrument_id}/open_interest" FUTURES_INSTRUMENT_PRICE_LIMIT = "/api/futures/v3/instruments/{instrument_id}/price_limit" FUTURES_INSTRUMENT_LIQUIDATION = "/api/futures/v3/instruments/{instrument_id}/liquidation" FUTURES_POSITION = "/api/futures/v3/position" FUTURES_INSTRUMENT_POSITION = "/api/futures/v3/{instrument_id}/position" FUTURES_ACCOUNTS = "/api/futures/v3/accounts" //FUTURES_ACCOUNT_CURRENCY_INFO = "/api/futures/v3/accounts/{currency}" FUTURES_ACCOUNT_CURRENCY_INFO = "/api/futures/v3/accounts/{underlying}" FUTURES_ACCOUNT_CURRENCY_LEDGER = "/api/futures/v3/accounts/{currency}/ledger" FUTURES_ACCOUNT_CURRENCY_LEVERAGE = "/api/futures/v3/accounts/{underlying}/leverage" FUTURES_ACCOUNT_MARGIN_MODE = "/api/futures/v3/accounts/margin_mode" FUTURES_ACCOUNT_INSTRUMENT_HOLDS = "/api/futures/v3/accounts/{instrument_id}/holds" FUTURES_ORDER = "/api/futures/v3/order" FUTURES_ORDERS = "/api/futures/v3/orders" FUTURES_INSTRUMENT_ORDER_LIST = "/api/futures/v3/orders/{instrument_id}" FUTURES_INSTRUMENT_ORDER_INFO = "/api/futures/v3/orders/{instrument_id}/{order_id}" FUTURES_INSTRUMENT_ORDER_CANCEL = "/api/futures/v3/cancel_order/{instrument_id}/{order_id}" FUTURES_INSTRUMENT_ORDER_BATCH_CANCEL = "/api/futures/v3/cancel_batch_orders/{instrument_id}" FUTURES_FILLS = "/api/futures/v3/fills" MARGIN_ACCOUNTS = "/api/margin/v3/accounts" MARGIN_ACCOUNTS_INSTRUMENT = "/api/margin/v3/accounts/{instrument_id}" MARGIN_ACCOUNTS_INSTRUMENT_LEDGER = "/api/margin/v3/accounts/{instrument_id}/ledger" MARGIN_ACCOUNTS_AVAILABILITY = "/api/margin/v3/accounts/availability" MARGIN_ACCOUNTS_INSTRUMENT_AVAILABILITY = "/api/margin/v3/accounts/{instrument_id}/availability" MARGIN_ACCOUNTS_BORROWED = "/api/margin/v3/accounts/borrowed" MARGIN_ACCOUNTS_INSTRUMENT_BORROWED = "/api/margin/v3/accounts/{instrument_id}/borrowed" MARGIN_ACCOUNTS_BORROW = "/api/margin/v3/accounts/borrow" MARGIN_ACCOUNTS_REPAYMENT = "/api/margin/v3/accounts/repayment" MARGIN_ORDERS = "/api/margin/v3/orders" MARGIN_BATCH_ORDERS = "/api/margin/v3/batch_orders" MARGIN_CANCEL_ORDERS_BY_ID = "/api/margin/v3/cancel_orders/{order_client_id}" MARGIN_CANCEL_BATCH_ORDERS = "/api/margin/v3/cancel_batch_orders" MARGIN_ORDERS_BY_ID = "/api/margin/v3/orders/{order_client_id}" MARGIN_ORDERS_PENDING = "/api/margin/v3/orders_pending" MARGIN_FILLS = "/api/margin/v3/fills" SPOT_ACCOUNTS = "/api/spot/v3/accounts" SPOT_ACCOUNTS_CURRENCY = "/api/spot/v3/accounts/{currency}" SPOT_ACCOUNTS_CURRENCY_LEDGER = "/api/spot/v3/accounts/{currency}/ledger" SPOT_ORDERS = "/api/spot/v3/orders" SPOT_BATCH_ORDERS = "/api/spot/v3/batch_orders" SPOT_CANCEL_ORDERS_BY_ID = "/api/spot/v3/cancel_orders/{order_client_id}" SPOT_CANCEL_BATCH_ORDERS = "/api/spot/v3/cancel_batch_orders" SPOT_ORDERS_PENDING = "/api/spot/v3/orders_pending" SPOT_ORDERS_BY_ID = "/api/spot/v3/orders/{order_client_id}" SPOT_FILLS = "/api/spot/v3/fills" SPOT_INSTRUMENTS = "/api/spot/v3/instruments" SPOT_INSTRUMENT_BOOK = "/api/spot/v3/instruments/{instrument_id}/book" SPOT_INSTRUMENTS_TICKER = "/api/spot/v3/instruments/ticker" SPOT_INSTRUMENT_TICKER = "/api/spot/v3/instruments/{instrument_id}/ticker" SPOT_INSTRUMENT_TRADES = "/api/spot/v3/instruments/{instrument_id}/trades" SPOT_INSTRUMENT_CANDLES = "/api/spot/v3/instruments/{instrument_id}/candles" SWAP_INSTRUMENT_ACCOUNT = "/api/swap/v3/{instrument_id}/accounts" SWAP_INSTRUMENT_POSITION = "/api/swap/v3/{instrument_id}/position" SWAP_ACCOUNTS = "/api/swap/v3/accounts" SWAP_ACCOUNTS_HOLDS = "/api/swap/v3/accounts/{instrument_id}/holds" SWAP_ACCOUNTS_LEDGER = "/api/swap/v3/accounts/{instrument_id}/ledger" SWAP_ACCOUNTS_LEVERAGE = "/api/swap/v3/accounts/{instrument_id}/leverage" SWAP_ACCOUNTS_SETTINGS = "/api/swap/v3/accounts/{instrument_id}/settings" SWAP_FILLS = "/api/swap/v3/fills" SWAP_INSTRUMENTS = "/api/swap/v3/instruments" SWAP_INSTRUMENTS_TICKER = "/api/swap/v3/instruments/ticker" SWAP_INSTRUMENT_CANDLES = "/api/swap/v3/instruments/{instrument_id}/candles" SWAP_INSTRUMENT_DEPTH = "/api/swap/v3/instruments/{instrument_id}/depth" SWAP_INSTRUMENT_FUNDING_TIME = "/api/swap/v3/instruments/{instrument_id}/funding_time" SWAP_INSTRUMENT_HISTORICAL_FUNDING_RATE = "/api/swap/v3/instruments/{instrument_id}/historical_funding_rate" SWAP_INSTRUMENT_INDEX = "/api/swap/v3/instruments/{instrument_id}/index" SWAP_INSTRUMENT_LIQUIDATION = "/api/swap/v3/instruments/{instrument_id}/liquidation" SWAP_INSTRUMENT_MARK_PRICE = "/api/swap/v3/instruments/{instrument_id}/mark_price" SWAP_INSTRUMENT_OPEN_INTEREST = "/api/swap/v3/instruments/{instrument_id}/open_interest" SWAP_INSTRUMENT_PRICE_LIMIT = "/api/swap/v3/instruments/{instrument_id}/price_limit" SWAP_INSTRUMENT_TICKER = "/api/swap/v3/instruments/{instrument_id}/ticker" SWAP_INSTRUMENT_TRADES = "/api/swap/v3/instruments/{instrument_id}/trades" SWAP_INSTRUMENT_ORDER_LIST = "/api/swap/v3/orders/{instrument_id}" SWAP_INSTRUMENT_ORDER_BY_ID = "/api/swap/v3/orders/{instrument_id}/{order_client_id}" SWAP_RATE = "/api/swap/v3/rate" SWAP_ORDER = "/api/swap/v3/order" SWAP_ORDERS = "/api/swap/v3/orders" SWAP_POSITION = "/api/swap/v3/position" SWAP_CANCEL_BATCH_ORDERS = "/api/swap/v3/cancel_batch_orders/{instrument_id}" SWAP_CANCEL_ORDER = "/api/swap/v3/cancel_order/{instrument_id}/{order_id}" INDEX_CONSTITUENTS = "/api/index/v3/{instrument_id}/constituents" )
Variables ¶
var ( ERR_WS_SUBSCRIOTION_PARAMS = errors.New(`ws subscription parameter error`) ERR_WS_CACHE_NOT_MATCH = errors.New(`ws hot cache not matched`) )
Functions ¶
func BuildAPIV1Params ¶
Get api v1 requestPath + requestParams params := okex.NewParams() params["symbol"] = "btc_usd" params["contract_type"] = "this_week" params["status"] = "1" requestPath := "/api/v1/future_explosive.do" return eg: /api/v1/future_explosive.do?api_key=88af5759-61f2-47e9-b2e9-17ce3a390488&contract_type=this_week&status=1&symbol=btc_usd&sign=966ACD0DE5F729BC9C9C03D92ABBEB68
func BuildOrderParams ¶
build http get request params, and order eg: params := make(map[string]string) params["bb"] = "222" params["aa"] = "111" params["cc"] = "333" return string: eg: aa=111&bb=222&cc=333
func BuildParams ¶
Get api requestPath + requestParams params := NewParams() params["depth"] = "200" params["conflated"] = "0" url := BuildParams("/api/futures/v3/products/BTC-USD-0310/book", params) return eg:/api/futures/v3/products/BTC-USD-0310/book?conflated=0&depth=200
func FlateUnCompress ¶
func GetCurrencyUri ¶
func GetInstrumentIdUri ¶
func GetUnderlyingUri ¶
func Headers ¶
Set http request headers:
Accept: application/json Content-Type: application/json; charset=UTF-8 (default) Cookie: locale=en_US (English) OK-ACCESS-KEY: (Your setting) OK-ACCESS-SIGN: (Use your setting, auto sign and add) OK-ACCESS-TIMESTAMP: (Auto add) OK-ACCESS-PASSPHRASE: Your setting
func HmacSha256Base64Signer ¶
signing a message using: hmac sha256 + base64
eg: message = Pre_hash function comment secretKey = E65791902180E9EF4510DB6A77F6EBAE return signed string = TO6uwdqz+31SIPkd4I+9NiZGmVH74dXi+Fd5X0EzzSQ=
func Int64ToString ¶
return decimalism string 9223372036854775807 -> "9223372036854775807"
func IntToString ¶
func IsoToTime ¶
iso time change to time.Time eg: "2018-11-18T16:51:55.933Z" -> 2018-11-18 16:51:55.000000933 +0000 UTC
func JsonBytes2Struct ¶
json byte array convert struct
func JsonString2Struct ¶
json string convert struct
func LongTimeToUTC8 ¶
Get utc +8 -- 1540365300000 -> 2018-10-24 15:15:00 +0800 CST
func LongTimeToUTC8Format ¶
1540365300000 -> 2018-10-24 15:15:00
func ParseProxy ¶
"socks5://127.0.0.1:1080"
func ParseRequestParams ¶
Get a http request body is a json string and a byte array.
func PreHashString ¶
the pre hash string
eg: timestamp = 2018-03-08T10:59:25.789Z method = POST request_path = /orders?before=2&limit=30 body = {"product_id":"BTC-USD-0309","order_id":"377454671037440"} return pre hash string = 2018-03-08T10:59:25.789ZPOST/orders?before=2&limit=30{"product_id":"BTC-USD-0309","order_id":"377454671037440"}
func StringToInt ¶
func StringToInt64 ¶
func Struct2JsonString ¶
struct convert json string
Types ¶
type ApiMessage ¶
type BaseCandleInfo ¶
type BaseCandleInfo []string
type BaseFillInfo ¶
type BaseFillInfo struct { InstrumentId string `json:"instrument_id"` OrderQty string `json:"order_qty"` TradeId string `json:"trade_id"` Fee string `json:"fee"` OrderId string `json:"order_id"` Timestamp string `json:"timestamp"` Price string `json:"price"` Side string `json:"side"` ExecType string `json:"exec_type"` }
type BaseInstrumentAmount ¶
type BaseInstrumentAmount struct { BizWarmTips InstrumentId string `json:"instrument_id"` Timestamp string `json:"timestamp"` Amount string `json:"amount"` }
type BaseInstrumentInfo ¶
type BaseInstrumentInfo struct { InstrumentId string `json:"instrument_id"` QuoteCurrency string `json:"quote_currency"` TickSize string `json:"tick_size"` ContractVal string `json:"contract_val"` Listing string `json:"listing"` UnderlyingIndex string `json:"underlying_index"` Delivery string `json:"delivery"` Coin string `json:"coin"` SizeIncrement string `json:"size_increment"` }
type BaseLedgerInfo ¶
type BaseLiquidationInfo ¶
type BaseOrderInfo ¶
type BaseOrderInfo struct { InstrumentId string `json:"instrument_id"` Status string `json:"status"` OrderId string `json:"order_id"` Timestamp string `json:"timestamp"` Price float64 `json:"price,string"` PriceAvg float64 `json:"price_avg,string"` Size int64 `json:"size,string"` Fee float64 `json:"fee,string"` FilledQty float64 `json:"filled_qty,string"` ContractVal string `json:"contract_val"` Type float64 `json:"type,string"` OrderType string `json:"order_type"` State int `json:"state,string"` }
type BasePlaceOrderInfo ¶
type BaseSwapOrderResult ¶
type BaseTickerInfo ¶
type BaseTradeInfo ¶
type BizWarmTips ¶
type Client ¶
func NewTestClient ¶
func NewTestClient() *Client
func (*Client) BatchCancelFuturesInstrumentOrders ¶
func (client *Client) BatchCancelFuturesInstrumentOrders(InstrumentId, orderIds string) ([]byte, FuturesBatchCancelInstrumentOrdersResult, error)
Batch Cancel the orders
func (*Client) CancelFuturesInstrumentOrder ¶
func (client *Client) CancelFuturesInstrumentOrder(InstrumentId string, orderId string) ([]byte, FuturesCancelInstrumentOrderResult, error)
Cancel the order
func (*Client) FuturesOrder ¶
func (client *Client) FuturesOrder(newOrderParams FuturesNewOrderParams) ([]byte, FuturesNewOrderResult, error)
Create a new order
func (*Client) FuturesOrders ¶
func (client *Client) FuturesOrders(batchNewOrder FuturesBatchNewOrderParams) ([]byte, FuturesBatchNewOrderResult, error)
Batch create new order.(Max of 5 orders are allowed per request)
func (*Client) GetAccountCurrencies ¶
获取平台所有币种列表。并非所有币种都可被用于交易。在ISO 4217标准中未被定义的币种代码可能使用的是自定义代码。
HTTP请求 GET /api/account/v3/currencies
func (*Client) GetAccountDepositAddress ¶
获取充值地址 获取各个币种的充值地址,包括曾使用过的老地址。
HTTP请求 GET /api/account/v3/deposit/address
请求示例 GET /api/account/v3/deposit/address?currency=btc
func (*Client) GetAccountDepositHistory ¶
获取所有币种充值记录 获取所有币种的充值记录。为最近一百条数据
HTTP请求 GET /api/account/v3/deposit/history
func (*Client) GetAccountDepositHistoryByCurrency ¶
func (client *Client) GetAccountDepositHistoryByCurrency(currency string) (*[]map[string]interface{}, error)
获取单个币种充值记录 获取单个币种的充值记录,为最近一百条数据
HTTP GET /api/account/v3/deposit/history/<currency>
func (*Client) GetAccountLeger ¶
func (client *Client) GetAccountLeger(optionalParams *map[string]string) (*[]map[string]interface{}, error)
账单流水查询 查询钱包账户账单流水。流水会分页,并且按时间倒序排序和储存,最新的排在最前面。请参阅分页部分以获取第一页之后的其他记录。为最近三个月的数据
HTTP请求 GET /api/account/v3/ledger
请求示例 GET /api/account/v3/ledger?type=2¤cy=btc&from=4&limit=10
func (*Client) GetAccountWallet ¶
钱包账户信息 获取钱包账户所有资产列表,查询各币种的余额、冻结和可用等信息。
HTTP请求 GET /api/account/v3/wallet
func (*Client) GetAccountWalletByCurrency ¶
func (client *Client) GetAccountWalletByCurrency(currency string) (*[]map[string]interface{}, error)
单一币种账户信息 获取钱包账户单个币种的余额、冻结和可用等信息。
HTTP请求 GET /api/account/v3/wallet/<currency>
请求示例 GET /api/account/v3/wallet/btc
func (*Client) GetAccountWithdrawalFeeByCurrency ¶
func (client *Client) GetAccountWithdrawalFeeByCurrency(currency *string) (*[]map[string]interface{}, error)
单一币种账户信息 获取钱包账户单个币种的余额、冻结和可用等信息。
HTTP请求 GET /api/account/v3/wallet/<currency>
func (*Client) GetAccountWithdrawalHistory ¶
查询最近所有币种的提币记录
HTTP请求 GET /api/account/v3/withdrawal/history
func (*Client) GetAccountWithdrawalHistoryByCurrency ¶
func (client *Client) GetAccountWithdrawalHistoryByCurrency(currency string) (*[]map[string]interface{}, error)
查询单个币种的提币记录。
HTTP请求 GET /api/account/v3/withdrawal/history/<currency>
func (*Client) GetFinancialRates ¶
func (client *Client) GetFinancialRates() (FinancialRatesResult, error)
https://www.okex.me/v2/asset/outer/financial/rates?t=1581044585771
func (*Client) GetFuturesAccounts ¶
func (client *Client) GetFuturesAccounts() (GetFuturesAccountsResult, error)
Get all of futures contract account list return struct: FuturesAccounts
func (*Client) GetFuturesAccountsByCurrency ¶
func (client *Client) GetFuturesAccountsByCurrency(currency string) (result FuturesCurrencyAccount, err error)
Get the futures contract currency account @see file : futures_constants.go return struct: FuturesCurrencyAccounts
func (*Client) GetFuturesAccountsHoldsByInstrumentId ¶
func (client *Client) GetFuturesAccountsHoldsByInstrumentId(InstrumentId string) (FuturesAccountsHolds, error)
Get the futures contract Instrument holds
func (*Client) GetFuturesAccountsLedgerByCurrency ¶
func (client *Client) GetFuturesAccountsLedgerByCurrency(currency string, from, to, limit int) ([]FuturesCurrencyLedger, error)
Get the futures contract currency ledger
func (*Client) GetFuturesAccountsLeverage ¶
获取合约账户币种杠杆倍数
限速规则:5次/2s HTTP请求 GET /api/futures/v3/accounts/<currency>/leverage
请求示例 GET/api/futures/v3/accounts/btc/leverage
func (*Client) GetFuturesExchangeRate ¶
func (client *Client) GetFuturesExchangeRate() (ExchangeRate, error)
=============================== Futures market api ===============================
The exchange rate of legal tender pairs
func (*Client) GetFuturesFills ¶
func (client *Client) GetFuturesFills(InstrumentId string, orderId int64, optionalParams map[string]int) ([]FuturesFillResult, error)
Get all of futures contract transactions.
func (*Client) GetFuturesInstrumentAllTicker ¶
func (client *Client) GetFuturesInstrumentAllTicker() ([]FuturesInstrumentTickerResult, error)
Get the futures contract Instrument all ticker
func (*Client) GetFuturesInstrumentBook ¶
func (client *Client) GetFuturesInstrumentBook(InstrumentId string, optionalParams map[string]string) (FuturesInstrumentBookResult, error)
获取深度数据 获取币对的深度列表。这个请求不支持分页,一个请求返回整个深度列表。
限速规则:20次/2s HTTP请求 GET /api/futrurs/v3/instruments/<instrument_id>/book
签名请求示例 2018-09-12T07:57:09.130ZGET/api/futrurs/v3/instruments/BTC-USD-180309/book?size=10&depth=0.001
func (*Client) GetFuturesInstrumentCandles ¶
func (client *Client) GetFuturesInstrumentCandles(InstrumentId string, optionalParams map[string]string) ([][]string, error)
Get the futures contract Instrument candles granularity: @see file: futures_constants.go
func (*Client) GetFuturesInstrumentCurrencies ¶
func (client *Client) GetFuturesInstrumentCurrencies() ([]FuturesInstrumentCurrenciesResult, error)
Get the futures contract currencies
func (*Client) GetFuturesInstrumentEstimatedPrice ¶
func (client *Client) GetFuturesInstrumentEstimatedPrice(InstrumentId string) (FuturesInstrumentEstimatedPriceResult, error)
Get the futures contract Instrument estimated price
func (*Client) GetFuturesInstrumentIndex ¶
func (client *Client) GetFuturesInstrumentIndex(InstrumentId string) (FuturesInstrumentIndexResult, error)
Get the futures contract Instrument index
func (*Client) GetFuturesInstrumentLiquidation ¶
func (client *Client) GetFuturesInstrumentLiquidation(InstrumentId string, status, from, to, limit int) (FuturesInstrumentLiquidationListResult, error)
Get the futures contract liquidation
func (*Client) GetFuturesInstrumentOpenInterest ¶
func (client *Client) GetFuturesInstrumentOpenInterest(InstrumentId string) (FuturesInstrumentOpenInterestResult, error)
Get the futures contract Instrument holds
func (*Client) GetFuturesInstrumentPosition ¶
func (client *Client) GetFuturesInstrumentPosition(InstrumentId string) (FuturesPosition, error)
Get all of futures contract position list. return struct: FuturesPositions
func (*Client) GetFuturesInstrumentPriceLimit ¶
func (client *Client) GetFuturesInstrumentPriceLimit(InstrumentId string) (FuturesInstrumentPriceLimitResult, error)
Get the futures contract Instrument limit price
func (*Client) GetFuturesInstrumentTicker ¶
func (client *Client) GetFuturesInstrumentTicker(InstrumentId string) (FuturesInstrumentTickerResult, error)
Get the futures contract Instrument ticker
func (*Client) GetFuturesInstrumentTrades ¶
func (client *Client) GetFuturesInstrumentTrades(InstrumentId string) ([]FuturesInstrumentTradesResult, error)
Get the futures contract Instrument trades
func (*Client) GetFuturesInstruments ¶
func (client *Client) GetFuturesInstruments() ([]FuturesInstrumentsResult, error)
Get all of futures contract list
func (*Client) GetFuturesOrder ¶
func (client *Client) GetFuturesOrder(InstrumentId string, orderId string) (FuturesGetOrderResult, error)
Get all of futures contract a order by order id
func (*Client) GetFuturesOrders ¶
func (client *Client) GetFuturesOrders(InstrumentId string, status int, after string, before string, limit int) (FuturesGetOrdersResult, error)
Get all of futures contract order list
func (*Client) GetFuturesPositions ¶
func (client *Client) GetFuturesPositions() (FuturesPosition, error)
Get all of futures contract position list. return struct: FuturesPositions
func (*Client) GetIndexConstituents ¶
func (client *Client) GetIndexConstituents(instrumentID string) (IndexConstituentsResult, error)
GetIndexConstituents 公共-获取指数成分
func (*Client) GetInstrumentMarkPrice ¶
func (client *Client) GetInstrumentMarkPrice(instrumentId string) (*FuturesMarkdown, error)
获取标记价格 获取合约标记价格。此接口为公共接口,不需要身份验证。
请求示例 GET/api/futures/v3/instruments/BTC-USD-180309/mark_price
func (*Client) GetMarginAccounts ¶
func (client *Client) GetMarginAccounts() (GetMarginAccountsResult, error)
币币杠杆账户信息 获取币币杠杆账户资产列表,查询各币种的余额、冻结和可用等信息。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/accounts
func (*Client) GetMarginAccountsAvailability ¶
杠杆配置信息 获取币币杠杆账户的借币配置信息,包括当前最大可借、借币利率、最大杠杆倍数。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/accounts/availability
func (*Client) GetMarginAccountsAvailabilityByInstrumentId ¶
func (client *Client) GetMarginAccountsAvailabilityByInstrumentId(instrumentId string) (GetMarginAccountsAvailabilityByInstrumentIdResult, error)
某个杠杆配置信息 获取某个币币杠杆账户的借币配置信息,包括当前最大可借、借币利率、最大杠杆倍数。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/accounts/<instrument_id>/availability
func (*Client) GetMarginAccountsBorrowed ¶
func (client *Client) GetMarginAccountsBorrowed(optionalParams *map[string]string) (*[]map[string]interface{}, error)
获取借币记录 获取币币杠杆帐户的借币记录。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/accounts/borrowed
func (*Client) GetMarginAccountsBorrowedByInstrumentId ¶
func (client *Client) GetMarginAccountsBorrowedByInstrumentId(instrumentId string, optionalParams *map[string]string) (GetMarginAccountsBorrowedByInstrumentIdResult, error)
某账户借币记录 获取币币杠杆帐户某币对的借币记录。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/accounts/<instrument_id>/borrowed
func (*Client) GetMarginAccountsByInstrument ¶
func (client *Client) GetMarginAccountsByInstrument(instrumentId string) (GetMarginAccountsByInstrumentResult, error)
单一币对账户信息 获取币币杠杆某币对账户的余额、冻结和可用等信息。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/accounts/<instrument_id>
func (*Client) GetMarginAccountsLegerByInstrument ¶
func (client *Client) GetMarginAccountsLegerByInstrument(instrumentId string, optionalParams *map[string]string) (*[]map[string]interface{}, error)
账单流水查询 列出杠杆帐户资产流水。帐户资产流水是指导致帐户余额增加或减少的行为。流水会分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/accounts/<instrument_id>/ledger
func (*Client) GetMarginFills ¶
func (client *Client) GetMarginFills(instrumentId, orderId string, optionalParams map[string]string) ([]FillItem, error)
获取成交明细 获取最近的成交明细列表。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/fills
func (*Client) GetMarginOrders ¶
func (client *Client) GetMarginOrders(instrumentId string, optionalParams map[string]string) ([]map[string]interface{}, error)
获取订单列表 列出您当前所有的订单信息。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/orders
func (*Client) GetMarginOrdersById ¶
func (client *Client) GetMarginOrdersById(instrumentId, orderOrClientId string) (MarginGetOrderResult, error)
获取订单信息 通过订单ID获取单个订单信息。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/orders/<order_id> 或者 GET /api/margin/v3/orders/<client_oid>
func (*Client) GetMarginOrdersPending ¶
func (client *Client) GetMarginOrdersPending(optionalParams map[string]string) ([]map[string]interface{}, error)
获取所有未成交订单 列出您当前所有的订单信息。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/margin/v3/orders_pending
func (*Client) GetServerTime ¶
func (client *Client) GetServerTime() (ServerTime, error)
Time of the server running OKEX's REST API.
func (*Client) GetSpotAccounts ¶
func (client *Client) GetSpotAccounts() (GetSpotAccountsResult, error)
币币账户信息 获取币币账户资产列表(仅展示拥有资金的币对),查询各币种的余额、冻结和可用等信息。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/accounts
func (*Client) GetSpotAccountsCurrency ¶
func (client *Client) GetSpotAccountsCurrency(currency string) (GetSpotAccountsCurrencyResult, error)
单一币种账户信息 获取币币账户单个币种的余额、冻结和可用等信息。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/accounts/<currency>
func (*Client) GetSpotAccountsCurrencyLeger ¶
func (client *Client) GetSpotAccountsCurrencyLeger(currency string, optionalParams *map[string]string) (*[]map[string]interface{}, error)
账单流水查询 列出账户资产流水。账户资产流水是指导致账户余额增加或减少的行为。流水会分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他记录。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/accounts/<currency>/ledger
func (*Client) GetSpotFills ¶
func (client *Client) GetSpotFills(order_id, instrument_id string, options *map[string]string) (*[]map[string]interface{}, error)
获取成交明细 获取最近的成交明细表。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他记录。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/fills
func (*Client) GetSpotInstrumentBook ¶
func (client *Client) GetSpotInstrumentBook(instrumentId string, optionalParams map[string]string) (SpotInstrumentBookResult, error)
获取深度数据 获取币对的深度列表。这个请求不支持分页,一个请求返回整个深度列表。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/instruments/<instrument_id>/book
func (*Client) GetSpotInstrumentCandles ¶
func (client *Client) GetSpotInstrumentCandles(instrumentID string, options *map[string]string) ([]byte, *[]interface{}, error)
获取成交数据 获取币对最新的60条成交列表。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/instruments/<instrument_id>/candles
func (*Client) GetSpotInstrumentTicker ¶
func (client *Client) GetSpotInstrumentTicker(instrument_id string) (*map[string]interface{}, error)
获取某个ticker信息 获取币对的最新成交价、买一价、卖一价和24小时交易量的快照信息。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/instruments/<instrument-id>/ticker
func (*Client) GetSpotInstrumentTrade ¶
func (client *Client) GetSpotInstrumentTrade(instrument_id string, options *map[string]string) ([]byte, *[]map[string]interface{}, error)
获取成交数据 获取币对最新的60条成交列表。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/instruments/<instrument_id>/trades
func (*Client) GetSpotInstruments ¶
获取币对信息 用于获取行情数据,这组公开接口提供了行情数据的快照,无需认证即可调用。
获取交易币对的列表,查询各币对的交易限制和价格步长等信息。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/instruments
func (*Client) GetSpotInstrumentsTicker ¶
获取全部ticker信息 获取平台全部币对的最新成交价、买一价、卖一价和24小时交易量的快照信息。
限速规则:50次/2s HTTP请求 GET /api/spot/v3/instruments/ticker
func (*Client) GetSpotOrders ¶
func (client *Client) GetSpotOrders(status, instrument_id string, options *map[string]string) (*[]map[string]interface{}, error)
获取订单列表 列出您当前所有的订单信息。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/orders
func (*Client) GetSpotOrdersById ¶
func (client *Client) GetSpotOrdersById(instrumentId, orderOrClientId string) (SpotGetOrderResult, error)
获取订单信息 通过订单ID获取单个订单信息。
限速规则:20次/2s
HTTP请求 GET /api/spot/v3/orders/<order_id> 或者 GET /api/spot/v3/orders/<client_oid>
func (*Client) GetSpotOrdersPending ¶
func (client *Client) GetSpotOrdersPending(options *map[string]string) (*[]map[string]interface{}, error)
获取所有未成交订单 列出您当前所有的订单信息。这个请求支持分页,并且按时间倒序排序和存储,最新的排在最前面。请参阅分页部分以获取第一页之后的其他纪录。
限速规则:20次/2s HTTP请求 GET /api/spot/v3/orders_pending
func (*Client) GetSwapAccount ¶
func (client *Client) GetSwapAccount(instrumentId string) (SwapAccount, error)
单个币种合约账户信息 HTTP请求 GET /api/swap/v3/<instrument_id>/accounts
func (*Client) GetSwapAccountLedger ¶
func (client *Client) GetSwapAccountLedger(instrumentId string, optionalParams map[string]string) (*SwapAccountsLedgerList, error)
账单流水查询 列出账户资产流水,账户资产流水是指导致账户余额增加或减少的行为。流水会分页,每页100条数据,并且按照时间倒序排序和存储,最新的排在最前面。
HTTP请求 GET /api/swap/v3/accounts/<instrument_id>/ledger
func (*Client) GetSwapAccounts ¶
func (client *Client) GetSwapAccounts() (SwapAccounts, error)
获取所有币种合约的账户信息 HTTP请求 GET /api/swap/v3/accounts
func (*Client) GetSwapAccountsHoldsByInstrument ¶
func (client *Client) GetSwapAccountsHoldsByInstrument(instrumentId string) (*SwapAccountHolds, error)
获取合约挂单冻结数量。
HTTP请求 GET /api/swap/v3/accounts/<instrument_id>/holds
func (*Client) GetSwapAccountsSettingsByInstrument ¶
func (client *Client) GetSwapAccountsSettingsByInstrument(instrumentId string) (SwapAccountsSetting, error)
获取某个合约的杠杆倍数,持仓模式
HTTP请求 GET /api/swap/v3/accounts/<instrument_id>/settings
func (*Client) GetSwapCandlesByInstrument ¶
func (client *Client) GetSwapCandlesByInstrument(instrumentId string, optionalParams map[string]string) (*SwapCandleList, error)
获取合约的K线数据。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/candles
请求示例 GET /api/swap/v3/instruments/BTC-USD-SWAP/candles?start=2018-10-26T02:31:00.000Z&end=2018-10-26T02:55:00.000Z&granularity=60(查询BTC-USD-SWAP的2018年10月26日02点31分到2018年10月26日02点55分的1分钟K线数据)
func (*Client) GetSwapDepthByInstrumentId ¶
func (client *Client) GetSwapDepthByInstrumentId(instrumentId string, optionalParams map[string]string) (SwapInstrumentDepth, error)
获取合约的深度列表。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/depth
请求示例 GET /api/swap/v3/instruments/<instrument_id>/depth?size=50
func (*Client) GetSwapFills ¶
func (client *Client) GetSwapFills(instrumentId string, orderId string, options map[string]string) (interface{}, error)
获取最近的成交明细列表。
HTTP请求 GET /api/swap/v3/fills
请求示例 GET /api/swap/v3/fills?order_id=64-2b-16122f931-3&instrument_id=BTC-USD-SWAP&from=1&limit=50(返回BTC-USD-SWAP中order_id为64-2b-16122f931-3的订单中第1页前50笔成交信息)
func (*Client) GetSwapFundingTimeByInstrument ¶
func (client *Client) GetSwapFundingTimeByInstrument(instrumentId string) (*SwapFundingTime, error)
获取合约下一次的结算时间。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/funding_time
func (*Client) GetSwapHistoricalFundingRateByInstrument ¶
func (client *Client) GetSwapHistoricalFundingRateByInstrument(instrumentId string, optionalParams map[string]string) (*SwapHistoricalFundingRateList, error)
获取合约历史资金费率。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/historical_funding_rate
请求示例 GET /api/swap/v3/instruments/BTC-USD-SWAP/historical_funding_rate?from=1&limit=50
func (*Client) GetSwapIndexByInstrument ¶
func (client *Client) GetSwapIndexByInstrument(instrumentId string) (*SwapIndexInfo, error)
获取币种指数。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/index
请求示例 GET /api/swap/v3/instruments/BTC-USD-SWAP/index
func (*Client) GetSwapInstruments ¶
func (client *Client) GetSwapInstruments() (SwapInstrumentList, error)
获取可用合约的列表,这组公开接口提供了行情数据的快照,无需认证即可调用。 获取可用合约的列表,查询各合约的交易限制和价格步长等信息。
HTTP请求 GET /api/swap/v3/instruments
func (*Client) GetSwapInstrumentsTicker ¶
func (client *Client) GetSwapInstrumentsTicker() (*SwapTickerList, error)
获取平台全部合约的最新成交价、买一价、卖一价和24交易量。
HTTP请求 GET /api/swap/v3/instruments/ticker
func (*Client) GetSwapLiquidationByInstrument ¶
func (client *Client) GetSwapLiquidationByInstrument(instrumentId string, status string, optionalParams map[string]string) (*SwapLiquidationList, error)
获取合约爆仓单。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/liquidation
请求示例 GET /api/swap/v3/instruments/BTC-USD-SWAP/liquidation?status=0&from=1&limit=50
func (*Client) GetSwapMarkPriceByInstrument ¶
func (client *Client) GetSwapMarkPriceByInstrument(instrumentId string) (*SwapMarkPrice, error)
获取合约标记价格。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/mark_price
func (*Client) GetSwapOpenInterestByInstrument ¶
func (client *Client) GetSwapOpenInterestByInstrument(instrumentId string) (*SwapOpenInterest, error)
获取合约整个平台的总持仓量。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/open_interest
func (*Client) GetSwapOrderById ¶
func (client *Client) GetSwapOrderById(instrumentId, orderOrClientId string) (BaseOrderInfo, error)
获取订单信息 通过订单id获取单个订单信息。
限速规则:40次/2s HTTP请求 GET /api/swap/v3/orders/<instrument_id>/<order_id> or GET /api/swap/v3/orders/<instrument_id>/<client_oid>
func (*Client) GetSwapOrderByInstrumentId ¶
func (client *Client) GetSwapOrderByInstrumentId(instrumentId string, paramMap map[string]string) (*SwapOrdersInfo, error)
列出您当前所有的订单信息。
HTTP请求 GET /api/swap/v3/orders/<instrument_id>
请求示例 GET /api/swap/v3/orders/BTC-USD-SWAP?status=2&from=4&limit=30
func (*Client) GetSwapOrderByOrderId ¶
func (client *Client) GetSwapOrderByOrderId(instrumentId string, orderId string) (BaseOrderInfo, error)
通过订单id获取单个订单信息。
HTTP请求 GET /api/swap/v3/orders/<instrument_id>/<order_id>
请求示例 GET /api/swap/v3/orders/BTC-USD-SWAP/64-2a-26132f931-3
func (*Client) GetSwapPositionByInstrument ¶
func (client *Client) GetSwapPositionByInstrument(instrumentId string) (SwapPosition, error)
获取某个合约的持仓信息 GET /api/swap/v3/<instrument_id>/position
func (*Client) GetSwapPositions ¶
func (client *Client) GetSwapPositions() (*SwapPositionList, error)
所有合约持仓信息 获取所有合约的持仓信息 限速规则:1次/10s GET /api/swap/v3/position
func (*Client) GetSwapPriceLimitByInstrument ¶
func (client *Client) GetSwapPriceLimitByInstrument(instrumentId string) (*SwapPriceLimit, error)
获取合约当前开仓的最高买价和最低卖价。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/price_limit
func (*Client) GetSwapTickerByInstrument ¶
func (client *Client) GetSwapTickerByInstrument(instrumentId string) (*BaseTickerInfo, error)
获取合约的最新成交价、买一价、卖一价和24交易量。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/ticker
func (*Client) GetSwapTradesByInstrument ¶
func (client *Client) GetSwapTradesByInstrument(instrumentId string, optionalParams map[string]string) (*SwapTradeList, error)
获取合约的成交记录。
HTTP请求 GET /api/swap/v3/instruments/<instrument_id>/trades
请求示例 GET /api/swap/v3/instruments/BTC-USD-SWAP/trades?from=1&limit=50
func (*Client) PostAccountTransfer ¶
func (client *Client) PostAccountTransfer( currency string, from, to int32, amount float32, optionalParams map[string]string) ([]byte, *map[string]interface{}, error)
资金划转 OKEx站内在钱包账户、交易账户和子账户之间进行资金划转。
限速规则:2次/s HTTP请求 POST /api/account/v3/transfer
func (*Client) PostAccountWithdrawal ¶
func (client *Client) PostAccountWithdrawal( currency, to_address, trade_pwd string, destination int32, amount, fee float32) ([]byte, *map[string]interface{}, error)
提币 提币到OKCoin国际站账户,OKEx账户或数字货币地址。
HTTP请求 POST /api/account/v3/withdrawal
func (*Client) PostFuturesAccountsLeverage ¶
func (client *Client) PostFuturesAccountsLeverage(currency string, leverage int, optionalParams map[string]string) (map[string]interface{}, error)
设定合约币种杠杆倍数 设定合约账户币种杠杆倍数,注意当前仓位有持仓或者挂单禁止切换杠杆。
HTTP请求 POST /api/futures/v3/accounts/<currency>/leverage
请求示例 POST/api/futures/v3/accounts/btc/leverage{"leverage":"10"}(全仓示例) POST/api/futures/v3/accounts/btc/leverage{"instrument_id":"BTC-USD-180213","direction":"long","leverage":"10"}(逐仓示例)
func (*Client) PostFuturesAccountsMarginNode ¶
func (*Client) PostMarginAccountsBorrow ¶
func (client *Client) PostMarginAccountsBorrow(instrumentId, currency, amount string) ([]byte, PostMarginAccountsBorrowResult, error)
借币 在某个币币杠杆账户里进行借币。
限速规则:100次/2s HTTP请求 POST /api/margin/v3/accounts/borrow
func (*Client) PostMarginAccountsRepayment ¶
func (client *Client) PostMarginAccountsRepayment(instrumentId, currency, amount string, optionalBorrowId *string) ([]byte, PostMarginAccountsRepaymentResult, error)
还币 在某个币币杠杆账户里进行还币。
限速规则:100次/2s HTTP请求 POST /api/margin/v3/accounts/repayment
func (*Client) PostMarginBatchOrders ¶
func (client *Client) PostMarginBatchOrders(orderInfos *[]map[string]string) ([]byte, *map[string]interface{}, error)
批量下单 下指定币对的多个订单(每次只能下最多4个币对且每个币对可批量下10个单)。
限速规则:50次/2s HTTP请求 POST /api/spot/v3/batch_orders
func (*Client) PostMarginCancelBatchOrders ¶
func (client *Client) PostMarginCancelBatchOrders(orderInfos *[]map[string]string) ([]byte, *map[string]interface{}, error)
批量撤销订单 撤销指定的某一种或多种币对的所有未完成订单,每个币对可批量撤10个单。
限速规则:50次/2s HTTP请求 POST /api/margin/v3/cancel_batch_orders
func (*Client) PostMarginCancelOrdersById ¶
func (client *Client) PostMarginCancelOrdersById(instrumentId, orderOrClientId string) ([]byte, MarginNewOrderResult, error)
撤销指定订单 撤销之前下的未完成订单。
限速规则:100次/2s HTTP请求 POST /api/margin/v3/cancel_orders/<order_id> 或者 POST /api/margin/v3/cancel_orders/<client_oid>
func (*Client) PostMarginOrders ¶
func (client *Client) PostMarginOrders(side, instrument_id string, optionalOrderInfo map[string]string) ([]byte, MarginNewOrderResult, error)
下单 OKEx API提供limit和market两种下单模式。只有当您的账户有足够的资金才能下单。一旦下单,您的账户资金将在订单生命周期内被冻结。被冻结的资金以及数量取决于订单指定的类型和参数。
限速规则:100次/2s HTTP请求 POST /api/margin/v3/orders
func (*Client) PostSpotBatchOrders ¶
func (client *Client) PostSpotBatchOrders(orderInfos *[]map[string]string) ([]byte, *map[string]interface{}, error)
批量下单 下指定币对的多个订单(每次只能下最多4个币对且每个币对可批量下10个单)。
限速规则:50次/2s HTTP请求 POST /api/spot/v3/batch_orders
func (*Client) PostSpotCancelBatchOrders ¶
func (client *Client) PostSpotCancelBatchOrders(orderInfos *[]map[string]interface{}) ([]byte, *map[string]interface{}, error)
批量撤销订单 撤销指定的某一种或多种币对的所有未完成订单,每个币对可批量撤10个单。
限速规则:50次/2s HTTP请求 POST /api/spot/v3/cancel_batch_orders
func (*Client) PostSpotCancelOrders ¶
func (client *Client) PostSpotCancelOrders(instrumentId, orderOrClientId string) ([]byte, *map[string]interface{}, error)
撤销指定订单 撤销之前下的未完成订单。
限速规则:100次/2s HTTP请求 POST /api/spot/v3/cancel_orders/<order_id> 或者 POST /api/spot/v3/cancel_orders/<client_oid>
func (*Client) PostSpotOrders ¶
func (client *Client) PostSpotOrders(side, instrumentID string, optionalOrderInfo *map[string]string) (respBody []byte, result SpotNewOrderResult, err error)
下单 OKEx币币交易提供限价单和市价单两种下单模式(更多下单模式将会在后期支持)。只有当您的账户有足够的资金才能下单。
一旦下单,您的账户资金将在订单生命周期内被冻结。被冻结的资金以及数量取决于订单指定的类型和参数。
限速规则:100次/2s HTTP请求 POST /api/spot/v3/orders
func (*Client) PostSwapAccountsLeverage ¶
func (client *Client) PostSwapAccountsLeverage(instrumentId string, leverage string, side string) ([]byte, SwapAccountsSetting, error)
设定某个合约的杠杆倍数
HTTP请求 POST /api/swap/v3/accounts/<instrument_id>/leverage
func (*Client) PostSwapBatchCancelOrders ¶
func (client *Client) PostSwapBatchCancelOrders(instrumentId string, orderIds []string) ([]byte, *SwapCancelOrderResult, error)
批量撤销之前下的未完成订单。
HTTP请求 POST /api/swap/v3/cancel_batch_orders/<instrument_id>
func (*Client) PostSwapCancelOrder ¶
func (client *Client) PostSwapCancelOrder(instrumentId string, orderId string) ([]byte, SwapCancelOrderResult, error)
撤销之前下的未完成订单。
HTTP请求 POST /api/swap/v3/cancel_order/<instrument_id>/<order_id>
func (*Client) PostSwapOrder ¶
func (client *Client) PostSwapOrder(instrumentId string, order BasePlaceOrderInfo) ([]byte, SwapOrderResult, error)
API交易提供限价单下单模式,只有当您的账户有足够的资金才能下单。一旦下单,您的账户资金将在订单生命周期内被冻结,被冻结的资金以及数量取决于订单指定的类型和参数。
HTTP请求 POST /api/swap/v3/order
func (*Client) PostSwapOrders ¶
func (client *Client) PostSwapOrders(instrumentId string, orders []*BasePlaceOrderInfo) ([]byte, *SwapOrdersResult, error)
批量进行下单请求。
HTTP请求 POST /api/swap/v3/orders
type ClosePositionData ¶
type ClosePositionInfo ¶
type ClosePositionInfo struct { InstrumentId string `json:"instrument_id"` CodeMessage }
type CodeMessage ¶
type Config ¶
type Config struct { // Rest api endpoint url. eg: http://www.okex.com/ Endpoint string // Rest websocket api endpoint url. eg: ws://192.168.80.113:10442/ WSEndpoint string // The user's api key provided by OKEx. ApiKey string // The user's secret key provided by OKEx. The secret key used to sign your request data. SecretKey string // The Passphrase will be provided by you to further secure your API access. Passphrase string // Http request timeout. TimeoutSecond int // Whether to print API information IsPrint bool // Internationalization @see file: constants.go I18n string // 设置代理 http://127.0.0.1:1080 ProxyURL string // Custom http client HTTPClient *http.Client }
func GetDefaultConfig ¶
func GetDefaultConfig() *Config
type Constituent ¶
type CursorPage ¶
type CursorPage struct { // Request page before (newer) this pagination id. Before int // Request page after (older) this pagination id. After int // Number of results per request. Maximum 100. (default 100) Limit int }
OKEX uses cursor pagination for all REST requests which return arrays
type DepthOrderBook ¶
type DepthOrderBook struct {
// contains filtered or unexported fields
}
func NewDepthOrderBook ¶
func NewDepthOrderBook(instrumentID string) *DepthOrderBook
func (*DepthOrderBook) GetInstrumentID ¶
func (d *DepthOrderBook) GetInstrumentID() string
func (*DepthOrderBook) GetOrderBook ¶
func (d *DepthOrderBook) GetOrderBook(depth int) (result OrderBook)
func (*DepthOrderBook) Update ¶
func (d *DepthOrderBook) Update(action string, data *WSDepthL2Tbt)
type ExchangeRate ¶
type FillItem ¶
type FillItem struct { CreatedAt string `json:"created_at"` ExecType string `json:"exec_type"` Fee float64 `json:"fee,string"` InstrumentID string `json:"instrument_id"` LedgerID string `json:"ledger_id"` Liquidity string `json:"liquidity"` OrderID string `json:"order_id"` Price string `json:"price"` ProductID string `json:"product_id"` Side string `json:"side"` Size float64 `json:"size,string"` Timestamp string `json:"timestamp"` }
type FinancialRate ¶
type FinancialRates ¶
type FinancialRates struct { Date int64 `json:"date"` Rates []FinancialRate `json:"rates"` }
type FinancialRatesResult ¶
type FinancialRatesResult struct { Code int `json:"code"` Data FinancialRates `json:"data"` DetailMsg string `json:"detailMsg"` Msg string `json:"msg"` }
type FuturesAccount ¶
type FuturesAccount struct { BizWarmTips Result MarginMode string CrossAccount map[string]FuturesCrossAccount FixedAccount map[string]FuturesFixedAccount }
type FuturesAccountsContract ¶
type FuturesAccountsContract struct { AvailableQty string `json:"available_qty"` FixedBalance string `json:"fixed_balance"` InstrumentID string `json:"instrument_id"` MarginForUnfilled string `json:"margin_for_unfilled"` MarginFrozen string `json:"margin_frozen"` RealizedPnl string `json:"realized_pnl"` UnrealizedPnl string `json:"unrealized_pnl"` MarginRatio string `json:"margin_ratio"` MaintMarginRatio string `json:"maint_margin_ratio"` CanWithdraw string `json:"can_withdraw"` Equity string `json:"equity"` MarginMode string `json:"margin_mode"` TotalAvailBalance float64 `json:"total_avail_balance,string"` AutoMargin string `json:"auto_margin"` Underlying string `json:"underlying"` }
type FuturesAccountsHolds ¶
type FuturesBatchNewOrderParams ¶
type FuturesBatchNewOrderParams struct { InstrumentId string `json:"instrument_id"` Leverage string `json:"leverage"` OrdersData string `json:"orders_data"` }
OrdersData: Batch create new orders json string.(Max of 5 orders are allowed per request))
type FuturesClosePositionParams ¶
type FuturesClosePositionParams struct {
ClosePositionData []ClosePositionData
}
type FuturesClosePositionResult ¶
type FuturesClosePositionResult struct { Result ClosePositionInfo []ClosePositionInfo `json:"close_position_info"` }
type FuturesCrossAccount ¶
type FuturesCrossAccount struct { Equity float64 `json:"equity,string"` Margin float64 `json:"margin,string"` MarginMode string `json:"margin_mode"` MarginRatio float64 `json:"margin_ratio,string"` RealizedPnl float64 `json:"realized_pnl,string"` UnrealizedPnl float64 `json:"unrealized_pnl,string"` TotalAvailBalance float64 `json:"total_avail_balance,string"` }
type FuturesCrossAccountInfo ¶
type FuturesCrossAccountInfo struct { Result Info map[string]FuturesCrossAccount `json:"info"` }
type FuturesCrossPosition ¶
type FuturesCrossPosition struct { Result MarginMode string `json:"margin_mode"` CrossPosition []FuturesCrossPositionHolding `json:"holding"` }
type FuturesCrossPositionHolding ¶
type FuturesCrossPositionHolding struct { FuturesPositionBase LiquidationPrice float64 `json:"liquidation_price,string"` Leverage float64 `json:"leverage,string"` }
type FuturesCurrencyAccount ¶
type FuturesCurrencyAccount struct { TotalAvailBalance float64 `json:"total_avail_balance,string"` // 账户余额(账户静态权益) Contracts []FuturesFixedAccountContracts `json:"contracts"` Equity float64 `json:"equity,string"` // 账户权益(账户动态权益) MarginMode string `json:"margin_mode"` // 账户类型 全仓:crossed 逐仓: fixed AutoMargin int `json:"auto_margin,string"` // 是否自动追加保证金 1: 自动追加已开启 0: 自动追加未开启 LiquiMode string `json:"liqui_mode"` // 强平模式:tier(梯度强平) CanWithdraw float64 `json:"can_withdraw,string"` // 可划转数量 RealizedPnl float64 `json:"realized_pnl,string"` // 全仓模式 已实现盈亏 UnRealizedPnl float64 `json:"unrealized_pnl,string"` // 全仓模式 未实现盈亏 Margin float64 `json:"margin,string"` // 保证金(挂单冻结+持仓已用) }
type FuturesCurrencyAccountV0 ¶
type FuturesCurrencyAccountV0 struct { BizWarmTips Result MarginMode string CrossAccount FuturesCrossAccount FixedAccount FuturesFixedAccount }
type FuturesCurrencyLedger ¶
type FuturesCurrencyLedger struct { LedgerId int64 `json:"ledger_id,string"` Amount float64 `json:"amount,string"` Balance float64 `json:"balance,string"` Currency string `json:"currency"` Type string `json:"type"` Timestamp string `json:"timestamp"` Details FuturesCurrencyLedgerDetails `json:"details"` }
type FuturesFillResult ¶
type FuturesFillResult struct { TradeId int64 `json:"trade_id,string"` InstrumentId string `json:"instrument_id"` Price float64 `json:"price,string"` OrderQty float64 `json:"order_qty,string"` OrderId string `json:"order_id"` CreatedAt string `json:"created_at"` ExecType string `json:"exec_type"` Fee float64 `json:"fee,string"` Side string `json:"side"` }
type FuturesFillsParams ¶
type FuturesFixedAccount ¶
type FuturesFixedAccount struct { MarginMode string `json:"margin_mode"` Equity float64 `json:"equity,string"` TotalAvailBalance float64 `json:"total_avail_balance,string"` Contracts []FuturesFixedAccountContracts `json:"contracts"` }
type FuturesFixedAccountContracts ¶
type FuturesFixedAccountContracts struct { AvailableQty float64 `json:"available_qty,string"` FixedBalance float64 `json:"fixed_balance,string"` InstrumentId string `json:"instrument_id"` MarginFixed float64 `json:"margin_fixed,string"` MarginForUnfilled float64 `json:"margin_for_unfilled,string"` MarginFrozen float64 `json:"margin_frozen,string"` RealizedPnl float64 `json:"realized_pnl,string"` UnrealizedPnl float64 `json:"unrealizedPnl,string"` }
type FuturesFixedAccountInfo ¶
type FuturesFixedAccountInfo struct { Result Info map[string]FuturesFixedAccount `json:"info"` }
type FuturesFixedPosition ¶
type FuturesFixedPosition struct { Result MarginMode string `json:"margin_mode"` FixedPosition []FuturesFixedPositionHolding `json:"holding"` }
type FuturesFixedPositionHolding ¶
type FuturesFixedPositionHolding struct { FuturesPositionBase LongMargin float64 `json:"long_margin,string"` LongLiquiPrice float64 `json:"long_liqui_price,string"` LongPnlRatio float64 `json:"long_pnl_ratio,string"` LongLeverage float64 `json:"long_leverage,string"` ShortMargin float64 `json:"short_margin,string"` ShortLiquiPrice float64 `json:"short_liqui_price,string"` ShortPnlRatio float64 `json:"short_pnl_ratio,string"` ShortLeverage float64 `json:"short_leverage,string"` }
type FuturesGetOrderResult ¶
type FuturesGetOrderResult struct { InstrumentId string `json:"instrument_id"` Size int64 `json:"size,string"` Timestamp string `json:"timestamp"` FilledQty float64 `json:"filled_qty,string"` Fee float64 `json:"fee,string"` OrderId string `json:"order_id"` ClientOId string `json:"client_oid"` Price float64 `json:"price,string"` PriceAvg float64 `json:"price_avg,string"` Status string `json:"status"` State int `json:"state,string"` Type int `json:"type,string"` OrderType int `json:"order_type,string"` ContractVal float64 `json:"contract_val,string"` Leverage float64 `json:"leverage,string"` }
type FuturesGetOrdersResult ¶
type FuturesGetOrdersResult struct { Result Orders []FuturesGetOrderResult `json:"order_info"` }
type FuturesInstrumentLiquidationListResult ¶
type FuturesInstrumentLiquidationListResult struct { Page PageResult LiquidationList []FuturesInstrumentLiquidationResult }
type FuturesInstrumentTickerResult ¶
type FuturesInstrumentTickerResult struct { InstrumentId string `json:"instrument_id"` BestBid float64 `json:"best_bid,string"` BestAsk float64 `json:"best_ask,string"` High24h float64 `json:"high_24h,string"` Low24h float64 `json:"low_24h,string"` Last float64 `json:"last,string"` Volume24h float64 `json:"volume_24h,string"` Timestamp string `json:"timestamp"` }
type FuturesInstrumentsResult ¶
type FuturesInstrumentsResult struct { InstrumentId string `json:"instrument_id"` UnderlyingIndex string `json:"underlying_index"` QuoteCurrency string `json:"quote_currency"` TickSize float64 `json:"tick_size,string"` ContractVal float64 `json:"contract_val,string"` Listing string `json:"listing"` Delivery string `json:"delivery"` TradeIncrement float64 `json:"trade_increment,string"` Alias string `json:"alias"` Underlying string `json:"underlying"` BaseCurrency string `json:"base_currency"` SettlementCurrency string `json:"settlement_currency"` IsInverse bool `json:"is_inverse,string"` ContractValCurrency string `json:"contract_val_currency"` }
type FuturesMarkdown ¶
type FuturesMarkdown struct { BizWarmTips InstrumentId string `json:"instrument_id"` Timestamp string `json:"timestamp"` MarkPrice float32 `json:"mark_price"` }
type FuturesNewOrderParams ¶
type FuturesNewOrderParams struct { InstrumentId string `json:"instrument_id"` Leverage string `json:"leverage"` FuturesBatchNewOrderItem }
Create a new order ClientOid: You setting order id.(optional) Type: The execution type @see file: futures_constants.go InstrumentId: The id of the futures, eg: BTC_USD_0331 Price: The order price: Maximum 1 million Amount: The order amount: Maximum 1 million MatchPrice: Match best counter party price (BBO)? 0: No 1: Yes If yes, the 'price' field is ignored LeverRate: lever, default 10.
type FuturesNewOrderResult ¶
type FuturesNewOrderResult struct { BizWarmTips Result ClientOid string `json:"client_oid"` OrderId string `json:"order_id"` }
type FuturesOrdersParams ¶
Order status: 0: waiting for transaction 1: 1: part of the deal 2: all transactions 3: cancelling 4: canceled. Currency: futures currencies @see file: futures_constants.go
type FuturesPosition ¶
type FuturesPosition struct { BizWarmTips Result MarginMode string CrossPosition []FuturesCrossPositionHolding FixedPosition []FuturesFixedPositionHolding }
type FuturesPositionBase ¶
type FuturesPositionBase struct { LongQty float64 `json:"long_qty,string"` LongAvailQty float64 `json:"long_avail_qty,string"` LongAvgCost float64 `json:"long_avg_cost,string"` LongSettlementPrice float64 `json:"long_settlement_price,string"` RealizedPnl float64 `json:"realized_pnl,string"` ShortQty float64 `json:"short_qty,string"` ShortAvailQty float64 `json:"short_avail_qty,string"` ShortAvgCost float64 `json:"short_avg_cost,string"` ShortSettlementPrice float64 `json:"short_settlement_price,string"` InstrumentId string `json:"instrument_id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type FuturesUsersSelfTrailingVolumesResult ¶
type FuturesUsersSelfTrailingVolumesResult struct {
FuturesUsersSelfTrailingVolumeResult []FuturesUsersSelfTrailingVolumeResult
}
type FuturesWS ¶
func NewFuturesWS ¶
func NewFuturesWS(wsURL string, accessKey string, secretKey string, passphrase string, debugMode bool) *FuturesWS
NewFuturesWS 创建合约WS wsURL: wss://real.okex.com:8443/ws/v3
func (*FuturesWS) SetAccountCallback ¶
func (*FuturesWS) SetDepth20SnapshotCallback ¶
func (*FuturesWS) SetDepthL2TbtCallback ¶
func (ws *FuturesWS) SetDepthL2TbtCallback(callback func(action string, data []WSDepthL2Tbt))
func (*FuturesWS) SetOrderCallback ¶
func (*FuturesWS) SetPositionCallback ¶
func (ws *FuturesWS) SetPositionCallback(callback func(positions []WSFuturesPosition))
func (*FuturesWS) SetProxy ¶
SetProxy 设置代理地址 porxyURL: socks5://127.0.0.1:1080 https://127.0.0.1:1080
func (*FuturesWS) SetTickerCallback ¶
func (*FuturesWS) SetTradeCallback ¶
func (*FuturesWS) SubscribeAccount ¶
func (*FuturesWS) SubscribeDepthL2Tbt ¶
SubscribeDepthL2Tbt 公共-400档增量数据频道 订阅后首次返回市场订单簿的400档深度数据并推送;后续只要订单簿深度有变化就推送有更改的数据。
func (*FuturesWS) SubscribeOrder ¶
func (*FuturesWS) SubscribePosition ¶
func (*FuturesWS) SubscribeTicker ¶
func (*FuturesWS) SubscribeTrade ¶
type GetFuturesAccountsResult ¶
type GetFuturesAccountsResult struct { Info struct { Btc FuturesAccountsContract `json:"btc"` Eth FuturesAccountsContract `json:"eth"` Etc FuturesAccountsContract `json:"etc"` Ltc FuturesAccountsContract `json:"ltc"` Xrp FuturesAccountsContract `json:"xrp"` Bsv FuturesAccountsContract `json:"bsv"` Trx FuturesAccountsContract `json:"trx"` Bch FuturesAccountsContract `json:"bch"` Eos FuturesAccountsContract `json:"eos"` BtcUSDT FuturesAccountsContract `json:"btc-usdt"` EthUSDT FuturesAccountsContract `json:"eth-usdt"` EtcUSDT FuturesAccountsContract `json:"etc-usdt"` LtcUSDT FuturesAccountsContract `json:"ltc-usdt"` XrpUSDT FuturesAccountsContract `json:"xrp-usdt"` BsvUSDT FuturesAccountsContract `json:"bsv-usdt"` TrxUSDT FuturesAccountsContract `json:"trx-usdt"` BchUSDT FuturesAccountsContract `json:"bch-usdt"` EosUSDT FuturesAccountsContract `json:"eos-usdt"` } `json:"info"` }
type GetMarginAccountsAvailabilityByInstrumentIdResult ¶
type GetMarginAccountsAvailabilityByInstrumentIdResult []struct { CurrencyBTC GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:BTC"` CurrencyLTC GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:LTC"` CurrencyETH GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:ETH"` CurrencyETC GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:ETC"` CurrencyBCH GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:BCH"` CurrencyEOS GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:EOS"` //CurrencyXRP GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:XRP"` CurrencyUSDT GetMarginAccountsAvailabilityByInstrumentIdItem `json:"currency:USDT"` InstrumentID string `json:"instrument_id"` ProductID string `json:"product_id"` }
type GetMarginAccountsBorrowedByInstrumentIdItem ¶
type GetMarginAccountsBorrowedByInstrumentIdItem struct { Amount float64 `json:"amount,string"` BorrowID string `json:"borrow_id"` CreatedAt time.Time `json:"created_at"` Currency string `json:"currency"` ForceRepayTime time.Time `json:"force_repay_time"` InstrumentID string `json:"instrument_id"` Interest float64 `json:"interest,string"` LastInterestTime time.Time `json:"last_interest_time"` PaidInterest float64 `json:"paid_interest,string"` ProductID string `json:"product_id"` Rate float64 `json:"rate,string"` RepayAmount float64 `json:"repay_amount,string"` RepayInterest float64 `json:"repay_interest,string"` ReturnedAmount float64 `json:"returned_amount,string"` Timestamp time.Time `json:"timestamp"` }
type GetMarginAccountsBorrowedByInstrumentIdResult ¶
type GetMarginAccountsBorrowedByInstrumentIdResult []GetMarginAccountsBorrowedByInstrumentIdItem
type GetMarginAccountsByInstrumentItem ¶
type GetMarginAccountsByInstrumentItem struct { Available float64 `json:"available,string"` // 可用于交易的数量 Balance float64 `json:"balance,string"` // 余额 Borrowed float64 `json:"borrowed,string"` // 已借币(已借未还的部分) CanWithdraw float64 `json:"can_withdraw,string"` // 可划转数量 Frozen float64 `json:"frozen,string"` Hold float64 `json:"hold,string"` // 冻结(不可用) Holds float64 `json:"holds,string"` LendingFee float64 `json:"lending_fee,string"` // 利息(未还的利息) }
type GetMarginAccountsByInstrumentResult ¶
type GetMarginAccountsByInstrumentResult struct { CurrencyBTC GetMarginAccountsByInstrumentItem `json:"currency:BTC"` CurrencyLTC GetMarginAccountsByInstrumentItem `json:"currency:LTC"` CurrencyETH GetMarginAccountsByInstrumentItem `json:"currency:ETH"` CurrencyETC GetMarginAccountsByInstrumentItem `json:"currency:ETC"` CurrencyBCH GetMarginAccountsByInstrumentItem `json:"currency:BCH"` CurrencyEOS GetMarginAccountsByInstrumentItem `json:"currency:EOS"` CurrencyXRP GetMarginAccountsByInstrumentItem `json:"currency:XRP"` CurrencyUSDT GetMarginAccountsByInstrumentItem `json:"currency:USDT"` LiquidationPrice float64 `json:"liquidation_price,string"` MarginRatio string `json:"margin_ratio"` RiskRate string `json:"risk_rate"` }
type GetMarginAccountsItem ¶
type GetMarginAccountsItem struct { CurrencyBTC MarginCurrency `json:"currency:BTC,omitempty"` CurrencyUSDT MarginCurrency `json:"currency:USDT,omitempty"` InstrumentID string `json:"instrument_id"` LiquidationPrice string `json:"liquidation_price"` MarginRatio string `json:"margin_ratio"` ProductID string `json:"product_id"` RiskRate string `json:"risk_rate"` CurrencyLTC MarginCurrency `json:"currency:LTC,omitempty"` CurrencyETH MarginCurrency `json:"currency:ETH,omitempty"` CurrencyETC MarginCurrency `json:"currency:ETC,omitempty"` CurrencyBCH MarginCurrency `json:"currency:BCH,omitempty"` CurrencyEOS MarginCurrency `json:"currency:EOS,omitempty"` CurrencyXRP MarginCurrency `json:"currency:XRP,omitempty"` CurrencyTRX MarginCurrency `json:"currency:TRX,omitempty"` CurrencyBSV MarginCurrency `json:"currency:BSV,omitempty"` CurrencyDASH MarginCurrency `json:"currency:DASH,omitempty"` CurrencyNEO MarginCurrency `json:"currency:NEO,omitempty"` CurrencyQTUM MarginCurrency `json:"currency:QTUM,omitempty"` CurrencyIOST MarginCurrency `json:"currency:IOST,omitempty"` }
type GetMarginAccountsResult ¶
type GetMarginAccountsResult []GetMarginAccountsItem
type GetSpotAccountsResult ¶
type GetSpotAccountsResult []GetSpotAccountsResultItem
type IndexConstituents ¶
type IndexConstituents struct { Last string `json:"last"` Constituents []Constituent `json:"constituents"` InstrumentID string `json:"instrument_id"` Timestamp time.Time `json:"timestamp"` }
type IndexConstituentsResult ¶
type IndexConstituentsResult struct { Code int `json:"code"` Data IndexConstituents `json:"data"` DetailMsg string `json:"detailMsg"` Msg string `json:"msg"` }
type Item ¶
func (Item) ExtractKey ¶
type MarginCurrency ¶
type MarginGetOrderResult ¶
type MarginGetOrderResult struct { ClientOid string `json:"client_oid"` CreatedAt time.Time `json:"created_at"` FilledNotional sjson.Number `json:"filled_notional"` FilledSize sjson.Number `json:"filled_size"` Funds string `json:"funds"` InstrumentID string `json:"instrument_id"` Notional string `json:"notional"` OrderID string `json:"order_id"` OrderType sjson.Number `json:"order_type"` /*int*/ Price sjson.Number `json:"price"` PriceAvg sjson.Number `json:"price_avg"` ProductID string `json:"product_id"` Side string `json:"side"` Size sjson.Number `json:"size"` Status string `json:"status"` // status为state旧版参数,会短期兼容,建议尽早切换state State sjson.Number `json:"state"` /*int*/ // -2:失败 -1:撤单成功 0:等待成交 1:部分成交 2:完全成交 3:下单中 4:撤单中 Timestamp time.Time `json:"timestamp"` Type string `json:"type"` }
func (*MarginGetOrderResult) GetState ¶
func (r *MarginGetOrderResult) GetState() int64
type MarginNewOrderResult ¶
type OrderInfo ¶
type OrderInfo struct { ClientOid string `json:"client_oid"` OrderId string `json:"order_id"` CodeMessage }
If OrderId = -1, ErrorCode > 0, error order
type PageResult ¶
type PlaceOrderInfo ¶
type PlaceOrderInfo struct { BasePlaceOrderInfo InstrumentId string `json:"instrument_id"` }
type PlaceOrdersInfo ¶
type PlaceOrdersInfo struct { InstrumentId string `json:"instrument_id"` OrderData []*BasePlaceOrderInfo `json:"order_data"` }
type ReceivedDataCallback ¶
type ReceivedDataCallback func(interface{}) error
type ServerTime ¶
type SpotGetOrderResult ¶
type SpotGetOrderResult struct { ClientOid string `json:"client_oid"` CreatedAt time.Time `json:"created_at"` FilledNotional float64 `json:"filled_notional,string"` FilledSize float64 `json:"filled_size,string"` Funds string `json:"funds"` InstrumentID string `json:"instrument_id"` Notional string `json:"notional"` OrderID string `json:"order_id"` OrderType string `json:"order_type"` Price string `json:"price"` ProductID string `json:"product_id"` Side string `json:"side"` Size string `json:"size"` Status string `json:"status"` State int `json:"state,string"` Timestamp time.Time `json:"timestamp"` Type string `json:"type"` }
type SpotInstrumentBookResult ¶
type SpotInstrumentBookResult struct { Asks [][]string `json:"asks"` Bids [][]string `json:"bids"` Timestamp string `json:"timestamp"` }
price String 价格 size String 数量 num_orders String 组成此条深度的订单数量
type SpotNewOrderResult ¶
type SubscriptionTopic ¶
type SubscriptionTopic struct {
// contains filtered or unexported fields
}
func (*SubscriptionTopic) ToString ¶
func (st *SubscriptionTopic) ToString() (topic string, err error)
type SwapAccount ¶
type SwapAccount struct {
Info SwapAccountInfo `json:"info"`
}
type SwapAccountHolds ¶
type SwapAccountHolds BaseInstrumentAmount
type SwapAccountInfo ¶
type SwapAccountInfo struct { InstrumentId string `json:"instrument_id"` Timestamp string `json:"timestamp"` MarginFrozen string `json:"margin_frozen"` TotalAvailBalance string `json:"total_avail_balance"` MarginRatio string `json:"margin_ratio"` RealizedPnl string `json:"realized_pnl"` UnrealizedPnl string `json:"unrealized_pnl"` FixedBalance string `json:"fixed_balance"` Equity string `json:"equity"` Margin string `json:"margin"` MarginMode string `json:"margin_mode"` }
type SwapAccounts ¶
type SwapAccounts struct { BizWarmTips Info []SwapAccountInfo `json:"info"` }
type SwapAccountsLedgerList ¶
type SwapAccountsLedgerList []BaseLedgerInfo
type SwapAccountsSetting ¶
type SwapAccountsSetting struct { BizWarmTips InstrumentId string `json:"instrument_id"` LongLeverage string `json:"long_leverage"` ShortLeverage string `json:"short_leverage"` MarginMode string `json:"margin_mode"` }
type SwapBatchCancelOrderResult ¶
type SwapBatchCancelOrderResult struct { BizWarmTips InstrumentId string `json:"instrument_id"` Ids []string `json:"ids"` Result string `json:"result"` }
type SwapCancelOrderResult ¶
type SwapCandleList ¶
type SwapCandleList []BaseCandleInfo
type SwapFillsInfo ¶
type SwapFillsInfo []BaseFillInfo
type SwapFundingTime ¶
type SwapFundingTime struct { BizWarmTips InstrumentId string `json:"instrument_id"` FundingTime string `json:"funding_time"` }
type SwapHistoricalFundingRateList ¶
type SwapHistoricalFundingRateList []BaseHistoricalFundingRate
type SwapIndexInfo ¶
type SwapIndexInfo struct { BizWarmTips InstrumentId string `json:"instrument_id"` Index string `json:"index"` Timestamp string `json:"timestamp"` }
type SwapInstrumentDepth ¶
type SwapInstrumentDepth struct { BizWarmTips Timestamp string `json:"timestamp"` Time string `json:"time"` Bids [][]string `json:"bids"` Asks [][]string `json:"asks"` }
type SwapInstrumentList ¶
type SwapInstrumentList []BaseInstrumentInfo
type SwapLiquidationList ¶
type SwapLiquidationList []BaseLiquidationInfo
type SwapMarkPrice ¶
type SwapMarkPrice struct { BizWarmTips InstrumentId string `json:"instrument_id"` MarkPrice string `json:"mark_price"` Timestamp string `json:"timestamp"` }
type SwapOpenInterest ¶
type SwapOpenInterest BaseInstrumentAmount
type SwapOrderResult ¶
type SwapOrderResult struct { BaseSwapOrderResult BizWarmTips }
type SwapOrdersInfo ¶
type SwapOrdersInfo struct { BizWarmTips OrderInfo []BaseOrderInfo `json:"order_info"` }
type SwapOrdersResult ¶
type SwapOrdersResult struct { BizWarmTips OrderInfo []BaseSwapOrderResult `json:"order_info"` }
type SwapPosition ¶
type SwapPosition struct { BizWarmTips MarginMode string `json:"margin_mode"` Holding []SwapPositionHolding `json:"holding"` }
type SwapPositionHolding ¶
type SwapPositionHolding struct { LiquidationPrice string `json:"liquidation_price"` Position string `json:"position"` AvailPosition string `json:"avail_position"` AvgCost string `json:"avg_cost"` SettlementPrice string `json:"settlement_price"` InstrumentId string `json:"instrument_id"` Leverage string `json:"leverage"` RealizedPnl string `json:"realized_pnl"` Side string `json:"side"` Timestamp string `json:"timestamp"` Margin string `json:"margin";default:""` }
type SwapPositionList ¶
type SwapPositionList []SwapPosition
type SwapPriceLimit ¶
type SwapPriceLimit struct { BizWarmTips InstrumentId string `json:"instrument_id"` Lowest string `json:"lowest"` Highest string `json:"highest"` Timestamp string `json:"timestamp"` }
type SwapTickerList ¶
type SwapTickerList []BaseTickerInfo
type SwapTradeList ¶
type SwapTradeList []BaseTradeInfo
type SwapWS ¶
func NewSwapWS ¶
func NewSwapWS(wsURL string, accessKey string, secretKey string, passphrase string, debugMode bool) *SwapWS
NewSwapWS 创建永续合约WS wsURL: wss://real.okex.com:8443/ws/v3
func (*SwapWS) SetAccountCallback ¶
func (*SwapWS) SetDepth20SnapshotCallback ¶
func (*SwapWS) SetDepthL2TbtCallback ¶
func (ws *SwapWS) SetDepthL2TbtCallback(callback func(action string, data []WSDepthL2Tbt))
func (*SwapWS) SetOrderCallback ¶
func (*SwapWS) SetPositionCallback ¶
func (ws *SwapWS) SetPositionCallback(callback func(position []WSSwapPositionData))
func (*SwapWS) SetProxy ¶
SetProxy 设置代理地址 porxyURL: socks5://127.0.0.1:1080 https://127.0.0.1:1080
func (*SwapWS) SetTickerCallback ¶
func (*SwapWS) SetTradeCallback ¶
func (*SwapWS) SubscribeAccount ¶
func (*SwapWS) SubscribeDepthL2Tbt ¶
SubscribeDepthL2Tbt 公共-400档增量数据频道 订阅后首次返回市场订单簿的400档深度数据并推送;后续只要订单簿深度有变化就推送有更改的数据。
func (*SwapWS) SubscribePosition ¶
type WSAccount ¶
type WSAccount struct { Available string `json:"available"` CanWithdraw string `json:"can_withdraw"` Currency string `json:"currency"` Equity string `json:"equity"` LiquiMode string `json:"liqui_mode"` MaintMarginRatio string `json:"maint_margin_ratio"` Margin string `json:"margin"` MarginForUnfilled string `json:"margin_for_unfilled"` MarginFrozen string `json:"margin_frozen"` MarginMode string `json:"margin_mode"` MarginRatio string `json:"margin_ratio"` OpenMax string `json:"open_max"` RealizedPnl string `json:"realized_pnl"` Timestamp time.Time `json:"timestamp"` TotalAvailBalance string `json:"total_avail_balance"` Underlying string `json:"underlying"` UnrealizedPnl string `json:"unrealized_pnl"` }
type WSAccountData ¶
type WSAccountResult ¶
type WSAccountResult struct { Table string `json:"table"` Data []WSAccountData `json:"data"` }
type WSDepthItem ¶
type WSDepthL2Tbt ¶
type WSDepthL2TbtResult ¶
type WSDepthL2TbtResult struct { Table string `json:"table"` Action string `json:"action"` Data []WSDepthL2Tbt `json:"data"` }
type WSDepthTableResponse ¶
type WSDepthTableResponse struct { Table string `json:"table"` Action string `json:"action",default:""` Data []WSDepthItem `json:"data"` }
func (*WSDepthTableResponse) Valid ¶
func (r *WSDepthTableResponse) Valid() bool
type WSErrorResponse ¶
type WSErrorResponse struct { Event string `json:"event"` Message string `json:"message"` ErrorCode int `json:"errorCode"` }
func (*WSErrorResponse) Valid ¶
func (r *WSErrorResponse) Valid() bool
type WSEventResponse ¶
type WSEventResponse struct { Event string `json:"event"` Success string `json:success` Channel string `json:"channel"` }
func (*WSEventResponse) Valid ¶
func (r *WSEventResponse) Valid() bool
type WSFuturesPosition ¶
type WSFuturesPosition struct { LongQty string `json:"long_qty"` LongAvailQty string `json:"long_avail_qty"` LongMargin string `json:"long_margin"` LongLiquiPrice string `json:"long_liqui_price"` LongPnlRatio string `json:"long_pnl_ratio"` LongAvgCost string `json:"long_avg_cost"` LongSettlementPrice string `json:"long_settlement_price"` RealisedPnl string `json:"realised_pnl"` ShortQty string `json:"short_qty"` ShortAvailQty string `json:"short_avail_qty"` ShortMargin string `json:"short_margin"` ShortLiquiPrice string `json:"short_liqui_price"` ShortPnlRatio string `json:"short_pnl_ratio"` ShortAvgCost string `json:"short_avg_cost"` ShortSettlementPrice string `json:"short_settlement_price"` InstrumentID string `json:"instrument_id"` LongLeverage string `json:"long_leverage"` ShortLeverage string `json:"short_leverage"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Timestamp time.Time `json:"timestamp"` MarginMode string `json:"margin_mode"` ShortMarginRatio string `json:"short_margin_ratio"` ShortMaintMarginRatio string `json:"short_maint_margin_ratio"` ShortPnl string `json:"short_pnl"` ShortUnrealisedPnl string `json:"short_unrealised_pnl"` LongMarginRatio string `json:"long_margin_ratio"` LongMaintMarginRatio string `json:"long_maint_margin_ratio"` LongPnl string `json:"long_pnl"` LongUnrealisedPnl string `json:"long_unrealised_pnl"` LongOpenOutstanding string `json:"long_open_outstanding"` ShortOpenOutstanding string `json:"short_open_outstanding"` LongSettledPnl string `json:"long_settled_pnl"` ShortSettledPnl string `json:"short_settled_pnl"` Last string `json:"last"` }
type WSFuturesPositionResult ¶
type WSFuturesPositionResult struct { Table string `json:"table"` Data []WSFuturesPosition `json:"data"` }
type WSHotDepths ¶
type WSHotDepths struct { Table string DepthMap map[string]*WSDepthItem }
func NewWSHotDepths ¶
func NewWSHotDepths(tb string) *WSHotDepths
type WSOrder ¶
type WSOrder struct { Leverage string `json:"leverage"` LastFillTime time.Time `json:"last_fill_time"` FilledQty string `json:"filled_qty"` Fee string `json:"fee"` PriceAvg string `json:"price_avg"` Type string `json:"type"` ClientOid string `json:"client_oid"` LastFillQty string `json:"last_fill_qty"` InstrumentID string `json:"instrument_id"` LastFillPx string `json:"last_fill_px"` Pnl string `json:"pnl"` Size string `json:"size"` Price string `json:"price"` LastFillID string `json:"last_fill_id"` ErrorCode string `json:"error_code"` State string `json:"state"` ContractVal string `json:"contract_val"` OrderID string `json:"order_id"` OrderType string `json:"order_type"` Timestamp time.Time `json:"timestamp"` Status string `json:"status"` }
type WSOrderResult ¶
type WSSwapPositionData ¶
type WSSwapPositionData struct { Holding []WSSwapPositionHolding `json:"holding"` InstrumentID string `json:"instrument_id"` MarginMode string `json:"margin_mode"` Timestamp time.Time `json:"timestamp"` }
type WSSwapPositionHolding ¶
type WSSwapPositionHolding struct { AvailPosition string `json:"avail_position"` AvgCost string `json:"avg_cost"` Last string `json:"last"` Leverage string `json:"leverage"` LiquidationPrice string `json:"liquidation_price"` MaintMarginRatio string `json:"maint_margin_ratio"` Margin string `json:"margin"` Position string `json:"position"` RealizedPnl string `json:"realized_pnl"` SettledPnl string `json:"settled_pnl"` SettlementPrice string `json:"settlement_price"` Side string `json:"side"` Timestamp time.Time `json:"timestamp"` }
type WSSwapPositionResult ¶
type WSSwapPositionResult struct { Table string `json:"table"` Data []WSSwapPositionData `json:"data"` }
type WSTableResponse ¶
type WSTableResponse struct { Table string `json:"table"` Action string `json:"action",default:""` Data []interface{} `json:"data"` }
func (*WSTableResponse) Valid ¶
func (r *WSTableResponse) Valid() bool
type WSTicker ¶
type WSTicker struct { Last string `json:"last"` Open24H string `json:"open_24h"` BestBid string `json:"best_bid"` High24H string `json:"high_24h"` Low24H string `json:"low_24h"` Volume24H string `json:"volume_24h"` VolumeToken24H string `json:"volume_token_24h"` BestAsk string `json:"best_ask"` OpenInterest string `json:"open_interest"` InstrumentID string `json:"instrument_id"` Timestamp time.Time `json:"timestamp"` BestBidSize string `json:"best_bid_size"` BestAskSize string `json:"best_ask_size"` LastQty string `json:"last_qty"` }
type WSTickerResult ¶
type WSTradeResult ¶
Source Files ¶
- account_rest_api.go
- base.go
- client.go
- config.go
- constants.go
- cursor_page.go
- futures_api.go
- futures_constants.go
- futures_params.go
- futures_results.go
- futures_ws.go
- futures_ws_results.go
- general_api.go
- index_api.go
- margin_rest_api.go
- margin_rest_results.go
- margin_results.go
- orderbook.go
- outer_api.go
- spot_rest_api.go
- spot_results.go
- swap_api.go
- swap_params.go
- swap_results.go
- swap_ws.go
- swap_ws_results.go
- test_helper.go
- uri_constants.go
- utils.go
- ws_base.go
- ws_results.go