Documentation ¶
Index ¶
- Constants
- Variables
- type AddChannelData
- type DepthData
- type IContractIDProvider
- type KlineData
- type OKCoinCN_API
- func (ctx *OKCoinCN_API) CancelOrder(orderId string, currency CurrencyPair) (bool, error)
- func (ctx *OKCoinCN_API) GetAccount() (*Account, error)
- func (ctx *OKCoinCN_API) GetDepth(size int, currency CurrencyPair) (*Depth, error)
- func (ctx *OKCoinCN_API) GetExchangeName() string
- func (ctx *OKCoinCN_API) GetKlineRecords(currency CurrencyPair, period, size, since int) ([]Kline, error)
- func (ctx *OKCoinCN_API) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)
- func (ctx *OKCoinCN_API) GetOrderHistorys(currency CurrencyPair, currentPage, pageSize int) ([]Order, error)
- func (ctx *OKCoinCN_API) GetTicker(currency CurrencyPair) (*Ticker, error)
- func (ok *OKCoinCN_API) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)
- func (ctx *OKCoinCN_API) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)
- func (ctx *OKCoinCN_API) LimitBuy(amount, price string, currency CurrencyPair) (*Order, error)
- func (ctx *OKCoinCN_API) LimitSell(amount, price string, currency CurrencyPair) (*Order, error)
- func (ctx *OKCoinCN_API) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)
- func (ctx *OKCoinCN_API) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)
- type OKCoinCOM_API
- type OKEx
- func (ok *OKEx) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)
- func (ok *OKEx) GetContractValue(currencyPair CurrencyPair) (float64, error)
- func (ok *OKEx) GetDeliveryTime() (int, int, int, int)
- func (ok *OKEx) GetExchangeName() string
- func (ok *OKEx) GetExchangeRate() (float64, error)
- func (ok *OKEx) GetFee() (float64, error)
- func (ok *OKEx) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)
- func (ok *OKEx) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)
- func (ok *OKEx) GetFutureIndex(currencyPair CurrencyPair) (float64, error)
- func (ok *OKEx) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)
- func (ok *OKEx) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (ok *OKEx) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)
- func (ok *OKEx) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)
- func (ok *OKEx) GetFutureUserinfo() (*FutureAccount, error)
- func (ok *OKEx) GetKlineRecords(contract_type string, currencyPair CurrencyPair, period, size, since int) ([]FutureKline, error)
- func (okFuture *OKEx) GetTrades(contract_type string, currencyPair CurrencyPair, since int64) ([]Trade, error)
- func (ok *OKEx) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (ok *OKEx) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, ...) (string, error)
- type OKExFutureWs
- func (okWs *OKExFutureWs) SetCallbacks(tickerCallback func(*FutureTicker), depthCallback func(*Depth), ...)
- func (okWs *OKExFutureWs) SubscribeDepth(pair CurrencyPair, contract string, size int) error
- func (okWs *OKExFutureWs) SubscribeTicker(pair CurrencyPair, contract string) error
- func (okWs *OKExFutureWs) SubscribeTrade(pair CurrencyPair, contract string) error
- type OKExSpot
- type OKExSpotWs
- func (okWs *OKExSpotWs) SetCallbacks(tickerCallback func(*Ticker), depthCallback func(*Depth), ...)
- func (okWs *OKExSpotWs) SubscribeDepth(pair CurrencyPair, size int) error
- func (okWs *OKExSpotWs) SubscribeKline(pair CurrencyPair, period int) error
- func (okWs *OKExSpotWs) SubscribeTicker(pair CurrencyPair) error
- func (okWs *OKExSpotWs) SubscribeTrade(pair CurrencyPair) error
- type OKExV3
- func (okv3 *OKExV3) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderID string) (bool, error)
- func (okv3 *OKExV3) GetContract(currencyPair CurrencyPair, contractType string) (*futureContract, error)
- func (okv3 *OKExV3) GetContractID(currencyPair CurrencyPair, contractType string) (string, error)
- func (okv3 *OKExV3) GetContractValue(currencyPair CurrencyPair) (float64, error)
- func (okv3 *OKExV3) GetDeliveryTime() (int, int, int, int)
- func (okv3 *OKExV3) GetExchangeName() string
- func (okv3 *OKExV3) GetFee() (float64, error)
- func (okv3 *OKExV3) GetFinishedFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (okv3 *OKExV3) GetFinishedFutureOrdersByIDs(orderIDs []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (okv3 *OKExV3) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)
- func (okv3 *OKExV3) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)
- func (okv3 *OKExV3) GetFutureIndex(currencyPair CurrencyPair) (float64, error)
- func (okv3 *OKExV3) GetFutureOrder(orderID string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)
- func (okv3 *OKExV3) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (okv3 *OKExV3) GetFutureOrdersByIDsAndState(orderIDs []string, state string, currencyPair CurrencyPair, ...) ([]FutureOrder, error)
- func (okv3 *OKExV3) GetFutureOrdersByState(state string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (okv3 *OKExV3) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)
- func (okv3 *OKExV3) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)
- func (okv3 *OKExV3) GetFutureUserinfo() (*FutureAccount, error)
- func (okv3 *OKExV3) GetKlineRecords(contractType string, currencyPair CurrencyPair, period, size, since int) ([]FutureKline, error)
- func (okv3 *OKExV3) GetTrades(contractType string, currencyPair CurrencyPair, since int64) ([]Trade, error)
- func (okv3 *OKExV3) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (okv3 *OKExV3) GetUnfinishFutureOrdersByIDs(orderIDs []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)
- func (okv3 *OKExV3) GetUrlRoot() (url string)
- func (okv3 *OKExV3) ParseContractID(contractID string) (CurrencyPair, string, error)
- func (okv3 *OKExV3) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, ...) (string, error)
- func (okv3 *OKExV3) PlaceFutureOrder2(currencyPair CurrencyPair, contractType, price, amount string, ...) (string, error)
- type OKExV3DataParser
- func (okV3dp *OKExV3DataParser) ParseDepth(depth *Depth, data interface{}, size int) (*Depth, error)
- func (okV3dp *OKExV3DataParser) ParseFutureOrder(data interface{}) (*FutureOrder, string, error)
- func (okV3dp *OKExV3DataParser) ParseFutureTicker(data interface{}) (*FutureTicker, error)
- func (okV3dp *OKExV3DataParser) ParseTrade(trade *Trade, contractType string, data interface{}) (*Trade, string, error)
- type OKExV3FutureWs
- func (okV3Ws *OKExV3FutureWs) DepthCallback(depthCallback func(*Depth)) *OKExV3FutureWs
- func (okV3Ws *OKExV3FutureWs) Login(apiKey string, apiSecretKey string, passphrase string) error
- func (okV3Ws *OKExV3FutureWs) OrderCallback(orderCallback func(*FutureOrder, string)) *OKExV3FutureWs
- func (okV3Ws *OKExV3FutureWs) SetCallbacks(tickerCallback func(*FutureTicker), depthCallback func(*Depth), ...)
- func (okV3Ws *OKExV3FutureWs) SubscribeDepth(currencyPair CurrencyPair, contractType string, size int) error
- func (okV3Ws *OKExV3FutureWs) SubscribeKline(currencyPair CurrencyPair, contractType string, period int) error
- func (okV3Ws *OKExV3FutureWs) SubscribeOrder(currencyPair CurrencyPair, contractType string) error
- func (okV3Ws *OKExV3FutureWs) SubscribeTicker(currencyPair CurrencyPair, contractType string) error
- func (okV3Ws *OKExV3FutureWs) SubscribeTrade(currencyPair CurrencyPair, contractType string) error
- func (okV3Ws *OKExV3FutureWs) TickerCallback(tickerCallback func(*FutureTicker)) *OKExV3FutureWs
- func (okV3Ws *OKExV3FutureWs) TradeCallback(tradeCallback func(*Trade, string)) *OKExV3FutureWs
- type TickerData
- type TradeData
- type WsBaseResp
Constants ¶
View Source
const ( FUTURE_API_BASE_URL = "https://www.okex.com/api/v1/" FUTURE_TICKER_URI = "future_ticker.do?symbol=%s&contract_type=%s" FUTURE_DEPTH_URI = "future_depth.do?symbol=%s&contract_type=%s" FUTURE_INDEX_PRICE = "future_index.do?symbol=%s" FUTURE_USERINFO_URI = "future_userinfo.do" FUTURE_CANCEL_URI = "future_cancel.do" FUTURE_ORDER_INFO_URI = "future_order_info.do" FUTURE_ORDERS_INFO_URI = "future_orders_info.do" FUTURE_POSITION_URI = "future_position.do" FUTURE_TRADE_URI = "future_trade.do" TRADES_URI = "future_trades.do" FUTURE_ESTIMATED_PRICE = "future_estimated_price.do?symbol=%s" )
View Source
const ( V3_FUTURE_HOST_URL = "https://www.okex.com/" V3_FUTURE_API_BASE_URL = "api/futures/v3/" V3_SWAP_API_BASE_URL = "api/swap/v3/" V3_FUTRUR_INSTRUMENTS_URL = "instruments" V3_FUTURE_TICKER_URI = "instruments/%s/ticker" V3_SWAP_DEPTH_URI = "instruments/%s/depth" //wtf api V3_FUTURE_DEPTH_URI = "instruments/%s/book" //wtf api V3_FUTURE_ESTIMATED_PRICE = "instruments/%s/estimated_price" V3_FUTURE_INDEX_PRICE = "instruments/%s/index" V3_FUTURE_USERINFOS_URI = "accounts/%s" V3_FUTURE_CANCEL_URI = "cancel_order/%s/%s" V3_FUTURE_ORDER_INFO_URI = "orders/%s/%s" V3_FUTURE_ORDERS_INFO_URI = "orders/%s" V3_FUTURE_POSITION_URI = "%s/position" V3_FUTURE_ORDER_URI = "order" V3_FUTURE_TRADES_URI = "instruments/%s/trades" V3_FUTURE_FILLS_URI = "fills" V3_EXCHANGE_RATE_URI = "instruments/%s/rate" V3_GET_KLINE_URI = "instruments/%s/candles" )
View Source
const (
EXCHANGE_NAME_COM = "okcoin.com"
)
Variables ¶
View Source
var ( OKEX_MARGIN_MODE_CROSSED = "crossed" OKEX_MARGIN_MODE_FIXED = "fixed" )
long and short position should be separated, current FuturePosition struct should be redesigned.
View Source
var KlineTypeSecondsMap = map[int]int{
KLINE_PERIOD_1MIN: 60,
KLINE_PERIOD_3MIN: 180,
KLINE_PERIOD_5MIN: 300,
KLINE_PERIOD_15MIN: 900,
KLINE_PERIOD_30MIN: 1800,
KLINE_PERIOD_60MIN: 3600,
KLINE_PERIOD_1H: 3600,
KLINE_PERIOD_2H: 7200,
KLINE_PERIOD_4H: 14400,
KLINE_PERIOD_6H: 21600,
KLINE_PERIOD_12H: 43200,
KLINE_PERIOD_1DAY: 86400,
KLINE_PERIOD_1WEEK: 604800,
}
View Source
var OKexOrderTypeMap = map[int]int{
ORDER_FEATURE_LIMIT: 0,
ORDER_FEATURE_POST_ONLY: 1,
ORDER_FEATURE_FOK: 2,
ORDER_FEATURE_FAK: 3,
}
Functions ¶
This section is empty.
Types ¶
type AddChannelData ¶
type IContractIDProvider ¶
type OKCoinCN_API ¶
type OKCoinCN_API struct {
// contains filtered or unexported fields
}
func NewOKCoinCn ¶
func NewOKCoinCn(client *http.Client, api_key, secret_key string) *OKCoinCN_API
func (*OKCoinCN_API) CancelOrder ¶
func (ctx *OKCoinCN_API) CancelOrder(orderId string, currency CurrencyPair) (bool, error)
func (*OKCoinCN_API) GetAccount ¶
func (ctx *OKCoinCN_API) GetAccount() (*Account, error)
func (*OKCoinCN_API) GetDepth ¶
func (ctx *OKCoinCN_API) GetDepth(size int, currency CurrencyPair) (*Depth, error)
func (*OKCoinCN_API) GetExchangeName ¶
func (ctx *OKCoinCN_API) GetExchangeName() string
func (*OKCoinCN_API) GetKlineRecords ¶
func (ctx *OKCoinCN_API) GetKlineRecords(currency CurrencyPair, period, size, since int) ([]Kline, error)
func (*OKCoinCN_API) GetOneOrder ¶
func (ctx *OKCoinCN_API) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)
func (*OKCoinCN_API) GetOrderHistorys ¶
func (ctx *OKCoinCN_API) GetOrderHistorys(currency CurrencyPair, currentPage, pageSize int) ([]Order, error)
func (*OKCoinCN_API) GetTicker ¶
func (ctx *OKCoinCN_API) GetTicker(currency CurrencyPair) (*Ticker, error)
func (*OKCoinCN_API) GetTrades ¶
func (ok *OKCoinCN_API) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)
func (*OKCoinCN_API) GetUnfinishOrders ¶
func (ctx *OKCoinCN_API) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)
func (*OKCoinCN_API) LimitBuy ¶
func (ctx *OKCoinCN_API) LimitBuy(amount, price string, currency CurrencyPair) (*Order, error)
func (*OKCoinCN_API) LimitSell ¶
func (ctx *OKCoinCN_API) LimitSell(amount, price string, currency CurrencyPair) (*Order, error)
func (*OKCoinCN_API) MarketBuy ¶
func (ctx *OKCoinCN_API) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)
func (*OKCoinCN_API) MarketSell ¶
func (ctx *OKCoinCN_API) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)
type OKCoinCOM_API ¶
type OKCoinCOM_API struct {
OKCoinCN_API
}
func (*OKCoinCOM_API) GetAccount ¶
func (ctx *OKCoinCOM_API) GetAccount() (*Account, error)
func (*OKCoinCOM_API) GetExchangeName ¶
func (ctx *OKCoinCOM_API) GetExchangeName() string
type OKEx ¶
type OKEx struct {
// contains filtered or unexported fields
}
func (*OKEx) FutureCancelOrder ¶
func (*OKEx) GetExchangeName ¶
func (*OKEx) GetExchangeRate ¶
func (*OKEx) GetFutureDepth ¶
func (*OKEx) GetFutureEstimatedPrice ¶
func (*OKEx) GetFutureIndex ¶
func (*OKEx) GetFutureOrder ¶
func (*OKEx) GetFutureOrders ¶
func (*OKEx) GetFuturePosition ¶
func (*OKEx) GetFutureTicker ¶
func (*OKEx) GetFutureUserinfo ¶
func (*OKEx) GetKlineRecords ¶
func (*OKEx) GetUnfinishFutureOrders ¶
type OKExFutureWs ¶
func NewOKExFutureWs ¶
func NewOKExFutureWs() *OKExFutureWs
func (*OKExFutureWs) SetCallbacks ¶
func (okWs *OKExFutureWs) SetCallbacks(tickerCallback func(*FutureTicker), depthCallback func(*Depth), tradeCallback func(*Trade, string))
func (*OKExFutureWs) SubscribeDepth ¶
func (okWs *OKExFutureWs) SubscribeDepth(pair CurrencyPair, contract string, size int) error
func (*OKExFutureWs) SubscribeTicker ¶
func (okWs *OKExFutureWs) SubscribeTicker(pair CurrencyPair, contract string) error
func (*OKExFutureWs) SubscribeTrade ¶
func (okWs *OKExFutureWs) SubscribeTrade(pair CurrencyPair, contract string) error
type OKExSpot ¶
type OKExSpot struct {
OKCoinCN_API
}
func (*OKExSpot) GetAccount ¶
func (*OKExSpot) GetExchangeName ¶
type OKExSpotWs ¶
func NewOKExSpotWs ¶
func NewOKExSpotWs() *OKExSpotWs
func (*OKExSpotWs) SetCallbacks ¶
func (okWs *OKExSpotWs) SetCallbacks(tickerCallback func(*Ticker), depthCallback func(*Depth), tradeCallback func(*Trade), klineCallback func(*Kline, int))
func (*OKExSpotWs) SubscribeDepth ¶
func (okWs *OKExSpotWs) SubscribeDepth(pair CurrencyPair, size int) error
func (*OKExSpotWs) SubscribeKline ¶
func (okWs *OKExSpotWs) SubscribeKline(pair CurrencyPair, period int) error
func (*OKExSpotWs) SubscribeTicker ¶
func (okWs *OKExSpotWs) SubscribeTicker(pair CurrencyPair) error
func (*OKExSpotWs) SubscribeTrade ¶
func (okWs *OKExSpotWs) SubscribeTrade(pair CurrencyPair) error
type OKExV3 ¶
type OKExV3 struct {
// contains filtered or unexported fields
}
NOTE: contracts 默认五分钟更新一次。 由于V3没有自动合约日期的映射,到了周五交割的时候,最好还是手动平仓,关闭策略,交割完后重启。
func (*OKExV3) FutureCancelOrder ¶
func (*OKExV3) GetContract ¶
func (*OKExV3) GetContractID ¶
func (*OKExV3) GetContractValue ¶
func (*OKExV3) GetExchangeName ¶
func (*OKExV3) GetFinishedFutureOrders ¶
func (*OKExV3) GetFinishedFutureOrdersByIDs ¶
func (*OKExV3) GetFutureDepth ¶
func (*OKExV3) GetFutureEstimatedPrice ¶
func (*OKExV3) GetFutureIndex ¶
func (*OKExV3) GetFutureOrder ¶
func (*OKExV3) GetFutureOrders ¶
func (*OKExV3) GetFutureOrdersByIDsAndState ¶
func (*OKExV3) GetFutureOrdersByState ¶
func (*OKExV3) GetFuturePosition ¶
func (*OKExV3) GetFutureTicker ¶
func (*OKExV3) GetFutureUserinfo ¶
GetFutureUserinfo 还只能查交割合约接口
func (*OKExV3) GetKlineRecords ¶
func (*OKExV3) GetUnfinishFutureOrders ¶
func (*OKExV3) GetUnfinishFutureOrdersByIDs ¶
func (*OKExV3) GetUrlRoot ¶
func (*OKExV3) ParseContractID ¶
func (*OKExV3) PlaceFutureOrder ¶
type OKExV3DataParser ¶
type OKExV3DataParser struct {
// contains filtered or unexported fields
}
func NewOKExV3DataParser ¶
func NewOKExV3DataParser(contractIDProvider IContractIDProvider) *OKExV3DataParser
func (*OKExV3DataParser) ParseDepth ¶
func (okV3dp *OKExV3DataParser) ParseDepth(depth *Depth, data interface{}, size int) (*Depth, error)
func (*OKExV3DataParser) ParseFutureOrder ¶
func (okV3dp *OKExV3DataParser) ParseFutureOrder(data interface{}) (*FutureOrder, string, error)
func (*OKExV3DataParser) ParseFutureTicker ¶
func (okV3dp *OKExV3DataParser) ParseFutureTicker(data interface{}) (*FutureTicker, error)
func (*OKExV3DataParser) ParseTrade ¶
func (okV3dp *OKExV3DataParser) ParseTrade(trade *Trade, contractType string, data interface{}) (*Trade, string, error)
type OKExV3FutureWs ¶
func NewOKExV3FutureWs ¶
func NewOKExV3FutureWs(contractIDProvider IContractIDProvider) *OKExV3FutureWs
func (*OKExV3FutureWs) DepthCallback ¶
func (okV3Ws *OKExV3FutureWs) DepthCallback(depthCallback func(*Depth)) *OKExV3FutureWs
func (*OKExV3FutureWs) Login ¶
func (okV3Ws *OKExV3FutureWs) Login(apiKey string, apiSecretKey string, passphrase string) error
func (*OKExV3FutureWs) OrderCallback ¶
func (okV3Ws *OKExV3FutureWs) OrderCallback(orderCallback func(*FutureOrder, string)) *OKExV3FutureWs
func (*OKExV3FutureWs) SetCallbacks ¶
func (okV3Ws *OKExV3FutureWs) SetCallbacks(tickerCallback func(*FutureTicker), depthCallback func(*Depth), tradeCallback func(*Trade, string), klineCallback func(*FutureKline, int), orderCallback func(*FutureOrder, string))
func (*OKExV3FutureWs) SubscribeDepth ¶
func (okV3Ws *OKExV3FutureWs) SubscribeDepth(currencyPair CurrencyPair, contractType string, size int) error
func (*OKExV3FutureWs) SubscribeKline ¶
func (okV3Ws *OKExV3FutureWs) SubscribeKline(currencyPair CurrencyPair, contractType string, period int) error
func (*OKExV3FutureWs) SubscribeOrder ¶
func (okV3Ws *OKExV3FutureWs) SubscribeOrder(currencyPair CurrencyPair, contractType string) error
func (*OKExV3FutureWs) SubscribeTicker ¶
func (okV3Ws *OKExV3FutureWs) SubscribeTicker(currencyPair CurrencyPair, contractType string) error
func (*OKExV3FutureWs) SubscribeTrade ¶
func (okV3Ws *OKExV3FutureWs) SubscribeTrade(currencyPair CurrencyPair, contractType string) error
func (*OKExV3FutureWs) TickerCallback ¶
func (okV3Ws *OKExV3FutureWs) TickerCallback(tickerCallback func(*FutureTicker)) *OKExV3FutureWs
func (*OKExV3FutureWs) TradeCallback ¶
func (okV3Ws *OKExV3FutureWs) TradeCallback(tradeCallback func(*Trade, string)) *OKExV3FutureWs
type TickerData ¶
type WsBaseResp ¶
type WsBaseResp struct { Channel string Data json.RawMessage }
Click to show internal directories.
Click to hide internal directories.