mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 15:10:59 +00:00
Exchanges: enrich order history with avg executed price, cost, and more (#792)
* Exchanges: enrich order history with avg executed price, cost, and more * Fix division by zero in order detail enrichment * Remove DateCompleted from Bithumb OrderData and fix OrderDate parsing * Fixes on order detail fields and rename EnrichOrderDetail to CalculateCostsAndAmounts * BTSE order history populate name and id * Calculate average executed price for market order or when order amount is zero * Minor fixes on infer order amounts, costs, and times * Attach InferAmountsCostsAndTimes to Order.Detail * Binance: fix order status * Always use order.StringToOrderStatus() and ensure order has at least one of executed/remaining amount set
This commit is contained in:
@@ -670,21 +670,26 @@ func (e *EXMO) GetOrderHistory(ctx context.Context, req *order.GetOrdersRequest)
|
||||
|
||||
var orders []order.Detail
|
||||
for i := range allTrades {
|
||||
symbol, err := currency.NewPairDelimiter(allTrades[i].Pair, "_")
|
||||
pair, err := currency.NewPairDelimiter(allTrades[i].Pair, "_")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orderDate := time.Unix(allTrades[i].Date, 0)
|
||||
orderSide := order.Side(strings.ToUpper(allTrades[i].Type))
|
||||
orders = append(orders, order.Detail{
|
||||
ID: strconv.FormatInt(allTrades[i].TradeID, 10),
|
||||
Amount: allTrades[i].Quantity,
|
||||
Date: orderDate,
|
||||
Price: allTrades[i].Price,
|
||||
Side: orderSide,
|
||||
Exchange: e.Name,
|
||||
Pair: symbol,
|
||||
})
|
||||
detail := order.Detail{
|
||||
ID: strconv.FormatInt(allTrades[i].TradeID, 10),
|
||||
Amount: allTrades[i].Quantity,
|
||||
ExecutedAmount: allTrades[i].Quantity,
|
||||
Cost: allTrades[i].Amount,
|
||||
CostAsset: pair.Quote,
|
||||
Date: orderDate,
|
||||
Price: allTrades[i].Price,
|
||||
Side: orderSide,
|
||||
Exchange: e.Name,
|
||||
Pair: pair,
|
||||
}
|
||||
detail.InferCostsAndTimes()
|
||||
orders = append(orders, detail)
|
||||
}
|
||||
|
||||
order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
|
||||
|
||||
Reference in New Issue
Block a user