Documentation ¶
Index ¶
- Constants
- func ConvertCandleToQuotes(table string, candles []Candle) ([]common.MessageRspCommon, error)
- func ConvertChannelToSubUnsub(channel string) (*common.MessageSubUnsub, error)
- func ConvertDepthToQuotes(table string, depths []Depth) ([]common.MessageRspCommon, error)
- func ConvertOrderTradeOkex2Common(productType string, okexTrade *OrderTrade) (*common.MessageRspCommon, error)
- func ConvertQuoteToChannel(quote *common.MessageQuote) (string, error)
- func ConvertTickerToQuotes(table string, tickers []Ticker) ([]common.MessageRspCommon, error)
- func GenWsSign(timestamp, method, requestPath, secret string) (string, error)
- func Headers(request *http.Request, config *Config, timestamp string, sign string)
- func HmacSha256Base64Signer(message string, secretKey string) (string, error)
- func HttpRequst(client *http.Client, config *Config, method string, requestPath string, ...) (response *http.Response, err error)
- func IsoTime() string
- func ParseRequestParams(params interface{}) (string, *bytes.Reader, error)
- func PreHashString(timestamp string, method string, requestPath string, body string) string
- type Candle
- type ChannelSplit
- type Config
- type Depth
- type FuturesTicker
- type OkexMsgCallback
- type Order
- type OrderRet
- type OrderTrade
- type Position
- type PositionHolding
- type Query
- type QuoteApi
- func (this *QuoteApi) OnActive(peer *cascade.Peer)
- func (this *QuoteApi) OnDepth(msg *RspCommon)
- func (this *QuoteApi) OnDepthL2(msg *RspCommon)
- func (this *QuoteApi) OnError(msg *RspCommon)
- func (this *QuoteApi) OnHubByteMessage(msg *cascade.HubByteMessage)
- func (this *QuoteApi) OnHubObjectMessage(msg *cascade.HubObjectMessage)
- func (this *QuoteApi) OnInactive(peer *cascade.Peer)
- func (this *QuoteApi) OnKline(msg *RspCommon)
- func (this *QuoteApi) OnLogin(msg *RspCommon)
- func (this *QuoteApi) OnRead(peer *cascade.Peer, message []byte)
- func (this *QuoteApi) OnSub(msg *RspCommon)
- func (this *QuoteApi) OnTicker(msg *RspCommon)
- func (this *QuoteApi) OnUnsub(msg *RspCommon)
- func (this *QuoteApi) Ping()
- func (this *QuoteApi) RegisterCallbacks()
- func (this *QuoteApi) Run() error
- func (this *QuoteApi) SetSpi(spi QuoteSpi) error
- func (this *QuoteApi) Subscribe(topics []string) error
- func (this *QuoteApi) Unsubscribe(topics []string) error
- type QuoteSpi
- type ReqCommon
- type RspCommon
- type Ticker
- type TradeAccount
- type TradeApi
- func (this *TradeApi) CancelOrder(order *Order, okexProductType, outsideOrderId string, result interface{}) (response *http.Response, err error)
- func (this *TradeApi) InsertOrder(order *Order, okexProductType string, result interface{}) (response *http.Response, err error)
- func (this *TradeApi) Login() error
- func (this *TradeApi) OnAccount(msg *RspCommon)
- func (this *TradeApi) OnActive(peer *cascade.Peer)
- func (this *TradeApi) OnError(msg *RspCommon)
- func (this *TradeApi) OnHubByteMessage(msg *cascade.HubByteMessage)
- func (this *TradeApi) OnHubObjectMessage(msg *cascade.HubObjectMessage)
- func (this *TradeApi) OnInactive(peer *cascade.Peer)
- func (this *TradeApi) OnLogin(msg *RspCommon)
- func (this *TradeApi) OnOrder(msg *RspCommon)
- func (this *TradeApi) OnPosition(msg *RspCommon)
- func (this *TradeApi) OnRead(peer *cascade.Peer, message []byte)
- func (this *TradeApi) OnSub(msg *RspCommon)
- func (this *TradeApi) OnUnsub(msg *RspCommon)
- func (this *TradeApi) Ping()
- func (this *TradeApi) QueryAccount(qry *Query, result interface{}) (response *http.Response, err error)
- func (this *TradeApi) QueryOrder(qry *Query, result interface{}) (response *http.Response, err error)
- func (this *TradeApi) QueryPosition(qry *Query, result interface{}) (response *http.Response, err error)
- func (this *TradeApi) RegisterCallbacks()
- func (this *TradeApi) Run() error
- func (this *TradeApi) SetSpi(spi TradeSpi) error
- func (this *TradeApi) Subscribe(topics []string) error
- func (this *TradeApi) Unsubscribe(topics []string) error
- type TradeSpi
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" )
Variables ¶
This section is empty.
Functions ¶
func ConvertCandleToQuotes ¶
func ConvertCandleToQuotes(table string, candles []Candle) ([]common.MessageRspCommon, error)
func ConvertChannelToSubUnsub ¶
func ConvertChannelToSubUnsub(channel string) (*common.MessageSubUnsub, error)
func ConvertDepthToQuotes ¶
func ConvertDepthToQuotes(table string, depths []Depth) ([]common.MessageRspCommon, error)
func ConvertOrderTradeOkex2Common ¶
func ConvertOrderTradeOkex2Common(productType string, okexTrade *OrderTrade) (*common.MessageRspCommon, error)
func ConvertQuoteToChannel ¶
func ConvertQuoteToChannel(quote *common.MessageQuote) (string, error)
func ConvertTickerToQuotes ¶
func ConvertTickerToQuotes(table string, tickers []Ticker) ([]common.MessageRspCommon, error)
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 HttpRequst ¶
func HttpRequst(client *http.Client, config *Config, method string, requestPath string, params, result interface{}) (response *http.Response, err error)
Send a http request to remote server and get a response data
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"}
Types ¶
type ChannelSplit ¶
type ChannelSplit struct { ProductType string Info1 string Info2 string Symbol string Contract string }
func SplitChannel ¶
func SplitChannel(channel string) (*ChannelSplit, error)
/////////////// converter /////////////////
type Config ¶
type Config struct { RestEndpoint string `json:"rest_endpoint"` WsEndpoint string `json:"ws_endpoint"` Key string `json:"key"` Secret string `json:"secret"` Passphrase string `json:"passphrase"` RestTimeoutSec int `json:"rest_timeout_sec"` QuoteSubTopics []string `json:"quote_sub_topics"` TradeSubTopics []string `json:"trade_sub_topics"` }
func LoadConfig ¶
type FuturesTicker ¶
type FuturesTicker struct { InstrumentId string `json:"instrument_id"` Last string `json:"last"` BestBid string `json:"best_bid"` BestAsk string `json:"best_ask"` Open24H string `json:"open_24h"` High24H string `json:"high_24h"` Low24H string `json:"low_24h"` Vol24H string `json:"volume_24h"` Timestamp string `json:"timestamp"` }
type Order ¶
type Order struct { ClientOid string `json:"client_oid,omitempty"` InstrumentId string `json:"instrument_id"` Type string `json:"type,omitempty"` Side string `json:"side,omitempty"` Price string `json:"price,omitempty"` Size string `json:"size,omitempty"` Notional string `json:"notional,omitempty"` Leverage string `json:"leverage,omitempty"` }
func ConvertCancelOrderCommon2Okex ¶
func ConvertCancelOrderCommon2Okex(order *common.MessageOrder) (string, *Order, error)
RETURN: productType, okex.Order, error
func ConvertInsertOrderCommon2Okex ¶
func ConvertInsertOrderCommon2Okex(order *common.MessageOrder) (string, *Order, error)
RETURN: productType, okex.Order, error
type OrderTrade ¶
type OrderTrade struct { InstrumentId string `json:"instrument_id"` OrderId string `json:"order_id"` Price string `json:"price"` Size string `json:"size"` Timestamp string `json:"timestamp"` Notional string `json:"notional"` Side string `json:"side"` Type string `json:"type"` FilledSize string `json:"filled_size"` FilledNotional string `json:"filled_notional"` Status string `json:"status"` MarginTrading string `json:"margin_trading"` FilledQty string `json:"filled_qty"` Fee string `json:"fee"` PriceAvg string `json:"price_avg"` ContractVal string `json:"contract_val"` Leverage string `json:"leverage"` }
type Position ¶
type Position struct { MarginMode string `json:"margin_mode"` Result bool `json:"result"` Holding []PositionHolding `json:"holding"` }
type PositionHolding ¶
type PositionHolding struct { MarginMode string `json:"margin_mode"` LongQty string `json:"long_qty"` LongAvailQty string `json:"long_avail_qty"` LongAvgCost string `json:"long_avg_cost"` LongSettlementPrice string `json:"long_settlement_price"` ShortQty string `json:"short_qty"` ShortAvailQty string `json:"short_avail_qty"` ShortAvgCost string `json:"short_avg_cost"` ShortSettlementPrice string `json:"short_settlement_price"` InstrumentId string `json:"instrument_id"` Leverage string `json:"leverage"` }
type Query ¶
func ConvertQryCommon2Okex ¶
func ConvertQryCommon2Okex(qry *common.MessageQuery) (*Query, error)
type QuoteApi ¶
type QuoteApi struct {
// contains filtered or unexported fields
}
func NewQuoteApi ¶
func (*QuoteApi) OnHubByteMessage ¶
func (this *QuoteApi) OnHubByteMessage(msg *cascade.HubByteMessage)
func (*QuoteApi) OnHubObjectMessage ¶
func (this *QuoteApi) OnHubObjectMessage(msg *cascade.HubObjectMessage)
func (*QuoteApi) OnInactive ¶
func (*QuoteApi) RegisterCallbacks ¶
func (this *QuoteApi) RegisterCallbacks()
func (*QuoteApi) Unsubscribe ¶
type Ticker ¶
type Ticker struct { InstrumentId string `json:"instrument_id"` Last string `json:"last"` BestBid string `json:"best_bid"` BestAsk string `json:"best_ask"` Open24H string `json:"open_24h"` High24H string `json:"high_24h"` Low24H string `json:"low_24h"` Vol24H string `json:"volume_24h"` BaseVol24H string `json:"base_volume_24h"` QuoteVol24H string `json:"quote_volume_24h"` Timestamp string `json:"timestamp"` }
type TradeAccount ¶
type TradeAccount struct { // futures MarginMode string `json:"margin_mode"` TotalAvailBalance string `json:"total_avail_balance"` Equity string `json:"equity"` MarginRatio string `json:"margin_ratio"` // spot Balance string `json:"balance"` Hold string `json:"hold"` Available string `json:"available"` }
type TradeApi ¶
func NewTradeApi ¶
func (*TradeApi) CancelOrder ¶
func (*TradeApi) InsertOrder ¶
func (*TradeApi) OnHubByteMessage ¶
func (this *TradeApi) OnHubByteMessage(msg *cascade.HubByteMessage)
func (*TradeApi) OnHubObjectMessage ¶
func (this *TradeApi) OnHubObjectMessage(msg *cascade.HubObjectMessage)
func (*TradeApi) OnInactive ¶
func (*TradeApi) OnPosition ¶
func (*TradeApi) QueryAccount ¶
func (*TradeApi) QueryOrder ¶
func (*TradeApi) QueryPosition ¶
func (*TradeApi) RegisterCallbacks ¶
func (this *TradeApi) RegisterCallbacks()
func (*TradeApi) Unsubscribe ¶
Click to show internal directories.
Click to hide internal directories.