mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +00:00
* init * updates config * wrapper configuration * updates exchange readme * adds SendAuthHTTPRequest and SendHTTPRequest * adds ratelimit file * adds test case and minor fixes * improve error handling * update testcases and improve GetSymbols API * adds SPOT API's * minor fix * WIP * WIP * adds test case * adds check in test case * fixes in Auth. HTTP * improvements * adds trade, kline support and testcases * adds SPOT API and testcases for same * adds SPOT API and testcases * adds SPOT API and testcase * WIP * adds API's * adds API's * adds test cases * adds comment to exported data types * adds API and test cases * adds API * adds API * rearrange functions * WIP: adds API * adds API for Post Order SPOT * adds API and few fixes * fixes * WIP * WIP * add PostBulkOrder API and its test case * fix issues * adds cancel order APIs and test cases for same * add minor test fixes * add API * adds API * fixes * add API * adds API and test cases * fix test * adds API * adds test * fix test * adds API and test * adds deposit API and test cases * WIP * adds API and test cases * WIP * WIP * add public future API and test cases * WIP * remove v2 API and replace them with v1 * update test cases * adds future order API and test cases * adds futures order API * adds API * add API and test cases * adds API and test cases * adds API and test cases * adds API and test cases * Adding wrapper functions * Fix on wrapper function * Adding websocket support * Complete addressing WS push datas * Adding spot push data unit tests * adding futures websocket push data handlers * Adding futures websocket push data handlers * Added unit tests * Updating unit tests * Updating wrapper and unit test functions * Adding missing wrapper functions and code cleaning up * Resolved linter issues * Fixing websocket issues * Fixing websocket issues * Slight fix on config_example file * Minor update * Basic nits updates * Fix minor linter issues * Minor update * Minor unit test update * Minor unit test update * Code update and linter issues fix * Removed unnecessary type conversion codes * Monor update based on review comment * Fix based on review comments * Adding rate-limiter * Websocket update and overall minor fixes * Removed IsAssetTypeEnabled method implementation * Fix connection and formatting issues * Updating orderbook issues * Very minor label fix * Minor error returning fix * code cleaning up and minor spelling fix * Updates on unit test * Update on unit tests and slight code structure * unit test update * orderbook update and minor fix * fix on race * Mini linter fix * fix minor parameter and unit test issues * handler funcs and models update * Fixing websocket and unit test issues * order side string for active orders * Fix on websocket and unit tests * Minor type changes * Minor Orderbook fix and unit test update * Small fix on orderbook * Updating orderbook functionality * FIx on websocket orderbook handlers * Small update on kucoin websocket * fix missed review comments * fix based on review comments * Updating websocket orderbook and fixing unit tests * Minor fixes * unit test update * Updating unit test according to enabled asset type * toggle canManipulateRealOrders const * Unit test update * Fix minor issues * minor fix * documentation fix * wrapper coverage and unused params fix * testing and minor changes * documentation, websocket and unit test update * minor linter fix * Websocket spot/margin subscription update * minor ticker update fix * minor fixes on endpoints * timestamp and number convert method and unit tests * timestamp convert minor update * minor type and conversion fix * create a common timestamp convert and fix minor issues * linter and ticker fix * Updating unit tests and order placing endpoint methods * Added a pairs check * Fix config test error * rm unused error variable * Fix source of linter issue * code update: convert, wrapper and websocket fix * minor code update * Websocket code and unit tests update * Websocket ticker ask/bid type change and small error msg fix * docs update * fix: websocket orderbook handling * change orderbook channel to marketOrderbookLevel2Channels and fix websocket orderbook update * Minor func rename and reciever change * Minor orderbook unit test issue fix * comment: about why we used a random delimiter '-' for futures * update config files and FetchTradablePair func for futures pairs * futures config pairs update * remove ConnextionMonitorDelay from websocket setup * fix on types and futures pair conversion * updating config pairs * change NewPairFromString to DeriveFrom * unit tests update * unit tests update * Added TickerBatching * added GetStandardConfig to GetDefaultConfig --------- Co-authored-by: Jaydeep Rajpurohit <jaydeeppurohit1996@gmail.com>
68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
package kucoin
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
// UnmarshalJSON valid data to SubAccountsResponse of return nil if the data is empty list.
|
|
// this is added to handle the empty list returned when there are no accounts.
|
|
func (a *SubAccountsResponse) UnmarshalJSON(data []byte) error {
|
|
var result interface{}
|
|
err := json.Unmarshal(data, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var ok bool
|
|
if a, ok = result.(*SubAccountsResponse); ok {
|
|
if a == nil {
|
|
return errNoValidResponseFromServer
|
|
}
|
|
return nil
|
|
} else if _, ok := result.([]interface{}); ok {
|
|
return nil
|
|
}
|
|
return fmt.Errorf("%w can not unmarshal to SubAccountsResponse", errMalformedData)
|
|
}
|
|
|
|
// kucoinNumber unmarshals and extract numeric value from a byte slice.
|
|
type kucoinNumber float64
|
|
|
|
// Float64 returns an float64 value from kucoinNumeric instance
|
|
func (a *kucoinNumber) Float64() float64 {
|
|
return float64(*a)
|
|
}
|
|
|
|
// UnmarshalJSON decerializes integer and string data having an integer value to int64
|
|
func (a *kucoinNumber) UnmarshalJSON(data []byte) error {
|
|
var value interface{}
|
|
err := json.Unmarshal(data, &value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
switch val := value.(type) {
|
|
case float64:
|
|
*a = kucoinNumber(val)
|
|
case float32:
|
|
*a = kucoinNumber(val)
|
|
case string:
|
|
if val == "" {
|
|
*a = kucoinNumber(0) // setting empty string value to zero to reset previous value if exist.
|
|
return nil
|
|
}
|
|
value, err := strconv.ParseFloat(val, 64)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*a = kucoinNumber(value)
|
|
case int64:
|
|
*a = kucoinNumber(val)
|
|
case int32:
|
|
*a = kucoinNumber(val)
|
|
default:
|
|
return fmt.Errorf("unsupported input numeric type %T", value)
|
|
}
|
|
return nil
|
|
}
|