Documentation
¶
Overview ¶
Package kucoin provides two kinds of APIs: `RESTful API` and `WebSocket feed`. The official document: https://docs.kucoin.com
Index ¶
- Constants
- func IntToString(i int64) string
- func ToJsonString(v interface{}) string
- type AccountHoldModel
- type AccountHoldsModel
- type AccountLedgerModel
- type AccountLedgersModel
- type AccountModel
- type AccountsModel
- type ApiResponse
- type ApiService
- func (as *ApiService) Account(accountId string) (*ApiResponse, error)
- func (as *ApiService) AccountHolds(accountId string, pagination *PaginationParam) (*ApiResponse, error)
- func (as *ApiService) AccountLedgers(accountId string, startAt, endAt int64, pagination *PaginationParam) (*ApiResponse, error)
- func (as *ApiService) Accounts(currency, typo string) (*ApiResponse, error)
- func (as *ApiService) AggregatedFullOrderBook(symbol string) (*ApiResponse, error)
- func (as *ApiService) AggregatedPartOrderBook(symbol string, depth int64) (*ApiResponse, error)
- func (as *ApiService) ApplyWithdrawal(currency, address, amount string, options map[string]string) (*ApiResponse, error)
- func (as *ApiService) AtomicFullOrderBook(symbol string) (*ApiResponse, error)
- func (as *ApiService) Call(request *Request) (*ApiResponse, error)
- func (as *ApiService) CancelOrder(orderId string) (*ApiResponse, error)
- func (as *ApiService) CancelOrders(symbol string) (*ApiResponse, error)
- func (as *ApiService) CancelWithdrawal(withdrawalId string) (*ApiResponse, error)
- func (as *ApiService) CreateAccount(typo, currency string) (*ApiResponse, error)
- func (as *ApiService) CreateDepositAddress(currency string) (*ApiResponse, error)
- func (as *ApiService) CreateOrder(params map[string]string) (*ApiResponse, error)
- func (as *ApiService) Currencies() (*ApiResponse, error)
- func (as *ApiService) Currency(currency string) (*ApiResponse, error)
- func (as *ApiService) DepositAddresses(currency string) (*ApiResponse, error)
- func (as *ApiService) Deposits(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
- func (as *ApiService) Fills(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
- func (as *ApiService) InnerTransfer(clientOid, payAccountId, recAccountId, amount string) (*ApiResponse, error)
- func (as *ApiService) KLines(symbol, typo string, startAt, endAt int64) (*ApiResponse, error)
- func (as *ApiService) Markets() (*ApiResponse, error)
- func (as *ApiService) NewWebSocketClient(token *WebSocketTokenModel, channel *WebSocketSubscribeMessage) *WebSocketClient
- func (as *ApiService) Order(orderId string) (*ApiResponse, error)
- func (as *ApiService) Orders(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
- func (as *ApiService) Prices(base, currencies string) (*ApiResponse, error)
- func (as *ApiService) RecentFills() (*ApiResponse, error)
- func (as *ApiService) RecentOrders() (*ApiResponse, error)
- func (as *ApiService) ServerTime() (*ApiResponse, error)
- func (as *ApiService) Stats24hr(symbol string) (*ApiResponse, error)
- func (as *ApiService) Symbols(market string) (*ApiResponse, error)
- func (as *ApiService) TickerLevel1(symbol string) (*ApiResponse, error)
- func (as *ApiService) Tickers() (*ApiResponse, error)
- func (as *ApiService) TradeHistories(symbol string) (*ApiResponse, error)
- func (as *ApiService) WebSocketPrivateToken() (*ApiResponse, error)
- func (as *ApiService) WebSocketPublicToken() (*ApiResponse, error)
- func (as *ApiService) WithdrawalQuotas(currency string) (*ApiResponse, error)
- func (as *ApiService) Withdrawals(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
- type ApiServiceOption
- type ApplyWithdrawalResultModel
- type BasicRequester
- type CancelOrderResultModel
- type CancelWithdrawalResultModel
- type CreateOrderResultModel
- type CurrenciesModel
- type CurrencyModel
- type DepositAddressModel
- type DepositAddressesModel
- type DepositModel
- type DepositsModel
- type FillModel
- type FillsModel
- type FullOrderBookModel
- type InterTransferResultModel
- type KLineModel
- type KLinesModel
- type KcSigner
- type OrderModel
- type OrdersModel
- type PaginationModel
- type PaginationParam
- type PartOrderBookModel
- type Request
- type Requester
- type Response
- type Sha256Signer
- type Signer
- type Stats24hrModel
- type SymbolModel
- type SymbolsModel
- type TickerLevel1Model
- type TickerModel
- type TickersModel
- type TickersResponseModel
- type TradeHistoriesModel
- type TradeHistoryModel
- type WebSocketClient
- type WebSocketDownstreamMessage
- type WebSocketMessage
- type WebSocketServerModel
- type WebSocketServersModel
- type WebSocketSubscribeMessage
- type WebSocketTokenModel
- type WithdrawalModel
- type WithdrawalQuotasModel
- type WithdrawalsModel
Constants ¶
const ( WelcomeMessage = "welcome" PingMessage = "ping" PongMessage = "pong" SubscribeMessage = "subscribe" AckMessage = "ack" UnsubscribeMessage = "unsubscribe" ErrorMessage = "error" )
All message types of WebSocket.
const (
ApiSuccess = "200000"
)
The predefined API codes
const ProductionApiBaseURI = "https://openapi-v2.kucoin.com"
ProductionApiBaseURI is api base uri for production.
Variables ¶
This section is empty.
Functions ¶
func ToJsonString ¶
func ToJsonString(v interface{}) string
ToJsonString converts any value to JSON string.
Types ¶
type AccountHoldModel ¶
type AccountHoldModel struct { Currency string `json:"currency"` HoldAmount string `json:"holdAmount"` BizType string `json:"bizType"` OrderId string `json:"orderId"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` }
An AccountHoldModel represents the holds on an account for any active orders or pending withdraw requests. As an order is filled, the hold amount is updated. If an order is canceled, any remaining hold is removed. For a withdraw, once it is completed, the hold is removed.
type AccountHoldsModel ¶
type AccountHoldsModel []*AccountHoldModel
An AccountHoldsModel is the set of *AccountHoldModel.
type AccountLedgerModel ¶ added in v1.0.3
type AccountLedgerModel struct { Currency string `json:"currency"` Amount string `json:"amount"` Fee string `json:"fee"` Balance string `json:"balance"` BizType string `json:"bizType"` Direction string `json:"direction"` CreatedAt int64 `json:"createdAt"` Context json.RawMessage `json:"context"` }
An AccountLedgerModel represents account activity either increases or decreases your account balance.
type AccountLedgersModel ¶ added in v1.0.3
type AccountLedgersModel []*AccountLedgerModel
An AccountLedgersModel the set of *AccountLedgerModel.
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"` // contains filtered or unexported fields }
An ApiResponse represents a API response wrapped Response.
func (*ApiResponse) ApiSuccessful ¶
func (ar *ApiResponse) ApiSuccessful() bool
ApiSuccessful judges the success of API.
func (*ApiResponse) HttpSuccessful ¶
func (ar *ApiResponse) HttpSuccessful() bool
HttpSuccessful judges the success of http.
func (*ApiResponse) ReadData ¶
func (ar *ApiResponse) ReadData(v interface{}) error
ReadData read the api response `data` as JSON into v.
func (*ApiResponse) ReadPaginationData ¶
func (ar *ApiResponse) ReadPaginationData(v interface{}) (*PaginationModel, error)
ReadPaginationData read the data `items` as JSON into v, and returns *PaginationModel.
type ApiService ¶
type ApiService struct {
// contains filtered or unexported fields
}
An ApiService provides a HTTP client and a signer to make a HTTP request with the signature to KuCoin API.
func NewApiService ¶
func NewApiService(opts ...ApiServiceOption) *ApiService
NewApiService creates a instance of ApiService by passing ApiServiceOptions, then you can call methods.
func NewApiServiceFromEnv ¶
func NewApiServiceFromEnv() *ApiService
NewApiServiceFromEnv creates a instance of ApiService by environmental variables such as `API_BASE_URI` `API_KEY` `API_SECRET` `API_PASSPHRASE`, then you can call the methods of ApiService.
func (*ApiService) Account ¶
func (as *ApiService) Account(accountId string) (*ApiResponse, error)
Account returns an account when you know the accountId.
func (*ApiService) AccountHolds ¶
func (as *ApiService) AccountHolds(accountId string, pagination *PaginationParam) (*ApiResponse, error)
AccountHolds returns a list of currency hold. Holds are placed on an account for any active orders or pending withdraw requests. As an order is filled, the hold amount is updated. If an order is canceled, any remaining hold is removed. For a withdraw, once it is completed, the hold is removed.
func (*ApiService) AccountLedgers ¶ added in v1.0.3
func (as *ApiService) AccountLedgers(accountId string, startAt, endAt int64, pagination *PaginationParam) (*ApiResponse, error)
AccountLedgers returns a list of ledgers. Account activity either increases or decreases your account balance. Items are paginated and sorted latest first.
func (*ApiService) Accounts ¶
func (as *ApiService) Accounts(currency, typo string) (*ApiResponse, error)
Accounts returns a list of accounts. See the Deposits section for documentation on how to deposit funds to begin trading.
func (*ApiService) AggregatedFullOrderBook ¶
func (as *ApiService) AggregatedFullOrderBook(symbol string) (*ApiResponse, error)
AggregatedFullOrderBook returns a list of open orders(aggregated) for a symbol.
func (*ApiService) AggregatedPartOrderBook ¶ added in v1.0.3
func (as *ApiService) AggregatedPartOrderBook(symbol string, depth int64) (*ApiResponse, error)
AggregatedPartOrderBook returns a list of open orders(aggregated) for a symbol.
func (*ApiService) ApplyWithdrawal ¶
func (as *ApiService) ApplyWithdrawal(currency, address, amount string, options map[string]string) (*ApiResponse, error)
ApplyWithdrawal applies a withdrawal.
func (*ApiService) AtomicFullOrderBook ¶
func (as *ApiService) AtomicFullOrderBook(symbol string) (*ApiResponse, error)
AtomicFullOrderBook returns a list of open orders for a symbol. Level-3 order book includes all bids and asks (non-aggregated, each item in Level-3 means a single order).
func (*ApiService) Call ¶
func (as *ApiService) Call(request *Request) (*ApiResponse, error)
Call calls the API by passing *Request and returns *ApiResponse.
func (*ApiService) CancelOrder ¶
func (as *ApiService) CancelOrder(orderId string) (*ApiResponse, error)
CancelOrder cancels a previously placed order.
func (*ApiService) CancelOrders ¶
func (as *ApiService) CancelOrders(symbol string) (*ApiResponse, error)
CancelOrders cancels all orders of the symbol. With best effort, cancel all open orders. The response is a list of ids of the canceled orders.
func (*ApiService) CancelWithdrawal ¶
func (as *ApiService) CancelWithdrawal(withdrawalId string) (*ApiResponse, error)
CancelWithdrawal cancels a withdrawal by withdrawalId.
func (*ApiService) CreateAccount ¶
func (as *ApiService) CreateAccount(typo, currency string) (*ApiResponse, error)
CreateAccount creates an account according to type(main|trade) and currency Parameter #1 typo is type of account.
func (*ApiService) CreateDepositAddress ¶
func (as *ApiService) CreateDepositAddress(currency string) (*ApiResponse, error)
CreateDepositAddress creates a deposit address.
func (*ApiService) CreateOrder ¶
func (as *ApiService) CreateOrder(params map[string]string) (*ApiResponse, error)
CreateOrder places a new order.
func (*ApiService) Currencies ¶
func (as *ApiService) Currencies() (*ApiResponse, error)
Currencies returns a list of known currencies.
func (*ApiService) Currency ¶
func (as *ApiService) Currency(currency string) (*ApiResponse, error)
Currency returns the details of the currency.
func (*ApiService) DepositAddresses ¶
func (as *ApiService) DepositAddresses(currency string) (*ApiResponse, error)
DepositAddresses returns the deposit address of currency for deposit. If return data is empty, you may need create a deposit address first.
func (*ApiService) Deposits ¶
func (as *ApiService) Deposits(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
Deposits returns a list of deposit.
func (*ApiService) Fills ¶
func (as *ApiService) Fills(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
Fills returns a list of recent fills.
func (*ApiService) InnerTransfer ¶
func (as *ApiService) InnerTransfer(clientOid, payAccountId, recAccountId, amount string) (*ApiResponse, error)
InnerTransfer makes a currency transfer internally. The inner transfer interface is used for assets transfer among the accounts of a user and is free of charges on the platform. For example, a user could transfer assets for free form the main account to the trading account on the platform.
func (*ApiService) KLines ¶ added in v1.0.5
func (as *ApiService) KLines(symbol, typo string, startAt, endAt int64) (*ApiResponse, error)
KLines returns the k lines for a symbol. Data are returned in grouped buckets based on requested type. Parameter #2 typo is the type of candlestick patterns.
func (*ApiService) Markets ¶
func (as *ApiService) Markets() (*ApiResponse, error)
Markets returns the transaction currencies for the entire trading market.
func (*ApiService) NewWebSocketClient ¶
func (as *ApiService) NewWebSocketClient(token *WebSocketTokenModel, channel *WebSocketSubscribeMessage) *WebSocketClient
NewWebSocketClient creates an instance of WebSocketClient.
func (*ApiService) Order ¶
func (as *ApiService) Order(orderId string) (*ApiResponse, error)
Order returns a single order by order id.
func (*ApiService) Orders ¶
func (as *ApiService) Orders(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
Orders returns a list your current orders.
func (*ApiService) Prices ¶ added in v1.0.5
func (as *ApiService) Prices(base, currencies string) (*ApiResponse, error)
Prices returns the fiat prices for currency.
func (*ApiService) RecentFills ¶ added in v1.0.2
func (as *ApiService) RecentFills() (*ApiResponse, error)
RecentFills returns the recent fills of the latest transactions within 24 hours.
func (*ApiService) RecentOrders ¶ added in v1.0.2
func (as *ApiService) RecentOrders() (*ApiResponse, error)
RecentOrders returns the recent orders of the latest transactions within 24 hours.
func (*ApiService) ServerTime ¶
func (as *ApiService) ServerTime() (*ApiResponse, error)
ServerTime returns the API server time.
func (*ApiService) Stats24hr ¶
func (as *ApiService) Stats24hr(symbol string) (*ApiResponse, error)
Stats24hr returns 24 hr stats for the symbol. volume is in base currency units. open, high, low are in quote currency units.
func (*ApiService) Symbols ¶
func (as *ApiService) Symbols(market string) (*ApiResponse, error)
Symbols returns a list of available currency pairs for trading.
func (*ApiService) TickerLevel1 ¶ added in v1.0.3
func (as *ApiService) TickerLevel1(symbol string) (*ApiResponse, error)
TickerLevel1 returns the ticker include only the inside (i.e. best) bid and ask data, last price and last trade size.
func (*ApiService) Tickers ¶ added in v1.0.3
func (as *ApiService) Tickers() (*ApiResponse, error)
Tickers returns all tickers as TickersResponseModel for all trading pairs in the market (including 24h volume).
func (*ApiService) TradeHistories ¶
func (as *ApiService) TradeHistories(symbol string) (*ApiResponse, error)
TradeHistories returns a list the latest trades for a symbol.
func (*ApiService) WebSocketPrivateToken ¶
func (as *ApiService) WebSocketPrivateToken() (*ApiResponse, error)
WebSocketPrivateToken returns the token for private channel.
func (*ApiService) WebSocketPublicToken ¶
func (as *ApiService) WebSocketPublicToken() (*ApiResponse, error)
WebSocketPublicToken returns the token for public channel.
func (*ApiService) WithdrawalQuotas ¶
func (as *ApiService) WithdrawalQuotas(currency string) (*ApiResponse, error)
WithdrawalQuotas returns the quotas of withdrawal.
func (*ApiService) Withdrawals ¶
func (as *ApiService) Withdrawals(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
Withdrawals returns a list of withdrawals.
type ApiServiceOption ¶
type ApiServiceOption func(service *ApiService)
An ApiServiceOption is a option parameter to create the instance of ApiService.
func ApiBaseURIOption ¶
func ApiBaseURIOption(uri string) ApiServiceOption
ApiBaseURIOption creates a instance of ApiServiceOption about apiBaseURI.
func ApiKeyOption ¶
func ApiKeyOption(key string) ApiServiceOption
ApiKeyOption creates a instance of ApiServiceOption about apiKey.
func ApiPassPhraseOption ¶
func ApiPassPhraseOption(passPhrase string) ApiServiceOption
ApiPassPhraseOption creates a instance of ApiServiceOption about apiPassPhrase.
func ApiSecretOption ¶
func ApiSecretOption(secret string) ApiServiceOption
ApiSecretOption creates a instance of ApiServiceOption about apiSecret.
func ApiSkipVerifyTlsOption ¶
func ApiSkipVerifyTlsOption(skipVerifyTls bool) ApiServiceOption
ApiSkipVerifyTlsOption creates a instance of ApiServiceOption about apiSkipVerifyTls.
type ApplyWithdrawalResultModel ¶
type ApplyWithdrawalResultModel struct {
WithdrawalId string `json:"withdrawalId"`
}
ApplyWithdrawalResultModel represents the result of ApplyWithdrawal().
type BasicRequester ¶
type BasicRequester struct { }
A BasicRequester represents a basic implement of Requester by http.Client.
type CancelOrderResultModel ¶
type CancelOrderResultModel struct {
CancelledOrderIds []string `json:"cancelledOrderIds"`
}
A CancelOrderResultModel represents the result of CancelOrder().
type CancelWithdrawalResultModel ¶
type CancelWithdrawalResultModel struct {
CancelledWithdrawIds []string `json:"cancelledWithdrawIds"`
}
CancelWithdrawalResultModel represents the result of CancelWithdrawal().
type CreateOrderResultModel ¶
type CreateOrderResultModel struct {
OrderId string `json:"orderId"`
}
A CreateOrderResultModel represents the result of CreateOrder().
type CurrenciesModel ¶
type CurrenciesModel []*CurrencyModel
A CurrenciesModel is the set of *CurrencyModel.
type CurrencyModel ¶
type CurrencyModel struct { Name string `json:"name"` Currency string `json:"currency"` FullName string `json:"fullName"` Precision uint8 `json:"precision"` WithdrawalMinSize string `json:"withdrawalMinSize"` WithdrawalMinFee string `json:"withdrawalMinFee"` IsWithdrawEnabled bool `json:"isWithdrawEnabled"` IsDepositEnabled bool `json:"isDepositEnabled"` }
A CurrencyModel represents a model of known currency.
type DepositAddressModel ¶
A DepositAddressModel represents a deposit address of currency for deposit.
type DepositAddressesModel ¶
type DepositAddressesModel []*DepositAddressModel
A DepositAddressesModel is the set of *DepositAddressModel.
type DepositModel ¶
type DepositModel struct { Address string `json:"address"` Memo string `json:"memo"` Amount string `json:"amount"` Fee string `json:"fee"` Currency string `json:"currency"` IsInner bool `json:"isInner"` WalletTxId string `json:"walletTxId"` Status string `json:"status"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` }
A DepositModel represents a deposit record.
type DepositsModel ¶
type DepositsModel []*DepositModel
A DepositsModel is the set of *DepositModel.
type FillModel ¶
type FillModel struct { Symbol string `json:"symbol"` TradeId string `json:"tradeId"` OrderId string `json:"orderId"` CounterOrderId string `json:"counterOrderId"` Side string `json:"side"` Liquidity string `json:"liquidity"` ForceTaker bool `json:"forceTaker"` Price string `json:"price"` Size string `json:"size"` Funds string `json:"funds"` Fee string `json:"fee"` FeeRate string `json:"feeRate"` FeeCurrency string `json:"feeCurrency"` Stop string `json:"stop"` Type string `json:"type"` CreatedAt int64 `json:"createdAt"` }
A FillModel represents the structure of fill.
type FullOrderBookModel ¶
type FullOrderBookModel struct { Sequence string `json:"sequence"` Bids [][]string `json:"bids"` Asks [][]string `json:"asks"` }
A FullOrderBookModel represents a list of open orders for a symbol, with full depth.
type InterTransferResultModel ¶
type InterTransferResultModel struct {
OrderId string `json:"orderId"`
}
An InterTransferResultModel represents the result of a inner-transfer operation.
type KLineModel ¶ added in v1.0.5
type KLineModel []string
KLineModel represents the k lines for a symbol. Rates are returned in grouped buckets based on requested type.
type KLinesModel ¶ added in v1.0.5
type KLinesModel []*KLineModel
A KLinesModel is the set of *KLineModel.
type KcSigner ¶
type KcSigner struct { Sha256Signer // contains filtered or unexported fields }
KcSigner is the implement of Signer for KuCoin.
func NewKcSigner ¶
NewKcSigner creates a instance of KcSigner.
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 uint64 `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"` }
An OrderModel represents an order.
type PaginationModel ¶
type PaginationModel struct { CurrentPage int64 `json:"currentPage"` PageSize int64 `json:"pageSize"` TotalNum int64 `json:"totalNum"` TotalPage int64 `json:"totalPage"` RawItems json.RawMessage `json:"items"` // delay parsing }
A PaginationModel represents the pagination in a response.
func (*PaginationModel) ReadItems ¶
func (p *PaginationModel) ReadItems(v interface{}) error
ReadItems read the `items` into v.
type PaginationParam ¶
A PaginationParam represents the pagination parameters `currentPage` `pageSize` in a request .
func (*PaginationParam) ReadParam ¶
func (p *PaginationParam) ReadParam(params map[string]string)
ReadParam read pagination parameters into params.
type PartOrderBookModel ¶
type PartOrderBookModel struct { Sequence string `json:"sequence"` 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 Request ¶
type Request struct { BaseURI string Method string Path string Query url.Values Body []byte Header http.Header Timeout time.Duration SkipVerifyTls bool // contains filtered or unexported fields }
A Request represents a HTTP request.
func NewRequest ¶
NewRequest creates a instance of Request.
func (*Request) HttpRequest ¶
HttpRequest creates a instance of *http.Request.
func (*Request) RequestURI ¶
RequestURI returns the request uri.
type Response ¶
A Response represents a HTTP response.
func (*Response) ReadJsonBody ¶
ReadJsonBody read the response data as JSON into v.
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 Stats24hrModel ¶
type Stats24hrModel struct { Symbol string `json:"symbol"` ChangeRate string `json:"changeRate"` ChangePrice string `json:"changePrice"` Open string `json:"open"` Close string `json:"close"` High string `json:"high"` Low string `json:"low"` Vol string `json:"vol"` VolValue string `json:"volValue"` }
A Stats24hrModel represents 24 hr stats for the symbol. Volume is in base currency units. Open, high, low are in quote currency units.
type SymbolModel ¶
type SymbolModel struct { Symbol string `json:"symbol"` Name string `json:"name"` BaseCurrency string `json:"baseCurrency"` QuoteCurrency string `json:"quoteCurrency"` 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"` EnableTrading bool `json:"enableTrading"` }
A SymbolModel represents an available currency pairs for trading.
type TickerLevel1Model ¶ added in v1.0.3
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 { Symbol string `json:"symbol"` 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"` Last string `json:"last"` }
A TickerModel represents a market ticker for all trading pairs in the market (including 24h volume).
type TickersModel ¶ added in v1.0.3
type TickersModel []*TickerModel
A TickersModel is the set of *MarketTickerModel.
type TickersResponseModel ¶ added in v1.0.3
type TickersResponseModel struct { Time int64 `json:"time"` Tickers TickersModel `json:"ticker"` }
TickersResponseModel represents the response model of MarketTickers().
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 WebSocketClient ¶
type WebSocketClient struct {
// contains filtered or unexported fields
}
A WebSocketClient represents a connection to WebSocket server.
func (*WebSocketClient) Connect ¶
func (wc *WebSocketClient) Connect() error
Connect connects the WebSocket server.
func (*WebSocketClient) Stop ¶
func (wc *WebSocketClient) Stop()
Stop stops subscribing the specified channel, all goroutines quit.
func (*WebSocketClient) Subscribe ¶
func (wc *WebSocketClient) Subscribe() (<-chan *WebSocketDownstreamMessage, <-chan error)
Subscribe subscribes the specified channel.
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.
func NewPingMessage ¶
func NewPingMessage() *WebSocketMessage
NewPingMessage creates a ping message instance.
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.
func NewSubscribeMessage ¶
func NewSubscribeMessage(topic string, privateChannel, response bool) *WebSocketSubscribeMessage
NewSubscribeMessage creates a subscribe message instance.
func NewUnsubscribeMessage ¶
func NewUnsubscribeMessage(topic string, privateChannel, response bool) *WebSocketSubscribeMessage
NewUnsubscribeMessage creates a unsubscribe message instance.
type WebSocketTokenModel ¶
type WebSocketTokenModel struct { Token string `json:"token"` Servers WebSocketServersModel `json:"instanceServers"` }
A WebSocketTokenModel contains a token and some servers for WebSocket feed.
type WithdrawalModel ¶
type WithdrawalModel struct { Id string `json:"id"` Address string `json:"address"` Memo string `json:"memo"` Currency string `json:"currency"` Amount string `json:"amount"` Fee string `json:"fee"` WalletTxId string `json:"walletTxId"` IsInner bool `json:"isInner"` Status string `json:"status"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` }
A WithdrawalModel represents a withdrawal.
type WithdrawalQuotasModel ¶
type WithdrawalQuotasModel struct { Currency string `json:"currency"` AvailableAmount string `json:"availableAmount"` RemainAmount string `json:"remainAmount"` WithdrawMinSize string `json:"withdrawMinSize"` LimitBTCAmount string `json:"limitBTCAmount"` InnerWithdrawMinFee string `json:"innerWithdrawMinFee"` UsedBTCAmount string `json:"usedBTCAmount"` IsWithdrawEnabled bool `json:"isWithdrawEnabled"` WithdrawMinFee string `json:"withdrawMinFee"` Precision uint8 `json:"precision"` }
A WithdrawalQuotasModel represents the quotas for a currency.
type WithdrawalsModel ¶
type WithdrawalsModel []*WithdrawalModel
A WithdrawalsModel is the set of *WithdrawalModel.