ccxt-go/latoken_wrapper.go
zhangkun9038@dingtalk.com 1a2ce7046a first add
2025-02-28 10:33:20 +08:00

673 lines
22 KiB
Go

package ccxt
type Latoken struct {
*latoken
Core *latoken
}
func NewLatoken(userConfig map[string]interface{}) Latoken {
p := &latoken{}
p.Init(userConfig)
return Latoken{
latoken: p,
Core: p,
}
}
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
/**
* @method
* @name latoken#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://api.latoken.com/doc/v2/#tag/Time/operation/currentTime
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
func (this *Latoken) FetchTime(params ...interface{}) ( int64, error) {
res := <- this.Core.FetchTime(params...)
if IsError(res) {
return -1, CreateReturnError(res)
}
return (res).(int64), nil
}
/**
* @method
* @name latoken#fetchMarkets
* @description retrieves data on all markets for latoken
* @see https://api.latoken.com/doc/v2/#tag/Pair/operation/getActivePairs
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
func (this *Latoken) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
res := <- this.Core.FetchMarkets(params...)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewMarketInterfaceArray(res), nil
}
func (this *Latoken) FetchCurrenciesFromCache(params ...interface{}) (map[string]interface{}, error) {
res := <- this.Core.FetchCurrenciesFromCache(params...)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name latoken#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://api.latoken.com/doc/v2/#tag/Account/operation/getBalancesByUser
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
*/
func (this *Latoken) FetchBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
/**
* @method
* @name latoken#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://api.latoken.com/doc/v2/#tag/Order-Book/operation/getOrderBook
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
*/
func (this *Latoken) FetchOrderBook(symbol string, options ...FetchOrderBookOptions) (OrderBook, error) {
opts := FetchOrderBookOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOrderBook(symbol, limit, params)
if IsError(res) {
return OrderBook{}, CreateReturnError(res)
}
return NewOrderBook(res), nil
}
/**
* @method
* @name latoken#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://api.latoken.com/doc/v2/#tag/Ticker/operation/getTicker
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
*/
func (this *Latoken) FetchTicker(symbol string, options ...FetchTickerOptions) (Ticker, error) {
opts := FetchTickerOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTicker(symbol, params)
if IsError(res) {
return Ticker{}, CreateReturnError(res)
}
return NewTicker(res), nil
}
/**
* @method
* @name latoken#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://api.latoken.com/doc/v2/#tag/Ticker/operation/getAllTickers
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
*/
func (this *Latoken) FetchTickers(options ...FetchTickersOptions) (Tickers, error) {
opts := FetchTickersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbols interface{} = nil
if opts.Symbols != nil {
symbols = *opts.Symbols
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTickers(symbols, params)
if IsError(res) {
return Tickers{}, CreateReturnError(res)
}
return NewTickers(res), nil
}
/**
* @method
* @name latoken#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getTradesByPair
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
*/
func (this *Latoken) FetchTrades(symbol string, options ...FetchTradesOptions) ([]Trade, error) {
opts := FetchTradesOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTrades(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTradeArray(res), nil
}
/**
* @method
* @name latoken#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getFeeByPair
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getAuthFeeByPair
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
*/
func (this *Latoken) FetchTradingFee(symbol string, options ...FetchTradingFeeOptions) (TradingFeeInterface, error) {
opts := FetchTradingFeeOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTradingFee(symbol, params)
if IsError(res) {
return TradingFeeInterface{}, CreateReturnError(res)
}
return NewTradingFeeInterface(res), nil
}
func (this *Latoken) FetchPublicTradingFee(symbol string, options ...FetchPublicTradingFeeOptions) (map[string]interface{}, error) {
opts := FetchPublicTradingFeeOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchPublicTradingFee(symbol, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
func (this *Latoken) FetchPrivateTradingFee(symbol string, options ...FetchPrivateTradingFeeOptions) (map[string]interface{}, error) {
opts := FetchPrivateTradingFeeOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchPrivateTradingFee(symbol, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name latoken#fetchMyTrades
* @description fetch all trades made by the user
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getTradesByTrader
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getTradesByAssetAndTrader
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
*/
func (this *Latoken) FetchMyTrades(options ...FetchMyTradesOptions) ([]Trade, error) {
opts := FetchMyTradesOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchMyTrades(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTradeArray(res), nil
}
/**
* @method
* @name latoken#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyActiveOrdersByPair
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyActiveStopOrdersByPair // stop
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if fetching trigger orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Latoken) FetchOpenOrders(options ...FetchOpenOrdersOptions) ([]Order, error) {
opts := FetchOpenOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOpenOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name latoken#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrders
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrdersByPair
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrders // stop
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrdersByPair // stop
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if fetching trigger orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Latoken) FetchOrders(options ...FetchOrdersOptions) ([]Order, error) {
opts := FetchOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name latoken#fetchOrder
* @description fetches information on an order made by the user
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getOrderById
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getStopOrderById
* @param {string} id order id
* @param {string} [symbol] not used by latoken fetchOrder
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if fetching a trigger order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Latoken) FetchOrder(id string, options ...FetchOrderOptions) (Order, error) {
opts := FetchOrderOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOrder(id, symbol, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name latoken#createOrder
* @description create a trade order
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/placeOrder
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/placeStopOrder // stop
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {string} [params.condition] "GTC", "IOC", or "FOK"
* @param {string} [params.clientOrderId] [ 0 .. 50 ] characters, client's custom order id (free field for your convenience)
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Latoken) CreateOrder(symbol string, typeVar string, side string, amount float64, options ...CreateOrderOptions) (Order, error) {
opts := CreateOrderOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var price interface{} = nil
if opts.Price != nil {
price = *opts.Price
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CreateOrder(symbol, typeVar, side, amount, price, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name latoken#cancelOrder
* @description cancels an open order
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelOrder
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/cancelStopOrder // stop
* @param {string} id order id
* @param {string} symbol not used by latoken cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if cancelling a trigger order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Latoken) CancelOrder(id string, options ...CancelOrderOptions) (Order, error) {
opts := CancelOrderOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CancelOrder(id, symbol, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name latoken#cancelAllOrders
* @description cancel all open orders in a market
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrders
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrdersByPair
* @param {string} symbol unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if cancelling trigger orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Latoken) CancelAllOrders(options ...CancelAllOrdersOptions) ([]Order, error) {
opts := CancelAllOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CancelAllOrders(symbol, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name latoken#fetchTransactions
* @deprecated
* @description use fetchDepositsWithdrawals instead
* @see https://api.latoken.com/doc/v2/#tag/Transaction/operation/getUserTransactions
* @param {string} code unified currency code for the currency of the transactions, default is undefined
* @param {int} [since] timestamp in ms of the earliest transaction, default is undefined
* @param {int} [limit] max number of transactions to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
func (this *Latoken) FetchTransactions(options ...FetchTransactionsOptions) ([]Transaction, error) {
opts := FetchTransactionsOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var code interface{} = nil
if opts.Code != nil {
code = *opts.Code
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTransactions(code, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTransactionArray(res), nil
}
/**
* @method
* @name latoken#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/getUsersTransfers
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfers structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Latoken) FetchTransfers(options ...FetchTransfersOptions) ([]TransferEntry, error) {
opts := FetchTransfersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var code interface{} = nil
if opts.Code != nil {
code = *opts.Code
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTransfers(code, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTransferEntryArray(res), nil
}
/**
* @method
* @name latoken#transfer
* @description transfer currency internally between wallets on the same account
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/transferByEmail
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/transferById
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/transferByPhone
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from
* @param {string} toAccount account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Latoken) Transfer(code string, amount float64, fromAccount string, toAccount string, options ...TransferOptions) (TransferEntry, error) {
opts := TransferOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.Transfer(code, amount, fromAccount, toAccount, params)
if IsError(res) {
return TransferEntry{}, CreateReturnError(res)
}
return NewTransferEntry(res), nil
}