mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 15:10:54 +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:
@@ -357,8 +357,7 @@ func (a *Alphapoint) GetActiveOrders(ctx context.Context, req *order.MultiOrderR
|
||||
if resp[x].OpenOrders[y].State != 1 {
|
||||
continue
|
||||
}
|
||||
|
||||
orderDetail := order.Detail{
|
||||
orders = append(orders, order.Detail{
|
||||
Amount: resp[x].OpenOrders[y].QtyTotal,
|
||||
Exchange: a.Name,
|
||||
ExecutedAmount: resp[x].OpenOrders[y].QtyTotal - resp[x].OpenOrders[y].QtyRemaining,
|
||||
@@ -366,12 +365,10 @@ func (a *Alphapoint) GetActiveOrders(ctx context.Context, req *order.MultiOrderR
|
||||
OrderID: strconv.FormatInt(int64(resp[x].OpenOrders[y].ServerOrderID), 10),
|
||||
Price: resp[x].OpenOrders[y].Price,
|
||||
RemainingAmount: resp[x].OpenOrders[y].QtyRemaining,
|
||||
}
|
||||
|
||||
orderDetail.Side = orderSideMap[resp[x].OpenOrders[y].Side]
|
||||
orderDetail.Date = time.Unix(resp[x].OpenOrders[y].ReceiveTime, 0)
|
||||
orderDetail.Type = orderTypeMap[resp[x].OpenOrders[y].OrderType]
|
||||
orders = append(orders, orderDetail)
|
||||
Side: orderSideMap[resp[x].OpenOrders[y].Side],
|
||||
Date: resp[x].OpenOrders[y].ReceiveTime.Time(),
|
||||
Type: orderTypeMap[resp[x].OpenOrders[y].OrderType],
|
||||
})
|
||||
}
|
||||
}
|
||||
return req.Filter(a.Name, orders), nil
|
||||
@@ -398,7 +395,7 @@ func (a *Alphapoint) GetOrderHistory(ctx context.Context, req *order.MultiOrderR
|
||||
continue
|
||||
}
|
||||
|
||||
orderDetail := order.Detail{
|
||||
orders = append(orders, order.Detail{
|
||||
Amount: resp[x].OpenOrders[y].QtyTotal,
|
||||
AccountID: strconv.FormatInt(int64(resp[x].OpenOrders[y].AccountID), 10),
|
||||
Exchange: a.Name,
|
||||
@@ -406,12 +403,10 @@ func (a *Alphapoint) GetOrderHistory(ctx context.Context, req *order.MultiOrderR
|
||||
OrderID: strconv.FormatInt(int64(resp[x].OpenOrders[y].ServerOrderID), 10),
|
||||
Price: resp[x].OpenOrders[y].Price,
|
||||
RemainingAmount: resp[x].OpenOrders[y].QtyRemaining,
|
||||
}
|
||||
|
||||
orderDetail.Side = orderSideMap[resp[x].OpenOrders[y].Side]
|
||||
orderDetail.Date = time.Unix(resp[x].OpenOrders[y].ReceiveTime, 0)
|
||||
orderDetail.Type = orderTypeMap[resp[x].OpenOrders[y].OrderType]
|
||||
orders = append(orders, orderDetail)
|
||||
Side: orderSideMap[resp[x].OpenOrders[y].Side],
|
||||
Date: resp[x].OpenOrders[y].ReceiveTime.Time(),
|
||||
Type: orderTypeMap[resp[x].OpenOrders[y].OrderType],
|
||||
})
|
||||
}
|
||||
}
|
||||
return req.Filter(a.Name, orders), nil
|
||||
|
||||
Reference in New Issue
Block a user