mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 15:10:59 +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:
@@ -344,7 +344,7 @@ func (g *Gemini) GetAccountFundingHistory(ctx context.Context) ([]exchange.Fundi
|
||||
resp[i] = exchange.FundingHistory{
|
||||
Status: transfers[i].Status,
|
||||
TransferID: transfers[i].WithdrawalID,
|
||||
Timestamp: time.UnixMilli(transfers[i].Timestamp),
|
||||
Timestamp: transfers[i].Timestamp.Time(),
|
||||
Currency: transfers[i].Currency.String(),
|
||||
Amount: transfers[i].Amount,
|
||||
Fee: transfers[i].FeeAmount,
|
||||
@@ -373,7 +373,7 @@ func (g *Gemini) GetWithdrawalsHistory(ctx context.Context, c currency.Code, a a
|
||||
resp = append(resp, exchange.WithdrawalHistory{
|
||||
Status: transfers[i].Status,
|
||||
TransferID: transfers[i].WithdrawalID,
|
||||
Timestamp: time.UnixMilli(transfers[i].Timestamp),
|
||||
Timestamp: transfers[i].Timestamp.Time(),
|
||||
Currency: transfers[i].Currency.String(),
|
||||
Amount: transfers[i].Amount,
|
||||
Fee: transfers[i].FeeAmount,
|
||||
@@ -406,16 +406,12 @@ func (g *Gemini) GetHistoricTrades(ctx context.Context, p currency.Pair, assetTy
|
||||
allTrades:
|
||||
for {
|
||||
var tradeData []Trade
|
||||
tradeData, err = g.GetTrades(ctx,
|
||||
p.String(),
|
||||
ts.Unix(),
|
||||
int64(limit),
|
||||
false)
|
||||
tradeData, err = g.GetTrades(ctx, p.String(), ts.Unix(), int64(limit), false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range tradeData {
|
||||
tradeTS := time.Unix(tradeData[i].Timestamp, 0)
|
||||
tradeTS := tradeData[i].Timestamp.Time()
|
||||
if tradeTS.After(timestampEnd) && !timestampEnd.IsZero() {
|
||||
break allTrades
|
||||
}
|
||||
@@ -569,7 +565,7 @@ func (g *Gemini) GetOrderInfo(ctx context.Context, orderID string, _ currency.Pa
|
||||
Amount: resp.OriginalAmount,
|
||||
RemainingAmount: resp.RemainingAmount,
|
||||
Pair: cp,
|
||||
Date: time.UnixMilli(resp.TimestampMS),
|
||||
Date: resp.TimestampMS.Time(),
|
||||
Price: resp.Price,
|
||||
HiddenOrder: resp.IsHidden,
|
||||
ClientOrderID: resp.ClientOrderID,
|
||||
@@ -678,7 +674,6 @@ func (g *Gemini) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orderDate := time.Unix(resp[i].Timestamp, 0)
|
||||
|
||||
orders[i] = order.Detail{
|
||||
Amount: resp[i].OriginalAmount,
|
||||
@@ -690,7 +685,7 @@ func (g *Gemini) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque
|
||||
Side: side,
|
||||
Price: resp[i].Price,
|
||||
Pair: symbol,
|
||||
Date: orderDate,
|
||||
Date: resp[i].Timestamp.Time(),
|
||||
}
|
||||
}
|
||||
return req.Filter(g.Name, orders), nil
|
||||
@@ -741,14 +736,12 @@ func (g *Gemini) GetOrderHistory(ctx context.Context, req *order.MultiOrderReque
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orderDate := time.Unix(trades[i].Timestamp, 0)
|
||||
|
||||
detail := order.Detail{
|
||||
OrderID: strconv.FormatInt(trades[i].OrderID, 10),
|
||||
Amount: trades[i].Amount,
|
||||
ExecutedAmount: trades[i].Amount,
|
||||
Exchange: g.Name,
|
||||
Date: orderDate,
|
||||
Date: trades[i].Timestamp.Time(),
|
||||
Side: side,
|
||||
Fee: trades[i].FeeAmount,
|
||||
Price: trades[i].Price,
|
||||
|
||||
Reference in New Issue
Block a user