okex

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 12 Imported by: 0

README

#使用特定交易所的API可以获取更多的接口实现

var okex = NewOKEx(&goex.APIConfig{
                    	Endpoint: "https://www.okex.com",
                    	//HttpClient: &http.Client{
                    	//	Transport: &http.Transport{
                    	//		Proxy: func(req *http.Request) (*url.URL, error) {
                    	//			return &url.URL{
                    	//				Scheme: "socks5",
                    	//				Host:   "127.0.0.1:1080"}, nil
                    	//		},
                    	//	},
                    	//},
                    	ApiKey:        "",
                    	ApiSecretKey:  "",
                    	ApiPassphrase: "",
                    })
 var (
   okexSpot = okex.OKExSpot
   okexSwap = okex.OKExSwap   //永续合约实现
   okexFuture=okex.OKExFuture //交割合约实现
   okexWallet =okex.OKExWallet //资金账户(钱包)操作
   )
 
  //接口调用,更多接口调用请看代码
  log.Prinitln(okexSpot.GetAccount()) //获取账户资产信息
  //okexSpot.BatchPlaceOrders([]goex.Order{...}) //批量下单,单个交易对同时最大只能下10笔
  log.Println(okexSwap.GetFutureUserinfo()) //获取账户权益信息
  log.Println(okexFuture.GetFutureUserinfo())//获取账户权益信息
  

Documentation

Index

Constants

View Source
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"

	BTC_USD_SWAP = "BTC-USD-SWAP"
	LTC_USD_SWAP = "LTC-USD-SWAP"
	ETH_USD_SWAP = "ETH-USD-SWAP"
	ETC_USD_SWAP = "ETC-USD-SWAP"
	BCH_USD_SWAP = "BCH-USD-SWAP"
	BSV_USD_SWAP = "BSV-USD-SWAP"
	EOS_USD_SWAP = "EOS-USD-SWAP"
	XRP_USD_SWAP = "XRP-USD-SWAP"

	/*Rest Endpoint*/
	Endpoint              = "https://www.okex.com"
	GET_ACCOUNTS          = "/api/swap/v3/accounts"
	PLACE_ORDER           = "/api/swap/v3/order"
	CANCEL_ORDER          = "/api/swap/v3/cancel_order/%s/%s"
	GET_ORDER             = "/api/swap/v3/orders/%s/%s"
	GET_POSITION          = "/api/swap/v3/%s/position"
	GET_DEPTH             = "/api/swap/v3/instruments/%s/depth?size=%d"
	GET_TICKER            = "/api/swap/v3/instruments/%s/ticker"
	GET_UNFINISHED_ORDERS = "/api/swap/v3/orders/%s?status=%d&limit=%d"
)
View Source
const (
	SUB_ACCOUNT = iota //子账户
	SPOT               // 币币交易

	FUTURE      //交割合约
	C2C         //法币
	SPOT_MARGIN //币币杠杆交易
	WALLET      // 资金账户

	TIPS //余币宝
	SWAP //永续合约
)
View Source
const (
	WITHDRAWAL_OKCOIN int = 2 //提币到okcoin国际站
	WITHDRAWAL_OKEx       = 3 //提币到okex,站内提币
	WITHDRAWAL_COIN       = 4 //提币到数字货币地址,跨平台提币或者提到自己钱包
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllFutureContractInfo

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

type BaesDepthInfo

type BaesDepthInfo []interface{}

type BaseCandleInfo

type BaseCandleInfo []interface{}

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 BaseHistoricalFundingRate

type BaseHistoricalFundingRate struct {
	InstrumentId string `json:"instrument_id"`
	InterestRate string `json:"interest_rate"`
	FundingRate  string `json:"funding_rate"`
	FundingTime  string `json:"funding_time"`
	RealizedRate string `json:"realized_rate"`
}

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 BaseLedgerInfo struct {
	InstrumentId string `json:"instrument_id"`
	Fee          string `json:"fee"`
	Timestamp    string `json:"timestamp"`
	Amount       string `json:"amount"`
	LedgerId     string `json:"ledger_id"`
	Type         string `json:"type"`
}

type BaseLiquidationInfo

type BaseLiquidationInfo struct {
	InstrumentId string `json:"instrument_id"`
	Loss         string `json:"loss"`
	CreatedAt    string `json:"created_at"`
	Type         string `json:"type"`
	Price        string `json:"price"`
	Size         string `json:"size"`
}

type BaseOrderInfo

type BaseOrderInfo struct {
	InstrumentId string  `json:"instrument_id"`
	Status       int     `json:"status,string"`
	OrderId      string  `json:"order_id"`
	ClientOid    string  `json:"client_oid"`
	Timestamp    string  `json:"timestamp"`
	Price        float64 `json:"price,string"`
	PriceAvg     float64 `json:"price_avg,string"`
	Size         float64 `json:"size,string"`
	Fee          float64 `json:"fee,string"`
	FilledQty    float64 `json:"filled_qty,string"`
	ContractVal  string  `json:"contract_val"`
	Type         int     `json:"type,string"`
}

type BasePlaceOrderInfo

type BasePlaceOrderInfo struct {
	ClientOid  string `json:"client_oid"`
	Price      string `json:"price"`
	MatchPrice string `json:"match_price"`
	Type       string `json:"type"`
	Size       string `json:"size"`
}

type BaseResponse

type BaseResponse struct {
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
	Result       bool   `json:"result,string"`
}

type BaseSwapOrderResult

type BaseSwapOrderResult struct {
	OrderId      string `json:"order_id"`
	ClientOid    string `json:"client_oid"`
	ErrorMessage string `json:"error_message"`
	ErrorCode    string `json:"error_code"`
	Result       string `json:"result"`
}

type BaseTickerInfo

type BaseTickerInfo struct {
	InstrumentId string  `json:"instrument_id"`
	Last         float64 `json:"last,string"`
	Timestamp    string  `json:"timestamp"`
	High24h      float64 `json:"high_24h,string"`
	Volume24h    float64 `json:"volume_24h,string"`
	Low24h       float64 `json:"low_24h,string"`
}

type BaseTradeInfo

type BaseTradeInfo struct {
	Timestamp string `json:"timestamp"`
	TradeId   string `json:"trade_id"`
	Side      string `json:"side"`
	Price     string `json:"price"`
	Size      string `json:"size"`
}

type BizWarmTips

type BizWarmTips struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type CrossedAccountInfo

type CrossedAccountInfo struct {
	MarginMode string  `json:"margin_mode"`
	Equity     float64 `json:"equity,string"`
}

type DepositAddress

type DepositAddress struct {
	Address     string `json:"address"`
	Tag         string `json:"tag"`
	PaymentId   string `json:"payment_id"`
	Currency    string `json:"currency"`
	CanDeposit  int    `json:"can_deposit"`
	CanWithdraw int    `json:"can_withdraw"`
	Memo        string `json:"memo"` //eos need
}

type DepositWithDrawHistory

type DepositWithDrawHistory struct {
	WithdrawalId string    `json:"withdrawal_id,omitempty"`
	Currency     string    `json:"currency"`
	Txid         string    `json:"txid"`
	Amount       float64   `json:"amount,string"`
	From         string    `json:"from,omitempty"`
	To           string    `json:"to"`
	Memo         string    `json:"memo,omitempty"`
	Fee          string    `json:"fee"`
	Status       int       `json:"status,string"`
	Timestamp    time.Time `json:"timestamp"`
}

type FutureContractInfo

type FutureContractInfo struct {
	InstrumentID    string  `json:"instrument_id"` //合约ID:如BTC-USD-180213
	UnderlyingIndex string  `json:"underlying_index"`
	QuoteCurrency   string  `json:"quote_currency"`
	TickSize        float64 `json:"tick_size,string"` //下单价格精度
	TradeIncrement  string  `json:"trade_increment"`  //数量精度
	ContractVal     string  `json:"contract_val"`     //合约面值(美元)
	Listing         string  `json:"listing"`
	Delivery        string  `json:"delivery"` //交割日期
	Alias           string  `json:"alias"`    //	本周 this_week 次周 next_week 季度 quarter
}

合约信息

type OKEx

type OKEx struct {
	OKExSpot   *OKExSpot
	OKExFuture *OKExFuture
	OKExSwap   *OKExSwap
	OKExWallet *OKExWallet
	OKExMargin *OKExMargin
	// contains filtered or unexported fields
}

func NewOKEx

func NewOKEx(config *APIConfig) *OKEx

func (*OKEx) BuildRequestBody

func (ok *OKEx) BuildRequestBody(params interface{}) (string, *bytes.Reader, error)

Get a http request body is a json string and a byte array.

func (*OKEx) CancelOrder

func (ok *OKEx) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

func (*OKEx) DoRequest

func (ok *OKEx) DoRequest(httpMethod, uri, reqBody string, response interface{}) error

func (*OKEx) GetAccount

func (ok *OKEx) GetAccount() (*Account, error)

func (*OKEx) GetDepth

func (ok *OKEx) GetDepth(size int, currency CurrencyPair) (*Depth, error)

func (*OKEx) GetExchangeName

func (ok *OKEx) GetExchangeName() string

func (*OKEx) GetKlineRecords

func (ok *OKEx) GetKlineRecords(currency CurrencyPair, period, size, since int) ([]Kline, error)

func (*OKEx) GetOneOrder

func (ok *OKEx) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

func (*OKEx) GetOrderHistorys

func (ok *OKEx) GetOrderHistorys(currency CurrencyPair, currentPage, pageSize int) ([]Order, error)

func (*OKEx) GetTicker

func (ok *OKEx) GetTicker(currency CurrencyPair) (*Ticker, error)

func (*OKEx) GetTrades

func (ok *OKEx) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*OKEx) GetUnfinishOrders

func (ok *OKEx) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*OKEx) IsoTime

func (ok *OKEx) IsoTime() string

Get a iso time

eg: 2018-03-16T18:02:48.284Z

func (*OKEx) LimitBuy

func (ok *OKEx) LimitBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKEx) LimitSell

func (ok *OKEx) LimitSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKEx) MarketBuy

func (ok *OKEx) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKEx) MarketSell

func (ok *OKEx) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKEx) UUID

func (ok *OKEx) UUID() string

type OKExFuture

type OKExFuture struct {
	*OKEx
	sync.Locker
	// contains filtered or unexported fields
}

func (*OKExFuture) FutureCancelOrder

func (ok *OKExFuture) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*OKExFuture) GetContractValue

func (ok *OKExFuture) GetContractValue(currencyPair CurrencyPair) (float64, error)

func (*OKExFuture) GetDeliveryTime

func (ok *OKExFuture) GetDeliveryTime() (int, int, int, int)

func (*OKExFuture) GetExchangeName

func (ok *OKExFuture) GetExchangeName() string

func (*OKExFuture) GetFee

func (ok *OKExFuture) GetFee() (float64, error)

func (*OKExFuture) GetFutureContractInfo

func (ok *OKExFuture) GetFutureContractInfo() ([]FutureContractInfo, error)

func (*OKExFuture) GetFutureDepth

func (ok *OKExFuture) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*OKExFuture) GetFutureEstimatedPrice

func (ok *OKExFuture) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*OKExFuture) GetFutureIndex

func (ok *OKExFuture) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*OKExFuture) GetFutureOrder

func (ok *OKExFuture) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

func (*OKExFuture) GetFutureOrders

func (ok *OKExFuture) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExFuture) GetFuturePosition

func (ok *OKExFuture) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*OKExFuture) GetFutureTicker

func (ok *OKExFuture) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*OKExFuture) GetFutureUserinfo

func (ok *OKExFuture) GetFutureUserinfo() (*FutureAccount, error)

func (*OKExFuture) GetKlineRecords

func (ok *OKExFuture) GetKlineRecords(contract_type string, currency CurrencyPair, period, size, since int) ([]FutureKline, error)

*

since : 单位秒,开始时间

func (*OKExFuture) GetRate

func (ok *OKExFuture) GetRate() (float64, error)

获取法币汇率

func (*OKExFuture) GetTrades

func (ok *OKExFuture) GetTrades(contract_type string, currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*OKExFuture) GetUnfinishFutureOrders

func (ok *OKExFuture) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExFuture) MarketCloseAllPosition

func (ok *OKExFuture) MarketCloseAllPosition(currency CurrencyPair, contract string, oType int) (bool, error)

特殊接口

市价全平仓
contract:合约ID
oType:平仓方向:CLOSE_SELL平空,CLOSE_BUY平多

func (*OKExFuture) PlaceFutureOrder

func (ok *OKExFuture) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error)

deprecated

func (*OKExFuture) PlaceFutureOrder2

func (ok *OKExFuture) PlaceFutureOrder2(matchPrice int, ord *FutureOrder) (*FutureOrder, error)

matchPrice:是否以对手价下单(0:不是 1:是),默认为0;当取值为1时,price字段无效,当以对手价下单,order_type只能选择0:普通委托

type OKExMargin

type OKExMargin struct {
	*OKEx
}

func (*OKExMargin) Borrow

func (ok *OKExMargin) Borrow(parameter BorrowParameter) (borrowId string, err error)

*

杠杆交易区借币,
pair : 操作的交易对
currency: 需要借的币种
amount : 借的金额

func (*OKExMargin) CancelOrder

func (ok *OKExMargin) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

func (*OKExMargin) GetMarginAccount

func (ok *OKExMargin) GetMarginAccount(pair CurrencyPair) (*MarginAccount, error)

func (*OKExMargin) GetOneOrder

func (ok *OKExMargin) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

orderId can set client oid or orderId

func (*OKExMargin) GetUnfinishOrders

func (ok *OKExMargin) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*OKExMargin) PlaceOrder

func (ok *OKExMargin) PlaceOrder(ord *Order) (*Order, error)

func (*OKExMargin) Repayment

func (ok *OKExMargin) Repayment(parameter RepaymentParameter) (repaymentId string, err error)

type OKExSpot

type OKExSpot struct {
	*OKEx
}

func (*OKExSpot) BatchPlaceOrders

func (ok *OKExSpot) BatchPlaceOrders(orders []Order) ([]PlaceOrderResponse, error)

* Must Set Client Oid

func (*OKExSpot) CancelOrder

func (ok *OKExSpot) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

orderId can set client oid or orderId

func (*OKExSpot) GetAccount

func (ok *OKExSpot) GetAccount() (*Account, error)

func (*OKExSpot) GetDepth

func (ok *OKExSpot) GetDepth(size int, currency CurrencyPair) (*Depth, error)

func (*OKExSpot) GetExchangeName

func (ok *OKExSpot) GetExchangeName() string

func (*OKExSpot) GetKlineRecords

func (ok *OKExSpot) GetKlineRecords(currency CurrencyPair, period, size, since int) ([]Kline, error)

func (*OKExSpot) GetOneOrder

func (ok *OKExSpot) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

orderId can set client oid or orderId

func (*OKExSpot) GetOrderHistorys

func (ok *OKExSpot) GetOrderHistorys(currency CurrencyPair, currentPage, pageSize int) ([]Order, error)

func (*OKExSpot) GetTicker

func (ok *OKExSpot) GetTicker(currency CurrencyPair) (*Ticker, error)

func (*OKExSpot) GetTrades

func (ok *OKExSpot) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)

非个人,整个交易所的交易记录

func (*OKExSpot) GetUnfinishOrders

func (ok *OKExSpot) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*OKExSpot) LimitBuy

func (ok *OKExSpot) LimitBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKExSpot) LimitSell

func (ok *OKExSpot) LimitSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKExSpot) MarketBuy

func (ok *OKExSpot) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKExSpot) MarketSell

func (ok *OKExSpot) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKExSpot) PlaceOrder

func (ok *OKExSpot) PlaceOrder(ty string, ord *Order) (*Order, error)

type OKExSwap

type OKExSwap struct {
	*OKEx
	// contains filtered or unexported fields
}

func NewOKExSwap

func NewOKExSwap(config *APIConfig) *OKExSwap

func (*OKExSwap) AdaptTradeStatus

func (ok *OKExSwap) AdaptTradeStatus(status int) TradeStatus

func (*OKExSwap) FutureCancelOrder

func (ok *OKExSwap) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*OKExSwap) GetContractValue

func (ok *OKExSwap) GetContractValue(currencyPair CurrencyPair) (float64, error)

*

  • BTC: 100美元一张合约
  • LTC/ETH/ETC/BCH: 10美元一张合约

func (*OKExSwap) GetDeliveryTime

func (ok *OKExSwap) GetDeliveryTime() (int, int, int, int)

func (*OKExSwap) GetExchangeName

func (ok *OKExSwap) GetExchangeName() string

func (*OKExSwap) GetExchangeRate

func (ok *OKExSwap) GetExchangeRate() (float64, error)

func (*OKExSwap) GetFee

func (ok *OKExSwap) GetFee() (float64, error)

func (*OKExSwap) GetFutureDepth

func (ok *OKExSwap) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*OKExSwap) GetFutureEstimatedPrice

func (ok *OKExSwap) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*OKExSwap) GetFutureIndex

func (ok *OKExSwap) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*OKExSwap) GetFutureOrder

func (ok *OKExSwap) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

*

*获取单个订单信息

func (*OKExSwap) GetFutureOrders

func (ok *OKExSwap) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

*

*获取订单信息

func (*OKExSwap) GetFuturePosition

func (ok *OKExSwap) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*OKExSwap) GetFutureTicker

func (ok *OKExSwap) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*OKExSwap) GetFutureUserinfo

func (ok *OKExSwap) GetFutureUserinfo() (*FutureAccount, error)

func (*OKExSwap) GetHistoricalFunding added in v1.0.5

func (ok *OKExSwap) GetHistoricalFunding(contractType string, currencyPair CurrencyPair, page int) ([]HistoricalFunding, error)

func (*OKExSwap) GetKlineRecords

func (ok *OKExSwap) GetKlineRecords(contract_type string, currency CurrencyPair, period, size, since int) ([]FutureKline, error)

func (*OKExSwap) GetTrades

func (ok *OKExSwap) GetTrades(contract_type string, currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*OKExSwap) GetUnfinishFutureOrders

func (ok *OKExSwap) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExSwap) PlaceFutureOrder

func (ok *OKExSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error)

type OKExWallet

type OKExWallet struct {
	*OKEx
}

func (*OKExWallet) GetAccount

func (ok *OKExWallet) GetAccount() (*Account, error)

func (*OKExWallet) GetDepositAddress

func (ok *OKExWallet) GetDepositAddress(currency Currency) ([]DepositAddress, error)

func (*OKExWallet) GetDepositHistory

func (ok *OKExWallet) GetDepositHistory(currency *Currency) ([]DepositWithDrawHistory, error)

func (*OKExWallet) GetWithDrawalFee

func (ok *OKExWallet) GetWithDrawalFee(currency *Currency) ([]WithdrawFee, error)

func (*OKExWallet) GetWithDrawalHistory

func (ok *OKExWallet) GetWithDrawalHistory(currency *Currency) ([]DepositWithDrawHistory, error)

func (*OKExWallet) Transfer

func (ok *OKExWallet) Transfer(param TransferParameter) error
解释说明

from或to指定为0时,sub_account为必填项。

当from为0时,to只能填6,即子账户的资金账户只能转到母账户的资金账户。

当from指定为6,to指定为1-9,且sub_account填写子账户名时,可从母账户直接划转至子账户对应的币币、合约等账户。

from或to指定为5时,instrument_id为必填项。

func (*OKExWallet) Withdrawal

func (ok *OKExWallet) Withdrawal(param WithdrawParameter) (withdrawId string, err error)

认证过的数字货币地址、邮箱或手机号。某些数字货币地址格式为:地址+标签,例:"ARDOR-7JF3-8F2E-QUWZ-CAN7F:123456"

type OrderResponse

type OrderResponse struct {
	InstrumentId   string  `json:"instrument_id"`
	ClientOid      string  `json:"client_oid"`
	OrderId        string  `json:"order_id"`
	Price          float64 `json:"price,string"`
	Size           float64 `json:"size,string"`
	Notional       string  `json:"notional"`
	Side           string  `json:"side"`
	Type           string  `json:"type"`
	FilledSize     string  `json:"filled_size"`
	FilledNotional string  `json:"filled_notional"`
	PriceAvg       string  `json:"price_avg"`
	State          int     `json:"state,string"`
	OrderType      int     `json:"order_type,string"`
	Timestamp      string  `json:"timestamp"`
}

type PlaceOrderInfo

type PlaceOrderInfo struct {
	BasePlaceOrderInfo
	InstrumentId string `json:"instrument_id"`
}

type PlaceOrderParam

type PlaceOrderParam struct {
	ClientOid     string  `json:"client_oid"`
	Type          string  `json:"type"`
	Side          string  `json:"side"`
	InstrumentId  string  `json:"instrument_id"`
	OrderType     int     `json:"order_type"`
	Price         float64 `json:"price"`
	Size          float64 `json:"size"`
	Notional      float64 `json:"notional"`
	MarginTrading string  `json:"margin_trading,omitempty"`
}

type PlaceOrderResponse

type PlaceOrderResponse struct {
	OrderId      string `json:"order_id"`
	ClientOid    string `json:"client_oid"`
	Result       bool   `json:"result"`
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

type PlaceOrdersInfo

type PlaceOrdersInfo struct {
	InstrumentId string                `json:"instrument_id"`
	OrderData    []*BasePlaceOrderInfo `json:"order_data"`
}

type SwapAccountHolds

type SwapAccountHolds BaseInstrumentAmount

type SwapAccountInfo

type SwapAccountInfo struct {
	InstrumentId      string  `json:"instrument_id"`
	Timestamp         string  `json:"timestamp"`
	MarginFrozen      float64 `json:"margin_frozen,string"`
	TotalAvailBalance float64 `json:"total_avail_balance,string"`
	MarginRatio       float64 `json:"margin_ratio,string"`
	RealizedPnl       float64 `json:"realized_pnl,string"`
	UnrealizedPnl     float64 `json:"unrealized_pnl,string"`
	FixedBalance      float64 `json:"fixed_balance,string"`
	Equity            float64 `json:"equity,string"`
	Margin            float64 `json:"margin,string"`
	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 SwapCancelOrderResult struct {
	ErrorMessage string `json:"error_message"`
	ErrorCode    string `json:"error_code"`
	OrderId      string `json:"order_id"`
	Result       bool   `json:"result,string"`
}

type SwapCandleList

type SwapCandleList []BaseCandleInfo

type SwapFillsInfo

type SwapFillsInfo struct {
	BizWarmTips
	FillInfo []*BaseFillInfo `json:"fill_info"`
}

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:"time"`
	Bids      []BaesDepthInfo `json:"bids"`
	Asks      []BaesDepthInfo `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 float64 `json:"liquidation_price , string"`
	Position         float64 `json:"position,string"`
	AvailPosition    float64 `json:"avail_position,string"`
	AvgCost          float64 `json:"avg_cost , string"`
	SettlementPrice  float64 `json:"settlement_price,string"`
	InstrumentId     string  `json:"instrument_id"`
	Leverage         string  `json:"leverage"`
	RealizedPnl      float64 `json:"realized_pnl,string"`
	Side             string  `json:"side"`
	Timestamp        string  `json:"timestamp"`
	Margin           string  `json:"margin";default:""`
}

type SwapPriceLimit

type SwapPriceLimit struct {
	BizWarmTips
	InstrumentId string `json:"instrument_id"`
	Lowest       string `json:"lowest"`
	Highest      string `json:"highest"`
	Timestamp    string `json:"timestamp"`
}

type SwapRate

type SwapRate struct {
	InstrumentId string `json:"instrument_id"`
	Timestamp    string `json:"timestamp"`
	Rate         string `json:"rate"`
}

type SwapTickerList

type SwapTickerList []BaseTickerInfo

type SwapTradeList

type SwapTradeList []BaseTradeInfo

type TransferParameter

type TransferParameter struct {
	Currency       string  `json:"currency"`
	From           int     `json:"from"`
	To             int     `json:"to"`
	Amount         float64 `json:"amount"`
	SubAccount     string  `json:"sub_account"`
	InstrumentId   string  `json:"instrument_id"`
	ToInstrumentId string  `json:"to_instrument_id"`
}

type WithdrawFee

type WithdrawFee struct {
	Currency string `json:"currency"`
	MaxFee   string `json:"max_fee"`
	MinFee   string `json:"min_fee"`
}

type WithdrawParameter

type WithdrawParameter struct {
	Currency    string  `json:"currency"`
	Amount      float64 `json:"amount,string"`
	Destination int     `json:"destination"` //提币到(2:OKCoin国际 3:OKEx 4:数字货币地址)
	ToAddress   string  `json:"to_address"`
	TradePwd    string  `json:"trade_pwd"`
	Fee         string  `json:"fee"`
}

Jump to

Keyboard shortcuts

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