kucoin

package module
v0.0.0-...-b069848 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

Kucoin REST-API Golang

GoDoc Go Report Card FOSSA Status

Unofficial Kucoin API implementation written on Golang.

Features

  • Ready to go solution. Just import the package
  • The most needed methods are implemented
  • Simple authorization handling
  • Pure and stable code
  • Built-in Golang performance

How to use

go get -u github.com/eeonevision/kucoin-go
package main

import (
	"github.com/eeonevision/kucoin-go"
)

func main() {
	// Set your own API key and secret
	k := kucoin.New("API_KEY", "API_SECRET")
	// Call resource
	k.GetCoinBalance("BTC")
}

Checklist

API Resource Type Done
Tick (symbols) Open
Get coin info Open
List coins Open
Tick (symbols) for logged user Auth
Get coin deposit address Auth
Get balance of coin Auth
Create an order Auth
Get user info Auth
List active orders (Both map and array) Auth
List deposit & withdrawal records Auth
List dealt orders (Both Specific and Merged) Auth
Order details Auth
Create withdrawal apply Auth
Cancel withdrawal Auth
Cancel orders Auth
Cancel all orders Auth
Order books Auth

Donate

Your ★Star will be best donation to my work)

License

FOSSA Status

Documentation

Overview

Package kucoin is an implementation of the Kucoin API in Golang.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountHistory

type AccountHistory struct {
	Datas []struct {
		Fee             float64     `json:"fee"`
		Oid             string      `json:"oid"`
		Type            string      `json:"type"`
		Amount          float64     `json:"amount"`
		Remark          string      `json:"remark"`
		Status          string      `json:"status"`
		Address         string      `json:"address"`
		Context         string      `json:"context"`
		UserOid         string      `json:"userOid"`
		CoinType        string      `json:"coinType"`
		CreatedAt       int64       `json:"createdAt"`
		DeletedAt       interface{} `json:"deletedAt"`
		UpdatedAt       int64       `json:"updatedAt"`
		OuterWalletTxid interface{} `json:"outerWalletTxid"`
	} `json:"datas"`
	Total           int         `json:"total"`
	Limit           int         `json:"limit"`
	PageNos         int         `json:"pageNos"`
	CurrPageNo      int         `json:"currPageNo"`
	NavigatePageNos []int       `json:"navigatePageNos"`
	CoinType        string      `json:"coinType"`
	Type            interface{} `json:"type"`
	UserOid         string      `json:"userOid"`
	Status          interface{} `json:"status"`
	FirstPage       bool        `json:"firstPage"`
	LastPage        bool        `json:"lastPage"`
	StartRow        int         `json:"startRow"`
}

AccountHistory struct represents kucoin data model.

type ActiveMapOrder

type ActiveMapOrder struct {
	SELL []struct {
		Oid           string      `json:"oid"`
		Type          string      `json:"type"`
		UserOid       interface{} `json:"userOid"`
		CoinType      string      `json:"coinType"`
		CoinTypePair  string      `json:"coinTypePair"`
		Direction     string      `json:"direction"`
		Price         float64     `json:"price"`
		DealAmount    float64     `json:"dealAmount"`
		PendingAmount float64     `json:"pendingAmount"`
		CreatedAt     int64       `json:"createdAt"`
		UpdatedAt     int64       `json:"updatedAt"`
	} `json:"SELL"`
	BUY []struct {
		Oid           string      `json:"oid"`
		Type          string      `json:"type"`
		UserOid       interface{} `json:"userOid"`
		CoinType      string      `json:"coinType"`
		CoinTypePair  string      `json:"coinTypePair"`
		Direction     string      `json:"direction"`
		Price         float64     `json:"price"`
		DealAmount    float64     `json:"dealAmount"`
		PendingAmount float64     `json:"pendingAmount"`
		CreatedAt     int64       `json:"createdAt"`
		UpdatedAt     int64       `json:"updatedAt"`
	} `json:"BUY"`
}

ActiveMapOrder struct represents kucoin data model.

type ActiveOrder

type ActiveOrder struct {
	SELL [][]interface{} `json:"SELL"`
	BUY  [][]interface{} `json:"BUY"`
}

ActiveOrder struct represents kucoin data model.

type Coin

type Coin struct {
	WithdrawMinFee    float64     `json:"withdrawMinFee"`
	WithdrawMinAmount float64     `json:"withdrawMinAmount"`
	WithdrawFeeRate   float64     `json:"withdrawFeeRate"`
	ConfirmationCount int         `json:"confirmationCount"`
	WithdrawRemark    string      `json:"withdrawRemark"`
	InfoURL           interface{} `json:"infoUrl"`
	Name              string      `json:"name"`
	TradePrecision    int         `json:"tradePrecision"`
	DepositRemark     interface{} `json:"depositRemark"`
	EnableWithdraw    bool        `json:"enableWithdraw"`
	EnableDeposit     bool        `json:"enableDeposit"`
	Coin              string      `json:"coin"`
}

Coin struct represents kucoin data model.

type CoinBalance

type CoinBalance struct {
	CoinType      string  `json:"coinType"`
	Balance       float64 `json:"balance"`
	FreezeBalance float64 `json:"freezeBalance"`
}

CoinBalance struct represents kucoin data model.

type CoinDepositAddress

type CoinDepositAddress struct {
	Oid            string      `json:"oid"`
	Address        string      `json:"address"`
	Context        interface{} `json:"context"`
	UserOid        string      `json:"userOid"`
	CoinType       string      `json:"coinType"`
	CreatedAt      int64       `json:"createdAt"`
	DeletedAt      interface{} `json:"deletedAt"`
	UpdatedAt      int64       `json:"updatedAt"`
	LastReceivedAt int64       `json:"lastReceivedAt"`
}

CoinDepositAddress struct represents kucoin data model.

type Kucoin

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

Kucoin represent a Kucoin client.

func New

func New(apiKey, apiSecret string) *Kucoin

New returns an instantiated Kucoin struct.

func NewCustomClient

func NewCustomClient(apiKey, apiSecret string, httpClient http.Client) *Kucoin

NewCustomClient returns an instantiated Kucoin struct with custom http client.

func NewCustomTimeout

func NewCustomTimeout(apiKey, apiSecret string, timeout time.Duration) *Kucoin

NewCustomTimeout returns an instantiated Kucoin struct with custom timeout.

func (*Kucoin) AccountHistory

func (b *Kucoin) AccountHistory(coin, side, status string, limit, page int) (accountHistory AccountHistory, err error)

AccountHistory is used to get the information about list deposit & withdrawal at Kucoin along with other meta data. Coin, Side (type in Kucoin docs.) and Status are required parameters. Limit and page may be zeros. Example: - Coin = KCS - Side = DEPOSIT | WITHDRAW - Status = FINISHED | CANCEL | PENDING

func (*Kucoin) CancelAllOrders

func (b *Kucoin) CancelAllOrders(symbol, side string) error

CancelAllOrders is used to cancel execution of all orders at Kucoin along with other meta data. Symbol, Side (type in Kucoin docs.) are optional parameters.

func (*Kucoin) CancelOrder

func (b *Kucoin) CancelOrder(orderOid, side, symbol string) error

CancelOrder is used to cancel execution of current order at Kucoin along with other meta data. Side (type in Kucoin docs.) and order ID are required parameters. Symbol is optional.

func (*Kucoin) CancelWithdrawal

func (b *Kucoin) CancelWithdrawal(coin, txOid string) (withdrawal Withdrawal, err error)

CancelWithdrawal used to cancel withdrawal for specific coin at Kucoin along with other meta data. coin, txOid are required parameters. Example: - coin = KCS - txOid = example_tx Result: - Nothing.

func (*Kucoin) CreateOrder

func (b *Kucoin) CreateOrder(symbol, side string, price, amount float64) (orderOid string, err error)

CreateOrder is used to create order at Kucoin along with other meta data.

func (*Kucoin) CreateOrderByString

func (b *Kucoin) CreateOrderByString(symbol, side, price, amount string) (orderOid string, err error)

CreateOrderByString is used to create order at Kucoin along with other meta data. This ByString version is fix precise problem.

func (*Kucoin) CreateWithdrawalApply

func (b *Kucoin) CreateWithdrawalApply(coin, address string, amount float64) (withdrawalApply Withdrawal, err error)

CreateWithdrawalApply is used to create withdrawal for specific coin at Kucoin along with other meta data. coin, address and amount are required parameters. Example: - coin = KCS - address = example_address - amount 0.68 Result: - Nothing.

func (*Kucoin) GetCoin

func (b *Kucoin) GetCoin(c string) (coin Coin, err error)

GetCoin is used to get the open and available trading coin at Kucoin along with other meta data.

func (*Kucoin) GetCoinBalance

func (b *Kucoin) GetCoinBalance(c string) (coinBalance CoinBalance, err error)

GetCoinBalance is used to get the balance at chosen coin at Kucoin along with other meta data.

func (*Kucoin) GetCoinDepositAddress

func (b *Kucoin) GetCoinDepositAddress(c string) (coinDepositAddress CoinDepositAddress, err error)

GetCoinDepositAddress is used to get the address at chosen coin at Kucoin along with other meta data.

func (*Kucoin) GetCoins

func (b *Kucoin) GetCoins() (coins []Coin, err error)

GetCoins is used to get the all open and available trading coins at Kucoin along with other meta data.

func (*Kucoin) GetSymbol

func (b *Kucoin) GetSymbol(market string) (symbol Symbol, err error)

GetSymbol is used to get the open and available trading market at Kucoin along with other meta data. Trading symbol e.g. KCS-BTC. If not specified then you will get data of all symbols.

func (*Kucoin) GetSymbols

func (b *Kucoin) GetSymbols() (symbols []Symbol, err error)

GetSymbols is used to get the all open and available trading markets at Kucoin along with other meta data.

func (*Kucoin) GetUserInfo

func (b *Kucoin) GetUserInfo() (userInfo UserInfo, err error)

GetUserInfo is used to get the user information at Kucoin along with other meta data.

func (*Kucoin) GetUserSymbols

func (b *Kucoin) GetUserSymbols(market, symbol, filter string) (symbols []Symbol, err error)

GetUserSymbols is used to get the all open and available trading markets at Kucoin along with other meta data. The user should be logged to call this method. Filter parameter can be whether 'FAVOURITE' or 'STICK', market and symbol parameters can be any as presented at exchange.

func (*Kucoin) ListActiveMapOrders

func (b *Kucoin) ListActiveMapOrders(symbol string, side string) (activeMapOrders ActiveMapOrder, err error)

ListActiveMapOrders is used to get the information about active orders in user-friendly view at Kucoin along with other meta data. Symbol is required parameter, and side (or type of order in kucoin docs) may be empty.

func (*Kucoin) ListActiveOrders

func (b *Kucoin) ListActiveOrders(symbol string, side string) (activeOrders ActiveOrder, err error)

ListActiveOrders is used to get the information about active orders in array mode at Kucoin along with other meta data. Symbol is required parameter, and side (or type of order in kucoin docs) may be empty.

func (*Kucoin) ListMergedDealtOrders

func (b *Kucoin) ListMergedDealtOrders(symbol, side string, limit, page int, since, before int64) (mergedDealtOrders MergedDealtOrder, err error)

ListMergedDealtOrders is used to get the information about dealt orders for all symbols at Kucoin along with other meta data. All parameters are optional. Timestamp must be in milliseconds from Unix epoch.

func (*Kucoin) ListSpecificDealtOrders

func (b *Kucoin) ListSpecificDealtOrders(symbol, side string, limit, page int) (specificDealtOrders SpecificDealtOrder, err error)

ListSpecificDealtOrders is used to get the information about dealt orders for specific symbol at Kucoin along with other meta data. Symbol, Side (type in Kucoin docs.) are required parameters. Limit and page may be zeros. Example: - Symbol = KCS-BTC - Side = BUY | SELL

func (*Kucoin) OrderDetails

func (b *Kucoin) OrderDetails(symbol, side, orderOid string, limit, page int) (orderDetails OrderDetails, err error)

OrderDetails is used to get the information about orders for specific symbol at Kucoin along with other meta data. Symbol, Side (type in Kucoin docs.) are required parameters. Limit may be zero, and not greater than 20. Page may be zero and by default is equal to 1. Example: - Symbol = KCS-BTC - Side = BUY | SELL

func (*Kucoin) OrdersBook

func (b *Kucoin) OrdersBook(symbol string, group, limit int) (ordersBook OrdersBook, err error)

OrdersBook is used to get the information about active orders at Kucoin along with other meta data. Symbol is required parameter, geoup and limit may be empty.

func (*Kucoin) SetDebug

func (b *Kucoin) SetDebug(enable bool)

SetDebug enables/disables http request/response dump.

type MergedDealtOrder

type MergedDealtOrder struct {
	Total int `json:"total"`
	Datas []struct {
		CreatedAt     int64   `json:"createdAt"`
		Amount        float64 `json:"amount"`
		DealValue     float64 `json:"dealValue"`
		DealPrice     float64 `json:"dealPrice"`
		Fee           float64 `json:"fee"`
		FeeRate       float64 `json:"feeRate"`
		Oid           string  `json:"oid"`
		OrderOid      string  `json:"orderOid"`
		CoinType      string  `json:"coinType"`
		CoinTypePair  string  `json:"coinTypePair"`
		Direction     string  `json:"direction"`
		DealDirection string  `json:"dealDirection"`
	} `json:"datas"`
	Limit int `json:"limit"`
	Page  int `json:"page"`
}

MergedDealtOrder struct represents kucoin data model.

type Order

type Order struct {
	OrderOid string `json:"orderOid"`
}

Order structs represents kucoin data model.

type OrderDetails

type OrderDetails struct {
	CoinType         string  `json:"coinType"`
	DealValueTotal   float64 `json:"dealValueTotal"`
	DealPriceAverage float64 `json:"dealPriceAverage"`
	FeeTotal         float64 `json:"feeTotal"`
	UserOid          string  `json:"userOid"`
	DealAmount       float64 `json:"dealAmount"`
	DealOrders       struct {
		Total     int  `json:"total"`
		FirstPage bool `json:"firstPage"`
		LastPage  bool `json:"lastPage"`
		Datas     []struct {
			Amount    float64 `json:"amount"`
			DealValue float64 `json:"dealValue"`
			Fee       float64 `json:"fee"`
			DealPrice float64 `json:"dealPrice"`
			FeeRate   float64 `json:"feeRate"`
		} `json:"datas"`
		CurrPageNo int `json:"currPageNo"`
		Limit      int `json:"limit"`
		PageNos    int `json:"pageNos"`
	} `json:"dealOrders"`
	CoinTypePair  string  `json:"coinTypePair"`
	OrderPrice    float64 `json:"orderPrice"`
	Type          string  `json:"type"`
	OrderOid      string  `json:"orderOid"`
	PendingAmount float64 `json:"pendingAmount"`
}

OrderDetails structs represents kucoin data model.

type OrdersBook

type OrdersBook struct {
	Comment string      `json:"_comment"`
	SELL    [][]float64 `json:"SELL"`
	BUY     [][]float64 `json:"BUY"`
}

OrdersBook struct represents kucoin data model.

type SpecificDealtOrder

type SpecificDealtOrder struct {
	Datas []struct {
		Oid       string  `json:"oid"`
		DealPrice float64 `json:"dealPrice"`
		OrderOid  string  `json:"orderOid"`
		Direction string  `json:"direction"`
		Amount    float64 `json:"amount"`
		DealValue float64 `json:"dealValue"`
		CreatedAt int64   `json:"createdAt"`
	} `json:"datas"`
	Total           int         `json:"total"`
	Limit           int         `json:"limit"`
	PageNos         int         `json:"pageNos"`
	CurrPageNo      int         `json:"currPageNo"`
	NavigatePageNos []int       `json:"navigatePageNos"`
	UserOid         string      `json:"userOid"`
	Direction       interface{} `json:"direction"`
	StartRow        int         `json:"startRow"`
	FirstPage       bool        `json:"firstPage"`
	LastPage        bool        `json:"lastPage"`
}

SpecificDealtOrder struct represents kucoin data model.

type Symbol

type Symbol struct {
	CoinType      string  `json:"coinType"`
	Trading       bool    `json:"trading"`
	Symbol        string  `json:"symbol"`
	LastDealPrice float64 `json:"lastDealPrice,omitempty"`
	Buy           float64 `json:"buy,omitempty"`
	Sell          float64 `json:"sell,omitempty"`
	Change        float64 `json:"change,omitempty"`
	CoinTypePair  string  `json:"coinTypePair"`
	Sort          int     `json:"sort"`
	FeeRate       float64 `json:"feeRate"`
	VolValue      float64 `json:"volValue"`
	High          float64 `json:"high,omitempty"`
	Datetime      int64   `json:"datetime"`
	Vol           float64 `json:"vol"`
	Low           float64 `json:"low,omitempty"`
	ChangeRate    float64 `json:"changeRate,omitempty"`
	Stick         bool    `json:"stick,omitempty"`
	Fav           bool    `json:"fav,omitempty"`
}

Symbol struct represents kucoin data model.

type UserInfo

type UserInfo struct {
	ReferrerCode             string      `json:"referrer_code"`
	PhotoCredentialValidated bool        `json:"photoCredentialValidated"`
	VideoValidated           bool        `json:"videoValidated"`
	Language                 string      `json:"language"`
	Currency                 string      `json:"currency"`
	Oid                      string      `json:"oid"`
	BaseFeeRate              float64     `json:"baseFeeRate"`
	HasCredential            bool        `json:"hasCredential"`
	CredentialNumber         string      `json:"credentialNumber"`
	PhoneValidated           bool        `json:"phoneValidated"`
	Phone                    string      `json:"phone"`
	CredentialValidated      bool        `json:"credentialValidated"`
	GoogleTwoFaBinding       bool        `json:"googleTwoFaBinding"`
	Nickname                 interface{} `json:"nickname"`
	Name                     string      `json:"name"`
	HasTradePassword         bool        `json:"hasTradePassword"`
	EmailValidated           bool        `json:"emailValidated"`
	Email                    string      `json:"email"`
	LoginRecord              struct {
		Last struct {
			IP      string      `json:"ip"`
			Context interface{} `json:"context"`
			Time    int64       `json:"time"`
		} `json:"last"`
		Current struct {
			IP      string      `json:"ip"`
			Context interface{} `json:"context"`
			Time    int64       `json:"time"`
		} `json:"current"`
	} `json:"loginRecord"`
}

UserInfo struct represents kucoin data model.

type Withdrawal

type Withdrawal struct {
}

Withdrawal struct represents kucoin data model.

Jump to

Keyboard shortcuts

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