Documentation ¶
Index ¶
- Constants
- func GenSignBody(method, requestURI, body string) string
- type AccountModel
- type AccountsModel
- type ApiResponse
- type CancelOrderResultModel
- type CreateOrderModel
- type KLineModel
- type KLinesModel
- type KcSigner
- type KuCoin
- func (k *KuCoin) CancelOrder(orderId string, currencyPair CurrencyPair) (bool, error)
- func (k *KuCoin) GetAccount() (*Account, error)
- func (k *KuCoin) GetBestTicker(currencyPair CurrencyPair) (*BestTicker, error)
- func (k *KuCoin) GetCurrencyPairs() ([]CurrencyPair, error)
- func (k *KuCoin) GetDepth(size int, currencyPair CurrencyPair) (*Depth, error)
- func (k *KuCoin) GetExchangeName() string
- func (k *KuCoin) GetKlineRecords(currencyPair CurrencyPair, period KlinePeriod, size int, ...) ([]Kline, error)
- func (k *KuCoin) GetOneOrder(orderId string, currencyPair CurrencyPair) (*Order, error)
- func (k *KuCoin) GetOrderHistorys(currencyPair CurrencyPair, optional ...OptionalParameter) ([]Order, error)
- func (kc *KuCoin) GetPrivateToken() (*WebSocketTokenModel, error)
- func (kc *KuCoin) GetPublicToken() (*WebSocketTokenModel, error)
- func (k *KuCoin) GetSubAccount(coin Currency) (*SubAccount, error)
- func (k *KuCoin) GetSubAccounts() ([]SubAccount, error)
- func (k *KuCoin) GetTicker(currencyPair CurrencyPair) (*Ticker, error)
- func (k *KuCoin) GetTradeFee(currencyPair CurrencyPair) (*TradeFee, error)
- func (k *KuCoin) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)
- func (k *KuCoin) GetUnfinishOrders(currencyPair CurrencyPair) ([]Order, error)
- func (k *KuCoin) LimitBuy(amount, price string, currencyPair CurrencyPair, ...) (*Order, error)
- func (k *KuCoin) LimitSell(amount, price string, currencyPair CurrencyPair, ...) (*Order, error)
- func (k *KuCoin) MarketBuy(amount, price string, currencyPair CurrencyPair) (*Order, error)
- func (k *KuCoin) MarketSell(amount, price string, currencyPair CurrencyPair) (*Order, error)
- func (k *KuCoin) PlaceOrder(amount, price string, currencyPair CurrencyPair, orderType, orderSide string) (*Order, error)
- type OrderModel
- type OrderPageModel
- type OrdersModel
- type PartOrderBookModel
- type ServiceError
- type Sha256Signer
- type Signer
- type SpotWs
- func (s *SpotWs) BestTickerCallback(f func(ticker *gocoinex.BestTicker, exchange string))
- func (s *SpotWs) DepthCallback(f func(depth *gocoinex.Depth, exchange string))
- func (s *SpotWs) HeartbeatData() []byte
- func (s *SpotWs) SubscribeBestTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeDepth(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeTrade(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeUserBalance() error
- func (s *SpotWs) SubscribeUserOrder() error
- func (s *SpotWs) TickerCallback(f func(ticker *gocoinex.Ticker, exchange string))
- func (s *SpotWs) TradeCallback(f func(trade *gocoinex.Trade, exchange string))
- func (s *SpotWs) UnSubscribeBestTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeDepth(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeTrade(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeUserBalance() error
- func (s *SpotWs) UnSubscribeUserOrder() error
- func (s *SpotWs) UserBalanceCallback(f func(trade *gocoinex.SubAccount, exchange string))
- func (s *SpotWs) UserOrderCallback(f func(ticker *gocoinex.Order, exchange string))
- type SymbolModel
- type SymbolsModel
- type TickerLevel1Model
- type TickerModel
- type TickersModel
- type TradeFeesResultModel
- type TradeHistoriesModel
- type TradeHistoryModel
- type WebSocketDownstreamMessage
- type WebSocketMessage
- type WebSocketServerModel
- type WebSocketServersModel
- type WebSocketSubscribeMessage
- type WebSocketTokenModel
Constants ¶
const ( ChannelSpotOrderBook = "/spotMarket/level2Depth5:" ChannelSpotTicker = "/market/snapshot:" ChannelSpotBestTicker = "/market/ticker:" ChannelSpotPublicTrade = "/market/match:" ChannelSpotUserOrder = "/spotMarket/tradeOrdersV2" // 现货订单变动 ChannelSpotUserBalance = "/account/balance" // 现货余额变动 )
spot channels
const ( Subscribe = "subscribe" UnSubscribe = "unsubscribe" )
Variables ¶
This section is empty.
Functions ¶
func GenSignBody ¶
Types ¶
type AccountModel ¶
type AccountModel struct { Id string `json:"id"` Currency string `json:"currency"` Type string `json:"type"` Balance string `json:"balance"` Available string `json:"available"` Holds string `json:"holds"` }
An AccountModel represents an account.
type AccountsModel ¶
type AccountsModel []*AccountModel
An AccountsModel is the set of *AccountModel.
type ApiResponse ¶
type ApiResponse struct { Code string `json:"code"` RawData json.RawMessage `json:"data"` // delay parsing Message string `json:"msg"` }
返回的数据结构
type CancelOrderResultModel ¶
type CancelOrderResultModel struct {
CancelledOrderIds []string `json:"cancelledOrderIds"`
}
A CancelOrderResultModel represents the result of CancelOrder().
type CreateOrderModel ¶
type CreateOrderModel struct { // BASE PARAMETERS ClientOid string `json:"clientOid"` Side string `json:"side"` Symbol string `json:"symbol,omitempty"` Type string `json:"type,omitempty"` Remark string `json:"remark,omitempty"` Stop string `json:"stop,omitempty"` StopPrice string `json:"stopPrice,omitempty"` STP string `json:"stp,omitempty"` TradeType string `json:"tradeType,omitempty"` // LIMIT ORDER PARAMETERS Price string `json:"price,omitempty"` Size string `json:"size,omitempty"` TimeInForce string `json:"timeInForce,omitempty"` CancelAfter int64 `json:"cancelAfter,omitempty"` PostOnly bool `json:"postOnly,omitempty"` Hidden bool `json:"hidden,omitempty"` IceBerg bool `json:"iceberg,omitempty"` VisibleSize string `json:"visibleSize,omitempty"` // MARKET ORDER PARAMETERS // Size string `json:"size"` Funds string `json:"funds,omitempty"` // MARGIN ORDER PARAMETERS MarginMode string `json:"marginMode,omitempty"` AutoBorrow bool `json:"autoBorrow,omitempty"` }
A CreateOrderModel is the input parameter of CreateOrder().
type KLineModel ¶
type KLineModel []string
KLineModel represents the k lines for a symbol. Rates are returned in grouped buckets based on requested type.
type KcSigner ¶
type KcSigner struct { Sha256Signer // contains filtered or unexported fields }
KcSigner is the implement of Signer for KuCoin.
func NewKcSignerV2 ¶
NewKcSignerV2 creates a instance of KcSigner.
type KuCoin ¶
type KuCoin struct { Accesskey, Secretkey, Passphrase string KcSigner *KcSigner // contains filtered or unexported fields }
func (*KuCoin) CancelOrder ¶
func (*KuCoin) GetAccount ¶
func (*KuCoin) GetBestTicker ¶
func (*KuCoin) GetCurrencyPairs ¶
获取所有交易对
func (*KuCoin) GetExchangeName ¶
func (*KuCoin) GetKlineRecords ¶
func (*KuCoin) GetOneOrder ¶
func (*KuCoin) GetOrderHistorys ¶
func (*KuCoin) GetPrivateToken ¶
func (kc *KuCoin) GetPrivateToken() (*WebSocketTokenModel, error)
func (*KuCoin) GetPublicToken ¶
func (kc *KuCoin) GetPublicToken() (*WebSocketTokenModel, error)
func (*KuCoin) GetSubAccount ¶
func (*KuCoin) GetSubAccounts ¶
func (*KuCoin) GetTradeFee ¶
私有权限
func (*KuCoin) GetUnfinishOrders ¶
查询指定交易对所有挂单
func (*KuCoin) LimitBuy ¶
func (k *KuCoin) LimitBuy(amount, price string, currencyPair CurrencyPair, optional ...LimitOrderOptionalParameter) (*Order, error)
限价买单
func (*KuCoin) MarketSell ¶
type OrderModel ¶
type OrderModel struct { Id string `json:"id"` Symbol string `json:"symbol"` OpType string `json:"opType"` Type string `json:"type"` Side string `json:"side"` Price string `json:"price"` Size string `json:"size"` Funds string `json:"funds"` DealFunds string `json:"dealFunds"` DealSize string `json:"dealSize"` Fee string `json:"fee"` FeeCurrency string `json:"feeCurrency"` Stp string `json:"stp"` Stop string `json:"stop"` StopTriggered bool `json:"stopTriggered"` StopPrice string `json:"stopPrice"` TimeInForce string `json:"timeInForce"` PostOnly bool `json:"postOnly"` Hidden bool `json:"hidden"` IceBerg bool `json:"iceberg"` VisibleSize string `json:"visibleSize"` CancelAfter int64 `json:"cancelAfter"` Channel string `json:"channel"` ClientOid string `json:"clientOid"` Remark string `json:"remark"` Tags string `json:"tags"` IsActive bool `json:"isActive"` CancelExist bool `json:"cancelExist"` CreatedAt int64 `json:"createdAt"` TradeType string `json:"tradeType"` }
An OrderModel represents an order.
type OrderPageModel ¶
type OrderPageModel struct { CurrentPage int `json:"currentPage"` PageSize int `json:"pageSize"` TotalNum int `json:"totalNum"` TotalPage int `json:"totalPage"` Items OrdersModel `json:"items"` }
type OrdersModel ¶
type OrdersModel []*OrderModel
type PartOrderBookModel ¶
type PartOrderBookModel struct { Sequence string `json:"sequence"` Time int64 `json:"time"` Bids [][]string `json:"bids"` Asks [][]string `json:"asks"` }
A PartOrderBookModel represents a list of open orders for a symbol, a part of Order Book within 100 depth for each side(ask or bid).
type ServiceError ¶
type Sha256Signer ¶
type Sha256Signer struct {
// contains filtered or unexported fields
}
Sha256Signer is the sha256 Signer.
func (*Sha256Signer) Sign ¶
func (ss *Sha256Signer) Sign(plain []byte) []byte
Sign makes a signature by sha256.
type SpotWs ¶
type SpotWs struct {
// contains filtered or unexported fields
}
func (*SpotWs) BestTickerCallback ¶
func (s *SpotWs) BestTickerCallback(f func(ticker *gocoinex.BestTicker, exchange string))
func (*SpotWs) DepthCallback ¶
func (*SpotWs) HeartbeatData ¶
func (*SpotWs) SubscribeBestTicker ¶
func (s *SpotWs) SubscribeBestTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeDepth ¶
func (s *SpotWs) SubscribeDepth(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeTicker ¶
func (s *SpotWs) SubscribeTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeTrade ¶
func (s *SpotWs) SubscribeTrade(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeUserBalance ¶
func (*SpotWs) SubscribeUserOrder ¶
func (*SpotWs) TickerCallback ¶
func (*SpotWs) TradeCallback ¶
func (*SpotWs) UnSubscribeBestTicker ¶
func (s *SpotWs) UnSubscribeBestTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeDepth ¶
func (s *SpotWs) UnSubscribeDepth(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeTicker ¶
func (s *SpotWs) UnSubscribeTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeTrade ¶
func (s *SpotWs) UnSubscribeTrade(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeUserBalance ¶
func (*SpotWs) UnSubscribeUserOrder ¶
func (*SpotWs) UserBalanceCallback ¶
func (s *SpotWs) UserBalanceCallback(f func(trade *gocoinex.SubAccount, exchange string))
type SymbolModel ¶
type SymbolModel struct { Symbol string `json:"symbol"` Name string `json:"name"` BaseCurrency string `json:"baseCurrency"` QuoteCurrency string `json:"quoteCurrency"` Market string `json:"market"` BaseMinSize string `json:"baseMinSize"` QuoteMinSize string `json:"quoteMinSize"` BaseMaxSize string `json:"baseMaxSize"` QuoteMaxSize string `json:"quoteMaxSize"` BaseIncrement string `json:"baseIncrement"` QuoteIncrement string `json:"quoteIncrement"` PriceIncrement string `json:"priceIncrement"` FeeCurrency string `json:"feeCurrency"` EnableTrading bool `json:"enableTrading"` IsMarginEnabled bool `json:"isMarginEnabled"` PriceLimitRate string `json:"priceLimitRate"` }
A SymbolModel represents an available currency pairs for trading.
type SymbolsModel ¶
type SymbolsModel []*SymbolModel
type TickerLevel1Model ¶
type TickerLevel1Model struct { Sequence string `json:"sequence"` Price string `json:"price"` Size string `json:"size"` BestBid string `json:"bestBid"` BestBidSize string `json:"bestBidSize"` BestAsk string `json:"bestAsk"` BestAskSize string `json:"bestAskSize"` Time int64 `json:"time"` }
A TickerLevel1Model represents ticker include only the inside (i.e. best) bid and ask data, last price and last trade size.
type TickerModel ¶
type TickerModel struct { Time int64 `json:"time"` Symbol string `json:"symbol"` SymbolName string `json:"symbolName"` Buy string `json:"buy"` Sell string `json:"sell"` ChangeRate string `json:"changeRate"` ChangePrice string `json:"changePrice"` High string `json:"high"` Low string `json:"low"` Vol string `json:"vol"` VolValue string `json:"volValue"` Last string `json:"last"` AveragePrice string `json:"averagePrice"` TakerFeeRate string `json:"takerFeeRate"` MakerFeeRate string `json:"makerFeeRate"` TakerCoefficient string `json:"takerCoefficient"` MakerCoefficient string `json:"makerCoefficient"` }
A TickerModel represents a market ticker for all trading pairs in the market (including 24h volume).
type TickersModel ¶
type TickersModel []*TickerModel
A TickersModel is the set of *MarketTickerModel.
type TradeFeesResultModel ¶
type TradeFeesResultModel []struct { Symbol string `json:"symbol"` TakerFeeRate string `json:"takerFeeRate"` MakerFeeRate string `json:"makerFeeRate"` }
交易手续费
type TradeHistoriesModel ¶
type TradeHistoriesModel []*TradeHistoryModel
A TradeHistoriesModel is the set of *TradeHistoryModel.
type TradeHistoryModel ¶
type TradeHistoryModel struct { Sequence string `json:"sequence"` Price string `json:"price"` Size string `json:"size"` Side string `json:"side"` Time int64 `json:"time"` }
A TradeHistoryModel represents a the latest trades for a symbol.
type WebSocketDownstreamMessage ¶
type WebSocketDownstreamMessage struct { *WebSocketMessage Sn string `json:"sn"` Topic string `json:"topic"` Subject string `json:"subject"` RawData json.RawMessage `json:"data"` }
A WebSocketDownstreamMessage represents a message from the WebSocket server to client.
func (*WebSocketDownstreamMessage) ReadData ¶
func (m *WebSocketDownstreamMessage) ReadData(v interface{}) error
ReadData read the data in channel.
type WebSocketMessage ¶
A WebSocketMessage represents a message between the WebSocket client and server.
type WebSocketServerModel ¶
type WebSocketServerModel struct { PingInterval int64 `json:"pingInterval"` Endpoint string `json:"endpoint"` Protocol string `json:"protocol"` Encrypt bool `json:"encrypt"` PingTimeout int64 `json:"pingTimeout"` }
A WebSocketServerModel contains some servers for WebSocket feed.
type WebSocketServersModel ¶
type WebSocketServersModel []*WebSocketServerModel
A WebSocketServersModel is the set of *WebSocketServerModel.
func (WebSocketServersModel) RandomServer ¶
func (s WebSocketServersModel) RandomServer() (*WebSocketServerModel, error)
RandomServer returns a server randomly.
type WebSocketSubscribeMessage ¶
type WebSocketSubscribeMessage struct { *WebSocketMessage Topic string `json:"topic"` PrivateChannel bool `json:"privateChannel"` Response bool `json:"response"` }
A WebSocketSubscribeMessage represents a message to subscribe the public/private channel.
type WebSocketTokenModel ¶
type WebSocketTokenModel struct { Token string `json:"token"` Servers WebSocketServersModel `json:"instanceServers"` AcceptUserMessage bool `json:"accept_user_message"` }
A WebSocketTokenModel contains a token and some servers for WebSocket feed.