mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-09 07:26:48 +00:00
exchanges: Refactor time handling and other minor improvements (#1948)
* exchanges: Refactor time handling and other minor improvements - Updated Kraken wrapper to utilise new time handling methods. - Simplified Kucoin types by removing unnecessary structures and using direct JSON unmarshalling. - Improved websocket handling in Kucoin to directly parse candlestick data. - Modified Lbank types to use the new time representation. - Adjusted Poloniex wrapper and types to utilise the new time handling. - Updated Yobit types and wrapper to reflect changes in time representation. - Introduced DateTime type for better handling of specific time formats. - Added tests for DateTime unmarshalling to ensure correctness. - Rid UTC().Unix and UTC().UnixMilli as it's not needed - Correct Huobi timestamp usage for some endpoints. - Rid RFC3339 time parsing since Go does that automatically. * exchanges: Refactor JSON unmarshalling for various types and improve test coverage * linter: Update error message in TestGetKlines * refactor: Simplify JSON unmarshalling in MovementHistory and improve test assertions in GetKlines * refactor: Improve JSON unmarshalling for channel name and clarify comment in wsProcessOpenOrders * refactor: Update time handling in Huobi types to use types.Time for createdAt fields and relax GetLiquidationOrders test * refactor: Move wsTicker, wsSpread, wsTrades, and wsCandle types to kraken_types.go for better organistion * refactor: Add validation for underlying parameter in GetExpirationTime and update tests
This commit is contained in:
@@ -406,10 +406,6 @@ func (bi *Binanceus) GetWithdrawalsHistory(ctx context.Context, c currency.Code,
|
||||
}
|
||||
resp := make([]exchange.WithdrawalHistory, len(withdrawals))
|
||||
for i := range withdrawals {
|
||||
tm, err := time.Parse(time.DateTime, withdrawals[i].ApplyTime)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp[i] = exchange.WithdrawalHistory{
|
||||
Status: strconv.FormatInt(withdrawals[i].Status, 10),
|
||||
TransferID: withdrawals[i].ID,
|
||||
@@ -419,7 +415,7 @@ func (bi *Binanceus) GetWithdrawalsHistory(ctx context.Context, c currency.Code,
|
||||
CryptoToAddress: withdrawals[i].Address,
|
||||
CryptoTxID: withdrawals[i].ID,
|
||||
CryptoChain: withdrawals[i].Network,
|
||||
Timestamp: tm,
|
||||
Timestamp: withdrawals[i].ApplyTime.Time(),
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
@@ -825,12 +821,12 @@ func (bi *Binanceus) GetHistoricCandles(ctx context.Context, pair currency.Pair,
|
||||
timeSeries := make([]kline.Candle, len(candles))
|
||||
for x := range candles {
|
||||
timeSeries[x] = kline.Candle{
|
||||
Time: candles[x].OpenTime,
|
||||
Open: candles[x].Open,
|
||||
High: candles[x].High,
|
||||
Low: candles[x].Low,
|
||||
Close: candles[x].Close,
|
||||
Volume: candles[x].Volume,
|
||||
Time: candles[x].OpenTime.Time(),
|
||||
Open: candles[x].Open.Float64(),
|
||||
High: candles[x].High.Float64(),
|
||||
Low: candles[x].Low.Float64(),
|
||||
Close: candles[x].Close.Float64(),
|
||||
Volume: candles[x].Volume.Float64(),
|
||||
}
|
||||
}
|
||||
return req.ProcessResponse(timeSeries)
|
||||
@@ -859,12 +855,12 @@ func (bi *Binanceus) GetHistoricCandlesExtended(ctx context.Context, pair curren
|
||||
|
||||
for i := range candles {
|
||||
timeSeries = append(timeSeries, kline.Candle{
|
||||
Time: candles[i].OpenTime,
|
||||
Open: candles[i].Open,
|
||||
High: candles[i].High,
|
||||
Low: candles[i].Low,
|
||||
Close: candles[i].Close,
|
||||
Volume: candles[i].Volume,
|
||||
Time: candles[i].OpenTime.Time(),
|
||||
Open: candles[i].Open.Float64(),
|
||||
High: candles[i].High.Float64(),
|
||||
Low: candles[i].Low.Float64(),
|
||||
Close: candles[i].Close.Float64(),
|
||||
Volume: candles[i].Volume.Float64(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user