kugo

package module
v0.0.0-...-2d35710 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 15 Imported by: 0

README

KuGo

Software License

The Best Go SDK for KuCoin API

This SDK is currently available for KuCoin V2 API KEY. All API request parameters and response details are described in the documentation at https://docs.kucoin.com.

Install

go get github.com/xiiiew/kugo

REST API Support

Account
DESCRIPTION METHOD URI
List Spot Accounts GET /api/v2/accounts
List Future Accounts GET /api/v1/account-overview
Spot
DESCRIPTION METHOD URI
Place a New Order POST /api/v1/orders
Place a Margin Order POST /api/v1/margin/order
Cancel an Order DELETE /api/v1/orders/{orderId}
List Orders GET /api/v1/orders
Get an Order GET /api/v1/orders/{orderId}
List Fills GET /api/v1/fills
Future
DESCRIPTION METHOD URI
Place an Order POST /api/v1/orders
Cancel an Order DELETE /api/v1/orders/{orderId}
List Orders GET /api/v1/orders
Get an Order GET /api/v1/orders/{orderId}
List Fills GET /api/v1/fills
Get Position Details GET /api/v1/position
Market
DESCRIPTION METHOD URI
Get Spot Symbols GET /api/v2/symbols
Get Future Symbols GET /api/v1/contracts/active

Usage

Create Instance
// Default instance
instance, err := kugo.NewKucoin()

// Set Kucoin V2 API Key
instance, err := kugo.NewKucoin(
    kugo.SetApiKey("accessKey", "secretKey", "passphrase"),
)

// Set environment
instance, err := kugo.NewKucoin(
    kugo.SetSpotEndpoint("https://openapi-sandbox.kucoin.com"),
    kugo.SetFutureEndpoint("https://api-sandbox-futures.kucoin.com"),
)

// Debug mode. Default output of debug information to the console
instance, err := kugo.NewKucoin(
    kugo.SetDebug(true),
)

// Set the output mode of debug information (e.g. to log files)
instance, err := kugo.NewKucoin(
    kugo.SetDebug(true),
    kugo.SetRequestLog(func(i ...interface{}) {
        // Output request log
    }),
    kugo.SetResponseLog(func(i ...interface{}) {
        // Output response log
    }),
)

// Set HTTP client
uProxy, _ := url.Parse("http://127.0.0.1:7890")
instance, err := kugo.NewKucoin(
    kugo.SetClient(&http.Client{Transport: &http.Transport{
			Proxy:             http.ProxyURL(uProxy),
			DisableKeepAlives: true},
			Timeout: 10 * time.Second},
    ),
)

Examples

See the test case for more examples.

// Spot symbols
symbols, err := instance.SpotSymbols("USDS")
if err != nil {
    t.Fatal(err)
}
t.Logf("result: %+v", symbols)

// Spot order
req := &kugo.SpotOrdersRequest{
    ClientOid:   "123",
    Side:        "buy",
    Symbol:      "BTC-USDT",
    Type:        "limit",
    TradeType:   "TRADE",
    Price:       decimal.NewFromFloat(450000),
    Size:        decimal.NewFromFloat(1),
    TimeInForce: "IOC",
}
result, err := instance.SpotOrder(req)
t.Log(result, err)

Contributing

We welcome contributions from anyone!

Contact

If you have any questions or concerns about the project, you can contact us at:

Documentation

Index

Constants

View Source
const (
	UriSpotSymbols     = "/api/v2/symbols"
	UriSpotAccount     = "/api/v1/accounts"
	UriSpotOrders      = "/api/v1/orders"
	UriSpotMarginOrder = "/api/v1/margin/order"
	UriSpotOrderFills  = "/api/v1/fills"
	UriSpotOrderCancel = "/api/v1/orders/%s"
	UriSpotOrderOne    = "/api/v1/orders/%s"

	UriFutureAccount     = "/api/v1/account-overview"
	UriFutureOrders      = "/api/v1/orders"
	UriFutureOrderCancel = "/api/v1/orders/%s"
	UriFutureOrderOne    = "/api/v1/orders/%s"
	UriFutureOrderFills  = "/api/v1/fills"
	UriFuturePosition    = "/api/v1/position"
	UriFutureSymbols     = "/api/v1/contracts/active"
)

URI

View Source
const ApiKeyVersionV2 = "2"
View Source
const FutureEndpoint = "https://api-futures.kucoin.com"
View Source
const SpotEndpoint = "https://api.kucoin.com"

SpotEndpoint Base URL

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountsData

type AccountsData struct {
	Id        string          `json:"id"`
	Currency  string          `json:"currency"`
	Type      string          `json:"type"`
	Balance   decimal.Decimal `json:"balance"`
	Available decimal.Decimal `json:"available"`
	Holds     decimal.Decimal `json:"holds"`
}

type AccountsResponse

type AccountsResponse struct {
	BaseResponse
	Data []AccountsData `json:"data"`
}

AccountsResponse Response of GET /api/v2/accounts

type BaseResponse

type BaseResponse struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
}

type BaseResponsePagination

type BaseResponsePagination struct {
	CurrentPage int `json:"currentPage"`
	PageSize    int `json:"pageSize"`
	TotalNum    int `json:"totalNum"`
	TotalPage   int `json:"totalPage"`
}

type FutureAccountData

type FutureAccountData struct {
	AccountEquity    decimal.Decimal `json:"accountEquity"` // Account equity = marginBalance + Unrealised PNL
	UnrealisedPNL    decimal.Decimal `json:"unrealisedPNL"` // Unrealised profit and loss
	MarginBalance    decimal.Decimal `json:"marginBalance"` // Margin balance = positionMargin + orderMargin + frozenFunds + availableBalance - unrealisedPNL
	PositionMargin   decimal.Decimal `json:"positionMargin"`
	OrderMargin      decimal.Decimal `json:"orderMargin"`
	FrozenFunds      decimal.Decimal `json:"frozenFunds"` // Frozen funds for withdrawal and out-transfer
	AvailableBalance decimal.Decimal `json:"availableBalance"`
	Currency         string          `json:"currency"`
}

type FutureAccountResponse

type FutureAccountResponse struct {
	BaseResponse
	Data FutureAccountData `json:"data"`
}

FutureAccountResponse Response of GET /api/v1/account-overview

type FutureOrderCancelData

type FutureOrderCancelData struct {
	CancelledOrderIds []string `json:"cancelledOrderIds"`
}

type FutureOrderCancelResponse

type FutureOrderCancelResponse struct {
	BaseResponse
	Data FutureOrderCancelData `json:"data"`
}

FutureOrderCancelResponse Response of DELETE /api/v1/orders/{orderId}

type FutureOrderData

type FutureOrderData struct {
	OrderId string `json:"orderId"`
}

type FutureOrderFillsData

type FutureOrderFillsData struct {
	BaseResponsePagination
	Items []FutureOrderFillsItem `json:"items"`
}

type FutureOrderFillsItem

type FutureOrderFillsItem struct {
	Symbol         string          `json:"symbol"`
	TradeId        string          `json:"tradeId"`
	OrderId        string          `json:"orderId"`
	Side           string          `json:"side"`
	Liquidity      string          `json:"liquidity"`
	ForceTaker     bool            `json:"forceTaker"`
	Price          decimal.Decimal `json:"price"`
	Size           int             `json:"size"` // Cont
	Value          decimal.Decimal `json:"value"`
	FeeRate        decimal.Decimal `json:"feeRate"`
	FixFee         decimal.Decimal `json:"fixFee"`
	FeeCurrency    string          `json:"feeCurrency"`
	Stop           string          `json:"stop"`
	Fee            decimal.Decimal `json:"fee"`
	OrderType      string          `json:"orderType"`
	TradeType      string          `json:"tradeType"` // trade, liquidation, ADL or settlement
	CreatedAt      int64           `json:"createdAt"`
	SettleCurrency string          `json:"settleCurrency"`
	TradeTime      int64           `json:"tradeTime"`
}

type FutureOrderFillsRequest

type FutureOrderFillsRequest struct {
	OrderId string `json:"orderId,omitempty"` // If you specify orderId, other parameters can be ignored
	Symbol  string `json:"symbol,omitempty"`
	Side    string `json:"side,omitempty"`    // buy or sell
	Type    string `json:"type,omitempty"`    // limit, market, limit_stop or market_stop
	StartAt int64  `json:"startAt,omitempty"` // Start time (millisecond)
	EndAt   int64  `json:"endAt,omitempty"`   // End time (millisecond)
}

FutureOrderFillsRequest Request of GET /api/v1/fills

type FutureOrderFillsResponse

type FutureOrderFillsResponse struct {
	BaseResponse
	Data FutureOrderFillsData `json:"data"`
}

FutureOrderFillsResponse Response of GET /api/v1/fills

type FutureOrderListData

type FutureOrderListData struct {
	BaseResponsePagination
	Items []FutureOrderOneData `json:"items"`
}

type FutureOrderListRequest

type FutureOrderListRequest struct {
	Status  string `json:"status"`  // [Optional] active or done
	Symbol  string `json:"symbol"`  // [Optional]
	Side    string `json:"side"`    // [Optional] buy or sell
	Type    string `json:"type"`    // [Optional] limit, market, limit_stop or market_stop
	StartAt int64  `json:"startAt"` // [Optional] Start time (millisecond)
	EndAt   int64  `json:"endAt"`   // [Optional] End time (millisecond)
}

FutureOrderListRequest Request of GET /api/v1/orders

type FutureOrderListResponse

type FutureOrderListResponse struct {
	BaseResponse
	Data FutureOrderListData `json:"data"`
}

FutureOrderListResponse Response of GET /api/v1/orders

type FutureOrderOneData

type FutureOrderOneData struct {
	Id             string          `json:"id"`
	Symbol         string          `json:"symbol"`
	Type           string          `json:"type"`
	Side           string          `json:"side"`
	Price          decimal.Decimal `json:"price"`
	Size           int             `json:"size"` // Cont
	Value          decimal.Decimal `json:"value"`
	DealValue      decimal.Decimal `json:"dealValue"`
	DealSize       decimal.Decimal `json:"dealSize"`
	Stp            string          `json:"stp"`
	Stop           string          `json:"stop"`
	StopPriceType  string          `json:"stopPriceType"`
	StopTriggered  bool            `json:"stopTriggered"`
	StopPrice      decimal.Decimal `json:"stopPrice"`
	TimeInForce    string          `json:"timeInForce"`
	PostOnly       bool            `json:"postOnly"`
	Hidden         bool            `json:"hidden"`
	Iceberg        bool            `json:"iceberg"`
	Leverage       decimal.Decimal `json:"leverage"`
	ForceHold      bool            `json:"forceHold"`
	CloseOrder     bool            `json:"closeOrder"`
	VisibleSize    decimal.Decimal `json:"visibleSize"`
	ClientOid      string          `json:"clientOid"`
	Remark         string          `json:"remark"`
	Tags           string          `json:"tags"`
	IsActive       bool            `json:"isActive"`
	CancelExist    bool            `json:"cancelExist"`
	CreatedAt      int64           `json:"createdAt"`
	UpdatedAt      int64           `json:"UpdatedAt"`
	EndAt          int64           `json:"endAt"`
	OrderTime      int64           `json:"orderTime"`
	SettleCurrency string          `json:"SettleCurrency"`
	Status         string          `json:"status"`
	FilledSize     decimal.Decimal `json:"filledSize"`
	FilledValue    decimal.Decimal `json:"filledValue"`
	ReduceOnly     bool            `json:"reduceOnly"`
}

type FutureOrderOneResponse

type FutureOrderOneResponse struct {
	BaseResponse
	Data FutureOrderOneData `json:"data"`
}

FutureOrderOneResponse Response of GET /api/v1/orders/{order-id}

type FutureOrderRequest

type FutureOrderRequest struct {
	ClientOid     string          `json:"clientOid,omitempty"`
	Side          string          `json:"side,omitempty"`   // buy or sell
	Symbol        string          `json:"symbol,omitempty"` // e.g. BTC-USDT
	Type          string          `json:"type,omitempty"`   // limit or market
	Leverage      decimal.Decimal `json:"leverage,omitempty"`
	Remark        string          `json:"remark,omitempty"`
	Stop          string          `json:"stop,omitempty"`
	StopPriceType string          `json:"stopPriceType,omitempty"` // TP, IP or MP
	StopPrice     decimal.Decimal `json:"stopPrice,omitempty"`
	ReduceOnly    bool            `json:"reduceOnly,omitempty"`
	CloseOrder    bool            `json:"closeOrder,omitempty"`
	ForceHold     bool            `json:"forceHold,omitempty"`
	Price         decimal.Decimal `json:"price,omitempty"`
	Size          int             `json:"size,omitempty"`        // Cont
	TimeInForce   string          `json:"timeInForce,omitempty"` // GTC, GTT, IOC or FOK
	PostOnly      bool            `json:"postOnly,omitempty"`
	Hidden        bool            `json:"hidden,omitempty"`
	Iceberg       bool            `json:"iceberg,omitempty"`
	VisibleSize   string          `json:"visibleSize,omitempty"`
}

FutureOrderRequest Request of POST /api/v1/orders

type FutureOrderResponse

type FutureOrderResponse struct {
	BaseResponse
	Data FutureOrderData `json:"data"`
}

FutureOrderResponse Response of POST /api/v1/orders

type FuturePositionData

type FuturePositionData struct {
	Id                string          `json:"id"`
	Symbol            string          `json:"symbol"`
	AutoDeposit       bool            `json:"autoDeposit"`
	MaintMarginReq    decimal.Decimal `json:"maintMarginReq"`
	RiskLimit         int             `json:"riskLimit"`
	RealLeverage      decimal.Decimal `json:"realLeverage"`
	CrossMode         bool            `json:"crossMode"`
	DelevPercentage   decimal.Decimal `json:"delevPercentage"`
	OpeningTimestamp  int64           `json:"openingTimestamp"`
	CurrentTimestamp  int64           `json:"currentTimestamp"`
	CurrentQty        int             `json:"currentQty"`
	CurrentCost       decimal.Decimal `json:"currentCost"`
	CurrentComm       decimal.Decimal `json:"currentComm"`
	UnrealisedCost    decimal.Decimal `json:"unrealisedCost"`
	RealisedGrossCost decimal.Decimal `json:"realisedGrossCost"`
	RealisedCost      decimal.Decimal `json:"realisedCost"`
	IsOpen            bool            `json:"isOpen"`
	MarkPrice         decimal.Decimal `json:"markPrice"`
	MarkValue         decimal.Decimal `json:"markValue"`
	PosCost           decimal.Decimal `json:"posCost"`
	PosCross          decimal.Decimal `json:"posCross"`
	PosInit           decimal.Decimal `json:"posInit"`
	PosComm           decimal.Decimal `json:"posComm"`
	PosLoss           decimal.Decimal `json:"posLoss"`
	PosMargin         decimal.Decimal `json:"posMargin"`
	PosMaint          decimal.Decimal `json:"posMaint"`
	MaintMargin       decimal.Decimal `json:"maintMargin"`
	RealisedGrossPnl  decimal.Decimal `json:"realisedGrossPnl"`
	RealisedPnl       decimal.Decimal `json:"realisedPnl"`
	UnrealisedPnl     decimal.Decimal `json:"unrealisedPnl"`
	UnrealisedPnlPcnt decimal.Decimal `json:"unrealisedPnlPcnt"`
	UnrealisedRoePcnt decimal.Decimal `json:"unrealisedRoePcnt"`
	AvgEntryPrice     decimal.Decimal `json:"avgEntryPrice"`
	LiquidationPrice  decimal.Decimal `json:"liquidationPrice"`
	BankruptPrice     decimal.Decimal `json:"bankruptPrice"`
	SettleCurrency    string          `json:"settleCurrency"`
	MaintainMargin    decimal.Decimal `json:"maintainMargin"`
	RiskLimitLevel    int             `json:"riskLimitLevel"`
}

type FuturePositionResponse

type FuturePositionResponse struct {
	BaseResponse
	Data FuturePositionData `json:"data"`
}

FuturePositionResponse Response of /api/v1/position

type FutureSymbolData

type FutureSymbolData struct {
	Symbol                  string          `json:"symbol"`
	RootSymbol              string          `json:"rootSymbol"`
	Type                    string          `json:"type"`
	FirstOpenDate           int64           `json:"firstOpenDate"`
	ExpireDate              interface{}     `json:"expireDate"`
	SettleDate              interface{}     `json:"settleDate"`
	BaseCurrency            string          `json:"baseCurrency"`
	QuoteCurrency           string          `json:"quoteCurrency"`
	SettleCurrency          string          `json:"settleCurrency"`
	MaxOrderQty             decimal.Decimal `json:"maxOrderQty"`
	MaxPrice                decimal.Decimal `json:"maxPrice"`
	LotSize                 decimal.Decimal `json:"lotSize"`
	TickSize                decimal.Decimal `json:"tickSize"`
	IndexPriceTickSize      decimal.Decimal `json:"indexPriceTickSize"`
	Multiplier              decimal.Decimal `json:"multiplier"`
	InitialMargin           decimal.Decimal `json:"initialMargin"`
	MaintainMargin          decimal.Decimal `json:"maintainMargin"`
	MaxRiskLimit            decimal.Decimal `json:"maxRiskLimit"`
	MinRiskLimit            decimal.Decimal `json:"minRiskLimit"`
	RiskStep                decimal.Decimal `json:"riskStep"`
	MakerFeeRate            decimal.Decimal `json:"makerFeeRate"`
	TakerFeeRate            decimal.Decimal `json:"takerFeeRate"`
	TakerFixFee             decimal.Decimal `json:"takerFixFee"`
	MakerFixFee             decimal.Decimal `json:"makerFixFee"`
	SettlementFee           decimal.Decimal `json:"settlementFee"`
	IsDeleverage            bool            `json:"isDeleverage"`
	IsQuanto                bool            `json:"isQuanto"`
	IsInverse               bool            `json:"isInverse"`
	MarkMethod              string          `json:"markMethod"`
	FairMethod              string          `json:"fairMethod"`
	FundingBaseSymbol       string          `json:"fundingBaseSymbol"`
	FundingQuoteSymbol      string          `json:"fundingQuoteSymbol"`
	FundingRateSymbol       string          `json:"fundingRateSymbol"`
	IndexSymbol             string          `json:"indexSymbol"`
	SettlementSymbol        string          `json:"settlementSymbol"`
	Status                  string          `json:"status"`
	FundingFeeRate          decimal.Decimal `json:"fundingFeeRate"`
	PredictedFundingFeeRate decimal.Decimal `json:"predictedFundingFeeRate"`
	OpenInterest            decimal.Decimal `json:"openInterest"`
	TurnoverOf24H           decimal.Decimal `json:"turnoverOf24h"`
	VolumeOf24H             decimal.Decimal `json:"volumeOf24h"`
	MarkPrice               decimal.Decimal `json:"markPrice"`
	IndexPrice              decimal.Decimal `json:"indexPrice"`
	LastTradePrice          decimal.Decimal `json:"lastTradePrice"`
	NextFundingRateTime     decimal.Decimal `json:"nextFundingRateTime"`
	MaxLeverage             decimal.Decimal `json:"maxLeverage"`
	SourceExchanges         []string        `json:"sourceExchanges"`
	PremiumsSymbol1M        string          `json:"premiumsSymbol1M"`
	PremiumsSymbol8H        string          `json:"premiumsSymbol8H"`
	FundingBaseSymbol1M     string          `json:"fundingBaseSymbol1M"`
	FundingQuoteSymbol1M    string          `json:"fundingQuoteSymbol1M"`
	LowPrice                decimal.Decimal `json:"lowPrice"`
	HighPrice               decimal.Decimal `json:"highPrice"`
	PriceChgPct             decimal.Decimal `json:"priceChgPct"`
	PriceChg                decimal.Decimal `json:"priceChg"`
}

type FutureSymbolResponse

type FutureSymbolResponse struct {
	BaseResponse
	Data []FutureSymbolData `json:"data"`
}

FutureSymbolResponse Response of /api/v1/contracts/active

type KcSigner

type KcSigner struct {
	Sha256Signer
	// contains filtered or unexported fields
}

KcSigner is the implement of Signer for KuCoin.

func NewKcSignerV2

func NewKcSignerV2(key, secret, passPhrase string) *KcSigner

NewKcSignerV2 creates a instance of KcSigner.

func (*KcSigner) Headers

func (ks *KcSigner) Headers(plain string) map[string]string

Headers returns a map of signature header.

func (*KcSigner) Sign

func (ks *KcSigner) Sign(plain []byte) []byte

Sign makes a signature by sha256 with `apiKey` `apiSecret` `apiPassPhrase`.

type Kucoin

type Kucoin struct {
	// contains filtered or unexported fields
}

func NewKucoin

func NewKucoin(opts ...Option) (*Kucoin, error)

NewKucoin Create a Kucoin API instance

func (*Kucoin) FutureAccount

func (kc *Kucoin) FutureAccount(currency string) (*FutureAccountData, error)

FutureAccount GET /api/v1/account-overview

func (*Kucoin) FutureOrder

func (kc *Kucoin) FutureOrder(req *FutureOrderRequest) (*FutureOrderData, error)

FutureOrder POST /api/v1/orders

func (*Kucoin) FutureOrderCancel

func (kc *Kucoin) FutureOrderCancel(orderId string) (*FutureOrderCancelData, error)

FutureOrderCancel DELETE /api/v1/orders/{orderId}

func (*Kucoin) FutureOrderFills

func (kc *Kucoin) FutureOrderFills(req *FutureOrderFillsRequest, currentPage, pageSize int) (*FutureOrderFillsData, error)

FutureOrderFills GET /api/v1/fills

func (*Kucoin) FutureOrderList

func (kc *Kucoin) FutureOrderList(req *FutureOrderListRequest, currentPage, pageSize int) (*FutureOrderListData, error)

FutureOrderList GET /api/v1/orders

func (*Kucoin) FutureOrderOne

func (kc *Kucoin) FutureOrderOne(orderId string) (*FutureOrderOneData, error)

FutureOrderOne GET /api/v1/orders/{orderId}

func (*Kucoin) FuturePosition

func (kc *Kucoin) FuturePosition(symbol string) (*FuturePositionData, error)

FuturePosition GET /api/v1/position

func (*Kucoin) FutureSymbols

func (kc *Kucoin) FutureSymbols() ([]FutureSymbolData, error)

FutureSymbols GET /api/v1/contracts/active

func (*Kucoin) Set

func (kc *Kucoin) Set(options ...Option) error

Set optional parameters

func (*Kucoin) SpotAccount

func (kc *Kucoin) SpotAccount(currency, _type string) ([]AccountsData, error)

SpotAccount GET /api/v1/accounts

func (*Kucoin) SpotMarginOrder

func (kc *Kucoin) SpotMarginOrder(req *SpotMarginOrderRequest) (*SpotMarginOrderData, error)

SpotMarginOrder POST /api/v1/margin/order

func (*Kucoin) SpotOrder

func (kc *Kucoin) SpotOrder(req *SpotOrdersRequest) (*SpotOrderData, error)

SpotOrder POST /api/v1/orders

func (*Kucoin) SpotOrderCancel

func (kc *Kucoin) SpotOrderCancel(orderId string) (*SpotOrderCancelData, error)

SpotOrderCancel DELETE /api/v1/orders/{orderId}

func (*Kucoin) SpotOrderFills

func (kc *Kucoin) SpotOrderFills(req *SpotOrderFillsRequest, currentPage, pageSize int) (*SpotOrderFillsData, error)

SpotOrderFills GET /api/v1/fills

func (*Kucoin) SpotOrderList

func (kc *Kucoin) SpotOrderList(req *SpotOrderListRequest, currentPage, pageSize int) (*SpotOrderListData, error)

SpotOrderList GET /api/v1/orders

func (*Kucoin) SpotOrderOne

func (kc *Kucoin) SpotOrderOne(orderId string) (*SpotOrderOneData, error)

SpotOrderOne GET /api/v1/orders/{orderId}

func (*Kucoin) SpotSymbols

func (kc *Kucoin) SpotSymbols(market string) ([]SymbolsData, error)

SpotSymbols GET /api/v2/symbols

type Option

type Option func(kc *Kucoin) error

func SetApiKey

func SetApiKey(accessKey, secretKey, passphrase string) Option

SetApiKey Set the API key created in Kucoin

func SetClient

func SetClient(client *http.Client) Option

SetClient Set HTTP client

func SetDebug

func SetDebug(debug bool) Option

SetDebug If set debug to ture, the http request and response logs will be output

func SetFutureEndpoint

func SetFutureEndpoint(futureEndpoint string) Option

SetFutureEndpoint Use the specified base URL to access the Kucoin future API interface

func SetRequestLog

func SetRequestLog(l func(...interface{})) Option

SetRequestLog Set the HTTP request log printing method. Set debug to true for it to work

func SetResponseLog

func SetResponseLog(l func(...interface{})) Option

SetResponseLog Set the HTTP response log printing method. Set debug to true for it to work

func SetSpotEndpoint

func SetSpotEndpoint(spotEndpoint string) Option

SetSpotEndpoint Use the specified base URL to access the Kucoin spot API interface

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 Signer

type Signer interface {
	Sign(plain []byte) []byte
}

Signer interface contains Sign() method.

type SpotMarginOrderData

type SpotMarginOrderData struct {
	OrderId     string          `json:"orderId"`
	BorrowSize  decimal.Decimal `json:"borrowSize"`
	LoanApplyId string          `json:"loanApplyId"`
}

type SpotMarginOrderRequest

type SpotMarginOrderRequest struct {
	ClientOid   string          `json:"clientOid,omitempty"`
	Side        string          `json:"side,omitempty"`   // buy or sell
	Symbol      string          `json:"symbol,omitempty"` // e.g. BTC-USDT
	Type        string          `json:"type,omitempty"`   // limit or market
	Remark      string          `json:"remark,omitempty"`
	Stp         string          `json:"stp,omitempty"` // CN, CO, CB or DC
	MarginModel string          `json:"marginModel"`   // cross or isolated
	AutoBorrow  bool            `json:"autoBorrow"`
	Price       decimal.Decimal `json:"price,omitempty"`
	Size        decimal.Decimal `json:"size,omitempty"`
	TimeInForce string          `json:"timeInForce,omitempty"` // GTC, GTT, IOC or FOK
	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"`
	Funds       string          `json:"funds,omitempty"` // MARKET order only, It is required that you use one of the two parameters, size or funds.
}

SpotMarginOrderRequest Request of POST /api/v1/margin/order

type SpotMarginOrderResponse

type SpotMarginOrderResponse struct {
	BaseResponse
	Data SpotMarginOrderData `json:"data"`
}

SpotMarginOrderResponse Response of POST /api/v1/margin/order

type SpotOrderCancelData

type SpotOrderCancelData struct {
	CancelledOrderIds []string `json:"cancelledOrderIds"`
}

type SpotOrderCancelResponse

type SpotOrderCancelResponse struct {
	BaseResponse
	Data SpotOrderCancelData `json:"data"`
}

SpotOrderCancelResponse Response of DELETE /api/v1/orders/{orderId}

type SpotOrderData

type SpotOrderData struct {
	OrderId string `json:"orderId"`
}

type SpotOrderFillsData

type SpotOrderFillsData struct {
	BaseResponsePagination
	Items []SpotOrderFillsItem `json:"items"`
}

type SpotOrderFillsItem

type SpotOrderFillsItem 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          decimal.Decimal `json:"price"`
	Size           decimal.Decimal `json:"size"`
	Funds          decimal.Decimal `json:"funds"`
	Fee            decimal.Decimal `json:"fee"`
	FeeRate        decimal.Decimal `json:"feeRate"`
	FeeCurrency    string          `json:"feeCurrency"`
	Stop           string          `json:"stop"`
	Type           string          `json:"type"`
	CreatedAt      int64           `json:"createdAt"`
	TradeType      string          `json:"tradeType"`
}

type SpotOrderFillsRequest

type SpotOrderFillsRequest struct {
	OrderId   string `json:"orderId,omitempty"` // If you specify orderId, other parameters can be ignored
	Symbol    string `json:"symbol,omitempty"`
	Side      string `json:"side,omitempty"`      // buy or sell
	Type      string `json:"type,omitempty"`      // limit, market, limit_stop or market_stop
	StartAt   int64  `json:"startAt,omitempty"`   // Start time (millisecond)
	EndAt     int64  `json:"endAt,omitempty"`     // End time (millisecond)
	TradeType string `json:"tradeType,omitempty"` // TRADE(Spot Trading), MARGIN_TRADE (Margin Trading), TRADE as default.
}

SpotOrderFillsRequest Request of GET /api/v1/fills

type SpotOrderFillsResponse

type SpotOrderFillsResponse struct {
	BaseResponse
	Data SpotOrderFillsData `json:"data"`
}

SpotOrderFillsResponse Response of GET /api/v1/fills

type SpotOrderListData

type SpotOrderListData struct {
	BaseResponsePagination
	Items []SpotOrderOneData `json:"items"`
}

type SpotOrderListRequest

type SpotOrderListRequest struct {
	Status    string `json:"status"`    // [Optional] active or done
	Symbol    string `json:"symbol"`    // [Optional]
	Side      string `json:"side"`      // [Optional] buy or sell
	Type      string `json:"type"`      // [Optional] limit, market, limit_stop or market_stop
	TradeType string `json:"tradeType"` // TRADE, MARGIN_TRADE or MARGIN_ISOLATED_TRADE
	StartAt   int64  `json:"startAt"`   // [Optional] Start time (millisecond)
	EndAt     int64  `json:"endAt"`     // [Optional] End time (millisecond)
}

SpotOrderListRequest Request of GET /api/v1/orders

type SpotOrderListResponse

type SpotOrderListResponse struct {
	BaseResponse
	Data SpotOrderListData `json:"data"`
}

SpotOrderListResponse Response of GET /api/v1/orders

type SpotOrderOneData

type SpotOrderOneData struct {
	Id            string          `json:"id"`
	Symbol        string          `json:"symbol"`
	OpType        string          `json:"opType"`
	Type          string          `json:"type"`
	Side          string          `json:"side"`
	Price         decimal.Decimal `json:"price"`
	Size          decimal.Decimal `json:"size"`
	Funds         decimal.Decimal `json:"funds"`
	DealFunds     decimal.Decimal `json:"dealFunds"`
	DealSize      decimal.Decimal `json:"dealSize"`
	Fee           decimal.Decimal `json:"fee"`
	FeeCurrency   string          `json:"feeCurrency"`
	Stp           string          `json:"stp"`
	Stop          string          `json:"stop"`
	StopTriggered bool            `json:"stopTriggered"`
	StopPrice     decimal.Decimal `json:"stopPrice"`
	TimeInForce   string          `json:"timeInForce"`
	PostOnly      bool            `json:"postOnly"`
	Hidden        bool            `json:"hidden"`
	Iceberg       bool            `json:"iceberg"`
	VisibleSize   decimal.Decimal `json:"visibleSize"`
	CancelAfter   int             `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"`
}

type SpotOrderOneResponse

type SpotOrderOneResponse struct {
	BaseResponse
	Data SpotOrderOneData `json:"data"`
}

SpotOrderOneResponse Response of GET /api/v1/orders/{order-id}

type SpotOrderResponse

type SpotOrderResponse struct {
	BaseResponse
	Data SpotOrderData `json:"data"`
}

SpotOrderResponse Response of POST /api/v1/orders

type SpotOrdersRequest

type SpotOrdersRequest struct {
	ClientOid   string          `json:"clientOid,omitempty"`
	Side        string          `json:"side,omitempty"`   // buy or sell
	Symbol      string          `json:"symbol,omitempty"` // e.g. BTC-USDT
	Type        string          `json:"type,omitempty"`   // limit or market
	Remark      string          `json:"remark,omitempty"`
	Stp         string          `json:"stp,omitempty"`
	TradeType   string          `json:"tradeType,omitempty"`
	Price       decimal.Decimal `json:"price,omitempty"`
	Size        decimal.Decimal `json:"size,omitempty"`
	TimeInForce string          `json:"timeInForce,omitempty"` // GTC, GTT, IOC or FOK
	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"`
	Funds       string          `json:"funds,omitempty"` // MARKET order only, It is required that you use one of the two parameters, size or funds.
}

SpotOrdersRequest Request of POST /api/v1/orders

type SymbolsData

type SymbolsData struct {
	Symbol          string          `json:"symbol"`
	Name            string          `json:"name"`
	BaseCurrency    string          `json:"baseCurrency"`
	QuoteCurrency   string          `json:"quoteCurrency"`
	FeeCurrency     string          `json:"feeCurrency"`
	Market          string          `json:"market"`
	BaseMinSize     decimal.Decimal `json:"baseMinSize"`
	QuoteMinSize    decimal.Decimal `json:"quoteMinSize"`
	BaseMaxSize     decimal.Decimal `json:"baseMaxSize"`
	QuoteMaxSize    decimal.Decimal `json:"quoteMaxSize"`
	BaseIncrement   decimal.Decimal `json:"baseIncrement"`
	QuoteIncrement  decimal.Decimal `json:"quoteIncrement"`
	PriceIncrement  decimal.Decimal `json:"priceIncrement"`
	PriceLimitRate  decimal.Decimal `json:"priceLimitRate"`
	MinFunds        decimal.Decimal `json:"minFunds"`
	IsMarginEnabled bool            `json:"isMarginEnabled"`
	EnableTrading   bool            `json:"enableTrading"`
}

type SymbolsResponse

type SymbolsResponse struct {
	BaseResponse
	Data []SymbolsData `json:"data"`
}

SymbolsResponse Response of GET /api/v2/symbols

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL