kucoin

package
v0.0.0-...-5439e55 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	API_URL         = "https://openapi-v2.kucoin.com"
	SANDBOX_API_URL = "https://openapi-sandbox.kucoin.com"
)

The Base Endpoint URL

View Source
const (
	DEFAULT_ID           = 6
	DEFAULT_TAKER_FEE    = 0.001
	DEFAULT_MAKER_FEE    = 0.001
	DEFAULT_LOT_SIZE     = 0.00000001
	DEFAULT_PRICE_FILTER = 0.00000001 //PRICE FILTER
	DEFAULT_CONFIRMATION = 1001
	DEFAULT_LISTED       = true
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalance

type AccountBalance []struct {
	Balance   string `json:"balance"`
	Available string `json:"available"`
	Holds     string `json:"holds"`
	Currency  string `json:"currency"`
	ID        string `json:"id"`
	Type      string `json:"type"`
}

type AccountID

type AccountID []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"`
}

type CancelOrder

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

type CoinsData

type CoinsData []struct {
	WithdrawalMinFee  string `json:"withdrawalMinFee"`
	Precision         int    `json:"precision"`
	Name              string `json:"name"`
	FullName          string `json:"fullName"`
	Currency          string `json:"currency"`
	WithdrawalMinSize string `json:"withdrawalMinSize"`
	IsWithdrawEnabled bool   `json:"isWithdrawEnabled"`
	IsDepositEnabled  bool   `json:"isDepositEnabled"`
}

type InnerTrans

type InnerTrans struct {
	Code    string `json:"code"`
	Msg     string `json:"msg"`
	OrderID string `json:"orderId"`
}

type JsonResponse

type JsonResponse struct {
	Success bool            `json:"success"`
	Code    string          `json:"code"`
	Msg     string          `json:"msg"`
	Retry   bool            `json:"retry"`
	Data    json.RawMessage `json:"data"`
}

type KLine

type KLine struct {
	Code string     `json:"code"`
	Data [][]string `json:"data"`
}

type Kucoin

type Kucoin struct {
	ID      int
	Name    string `bson:"name"`
	Website string `bson:"website"`

	API_KEY    string
	API_SECRET string
	Passphrase string

	Source    exchange.DataSource // / exchange API / microservicve api 1 / PSQL
	SourceURI string
}

func CreateKucoin

func CreateKucoin(config *exchange.Config) *Kucoin

*************************************************

func (*Kucoin) ApiKeyRequest

func (e *Kucoin) ApiKeyRequest(strMethod, strRequestPath string, mapParams map[string]string, sandbox bool) string

************** Signature Http Request ************** Method: API Request and Signature is required Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Create mapParams Depend on API Signature request Step 3: Add HttpGetRequest below strUrl if API has different requests

func (*Kucoin) CanDeposit

func (e *Kucoin) CanDeposit(coin *coin.Coin) bool

func (*Kucoin) CanWithdraw

func (e *Kucoin) CanWithdraw(coin *coin.Coin) bool

func (*Kucoin) CancelAllOrder

func (e *Kucoin) CancelAllOrder() error

func (*Kucoin) CancelOrder

func (e *Kucoin) CancelOrder(order *exchange.Order) error

func (*Kucoin) DeleteCoin

func (e *Kucoin) DeleteCoin(coin *coin.Coin)

func (*Kucoin) DeletePair

func (e *Kucoin) DeletePair(pair *pair.Pair)

func (*Kucoin) DoAccountOperation

func (e *Kucoin) DoAccountOperation(operation *exchange.AccountOperation) error

func (*Kucoin) GetBalance

func (e *Kucoin) GetBalance(coin *coin.Coin) float64

func (*Kucoin) GetCoinBySymbol

func (e *Kucoin) GetCoinBySymbol(symbol string) *coin.Coin

func (*Kucoin) GetCoinConstraint

func (e *Kucoin) GetCoinConstraint(coin *coin.Coin) *exchange.CoinConstraint

************** Coins on the Exchanges **************

func (*Kucoin) GetCoins

func (e *Kucoin) GetCoins() []*coin.Coin

func (*Kucoin) GetCoinsData

func (e *Kucoin) GetCoinsData() error

************** Public API ************** Get Coins Information (If API provide) Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Kucoin) GetConfirmation

func (e *Kucoin) GetConfirmation(coin *coin.Coin) int

func (*Kucoin) GetConstraintFetchMethod

func (e *Kucoin) GetConstraintFetchMethod(pair *pair.Pair) *exchange.ConstrainFetchMethod

*************** Exchange Constraint ***************

func (*Kucoin) GetFee

func (e *Kucoin) GetFee(pair *pair.Pair) float64

*************** Pair Constraint ***************

func (*Kucoin) GetID

func (e *Kucoin) GetID() int

*************** Exchange Information ***************

func (*Kucoin) GetLotSize

func (e *Kucoin) GetLotSize(pair *pair.Pair) float64

func (*Kucoin) GetName

func (e *Kucoin) GetName() exchange.ExchangeName

func (*Kucoin) GetPairBySymbol

func (e *Kucoin) GetPairBySymbol(symbol string) *pair.Pair

func (*Kucoin) GetPairConstraint

func (e *Kucoin) GetPairConstraint(pair *pair.Pair) *exchange.PairConstraint

************** Pairs on the Exchanges **************

func (*Kucoin) GetPairs

func (e *Kucoin) GetPairs() []*pair.Pair

func (*Kucoin) GetPairsData

func (e *Kucoin) GetPairsData() error
GetPairsData - Get Pairs Information (If API provide)

Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Kucoin) GetPriceFilter

func (e *Kucoin) GetPriceFilter(pair *pair.Pair) float64

func (*Kucoin) GetSymbolByCoin

func (e *Kucoin) GetSymbolByCoin(coin *coin.Coin) string

func (*Kucoin) GetSymbolByPair

func (e *Kucoin) GetSymbolByPair(pair *pair.Pair) string

func (*Kucoin) GetTradingWebURL

func (e *Kucoin) GetTradingWebURL(pair *pair.Pair) string

func (*Kucoin) GetTxFee

func (e *Kucoin) GetTxFee(coin *coin.Coin) float64

*************** Coin Constraint ***************

func (*Kucoin) HasPair

func (e *Kucoin) HasPair(pair *pair.Pair) bool

func (*Kucoin) InitData

func (e *Kucoin) InitData() error

func (*Kucoin) LimitBuy

func (e *Kucoin) LimitBuy(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Kucoin) LimitSell

func (e *Kucoin) LimitSell(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Kucoin) ListOrders

func (e *Kucoin) ListOrders() ([]*exchange.Order, error)

func (*Kucoin) LoadPublicData

func (e *Kucoin) LoadPublicData(operation *exchange.PublicOperation) error

func (*Kucoin) OrderBook

func (e *Kucoin) OrderBook(p *pair.Pair) (*exchange.Maker, error)

Get Pair Market Depth Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Get Exchange Pair Code ex. symbol := e.GetPairCode(p) Step 4: Modify API Path(strRequestUrl) Step 5: Add Params - Depend on API request Step 6: Convert the response to Standard Maker struct

func (*Kucoin) OrderStatus

func (e *Kucoin) OrderStatus(order *exchange.Order) error

func (*Kucoin) SetCoinConstraint

func (e *Kucoin) SetCoinConstraint(coinConstraint *exchange.CoinConstraint)

func (*Kucoin) SetPairConstraint

func (e *Kucoin) SetPairConstraint(pairConstraint *exchange.PairConstraint)

func (*Kucoin) UpdateAllBalances

func (e *Kucoin) UpdateAllBalances()

func (*Kucoin) UpdateConstraint

func (e *Kucoin) UpdateConstraint()

func (*Kucoin) Withdraw

func (e *Kucoin) Withdraw(coin *coin.Coin, quantity float64, addr, tag string) bool

Withdraw(coin *coin.Coin, quantity float64, addr, tag string)

type OpenOrders

type OpenOrders struct {
	CurrentPage int `json:"currentPage"`
	PageSize    int `json:"pageSize"`
	TotalNum    int `json:"totalNum"`
	TotalPage   int `json:"totalPage"`
	Items       []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   int         `json:"cancelAfter"`
		Channel       string      `json:"channel"`
		ClientOid     string      `json:"clientOid"`
		Remark        interface{} `json:"remark"`
		Tags          interface{} `json:"tags"`
		IsActive      bool        `json:"isActive"`
		CancelExist   bool        `json:"cancelExist"`
		CreatedAt     int64       `json:"createdAt"`
		TradeType     string      `json:"tradeType"`
	} `json:"items"`
}

type OrderBook

type OrderBook struct {
	Sequence string     `json:"sequence"`
	Asks     [][]string `json:"asks"`
	Bids     [][]string `json:"bids"`
}

type OrderDetail

type OrderDetail struct {
	OrderID string `json:"orderId"`
}

type OrderStatus

type OrderStatus 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   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"`
}

type PairsData

type PairsData []struct {
	Symbol         string `json:"symbol"`
	QuoteMaxSize   string `json:"quoteMaxSize"`
	EnableTrading  bool   `json:"enableTrading"`
	PriceIncrement string `json:"priceIncrement"`
	BaseMaxSize    string `json:"baseMaxSize"`
	BaseCurrency   string `json:"baseCurrency"`
	QuoteCurrency  string `json:"quoteCurrency"`
	Market         string `json:"market"`
	QuoteIncrement string `json:"quoteIncrement"`
	BaseMinSize    string `json:"baseMinSize"`
	QuoteMinSize   string `json:"quoteMinSize"`
	Name           string `json:"name"`
	BaseIncrement  string `json:"baseIncrement"`
}

type SubAccountBalances

type SubAccountBalances struct {
	SubUserID    string `json:"subUserId"`
	SubName      string `json:"subName"`
	MainAccounts []struct {
		Currency          string `json:"currency"`
		Balance           string `json:"balance"`
		Available         string `json:"available"`
		Holds             string `json:"holds"`
		BaseCurrency      string `json:"baseCurrency"`
		BaseCurrencyPrice string `json:"baseCurrencyPrice"`
		BaseAmount        string `json:"baseAmount"`
	} `json:"mainAccounts"`
	TradeAccounts []struct {
		Currency          string `json:"currency"`
		Balance           string `json:"balance"`
		Available         string `json:"available"`
		Holds             string `json:"holds"`
		BaseCurrency      string `json:"baseCurrency"`
		BaseCurrencyPrice string `json:"baseCurrencyPrice"`
		BaseAmount        string `json:"baseAmount"`
	} `json:"tradeAccounts"`
	MarginAccounts []struct {
		Currency          string `json:"currency"`
		Balance           string `json:"balance"`
		Available         string `json:"available"`
		Holds             string `json:"holds"`
		BaseCurrency      string `json:"baseCurrency"`
		BaseCurrencyPrice string `json:"baseCurrencyPrice"`
		BaseAmount        string `json:"baseAmount"`
	} `json:"marginAccounts"`
}

type SubAccountList

type SubAccountList []struct {
	UserID  string `json:"userId"`
	SubName string `json:"subName"`
	Remarks string `json:"remarks"`
}

type SubAllAccountBalances

type SubAllAccountBalances []struct {
	SubUserID    string `json:"subUserId"`
	SubName      string `json:"subName"`
	MainAccounts []struct {
		Currency          string `json:"currency"`
		Balance           string `json:"balance"`
		Available         string `json:"available"`
		Holds             string `json:"holds"`
		BaseCurrency      string `json:"baseCurrency"`
		BaseCurrencyPrice string `json:"baseCurrencyPrice"`
		BaseAmount        string `json:"baseAmount"`
	} `json:"mainAccounts"`
	TradeAccounts []struct {
		Currency          string `json:"currency"`
		Balance           string `json:"balance"`
		Available         string `json:"available"`
		Holds             string `json:"holds"`
		BaseCurrency      string `json:"baseCurrency"`
		BaseCurrencyPrice string `json:"baseCurrencyPrice"`
		BaseAmount        string `json:"baseAmount"`
	} `json:"tradeAccounts"`
	MarginAccounts []struct {
		Currency          string `json:"currency"`
		Balance           string `json:"balance"`
		Available         string `json:"available"`
		Holds             string `json:"holds"`
		BaseCurrency      string `json:"baseCurrency"`
		BaseCurrencyPrice string `json:"baseCurrencyPrice"`
		BaseAmount        string `json:"baseAmount"`
	} `json:"marginAccounts"`
}

type TickerPrice

type TickerPrice struct {
	Time   int64 `json:"time"`
	Ticker []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"`
	} `json:"ticker"`
}

type TradeHistory

type TradeHistory []struct {
	Sequence string `json:"sequence"`
	Side     string `json:"side"`
	Size     string `json:"size"`
	Price    string `json:"price"`
	Time     int64  `json:"time"`
}

type Withdraw

type Withdraw struct {
	WithdrawalID string `json:"withdrawalId"`
}

Jump to

Keyboard shortcuts

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