kucoin

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

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 24 Imported by: 0

README

Go SDK for KuCoin API

The detailed document https://docs.kucoin.com, in order to receive the latest API change notifications, please Watch this repository.

Latest Version GoDoc Build Status Go Report Card Sourcegraph

Install

go get github.com/Kucoin/kucoin-go-sdk

Usage

Choose environment
Environment BaseUri
Production https://api.kucoin.com(DEFAULT) https://api.kucoin.cc
Sandbox https://openapi-sandbox.kucoin.com
Create ApiService
Note

To reinforce the security of the APIS, KuCoin upgraded the API key to version 2.0, the validation logic has also been changed. It is recommended to create(https://www.kucoin.com/account/api) and update your API key to version 2.0. The API key of version 1.0 will be still valid until May 1, 2021.

// API key version 2.0
s :=  kucoin.NewApiService( 
	// kucoin.ApiBaseURIOption("https://api.kucoin.com"), 
	kucoin.ApiKeyOption("key"),
	kucoin.ApiSecretOption("secret"),
	kucoin.ApiPassPhraseOption("passphrase"),
	kucoin.ApiKeyVersionOption(ApiKeyVersionV2)
)

// API key version 1.0
s := kucoin.NewApiService( 
	// kucoin.ApiBaseURIOption("https://api.kucoin.com"), 
	kucoin.ApiKeyOption("key"),
	kucoin.ApiSecretOption("secret"),
	kucoin.ApiPassPhraseOption("passphrase"), 
)
// Or add these options into the environmental variable
// Bash: 
// export API_BASE_URI=https://api.kucoin.com
// export API_KEY=key
// export API_SECRET=secret
// export API_PASSPHRASE=passphrase
// export API_KEY_VERSION=2
// s := NewApiServiceFromEnv()
Debug mode & logging
// Require package github.com/sirupsen/logrus
// Debug mode will record the logs of API and WebSocket to files.
// Default values: LogLevel=logrus.DebugLevel, LogDirectory="/tmp"
kucoin.DebugMode = true
// Or export API_DEBUG_MODE=1

// Logging in your code
// kucoin.SetLoggerDirectory("/tmp")
// logrus.SetLevel(logrus.DebugLevel)
logrus.Debugln("I'm a debug message")
Examples

See the test case for more examples.

Example of API without authentication
rsp, err := s.ServerTime()
if err != nil {
    log.Printf("Error: %s", err.Error())
    // Handle error
    return
}

var ts int64
if err := rsp.ReadData(&ts); err != nil {
    // Handle error
    return
}
log.Printf("The server time: %d", ts)
Example of API with authentication
// Without pagination
rsp, err := s.Accounts("", "")
if err != nil {
    // Handle error
    return
}

as := kucoin.AccountsModel{}
if err := rsp.ReadData(&as); err != nil {
    // Handle error
    return
}

for _, a := range as {
    log.Printf("Available balance: %s %s => %s", a.Type, a.Currency, a.Available)
}
// Handle pagination
rsp, err := s.Orders(map[string]string{}, &kucoin.PaginationParam{CurrentPage: 1, PageSize: 10})
if err != nil {
    // Handle error
    return
}

os := kucoin.OrdersModel{}
pa, err := rsp.ReadPaginationData(&os)
if err != nil {
    // Handle error
    return
}
log.Printf("Total num: %d, total page: %d", pa.TotalNum, pa.TotalPage)
for _, o := range os {
    log.Printf("Order: %s, %s, %s", o.Id, o.Type, o.Price)
}
Example of WebSocket feed

Require package gorilla/websocket

go get github.com/gorilla/websocket github.com/pkg/errors
rsp, err := s.WebSocketPublicToken()
if err != nil {
    // Handle error
    return
}

tk := &kucoin.WebSocketTokenModel{}
if err := rsp.ReadData(tk); err != nil {
    // Handle error
    return
}

c := s.NewWebSocketClient(tk)

mc, ec, err := c.Connect()
if err != nil {
    // Handle error
    return
}

ch1 := kucoin.NewSubscribeMessage("/market/ticker:KCS-BTC", false)
ch2 := kucoin.NewSubscribeMessage("/market/ticker:ETH-BTC", false)
uch := kucoin.NewUnsubscribeMessage("/market/ticker:ETH-BTC", false)

if err := c.Subscribe(ch1, ch2); err != nil {
    // Handle error
    return
}

var i = 0
for {
    select {
    case err := <-ec:
        c.Stop() // Stop subscribing the WebSocket feed
        log.Printf("Error: %s", err.Error())
        // Handle error
        return
    case msg := <-mc:
        // log.Printf("Received: %s", kucoin.ToJsonString(m))
        t := &kucoin.TickerLevel1Model{}
        if err := msg.ReadData(t); err != nil {
            log.Printf("Failure to read: %s", err.Error())
            return
        }
        log.Printf("Ticker: %s, %s, %s, %s", msg.Topic, t.Sequence, t.Price, t.Size)
        i++
        if i == 5 {
            log.Println("Unsubscribe ETH-BTC")
            if err = c.Unsubscribe(uch); err != nil {
                log.Printf("Error: %s", err.Error())
                // Handle error
                return
            }
        }
        if i == 10 {
            log.Println("Subscribe ETH-BTC")
            if err = c.Subscribe(ch2); err != nil {
                log.Printf("Error: %s", err.Error())
                // Handle error
                return
            }
        }
        if i == 15 {
            log.Println("Exit subscription")
            c.Stop() // Stop subscribing the WebSocket feed
            return
        }
    }
}
API list
Trade Fee
API Authentication Description
ApiService.BaseFee() YES https://docs.kucoin.com/#basic-user-fee
ApiService.ActualFee() YES https://docs.kucoin.com/#actual-fee-rate-of-the-trading-pair
Stop Order
API Authentication Description
ApiService.CreateStopOrder() YES https://docs.kucoin.com/#place-a-new-order-2
ApiService.CancelStopOrder() YES https://docs.kucoin.com/#cancel-an-order-2
ApiService.CancelStopOrderBy() YES https://docs.kucoin.com/#cancel-orders
ApiService.StopOrder() YES https://docs.kucoin.com/#get-single-order-info
ApiService.StopOrders() YES https://docs.kucoin.com/#list-stop-orders
ApiService.StopOrderByClient() YES https://docs.kucoin.com/#get-single-order-by-clientoid
ApiService.CancelStopOrderByClient() YES https://docs.kucoin.com/#cancel-single-order-by-clientoid-2
Account
API Authentication Description
ApiService.CreateAccount() YES https://docs.kucoin.com/#create-an-account
ApiService.Accounts() YES https://docs.kucoin.com/#list-accounts
ApiService.Account() YES https://docs.kucoin.com/#get-an-account
ApiService.SubAccountUsers() YES https://docs.kucoin.com/#get-user-info-of-all-sub-accounts
ApiService.SubAccounts() YES https://docs.kucoin.com/#get-the-aggregated-balance-of-all-sub-accounts-of-the-current-user
ApiService.SubAccount() YES https://docs.kucoin.com/#get-account-balance-of-a-sub-account
ApiService.AccountLedgers() YES DEPRECATED https://docs.kucoin.com/#get-account-ledgers-deprecated
ApiService.AccountHolds() YES https://docs.kucoin.com/#get-holds
ApiService.InnerTransfer() YES DEPRECATED https://docs.kucoin.com/#inner-transfer
ApiService.InnerTransferV2() YES https://docs.kucoin.com/#inner-transfer
ApiService.SubTransfer() YES DEPRECATED
ApiService.SubTransferV2() YES https://docs.kucoin.com/#transfer-between-master-user-and-sub-user
ApiService.AccountLedgersV2() YES https://docs.kucoin.com/#get-account-ledgers
Deposit
API Authentication Description
ApiService.CreateDepositAddress() YES https://docs.kucoin.com/#create-deposit-address
ApiService.DepositAddresses() YES https://docs.kucoin.com/#get-deposit-address
ApiService.V1Deposits() YES https://docs.kucoin.com/#get-v1-historical-deposits-list
ApiService.Deposits() YES https://docs.kucoin.com/#get-deposit-list
Fill
API Authentication Description
ApiService.Fills() YES https://docs.kucoin.com/#list-fills
ApiService.RecentFills() YES https://docs.kucoin.com/#recent-fills
Order
API Authentication Description
ApiService.CreateOrder() YES https://docs.kucoin.com/#place-a-new-order
ApiService.CreateMultiOrder() YES https://docs.kucoin.com/#place-bulk-orders
ApiService.CancelOrder() YES https://docs.kucoin.com/#cancel-an-order
ApiService.CancelOrders() YES https://docs.kucoin.com/#cancel-all-orders
ApiService.V1Orders() YES https://docs.kucoin.com/#get-v1-historical-orders-list
ApiService.Orders() YES https://docs.kucoin.com/#list-orders
ApiService.Order() YES https://docs.kucoin.com/#get-an-order
ApiService.RecentOrders() YES https://docs.kucoin.com/#recent-orders
ApiService.CreateMarginOrder() YES https://docs.kucoin.com/#place-a-margin-order
ApiService.CancelOrderByClient() YES https://docs.kucoin.com/#cancel-single-order-by-clientoid
ApiService.OrderByClient() YES https://docs.kucoin.com/#get-single-active-order-by-clientoid
WebSocket Feed
API Authentication Description
ApiService.WebSocketPublicToken() NO https://docs.kucoin.com/#apply-connect-token
ApiService.WebSocketPrivateToken() YES https://docs.kucoin.com/#apply-connect-token
ApiService.NewWebSocketClient() - https://docs.kucoin.com/#websocket-feed
Withdrawal
API Authentication Description
ApiService.WithdrawalQuotas() YES https://docs.kucoin.com/#get-withdrawal-quotas
ApiService.V1Withdrawals() YES https://docs.kucoin.com/#get-v1-historical-withdrawals-list
ApiService.Withdrawals() YES https://docs.kucoin.com/#get-withdrawals-list
ApiService.ApplyWithdrawal() YES https://docs.kucoin.com/#apply-withdraw
ApiService.CancelWithdrawal() YES https://docs.kucoin.com/#cancel-withdrawal
Currency
API Authentication Description
ApiService.Currencies() NO https://docs.kucoin.com/#get-currencies
ApiService.Currency() NO https://docs.kucoin.com/#get-currency-detail
ApiService.Prices() NO https://docs.kucoin.com/#get-fiat-price
Symbol
API Authentication Description
ApiService.Symbols() NO https://docs.kucoin.com/#get-symbols-list
ApiService.TickerLevel1() NO https://docs.kucoin.com/#get-ticker
ApiService.Tickers() NO https://docs.kucoin.com/#get-all-tickers
ApiService.AggregatedPartOrderBook() NO https://docs.kucoin.com/#get-part-order-book-aggregated
ApiService.AggregatedFullOrderBook() NO https://docs.kucoin.com/#get-full-order-book-aggregated
ApiService.AtomicFullOrderBook() NO https://docs.kucoin.com/#get-full-order-book-atomic
ApiService.TradeHistories() NO https://docs.kucoin.com/#get-trade-histories
ApiService.KLines() NO https://docs.kucoin.com/#get-klines
ApiService.Stats24hr() NO https://docs.kucoin.com/#get-24hr-stats
ApiService.Markets() NO https://docs.kucoin.com/#get-market-list
Time
API Authentication Description
ApiService.ServerTime() NO https://docs.kucoin.com/#server-time
Service Status
API Authentication Description
ApiService.ServiceStatus() NO https://docs.kucoin.com/#service-status

Run tests

# Add your API configuration items into the environmental variable first
export API_BASE_URI=https://api.kucoin.com
export API_KEY=key
export API_SECRET=secret
export API_PASSPHRASE=passphrase
export API_KEY_VERSION=2

# Run tests
go test -v

License

MIT

Documentation

Overview

Package kucoin provides two kinds of APIs: `RESTful API` and `WebSocket feed`. The official document: https://docs.kucoin.com

Index

Constants

View Source
const (
	WelcomeMessage     = "welcome"
	PingMessage        = "ping"
	PongMessage        = "pong"
	SubscribeMessage   = "subscribe"
	AckMessage         = "ack"
	UnsubscribeMessage = "unsubscribe"
	ErrorMessage       = "error"
	Message            = "message"
	Notice             = "notice"
	Command            = "command"
)

All message types of WebSocket.

View Source
const ApiKeyVersionV1 = "1"

ApiKeyVersionV1 is v1 api key version

View Source
const ApiKeyVersionV2 = "2"

ApiKeyVersionV2 is v2 api key version

View Source
const (
	ApiSuccess = "200000"
)

The predefined API codes

View Source
const ProductionApiBaseURI = "https://api.kucoin.com"

ProductionApiBaseURI is api base uri for production.

Variables

View Source
var (
	// Version is SDK version.
	Version = "1.2.10"
	// DebugMode will record the logs of API and WebSocket to files in the directory "kucoin.LogDirectory" according to the minimum log level "kucoin.LogLevel".
	DebugMode = os.Getenv("API_DEBUG_MODE") == "1"
)

Functions

func IntToString

func IntToString(i int64) string

IntToString converts int64 to string.

func SetLoggerDirectory

func SetLoggerDirectory(directory string)

SetLoggerDirectory sets the directory for logrus output.

func ToJsonString

func ToJsonString(v interface{}) string

ToJsonString converts any value to JSON string.

Types

type AUtoCancelSettingModel

type AUtoCancelSettingModel struct {
	Timeout     int64       `json:"timeout"`
	Symbols     string      `json:"symbols"`
	CurrentTime json.Number `json:"currentTime"`
	TriggerTime json.Number `json:"triggerTime"`
}

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

type AccountLedgerModel struct {
	ID          string          `json:"id"`
	Currency    string          `json:"currency"`
	Amount      string          `json:"amount"`
	Fee         string          `json:"fee"`
	Balance     string          `json:"balance"`
	AccountType string          `json:"accountType"`
	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

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 AccountsTransferableModel

type AccountsTransferableModel struct {
	Currency     string `json:"currency"`
	Balance      string `json:"balance"`
	Available    string `json:"available"`
	Holds        string `json:"holds"`
	Transferable string `json:"transferable"`
}

AccountsTransferableModel RESPONSES of AccountsTransferable

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

func (as *ApiService) AccountLedgers(accountId string, startAt, endAt int64, options map[string]string, pagination *PaginationParam) (*ApiResponse, error)

AccountLedgers returns a list of ledgers. Deprecated: This interface was discontinued on Nov 05, 2020. Please use AccountLedgersV2. Account activity either increases or decreases your account balance. Items are paginated and sorted latest first. Deprecated

func (*ApiService) AccountLedgersV2

func (as *ApiService) AccountLedgersV2(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)

AccountLedgersV2 returns a list of ledgers. Recommended for use on Nov 05, 2020. 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) AccountsTransferable

func (as *ApiService) AccountsTransferable(currency, typo string) (*ApiResponse, error)

AccountsTransferable returns the transferable balance of a specified account.

func (*ApiService) ActualFee

func (as *ApiService) ActualFee(symbols string) (*ApiResponse, error)

ActualFee returns the actual fee rate of the trading pair. You can inquire about fee rates of 10 trading pairs each time at most.

func (*ApiService) AggregatedFullOrderBook

func (as *ApiService) AggregatedFullOrderBook(symbol string) (*ApiResponse, error)

AggregatedFullOrderBook returns a list of open orders(aggregated) for a symbol. Deprecated: Use AggregatedFullOrderBookV3/WebSocket instead.

func (*ApiService) AggregatedFullOrderBookV3

func (as *ApiService) AggregatedFullOrderBookV3(symbol string) (*ApiResponse, error)

AggregatedFullOrderBookV3 returns a list of open orders(aggregated) for a symbol.

func (*ApiService) AggregatedPartOrderBook

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) AtomicFullOrderBookV2

func (as *ApiService) AtomicFullOrderBookV2(symbol string) (*ApiResponse, error)

AtomicFullOrderBookV2 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) BaseFee

func (as *ApiService) BaseFee(currencyType string) (*ApiResponse, error)

BaseFee returns the basic fee rate of users.

func (*ApiService) BorrowOrder

func (as *ApiService) BorrowOrder(orderId string) (*ApiResponse, error)

BorrowOrder returns a specific borrow order

func (*ApiService) BorrowOutstandingRecords

func (as *ApiService) BorrowOutstandingRecords(currency string, pagination *PaginationParam) (*ApiResponse, error)

BorrowOutstandingRecords returns borrow outstanding records

func (*ApiService) BorrowRepaidRecords

func (as *ApiService) BorrowRepaidRecords(currency string, pagination *PaginationParam) (*ApiResponse, error)

BorrowRepaidRecords returns repaid borrow records

func (*ApiService) Call

func (as *ApiService) Call(request *Request) (*ApiResponse, error)

Call calls the API by passing *Request and returns *ApiResponse.

func (*ApiService) CancelLendOrder

func (as *ApiService) CancelLendOrder(orderId string) (*ApiResponse, error)

CancelLendOrder cancel a lend order

func (*ApiService) CancelOrder

func (as *ApiService) CancelOrder(orderId string) (*ApiResponse, error)

CancelOrder cancels a previously placed order.

func (*ApiService) CancelOrderByClient

func (as *ApiService) CancelOrderByClient(clientOid string) (*ApiResponse, error)

CancelOrderByClient cancels a previously placed order by client ID.

func (*ApiService) CancelOrders

func (as *ApiService) CancelOrders(p map[string]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) CancelStopOrder

func (as *ApiService) CancelStopOrder(orderId string) (*ApiResponse, error)

CancelStopOrder cancels a previously placed stop-order.

func (*ApiService) CancelStopOrderBy

func (as *ApiService) CancelStopOrderBy(params map[string]string) (*ApiResponse, error)

CancelStopOrderBy returns a list your current orders.

func (*ApiService) CancelStopOrderByClient

func (as *ApiService) CancelStopOrderByClient(clientOid string, p map[string]string) (*ApiResponse, error)

CancelStopOrderByClient cancels a previously placed stop-order by client ID.

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. Deprecated

func (*ApiService) CreateBorrowOrder

func (as *ApiService) CreateBorrowOrder(params map[string]string) (*ApiResponse, error)

CreateBorrowOrder returns the result of create a borrow order

func (*ApiService) CreateDepositAddress

func (as *ApiService) CreateDepositAddress(currency, chain string) (*ApiResponse, error)

CreateDepositAddress creates a deposit address.

func (*ApiService) CreateLendOrder

func (as *ApiService) CreateLendOrder(params map[string]string) (*ApiResponse, error)

CreateLendOrder returns the result of create a lend order

func (*ApiService) CreateMarginOrder

func (as *ApiService) CreateMarginOrder(o *CreateOrderModel) (*ApiResponse, error)

CreateMarginOrder places a new margin order.

func (*ApiService) CreateMultiOrder

func (as *ApiService) CreateMultiOrder(symbol string, orders []*CreateOrderModel) (*ApiResponse, error)

CreateMultiOrder places bulk orders.

func (*ApiService) CreateOrder

func (as *ApiService) CreateOrder(o *CreateOrderModel) (*ApiResponse, error)

CreateOrder places a new order.

func (*ApiService) CreateStopOrder

func (as *ApiService) CreateStopOrder(o *CreateOrderModel) (*ApiResponse, error)

CreateStopOrder places a new stop-order.

func (*ApiService) CreateSubAccountV2

func (as *ApiService) CreateSubAccountV2(password, remarks, subName, access string) (*ApiResponse, error)

CreateSubAccountV2 Create sub account v2.

func (*ApiService) CreateSubApiKey

func (as *ApiService) CreateSubApiKey(subName, passphrase, remark, permission, ipWhitelist, expire string) (*ApiResponse, error)

CreateSubApiKey create sub api key of spot.

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, chain string) (*ApiResponse, error)

Currency returns the details of the currency. Deprecated: Use CurrencyV2 instead.

func (*ApiService) CurrencyV2

func (as *ApiService) CurrencyV2(currency string, chain string) (*ApiResponse, error)

CurrencyV2 returns the details of the currency.

func (*ApiService) CurrentMarkPrice

func (as *ApiService) CurrentMarkPrice(symbol string) (*ApiResponse, error)

CurrentMarkPrice returns current mark price of the input symbol

func (*ApiService) DeleteSubApiKey

func (as *ApiService) DeleteSubApiKey(subName, passphrase, apiKey string) (*ApiResponse, error)

DeleteSubApiKey delete sub api key of spot.

func (*ApiService) DepositAddresses

func (as *ApiService) DepositAddresses(currency, chain 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) DepositAddressesV2

func (as *ApiService) DepositAddressesV2(currency string) (*ApiResponse, error)

DepositAddressesV2 Get all deposit addresses for the currency you intend to deposit. If the returned data is empty, you may need to 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) HfAccount

func (as *ApiService) HfAccount(accountId string) (*ApiResponse, error)

HfAccount Get the details of the high-frequency trading account

func (*ApiService) HfAccountInnerTransfer

func (as *ApiService) HfAccountInnerTransfer(params map[string]string) (*ApiResponse, error)

HfAccountInnerTransfer Users can transfer funds between their main account, trading account, and high-frequency trading account free of charge.

func (*ApiService) HfAccountLedgers

func (as *ApiService) HfAccountLedgers(params map[string]string) (*ApiResponse, error)

HfAccountLedgers returns all transfer (in and out) records in high-frequency trading account and supports multi-coin queries. The query results are sorted in descending order by createdAt and id.

func (*ApiService) HfAccountTransferable

func (as *ApiService) HfAccountTransferable(currency string) (*ApiResponse, error)

HfAccountTransferable This API can be used to obtain the amount of transferrable funds in high-frequency trading accounts.

func (*ApiService) HfAccounts

func (as *ApiService) HfAccounts(currency, accountType string) (*ApiResponse, error)

HfAccounts Get a list of high-frequency trading accounts.

func (*ApiService) HfAutoCancelSetting

func (as *ApiService) HfAutoCancelSetting(timeout int64, symbol string) (*ApiResponse, error)

HfAutoCancelSetting automatically cancel all orders of the set trading pair after the specified time. If this interface is not called again for renewal or cancellation before the set time, the system will help the user to cancel the order of the corresponding trading pair. otherwise it will not.

func (*ApiService) HfCancelOrder

func (as *ApiService) HfCancelOrder(orderId, symbol string) (*ApiResponse, error)

HfCancelOrder This endpoint can be used to cancel a high-frequency order by orderId.

func (*ApiService) HfCancelOrderByClientId

func (as *ApiService) HfCancelOrderByClientId(clientOid, symbol string) (*ApiResponse, error)

HfCancelOrderByClientId This endpoint sends out a request to cancel a high-frequency order using clientOid.

func (*ApiService) HfModifyOrder

func (as *ApiService) HfModifyOrder(params map[string]string) (*ApiResponse, error)

HfModifyOrder This interface can modify the price and quantity of the order according to orderId or clientOid.

func (*ApiService) HfObtainActiveOrders

func (as *ApiService) HfObtainActiveOrders(symbol string) (*ApiResponse, error)

HfObtainActiveOrders This endpoint obtains a list of all active HF orders. The return data is sorted in descending order based on the latest update times.

func (*ApiService) HfObtainActiveSymbols

func (as *ApiService) HfObtainActiveSymbols() (*ApiResponse, error)

HfObtainActiveSymbols This interface can query all trading pairs that the user has active orders

func (*ApiService) HfObtainFilledOrders

func (as *ApiService) HfObtainFilledOrders(p map[string]string) (*ApiResponse, error)

HfObtainFilledOrders This endpoint obtains a list of filled HF orders and returns paginated data. The returned data is sorted in descending order based on the latest order update times.

func (*ApiService) HfOrderDetail

func (as *ApiService) HfOrderDetail(orderId, symbol string) (*ApiResponse, error)

HfOrderDetail This endpoint can be used to obtain information for a single HF order using the order id.

func (*ApiService) HfOrderDetailByClientOid

func (as *ApiService) HfOrderDetailByClientOid(clientOid, symbol string) (*ApiResponse, error)

HfOrderDetailByClientOid The endpoint can be used to obtain information about a single order using clientOid. If the order does not exist, then there will be a prompt saying that the order does not exist.

func (*ApiService) HfPlaceMultiOrders

func (as *ApiService) HfPlaceMultiOrders(orders []*HFCreateMultiOrderModel) (*ApiResponse, error)

HfPlaceMultiOrders This endpoint supports sequential batch order placement from a single endpoint. A maximum of 5orders can be placed simultaneously. The order types must be limit orders of the same trading pair (this endpoint currently only supports spot trading and does not support margin trading)

func (*ApiService) HfPlaceOrder

func (as *ApiService) HfPlaceOrder(params map[string]string) (*ApiResponse, error)

HfPlaceOrder There are two types of orders: (limit) order: set price and quantity for the transaction. (market) order : set amount or quantity for the transaction.

func (*ApiService) HfQueryAutoCancelSetting

func (as *ApiService) HfQueryAutoCancelSetting() (*ApiResponse, error)

HfQueryAutoCancelSetting Through this interface, you can query the settings of automatic order cancellation

func (*ApiService) HfSyncCancelAllOrders

func (as *ApiService) HfSyncCancelAllOrders(symbol string) (*ApiResponse, error)

HfSyncCancelAllOrders his endpoint allows cancellation of all orders related to a specific trading pair with a status of open (including all orders pertaining to high-frequency trading accounts and non-high-frequency trading accounts)

func (*ApiService) HfSyncCancelOrder

func (as *ApiService) HfSyncCancelOrder(orderId, symbol string) (*ApiResponse, error)

HfSyncCancelOrder The difference between this interface and "Cancel orders by orderId" is that this interface will synchronously return the order information after the order canceling is completed.

func (*ApiService) HfSyncCancelOrderByClientId

func (as *ApiService) HfSyncCancelOrderByClientId(clientOid, symbol string) (*ApiResponse, error)

HfSyncCancelOrderByClientId The difference between this interface and "Cancellation of order by clientOid" is that this interface will synchronously return the order information after the order canceling is completed.

func (*ApiService) HfSyncCancelOrderWithSize

func (as *ApiService) HfSyncCancelOrderWithSize(orderId, symbol, cancelSize string) (*ApiResponse, error)

HfSyncCancelOrderWithSize This interface can cancel the specified quantity of the order according to the orderId.

func (*ApiService) HfSyncPlaceMultiOrders

func (as *ApiService) HfSyncPlaceMultiOrders(orders []*HFCreateMultiOrderModel) (*ApiResponse, error)

HfSyncPlaceMultiOrders The request parameters of this interface are the same as those of the "Sync place multiple hf orders" interface The difference between this interface and "Sync place multiple hf orders" is that this interface will synchronously return the order information after the order matching is completed.

func (*ApiService) HfSyncPlaceOrder

func (as *ApiService) HfSyncPlaceOrder(params map[string]string) (*ApiResponse, error)

HfSyncPlaceOrder The difference between this interface and "Place hf order" is that this interface will synchronously return the order information after the order matching is completed. For higher latency requirements, please select the "Place hf order" interface. If there is a requirement for returning data integrity, please select this interface

func (*ApiService) HfTransactionDetails

func (as *ApiService) HfTransactionDetails(p map[string]string) (*ApiResponse, error)

HfTransactionDetails This endpoint can be used to obtain a list of the latest HF transaction details. The returned results are paginated. The data is sorted in descending order according to time.

func (*ApiService) InnerTransferV2

func (as *ApiService) InnerTransferV2(clientOid, currency, from, to, amount string) (*ApiResponse, error)

InnerTransferV2 makes a currency transfer internally. Recommended for use on June 5, 2019. The inner transfer interface is used for transferring assets between the accounts of a user and is free of charges. For example, a user could transfer assets from their main account to their trading account on the platform.

func (*ApiService) IsolatedAccount

func (as *ApiService) IsolatedAccount(symbol string) (*ApiResponse, error)

IsolatedAccount query margin isolated account by symbol

func (*ApiService) IsolatedBorrow

func (as *ApiService) IsolatedBorrow(params map[string]string) (*ApiResponse, error)

IsolatedBorrow margin isolated borrow

func (*ApiService) IsolatedBorrowOutstandingRecord

func (as *ApiService) IsolatedBorrowOutstandingRecord(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)

IsolatedBorrowOutstandingRecord query margin isolated borrow outstanding records

func (*ApiService) IsolatedBorrowRepaidRecord

func (as *ApiService) IsolatedBorrowRepaidRecord(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)

IsolatedBorrowRepaidRecord query margin isolated borrow repaid records

func (*ApiService) IsolatedRepayAll

func (as *ApiService) IsolatedRepayAll(params map[string]string) (*ApiResponse, error)

IsolatedRepayAll repay all isolated

func (*ApiService) IsolatedRepaySingle

func (as *ApiService) IsolatedRepaySingle(params map[string]string) (*ApiResponse, error)

IsolatedRepaySingle repay single isolated

func (*ApiService) KLines

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) LendActiveOrders

func (as *ApiService) LendActiveOrders(currency string, pagination *PaginationParam) (*ApiResponse, error)

LendActiveOrders returns the active lend orders

func (*ApiService) LendAssets

func (as *ApiService) LendAssets(currency string) (*ApiResponse, error)

LendAssets returns account lend assets

func (*ApiService) LendDoneOrders

func (as *ApiService) LendDoneOrders(currency string, pagination *PaginationParam) (*ApiResponse, error)

LendDoneOrders returns the history lend orders

func (*ApiService) LendTradeSettledRecords

func (as *ApiService) LendTradeSettledRecords(currency string, pagination *PaginationParam) (*ApiResponse, error)

LendTradeSettledRecords returns settled lend records

func (*ApiService) LendTradeUnsettledRecords

func (as *ApiService) LendTradeUnsettledRecords(currency string, pagination *PaginationParam) (*ApiResponse, error)

LendTradeUnsettledRecords returns unsettled lend records

func (*ApiService) MarginAccount

func (as *ApiService) MarginAccount() (*ApiResponse, error)

MarginAccount returns a margin account information

func (*ApiService) MarginConfig

func (as *ApiService) MarginConfig() (*ApiResponse, error)

MarginConfig returns a margin configuration

func (*ApiService) MarginIsolatedAccounts

func (as *ApiService) MarginIsolatedAccounts(balanceCurrency string) (*ApiResponse, error)

MarginIsolatedAccounts query margin isolated account

func (*ApiService) MarginIsolatedSymbols

func (as *ApiService) MarginIsolatedSymbols() (*ApiResponse, error)

MarginIsolatedSymbols query margin isolated symbols

func (*ApiService) MarginMarkets

func (as *ApiService) MarginMarkets(params map[string]string) (*ApiResponse, error)

MarginMarkets returns lending market data

func (*ApiService) MarginRiskLimit

func (as *ApiService) MarginRiskLimit(marginModel string) (*ApiResponse, error)

func (*ApiService) MarginTradeLast

func (as *ApiService) MarginTradeLast(currency string) (*ApiResponse, error)

MarginTradeLast returns latest lending market trade datas

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) *WebSocketClient

NewWebSocketClient creates an instance of WebSocketClient.

func (*ApiService) NewWebSocketClientOpts

func (as *ApiService) NewWebSocketClientOpts(opts WebSocketClientOpts) *WebSocketClient

NewWebSocketClientOpts creates an instance of WebSocketClient with the parsed options.

func (*ApiService) Order

func (as *ApiService) Order(orderId string) (*ApiResponse, error)

Order returns a single order by order id.

func (*ApiService) OrderByClient

func (as *ApiService) OrderByClient(clientOid string) (*ApiResponse, error)

OrderByClient returns a single order by client 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

func (as *ApiService) Prices(base, currencies string) (*ApiResponse, error)

Prices returns the fiat prices for currency.

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) RepayAll

func (as *ApiService) RepayAll(params map[string]string) (*ApiResponse, error)

RepayAll repay borrow orders of one currency

func (*ApiService) RepaySingle

func (as *ApiService) RepaySingle(params map[string]string) (*ApiResponse, error)

RepaySingle repay a single borrow order

func (*ApiService) ServerTime

func (as *ApiService) ServerTime() (*ApiResponse, error)

ServerTime returns the API server time.

func (*ApiService) ServiceStatus

func (as *ApiService) ServiceStatus() (*ApiResponse, error)

ServiceStatus returns the service status.

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) StopOrderByClient

func (as *ApiService) StopOrderByClient(clientOid string, p map[string]string) (*ApiResponse, error)

StopOrderByClient returns a single stop-order by client id.

func (*ApiService) StopOrders

func (as *ApiService) StopOrders(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)

StopOrders returns a list your current orders.

func (*ApiService) SubAccount

func (as *ApiService) SubAccount(subUserId string) (*ApiResponse, error)

SubAccount returns the detail of a sub-account.

func (*ApiService) SubAccountUsers

func (as *ApiService) SubAccountUsers() (*ApiResponse, error)

SubAccountUsers returns a list of sub-account user.

func (*ApiService) SubAccountUsersV2

func (as *ApiService) SubAccountUsersV2(pagination *PaginationParam) (*ApiResponse, error)

SubAccountUsersV2 returns a list of sub-account user by page.

func (*ApiService) SubAccounts

func (as *ApiService) SubAccounts() (*ApiResponse, error)

SubAccounts returns the aggregated balance of all sub-accounts of the current user.

func (*ApiService) SubAccountsV2

func (as *ApiService) SubAccountsV2(pagination *PaginationParam) (*ApiResponse, error)

SubAccountsV2 returns subAccounts of user with page info.

func (*ApiService) SubApiKey

func (as *ApiService) SubApiKey(subName, apiKey string) (*ApiResponse, error)

SubApiKey returns sub api key of spot.

func (*ApiService) SubTransfer

func (as *ApiService) SubTransfer(params map[string]string) (*ApiResponse, error)

SubTransfer transfers between master account and sub-account. Deprecated: This interface was discontinued on Oct 28, 2020. Please use SubTransferV2.

func (*ApiService) SubTransferV2

func (as *ApiService) SubTransferV2(params map[string]string) (*ApiResponse, error)

SubTransferV2 transfers between master account and sub-account. Recommended for use on Oct 28, 2020.

func (*ApiService) Symbols

func (as *ApiService) Symbols(market string) (*ApiResponse, error)

Symbols returns a list of available currency pairs for trading. Deprecated

func (*ApiService) SymbolsV2

func (as *ApiService) SymbolsV2(market string) (*ApiResponse, error)

SymbolsV2 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).

func (*ApiService) ToggleAutoLend

func (as *ApiService) ToggleAutoLend(params map[string]string) (*ApiResponse, error)

ToggleAutoLend set auto lend rules

func (*ApiService) TradeHistories

func (as *ApiService) TradeHistories(symbol string) (*ApiResponse, error)

TradeHistories returns a list the latest trades for a symbol.

func (*ApiService) UpdateSubApiKey

func (as *ApiService) UpdateSubApiKey(subName, passphrase, apiKey, permission, ipWhitelist, expire string) (*ApiResponse, error)

UpdateSubApiKey update sub api key of spot.

func (*ApiService) UserSummaryInfoV2

func (as *ApiService) UserSummaryInfoV2() (*ApiResponse, error)

UserSummaryInfoV2 returns summary information of user.

func (*ApiService) V1Deposits

func (as *ApiService) V1Deposits(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)

V1Deposits returns a list of v1 historical deposits.

func (*ApiService) V1Orders

func (as *ApiService) V1Orders(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)

V1Orders returns a list of v1 historical orders. Deprecated

func (*ApiService) V1Withdrawals

func (as *ApiService) V1Withdrawals(params map[string]string, pagination *PaginationParam) (*ApiResponse, error)

V1Withdrawals returns a list of v1 historical withdrawals.

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, chain 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 ApiKeyVersionOption

func ApiKeyVersionOption(apiKeyVersion string) ApiServiceOption

ApiKeyVersionOption creates a instance of ApiServiceOption about apiKeyVersion.

func ApiPassPhraseOption

func ApiPassPhraseOption(passPhrase string) ApiServiceOption

ApiPassPhraseOption creates a instance of ApiServiceOption about apiPassPhrase.

func ApiRequesterOption

func ApiRequesterOption(requester Requester) ApiServiceOption

ApiRequesterOption creates a instance of ApiServiceOption about requester.

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 BaseFeeModel

type BaseFeeModel struct {
	TakerFeeRate string `json:"takerFeeRate"`
	MakerFeeRate string `json:"makerFeeRate"`
}

BaseFeeModel RESPONSES of BaseFee endpoint

type BasicRequester

type BasicRequester struct {
}

A BasicRequester represents a basic implement of Requester by http.Client.

func (*BasicRequester) Request

func (br *BasicRequester) Request(request *Request, timeout time.Duration) (*Response, error)

Request makes a http request.

type BorrowOrderModel

type BorrowOrderModel struct {
	OrderId   string      `json:"orderId"`
	Currency  string      `json:"currency"`
	Size      json.Number `json:"size"`
	Filled    json.Number `json:"filled"`
	Status    string      `json:"status"`
	MatchList []struct {
		Currency     string      `json:"currency"`
		DailyIntRate json.Number `json:"dailyIntRate"`
		Size         json.Number `json:"size"`
		Term         json.Number `json:"term"`
		Timestamp    json.Number `json:"timestamp"`
		TradeId      string      `json:"tradeId"`
	} `json:"matchList"`
}

BorrowOrderModel represents a borrow order

type BorrowOutstandingRecordModel

type BorrowOutstandingRecordModel struct {
	Currency        string      `json:"currency"`
	TradeId         string      `json:"tradeId"`
	Liability       json.Number `json:"liability"`
	Principal       json.Number `json:"principal"`
	AccruedInterest json.Number `json:"accruedInterest"`
	CreatedAt       json.Number `json:"createdAt"`
	MaturityTime    json.Number `json:"maturityTime"`
	Term            json.Number `json:"term"`
	RepaidSize      json.Number `json:"repaidSize"`
	DailyIntRate    json.Number `json:"dailyIntRate"`
}

BorrowOutstandingRecordModel represents borrow outstanding record

type BorrowOutstandingRecordsModel

type BorrowOutstandingRecordsModel []*BorrowOutstandingRecordModel

BorrowOutstandingRecordsModel is a list of *BorrowOutstandingRecordModel

type BorrowRepaidRecordModel

type BorrowRepaidRecordModel struct {
	Currency     string      `json:"currency"`
	DailyIntRate json.Number `json:"dailyIntRate"`
	Interest     json.Number `json:"interest"`
	Principal    json.Number `json:"principal"`
	RepaidSize   json.Number `json:"repaidSize"`
	RepayTime    json.Number `json:"repayTime"`
	Term         json.Number `json:"term"`
	TradeId      string      `json:"tradeId"`
}

BorrowRepaidRecordModel represents a repaid borrow record

type BorrowRepaidRecordsModel

type BorrowRepaidRecordsModel []*BorrowRepaidRecordModel

BorrowRepaidRecordsModel is a list of *BorrowRepaidRecordModel

type CancelOrderByClientResultModel

type CancelOrderByClientResultModel struct {
	CancelledOrderId string `json:"cancelledOrderId"`
	ClientOid        string `json:"clientOid"`
}

A CancelOrderByClientResultModel represents the result of CancelOrderByClient().

type CancelOrderResultModel

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

A CancelOrderResultModel represents the result of CancelOrder().

type CancelStopOrderByClientModel

type CancelStopOrderByClientModel struct {
	CancelledOrderId string `json:"cancelledOrderId"`
	ClientOid        string `json:"clientOid"`
}

CancelStopOrderByClientModel returns Model of CancelStopOrderByClient API

type CancelWithdrawalResultModel

type CancelWithdrawalResultModel struct {
	CancelledWithdrawIds []string `json:"cancelledWithdrawIds"`
}

CancelWithdrawalResultModel represents the result of CancelWithdrawal().

type ChainsModel

type ChainsModel struct {
	ChainName         string `json:"chainName"`
	WithdrawalMinSize string `json:"withdrawalMinSize"`
	WithdrawalMinFee  string `json:"withdrawalMinFee"`
	IsWithdrawEnabled bool   `json:"isWithdrawEnabled"`
	IsDepositEnabled  bool   `json:"isDepositEnabled"`
	Confirms          int64  `json:"confirms"`
	ContractAddress   string `json:"contractAddress"`
}

ChainsModel Chains Model

type CreateAccountModel

type CreateAccountModel struct {
	Id string `json:"id"`
}

CreateAccountModel represents The account id returned from creating an account

type CreateBorrowOrderResultModel

type CreateBorrowOrderResultModel struct {
	OrderId  string `json:"orderId"`
	Currency string `json:"currency"`
}

CreateBorrowOrderResultModel represents the result of create a borrow order

type CreateLendOrderResultModel

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

CreateLendOrderResultModel the result of create a lend order

type CreateMultiOrderResultModel

type CreateMultiOrderResultModel struct {
	Data OrdersModel `json:"data"`
}

A CreateMultiOrderResultModel represents the result of CreateMultiOrder().

type CreateOrderModel

type CreateOrderModel struct {
	// BASE PARAMETERS
	ClientOid string `json:"clientOid"`
	Side      string `json:"side"`
	Symbol    string `json:"symbol,omitempty"`
	Type      string `json:"type,omitempty"`
	Remark    string `json:"remark,omitempty"`
	Stop      string `json:"stop,omitempty"`
	StopPrice string `json:"stopPrice,omitempty"`
	STP       string `json:"stp,omitempty"`
	TradeType string `json:"tradeType,omitempty"`

	// LIMIT ORDER PARAMETERS
	Price       string `json:"price,omitempty"`
	Size        string `json:"size,omitempty"`
	TimeInForce string `json:"timeInForce,omitempty"`
	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"`

	// MARKET ORDER PARAMETERS
	// Size  string `json:"size"`
	Funds string `json:"funds,omitempty"`

	// MARGIN ORDER PARAMETERS
	MarginMode string `json:"marginMode,omitempty"`
	AutoBorrow bool   `json:"autoBorrow,omitempty"`
}

A CreateOrderModel is the input parameter of CreateOrder().

type CreateOrderResultModel

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

A CreateOrderResultModel represents the result of CreateOrder().

type CreateSubAccountV2Res

type CreateSubAccountV2Res struct {
	Uid     int64  `json:"uid"`
	SubName string `json:"subName"`
	Remarks string `json:"remarks"`
	Access  string `json:"access"`
}

CreateSubAccountV2Res returns Create Sub account response

type CreateSubApiKeyRes

type CreateSubApiKeyRes struct {
	ApiKey      string      `json:"apiKey"`
	CreatedAt   json.Number `json:"createdAt"`
	IpWhitelist string      `json:"ipWhitelist"`
	Permission  string      `json:"permission"`
	Remark      string      `json:"remark"`
	SubName     string      `json:"subName"`
	ApiSecret   string      `json:"apiSecret"`
	Passphrase  string      `json:"passphrase"`
}

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"`
	Confirms          int64  `json:"confirms"`
	ContractAddress   string `json:"contractAddress"`
	WithdrawalMinSize string `json:"withdrawalMinSize"`
	WithdrawalMinFee  string `json:"withdrawalMinFee"`
	IsWithdrawEnabled bool   `json:"isWithdrawEnabled"`
	IsDepositEnabled  bool   `json:"isDepositEnabled"`
	IsMarginEnabled   bool   `json:"isMarginEnabled"`
	IsDebitEnabled    bool   `json:"isDebitEnabled"`
}

A CurrencyModel represents a model of known currency.

type CurrencyV2Model

type CurrencyV2Model struct {
	Name            string         `json:"name"`
	Currency        string         `json:"currency"`
	FullName        string         `json:"fullName"`
	Precision       uint8          `json:"precision"`
	Confirms        int64          `json:"confirms"`
	ContractAddress string         `json:"contractAddress"`
	IsMarginEnabled bool           `json:"isMarginEnabled"`
	IsDebitEnabled  bool           `json:"isDebitEnabled"`
	Chains          []*ChainsModel `json:"chains"`
}

CurrencyV2Model CurrencyV2 Model

type DeleteSubApiKeyRes

type DeleteSubApiKeyRes struct {
	ApiKey  string `json:"apiKey"`
	SubName string `json:"subName"`
}

type DepositAddressModel

type DepositAddressModel struct {
	Address string `json:"address"`
	Memo    string `json:"memo"`
	Chain   string `json:"chain"`
}

A DepositAddressModel represents a deposit address of currency for deposit.

type DepositAddressesModel

type DepositAddressesModel DepositAddressModel

A DepositAddressesModel is the set of *DepositAddressModel.

type DepositAddressesV2Model

type DepositAddressesV2Model []*depositAddressV2Model

type DepositModel

type DepositModel struct {
	Chain      string `json:"chain"`
	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"`
	Remark     string `json:"remark"`
	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"`
	TradeType      string `json:"tradeType"`
}

A FillModel represents the structure of fill.

type FillsModel

type FillsModel []*FillModel

A FillsModel is the set of *FillModel.

type FullOrderBookModel

type FullOrderBookModel struct {
	Sequence string     `json:"sequence"`
	Time     int64      `json:"time"`
	Bids     [][]string `json:"bids"`
	Asks     [][]string `json:"asks"`
}

A FullOrderBookModel represents a list of open orders for a symbol, with full depth.

type FullOrderBookV2Model

type FullOrderBookV2Model struct {
	Sequence int64           `json:"sequence"`
	Time     int64           `json:"time"`
	Bids     [][]interface{} `json:"bids"`
	Asks     [][]interface{} `json:"asks"`
}

A FullOrderBookV2Model represents a list of open orders for a symbol, with full depth.

type HFCreateMultiOrderModel

type HFCreateMultiOrderModel struct {
	ClientOid   string  `json:"clientOid"`
	Symbol      string  `json:"symbol"`
	OrderType   string  `json:"type"`
	TimeInForce string  `json:"timeInForce"`
	Stp         string  `json:"stp"`
	Side        string  `json:"side"`
	Price       string  `json:"price"`
	Size        string  `json:"size"`
	CancelAfter big.Int `json:"cancelAfter"`
	PostOnly    bool    `json:"postOnly"`
	Hidden      bool    `json:"hidden"`
	Iceberg     bool    `json:"iceberg"`
	VisibleSize string  `json:"visibleSize"`
	Tags        string  `json:"tags"`
	Remark      string  `json:"remark"`
}

type HfAccountInnerTransferRes

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

type HfAccountLedgerModel

type HfAccountLedgerModel struct {
	Id          string `json:"id"`
	Currency    string `json:"currency"`
	Amount      string `json:"amount"`
	Fee         string `json:"fee"`
	Balance     string `json:"balance"`
	AccountType string `json:"accountType"`
	BizType     string `json:"bizType"`
	Direction   string `json:"direction"`
	CreatedAt   string `json:"createdAt"`
	Context     string `json:"context"`
}

type HfAccountLedgersModel

type HfAccountLedgersModel []*HfAccountLedgerModel

type HfAccountModel

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

type HfAccountTransferableModel

type HfAccountTransferableModel struct {
	Balance      string `json:"balance"`
	Available    string `json:"available"`
	Currency     string `json:"currency"`
	Holds        string `json:"holds"`
	Transferable string `json:"transferable"`
}

type HfAccountsModel

type HfAccountsModel []HfAccountModel

type HfAutoCancelSettingRes

type HfAutoCancelSettingRes struct {
	CurrentTime json.Number `json:"currentTime"`
	TriggerTime json.Number `json:"triggerTime"`
}

type HfClientOidModel

type HfClientOidModel struct {
	ClientOid string `json:"clientOid"`
}

type HfFilledOrdersModel

type HfFilledOrdersModel struct {
	LastId json.Number     `json:"lastId"`
	Items  []*HfOrderModel `json:"items"`
}

type HfModifyOrderRes

type HfModifyOrderRes struct {
	NewOrderId string `json:"newOrderId"`
}

type HfOrderIdModel

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

type HfOrderModel

type HfOrderModel 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"`
	DealSize       string      `json:"dealSize"`
	DealFunds      string      `json:"dealFunds"`
	Fee            string      `json:"fee"`
	FeeCurrency    string      `json:"feeCurrency"`
	Stp            string      `json:"stp"`
	TimeInForce    string      `json:"timeInForce"`
	PostOnly       bool        `json:"postOnly"`
	Hidden         bool        `json:"hidden"`
	Iceberg        bool        `json:"iceberg"`
	VisibleSize    string      `json:"visibleSize"`
	CancelAfter    int64       `json:"cancelAfter"`
	Channel        string      `json:"channel"`
	ClientOid      string      `json:"clientOid"`
	Remark         string      `json:"remark"`
	Tags           string      `json:"tags"`
	CancelExist    bool        `json:"cancelExist"`
	CreatedAt      json.Number `json:"createdAt"`
	LastUpdatedAt  json.Number `json:"lastUpdatedAt"`
	TradeType      string      `json:"tradeType"`
	InOrderBook    bool        `json:"inOrderBook"`
	Active         bool        `json:"active"`
	CancelledSize  string      `json:"cancelledSize"`
	CancelledFunds string      `json:"cancelledFunds"`
	RemainSize     string      `json:"remainSize"`
	RemainFunds    string      `json:"remainFunds"`
}

type HfOrdersModel

type HfOrdersModel []*HfOrderModel

type HfPlaceMultiOrdersRes

type HfPlaceMultiOrdersRes []*HfPlaceOrderRes

type HfPlaceOrderRes

type HfPlaceOrderRes struct {
	OrderId string `json:"orderId"`
	Success bool   `json:"success"`
}

type HfSymbolsModel

type HfSymbolsModel struct {
	Symbols []string `json:"symbols"`
}

type HfSyncCancelOrderRes

type HfSyncCancelOrderRes struct {
	OrderId      string `json:"orderId"`
	OriginSize   string `json:"originSize"`
	OriginFunds  string `json:"originFunds"`
	DealSize     string `json:"dealSize"`
	RemainSize   string `json:"remainSize"`
	CanceledSize string `json:"canceledSize"`
	Status       string `json:"status"`
}

type HfSyncCancelOrderWithSizeRes

type HfSyncCancelOrderWithSizeRes struct {
	OrderId    string `json:"orderId"`
	CancelSize string `json:"cancelSize"`
}

type HfSyncPlaceMultiOrdersRes

type HfSyncPlaceMultiOrdersRes []*HfSyncPlaceOrderRes

type HfSyncPlaceOrderRes

type HfSyncPlaceOrderRes struct {
	OrderId      string      `json:"orderId"`
	OrderTime    json.Number `json:"orderTime"`
	OriginSize   string      `json:"originSize"`
	DealSize     string      `json:"dealSize"`
	RemainSize   string      `json:"remainSize"`
	CanceledSize string      `json:"canceledSize"`
	Status       string      `json:"status"`
	MatchTime    json.Number `json:"matchTime"`
}

type HfTransactionDetailModel

type HfTransactionDetailModel struct {
	Id             json.Number `json:"id"`
	Symbol         string      `json:"symbol"`
	TradeId        json.Number `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"`
	OrderType      string      `json:"type"`
	Stop           string      `json:"stop"`
	CreatedAt      json.Number `json:"createdAt"`
	TradeType      string      `json:"tradeType"`
}

type HfTransactionDetailsModel

type HfTransactionDetailsModel struct {
	LastId json.Number                 `json:"lastId"`
	Items  []*HfTransactionDetailModel `json:"items"`
}

type InnerTransferResultModel

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

An InnerTransferResultModel represents the result of a inner-transfer operation.

type IsolatedBorrowOutstandingRecordModel

type IsolatedBorrowOutstandingRecordModel struct {
	LoanId            string      `json:"loanId"`
	Symbol            string      `json:"symbol"`
	Currency          string      `json:"currency"`
	LiabilityBalance  string      `json:"liabilityBalance"`
	PrincipalTotal    string      `json:"principalTotal"`
	InterestBalance   string      `json:"interestBalance"`
	CreatedAt         json.Number `json:"createdAt"`
	MaturityTime      json.Number `json:"maturityTime"`
	Period            int64       `json:"period"`
	RepaidSize        string      `json:"repaidSize"`
	DailyInterestRate string      `json:"dailyInterestRate"`
}

type IsolatedBorrowOutstandingRecordsModel

type IsolatedBorrowOutstandingRecordsModel []*IsolatedBorrowOutstandingRecordModel

type IsolatedBorrowRepaidRecordRecordModel

type IsolatedBorrowRepaidRecordRecordModel struct {
	LoanId            string      `json:"loanId"`
	Symbol            string      `json:"symbol"`
	Currency          string      `json:"currency"`
	PrincipalTotal    string      `json:"principalTotal"`
	InterestBalance   string      `json:"interestBalance"`
	RepaidSize        string      `json:"repaidSize"`
	CreatedAt         json.Number `json:"createdAt"`
	Period            int64       `json:"period"`
	DailyInterestRate string      `json:"dailyInterestRate"`
	RepayFinishAt     json.Number `json:"repayFinishAt"`
}

type IsolatedBorrowRepaidRecordRecordsModel

type IsolatedBorrowRepaidRecordRecordsModel []*IsolatedBorrowRepaidRecordRecordModel

type KLineModel

type KLineModel []string

KLineModel represents the k lines for a symbol. Rates are returned in grouped buckets based on requested type.

type KLinesModel

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

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

NewKcSigner creates a instance of KcSigner.

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 LendActiveOrderModel

type LendActiveOrderModel struct {
	LendOrderBaseModel
}

LendActiveOrderModel represents a active lend order

type LendActiveOrdersModel

type LendActiveOrdersModel []*LendActiveOrderModel

LendActiveOrdersModel is a list of *LendActiveOrderModel

type LendAssetModel

type LendAssetModel struct {
	Currency        string      `json:"currency"`
	Outstanding     json.Number `json:"outstanding"`
	FilledSize      json.Number `json:"filledSize"`
	AccruedInterest json.Number `json:"accruedInterest"`
	RealizedProfit  json.Number `json:"realizedProfit"`
	IsAutoLend      bool        `json:"isAutoLend"`
}

LendAssetModel represents account lend asset

type LendAssetsModel

type LendAssetsModel []*LendAssetModel

LendAssetsModel is a list of *LendAssetModel

type LendDoneOrderModel

type LendDoneOrderModel struct {
	LendOrderBaseModel
	Status string `json:"status"`
}

LendDoneOrderModel represents a history lend order

type LendDoneOrdersModel

type LendDoneOrdersModel []*LendDoneOrderModel

LendDoneOrdersModel is a list of *LendDoneOrderModel

type LendOrderBaseModel

type LendOrderBaseModel struct {
	OrderId      string      `json:"orderId"`
	Currency     string      `json:"currency"`
	Size         json.Number `json:"size"`
	FilledSize   json.Number `json:"filledSize"`
	DailyIntRate json.Number `json:"dailyIntRate"`
	Term         json.Number `json:"term"`
	CreatedAt    json.Number `json:"createdAt"`
}

LendOrderBaseModel represents Base model of lend order

type LendTradeSettledRecordModel

type LendTradeSettledRecordModel struct {
	TradeId      string      `json:"tradeId"`
	Currency     string      `json:"currency"`
	Size         json.Number `json:"size"`
	Interest     json.Number `json:"interest"`
	Repaid       json.Number `json:"repaid"`
	DailyIntRate json.Number `json:"dailyIntRate"`
	Term         json.Number `json:"term"`
	SettledAt    json.Number `json:"settledAt"`
	Note         string      `json:"note"`
}

LendTradeSettledRecordModel represents a settled lend record

type LendTradeSettledRecordsModel

type LendTradeSettledRecordsModel []*LendTradeSettledRecordModel

LendTradeSettledRecordsModel is a list of *LendTradeSettledRecordModel

type LendTradeUnsettledRecordModel

type LendTradeUnsettledRecordModel struct {
	TradeId         string      `json:"tradeId"`
	Currency        string      `json:"currency"`
	Size            json.Number `json:"size"`
	AccruedInterest json.Number `json:"accruedInterest"`
	Repaid          json.Number `json:"repaid"`
	DailyIntRate    json.Number `json:"dailyIntRate"`
	Term            json.Number `json:"term"`
	MaturityTime    json.Number `json:"maturityTime"`
}

LendTradeUnsettledRecordModel represents a unsettled lend record

type LendTradeUnsettledRecordsModel

type LendTradeUnsettledRecordsModel []*LendTradeUnsettledRecordModel

LendTradeUnsettledRecordsModel is a list of *LendTradeUnsettledRecordModel

type MarginAccountModel

type MarginAccountModel struct {
	Accounts []struct {
		AvailableBalance json.Number `json:"availableBalance"`
		Currency         string      `json:"currency"`
		HoldBalance      json.Number `json:"holdBalance"`
		Liability        json.Number `json:"liability"`
		MaxBorrowSize    json.Number `json:"maxBorrowSize"`
		TotalBalance     json.Number `json:"totalBalance"`
	} `json:"accounts"`
	DebtRatio json.Number `json:"debtRatio"`
}

MarginAccountModel represents a margin account information

type MarginConfigModel

type MarginConfigModel struct {
	CurrencyList     []string    `json:"currencyList"`
	WarningDebtRatio json.Number `json:"warningDebtRatio"`
	LiqDebtRatio     json.Number `json:"liqDebtRatio"`
	MaxLeverage      json.Number `json:"maxLeverage"`
}

MarginConfigModel represents a margin configuration

type MarginIsolatedAccountAssetsModel

type MarginIsolatedAccountAssetsModel struct {
	Symbol    string `json:"symbol"`
	Status    string `json:"status"`
	DebtRatio string `json:"debtRatio"`
	BaseAsset struct {
		Currency         string `json:"currency"`
		TotalBalance     string `json:"totalBalance"`
		HoldBalance      string `json:"holdBalance"`
		AvailableBalance string `json:"availableBalance"`
		Liability        string `json:"liability"`
		Interest         string `json:"interest"`
		BorrowableAmount string `json:"borrowableAmount"`
	} `json:"baseAsset"`
	QuoteAsset struct {
		Currency         string `json:"currency"`
		TotalBalance     string `json:"totalBalance"`
		HoldBalance      string `json:"holdBalance"`
		AvailableBalance string `json:"availableBalance"`
		Liability        string `json:"liability"`
		Interest         string `json:"interest"`
		BorrowableAmount string `json:"borrowableAmount"`
	} `json:"quoteAsset"`
}

type MarginIsolatedAccountsModel

type MarginIsolatedAccountsModel struct {
	TotalConversionBalance     string                              `json:"totalConversionBalance"`
	LiabilityConversionBalance string                              `json:"liabilityConversionBalance"`
	Assets                     []*MarginIsolatedAccountAssetsModel `json:"assets"`
}

type MarginIsolatedBorrowRes

type MarginIsolatedBorrowRes struct {
	OrderId    string `json:"orderId"`
	Currency   string `json:"currency"`
	ActualSize string `json:"actualSize"`
}

type MarginIsolatedSymbolModel

type MarginIsolatedSymbolModel struct {
	Symbol                string `json:"symbol"`
	SymbolName            string `json:"symbolName"`
	BaseCurrency          string `json:"baseCurrency"`
	QuoteCurrency         string `json:"quoteCurrency"`
	MaxLeverage           int64  `json:"maxLeverage"`
	FlDebtRatio           string `json:"flDebtRatio"`
	TradeEnable           bool   `json:"tradeEnable"`
	AutoRenewMaxDebtRatio string `json:"autoRenewMaxDebtRatio"`
	BaseBorrowEnable      bool   `json:"baseBorrowEnable"`
	QuoteBorrowEnable     bool   `json:"quoteBorrowEnable"`
	BaseTransferInEnable  bool   `json:"baseTransferInEnable"`
	QuoteTransferInEnable bool   `json:"quoteTransferInEnable"`
}

type MarginIsolatedSymbolsModel

type MarginIsolatedSymbolsModel []*MarginIsolatedSymbolModel

type MarginMarketModel

type MarginMarketModel struct {
	DailyIntRate json.Number `json:"dailyIntRate"`
	Term         json.Number `json:"term"`
	Size         json.Number `json:"size"`
}

MarginMarketModel represents lending market data

type MarginMarketsModel

type MarginMarketsModel []*MarginMarketModel

MarginMarketsModel is a list of *MarginMarketModel

type MarginRiskLimitItemModel

type MarginRiskLimitItemModel struct {
	Currency        string      `json:"currency"`
	BorrowMaxAmount string      `json:"borrowMaxAmount"`
	BuyMaxAmount    string      `json:"buyMaxAmount"`
	Precision       json.Number `json:"precision"`
}

MarginRiskLimitItemModel is item of *MarginRiskLimitModel

type MarginRiskLimitModel

type MarginRiskLimitModel []*MarginRiskLimitItemModel

MarginRiskLimitModel is a list of *MarginRiskLimitModel

type MarginTradeModel

type MarginTradeModel struct {
	TradeId      string      `json:"tradeId"`
	Currency     string      `json:"currency"`
	Size         json.Number `json:"size"`
	DailyIntRate json.Number `json:"dailyIntRate"`
	Term         json.Number `json:"term"`
	Timestamp    json.Number `json:"timestamp"`
}

MarginTradeModel represents lending market trade data

type MarginTradesModel

type MarginTradesModel []*MarginTradeModel

MarginTradesModel is a list of *MarginTradeModel

type MarkPriceModel

type MarkPriceModel struct {
	Symbol      string      `json:"symbol"`
	Granularity json.Number `json:"granularity"`
	TimePoint   json.Number `json:"timePoint"`
	Value       json.Number `json:"value"`
}

MarkPriceModel represents mark price of a symbol

type MarketsModel

type MarketsModel []string

MarketsModel returns Model of Markets API.

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   int64  `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"`
}

An OrderModel represents an order.

type OrdersModel

type OrdersModel []*OrderModel

A OrdersModel is the set of *OrderModel.

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

type PaginationParam struct {
	CurrentPage int64
	PageSize    int64
}

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"`
	Time     int64      `json:"time"`
	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 PricesModel

type PricesModel map[string]string

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

func NewRequest(method, path string, params interface{}) *Request

NewRequest creates a instance of Request.

func (*Request) FullURL

func (r *Request) FullURL() string

FullURL returns the full url.

func (*Request) HttpRequest

func (r *Request) HttpRequest() (*http.Request, error)

HttpRequest creates a instance of *http.Request.

func (*Request) RequestURI

func (r *Request) RequestURI() string

RequestURI returns the request uri.

type Requester

type Requester interface {
	Request(request *Request, timeout time.Duration) (*Response, error)
}

Requester contains Request() method, can launch a http request.

type Response

type Response struct {
	*http.Response
	// contains filtered or unexported fields
}

A Response represents a HTTP response.

func NewResponse

func NewResponse(
	request *Request,
	response *http.Response,
	body []byte,
) *Response

NewResponse Creates a new Response

func (*Response) ReadBody

func (r *Response) ReadBody() ([]byte, error)

ReadBody read the response data, then return it.

func (*Response) ReadJsonBody

func (r *Response) ReadJsonBody(v interface{}) error

ReadJsonBody read the response data as JSON into v.

type ServerTimeModel

type ServerTimeModel int64

type ServiceStatusModel

type ServiceStatusModel struct {
	Status string `json:"status"`
	Msg    string `json:"msg"`
}

A ServiceStatusModel represents the structure of service status.

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 Stats24hrModel

type Stats24hrModel struct {
	Time             int64  `json:"time"`
	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"`
	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 Stats24hrModel represents 24 hr stats for the symbol. Volume is in base currency units. Open, high, low are in quote currency units.

type StopOrderListModel

type StopOrderListModel []*StopOrderModel

StopOrderListModel StopOrderByClient model

type StopOrderModel

type StopOrderModel struct {
	Id              string `json:"id"`
	Symbol          string `json:"symbol"`
	UserId          string `json:"userId"`
	Status          string `json:"status"`
	Type            string `json:"type"`
	Side            string `json:"side"`
	Price           string `json:"price"`
	Size            string `json:"size"`
	Funds           string `json:"funds"`
	Stp             string `json:"stp"`
	TimeInForce     string `json:"timeInForce"`
	CancelAfter     int64  `json:"cancelAfter"`
	PostOnly        bool   `json:"postOnly"`
	Hidden          bool   `json:"hidden"`
	IceBerg         bool   `json:"iceberg"`
	VisibleSize     string `json:"visibleSize"`
	Channel         string `json:"channel"`
	ClientOid       string `json:"clientOid"`
	Remark          string `json:"remark"`
	Tags            string `json:"tags"`
	OrderTime       int64  `json:"orderTime"`
	DomainId        string `json:"domainId"`
	TradeSource     string `json:"tradeSource"`
	TradeType       string `json:"tradeType"`
	FeeCurrency     string `json:"feeCurrency"`
	TakerFeeRate    string `json:"takerFeeRate"`
	MakerFeeRate    string `json:"makerFeeRate"`
	CreatedAt       int64  `json:"createdAt"`
	Stop            string `json:"stop"`
	StopTriggerTime string `json:"stopTriggerTime"`
	StopPrice       string `json:"stopPrice"`
}

StopOrderModel RESPONSES of StopOrder

type SubAccountModel

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

A SubAccountModel represents the balance of a sub-account user.

type SubAccountUserModel

type SubAccountUserModel struct {
	UserId  string `json:"userId"`
	SubName string `json:"subName"`
	Remarks string `json:"remarks"`
	Type    int    `json:"type"`
	Access  string `json:"access"`
	Uid     int64  `json:"uid"`
}

A SubAccountUserModel represents a sub-account user.

type SubAccountUserModelV2

type SubAccountUserModelV2 struct {
	UserId    string      `json:"userId"`
	Uid       int64       `json:"uid"`
	SubName   string      `json:"subName"`
	Status    int         `json:"status"`
	Type      int         `json:"type"`
	Access    string      `json:"access"`
	CreatedAt json.Number `json:"createdAt"`
	Remarks   string      `json:"remarks"`
}

A SubAccountUserModelV2 represents a sub-account user.

type SubAccountUsersModel

type SubAccountUsersModel []*SubAccountUserModel

A SubAccountUsersModel is the set of *SubAccountUserModel.

type SubAccountUsersModelV2

type SubAccountUsersModelV2 []*SubAccountUserModelV2

A SubAccountUsersModelV2 is the set of *SubAccountUserModelV2.

type SubAccountsModel

type SubAccountsModel []*SubAccountModel

A SubAccountsModel is the set of *SubAccountModel.

type SubApiKeyModel

type SubApiKeyModel struct {
	SubName     string      `json:"subName"`
	Remark      string      `json:"remark"`
	ApiKey      string      `json:"apiKey"`
	Permission  string      `json:"permission"`
	IpWhitelist string      `json:"ipWhitelist"`
	CreatedAt   json.Number `json:"createdAt"`
}

type SubApiKeyRes

type SubApiKeyRes []*SubApiKeyModel

type SubTransferResultModel

type SubTransferResultModel InnerTransferResultModel

A SubTransferResultModel represents the result of a sub-transfer operation.

type SymbolModel

type SymbolModel struct {
	Symbol          string `json:"symbol"`
	Name            string `json:"name"`
	BaseCurrency    string `json:"baseCurrency"`
	QuoteCurrency   string `json:"quoteCurrency"`
	Market          string `json:"market"`
	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 SymbolModelV2

type SymbolModelV2 struct {
	Symbol          string `json:"symbol"`
	Name            string `json:"name"`
	BaseCurrency    string `json:"baseCurrency"`
	QuoteCurrency   string `json:"quoteCurrency"`
	Market          string `json:"market"`
	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"`
	MinFunds        string `json:"minFunds"`
}

type SymbolsModel

type SymbolsModel []*SymbolModel

A SymbolsModel is the set of *SymbolModel.

type SymbolsModelV2

type SymbolsModelV2 []*SymbolModelV2

A SymbolsModelV2 is the set of *SymbolsModelV2.

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().

type TradeFeesResultModel

type TradeFeesResultModel []struct {
	Symbol       string `json:"symbol"`
	TakerFeeRate string `json:"takerFeeRate"`
	MakerFeeRate string `json:"makerFeeRate"`
}

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 UpdateSubApiKeyRes

type UpdateSubApiKeyRes struct {
	ApiKey      string `json:"apiKey"`
	IpWhitelist string `json:"ipWhitelist"`
	Permission  string `json:"permission"`
	SubName     string `json:"subName"`
}

type UserSummaryInfoModelV2

type UserSummaryInfoModelV2 struct {
	Level                 int `json:"level"`
	SubQuantity           int `json:"subQuantity"`
	MaxDefaultSubQuantity int `json:"maxDefaultSubQuantity"`
	MaxSubQuantity        int `json:"maxSubQuantity"`
	SpotSubQuantity       int `json:"spotSubQuantity"`
	MarginSubQuantity     int `json:"marginSubQuantity"`
	FuturesSubQuantity    int `json:"futuresSubQuantity"`
	MaxSpotSubQuantity    int `json:"maxSpotSubQuantity"`
	MaxMarginSubQuantity  int `json:"maxMarginSubQuantity"`
	MaxFuturesSubQuantity int `json:"maxFuturesSubQuantity"`
}

An UserSummaryInfoModelV2 represents an account.

type V1DepositModel

type V1DepositModel struct {
	Amount     string `json:"amount"`
	Currency   string `json:"currency"`
	IsInner    bool   `json:"isInner"`
	WalletTxId string `json:"walletTxId"`
	Status     string `json:"status"`
	CreateAt   int64  `json:"createAt"`
}

A V1DepositModel represents a v1 deposit record.

type V1DepositsModel

type V1DepositsModel []*V1DepositModel

A V1DepositsModel is the set of *V1DepositModel.

type V1OrderModel

type V1OrderModel struct {
	Symbol    string `json:"symbol"`
	DealPrice string `json:"dealPrice"`
	DealValue string `json:"dealValue"`
	Amount    string `json:"amount"`
	Fee       string `json:"fee"`
	Side      string `json:"side"`
	CreatedAt int64  `json:"createdAt"`
}

A V1OrderModel represents a v1 order.

type V1OrdersModel

type V1OrdersModel []*V1OrderModel

A V1OrdersModel is the set of *V1OrderModel.

type V1WithdrawalModel

type V1WithdrawalModel struct {
	Address    string `json:"address"`
	Amount     string `json:"amount"`
	Currency   string `json:"currency"`
	IsInner    bool   `json:"isInner"`
	WalletTxId string `json:"walletTxId"`
	Status     string `json:"status"`
	CreateAt   int64  `json:"createAt"`
}

A V1WithdrawalModel represents a v1 historical withdrawal.

type V1WithdrawalsModel

type V1WithdrawalsModel []*V1WithdrawalModel

A V1WithdrawalsModel is the set of *V1WithdrawalModel.

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() (<-chan *WebSocketDownstreamMessage, <-chan error, 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(channels ...*WebSocketSubscribeMessage) error

Subscribe subscribes the specified channel.

func (*WebSocketClient) Unsubscribe

func (wc *WebSocketClient) Unsubscribe(channels ...*WebSocketUnsubscribeMessage) error

Unsubscribe unsubscribes the specified channel.

type WebSocketClientOpts

type WebSocketClientOpts struct {
	Token         *WebSocketTokenModel
	TLSSkipVerify bool
	Timeout       time.Duration
}

WebSocketClientOpts defines the options for the client during the websocket connection.

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

type WebSocketMessage struct {
	Id   string `json:"id"`
	Type string `json:"type"`
}

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 bool) *WebSocketSubscribeMessage

NewSubscribeMessage creates a subscribe message instance.

type WebSocketTokenModel

type WebSocketTokenModel struct {
	Token             string                `json:"token"`
	Servers           WebSocketServersModel `json:"instanceServers"`
	AcceptUserMessage bool                  `json:"accept_user_message"`
}

A WebSocketTokenModel contains a token and some servers for WebSocket feed.

type WebSocketUnsubscribeMessage

type WebSocketUnsubscribeMessage WebSocketSubscribeMessage

A WebSocketUnsubscribeMessage represents a message to unsubscribe the public/private channel.

func NewUnsubscribeMessage

func NewUnsubscribeMessage(topic string, privateChannel bool) *WebSocketUnsubscribeMessage

NewUnsubscribeMessage creates a unsubscribe message instance.

type WithdrawalModel

type WithdrawalModel struct {
	Chain      string `json:"chain"`
	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"`
	Remark     string `json:"remark"`
	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"`
	Chain               string `json:"chain"`
}

A WithdrawalQuotasModel represents the quotas for a currency.

type WithdrawalsModel

type WithdrawalsModel []*WithdrawalModel

A WithdrawalsModel is the set of *WithdrawalModel.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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