Documentation ¶
Index ¶
- Constants
- Variables
- func IntToString(i int64) string
- func ToJsonString(v interface{}) string
- type AccountModel
- type AccountsModel
- type ApiResponse
- type ApiService
- func (as *ApiService) Accounts(currency, typo string) (*ApiResponse, error)
- func (as *ApiService) AggregatedFullOrderBook(symbol string) (*ApiResponse, error)
- func (as *ApiService) CancelOrder(orderId string) (*ApiResponse, error)
- func (as *ApiService) CancelStopOrder(orderId string) (*ApiResponse, error)
- func (as *ApiService) CreateOrder(params map[string]string) (*ApiResponse, error)
- func (as *ApiService) CreateStopOrder(params map[string]string) (*ApiResponse, error)
- func (as *ApiService) Fills(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
- func (as *ApiService) Markets() (*ApiResponse, error)
- func (as *ApiService) Order(orderId string) (*ApiResponse, error)
- func (as *ApiService) Orders(params map[string]string, pagination *PaginationParam) (*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) StopOrder(orderId string) (*ApiResponse, error)
- func (as *ApiService) StopOrders(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
- func (as *ApiService) Symbols(market string) (*ApiResponse, error)
- func (as *ApiService) TickerLevel1(symbol string) (*ApiResponse, error)
- func (as *ApiService) Tickers() (*ApiResponse, error)
- type ApiServiceOption
- func ApiBaseURIOption(uri string) ApiServiceOption
- func ApiKeyOption(key string) ApiServiceOption
- func ApiPartnerIdOption(partnerID string) ApiServiceOption
- func ApiPartnerSecretOption(partnerSecret string) ApiServiceOption
- func ApiPassPhraseOption(passPhrase string) ApiServiceOption
- func ApiSecretOption(secret string) ApiServiceOption
- type BasicRequester
- type BookEntry
- type CancelOrderResultModel
- type CreateOrderResultModel
- type FillModel
- type FillsModel
- type FullOrderBookModel
- type KcSigner
- type OrderModel
- type OrderPredicate
- type OrdersModel
- type PaginationModel
- type PaginationParam
- type Request
- type Requester
- type Response
- type Stats24hrModel
- type SymbolModel
- type SymbolsModel
- type TickerLevel1Model
- type TickerModel
- type TickersModel
- type TickersResponseModel
Constants ¶
const (
ApiSuccess = "200000"
)
The predefined API codes
const ProductionApiBaseURI = "https://api.kucoin.com"
ProductionApiBaseURI is api base uri for production.
Variables ¶
var ( BeforeRequest func(client *ApiService, request *Request, rps float64) error = nil AfterRequest func() = nil )
Functions ¶
func ToJsonString ¶
func ToJsonString(v interface{}) string
ToJsonString converts any value to JSON string.
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 interface{} `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 (*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) CancelOrder ¶
func (as *ApiService) CancelOrder(orderId string) (*ApiResponse, error)
CancelOrder cancels a previously placed order.
func (*ApiService) CancelStopOrder ¶
func (as *ApiService) CancelStopOrder(orderId string) (*ApiResponse, error)
CancelStopOrder cancels a previously placed stop-order.
func (*ApiService) CreateOrder ¶
func (as *ApiService) CreateOrder(params map[string]string) (*ApiResponse, error)
CreateOrder places a new order.
func (*ApiService) CreateStopOrder ¶
func (as *ApiService) CreateStopOrder(params map[string]string) (*ApiResponse, error)
CreateStopOrder places a new stop-order.
func (*ApiService) Fills ¶
func (as *ApiService) Fills(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
Fills returns a list of recent fills.
func (*ApiService) Markets ¶
func (as *ApiService) Markets() (*ApiResponse, error)
Markets returns the transaction currencies for the entire trading market.
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) RecentFills ¶
func (as *ApiService) RecentFills() (*ApiResponse, error)
RecentFills returns the recent fills of the latest transactions within 24 hours.
func (*ApiService) RecentOrders ¶
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) StopOrder ¶
func (as *ApiService) StopOrder(orderId string) (*ApiResponse, error)
StopOrder returns a single order by stop-order id.
func (*ApiService) StopOrders ¶
func (as *ApiService) StopOrders(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)
StopOrders returns a list your current stop-orders.
func (*ApiService) Symbols ¶
func (as *ApiService) Symbols(market string) (*ApiResponse, error)
Symbols returns a list of available currency pairs for trading.
func (*ApiService) TickerLevel1 ¶
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 ¶
func (as *ApiService) Tickers() (*ApiResponse, error)
Tickers returns all tickers as TickersResponseModel for all trading pairs in the market (including 24h volume).
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 ApiPartnerIdOption ¶
func ApiPartnerIdOption(partnerID string) ApiServiceOption
func ApiPartnerSecretOption ¶
func ApiPartnerSecretOption(partnerSecret string) ApiServiceOption
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.
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 CreateOrderResultModel ¶
type CreateOrderResultModel struct {
OrderId string `json:"orderId"`
}
A CreateOrderResultModel represents the result of CreateOrder().
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.
func (*FillModel) ParseCreatedAt ¶
ParseCreatedAt returns the creation time as time.Time
func (*FillModel) ParsePrice ¶
ParsePrice returns the price as float64
type FillsModel ¶
type FillsModel []*FillModel
A FillsModel is the set of *FillModel.
func (FillsModel) IndexOfOrderId ¶
func (fills FillsModel) IndexOfOrderId(orderId string) int
type FullOrderBookModel ¶
type FullOrderBookModel struct { Sequence string `json:"sequence"` Bids []BookEntry `json:"bids"` Asks []BookEntry `json:"asks"` }
A FullOrderBookModel represents a list of open orders for a symbol, with full depth.
type KcSigner ¶
type KcSigner struct {
// 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,omitempty"` DealFunds string `json:"dealFunds,omitempty"` DealSize string `json:"dealSize,omitempty"` Fee string `json:"fee,omitempty"` FeeCurrency string `json:"feeCurrency,omitempty"` Stp string `json:"stp,omitempty"` Stop string `json:"stop,omitempty"` StopTriggered bool `json:"stopTriggered,omitempty"` StopPrice string `json:"stopPrice,omitempty"` TimeInForce string `json:"timeInForce,omitempty"` PostOnly bool `json:"postOnly,omitempty"` Hidden bool `json:"hidden,omitempty"` IceBerg bool `json:"iceberg,omitempty"` VisibleSize string `json:"visibleSize,omitempty"` CancelAfter int64 `json:"cancelAfter,omitempty"` Channel string `json:"channel,omitempty"` ClientOid string `json:"clientOid,omitempty"` Remark string `json:"remark,omitempty"` Tags string `json:"tags,omitempty"` IsActive bool `json:"isActive,omitempty"` CancelExist bool `json:"cancelExist,omitempty"` CreatedAt int64 `json:"createdAt,omitempty"` TradeType string `json:"tradeType,omitempty"` Status string `json:"status,omitempty"` FailMsg string `json:"failMsg,omitempty"` }
An OrderModel represents an order.
func (*OrderModel) ParseCreatedAt ¶
func (o *OrderModel) ParseCreatedAt() time.Time
ParseCreatedAt returns the creation time as time.Time
func (*OrderModel) ParsePrice ¶
func (o *OrderModel) ParsePrice() float64
ParsePrice returns the Price as float64
func (*OrderModel) ParseSize ¶
func (o *OrderModel) ParseSize() float64
ParseSize returns the Quantity as float64
func (*OrderModel) ParseStopPrice ¶
func (o *OrderModel) ParseStopPrice() float64
ParseStopPrice returns the StopPrice as float64
type OrderPredicate ¶
type OrderPredicate func(order *OrderModel) bool
A OrdersModel is the set of *OrderModel.
type OrdersModel ¶
type OrdersModel []*OrderModel
A OrdersModel is the set of *OrderModel.
func (OrdersModel) Find ¶
func (orders OrdersModel) Find(callback *OrderPredicate) int
func (OrdersModel) IndexOfId ¶
func (orders OrdersModel) IndexOfId(Id string) int
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 Request ¶
type Request struct { BaseURI string Method string Path string Query url.Values Body []byte Header http.Header Timeout time.Duration // 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 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"` 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 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 { 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 TickersResponseModel ¶
type TickersResponseModel struct { Time int64 `json:"time"` Tickers TickersModel `json:"ticker"` }
TickersResponseModel represents the response model of MarketTickers().