mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 23:16:53 +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:
@@ -757,18 +757,24 @@ func (g *Gemini) GetOrderHistory(ctx context.Context, req *order.GetOrdersReques
|
||||
side := order.Side(strings.ToUpper(trades[i].Type))
|
||||
orderDate := time.Unix(trades[i].Timestamp, 0)
|
||||
|
||||
orders = append(orders, order.Detail{
|
||||
Amount: trades[i].Amount,
|
||||
ID: strconv.FormatInt(trades[i].OrderID, 10),
|
||||
Exchange: g.Name,
|
||||
Date: orderDate,
|
||||
Side: side,
|
||||
Fee: trades[i].FeeAmount,
|
||||
Price: trades[i].Price,
|
||||
Pair: currency.NewPairWithDelimiter(trades[i].BaseCurrency,
|
||||
detail := order.Detail{
|
||||
ID: strconv.FormatInt(trades[i].OrderID, 10),
|
||||
Amount: trades[i].Amount,
|
||||
ExecutedAmount: trades[i].Amount,
|
||||
Exchange: g.Name,
|
||||
Date: orderDate,
|
||||
Side: side,
|
||||
Fee: trades[i].FeeAmount,
|
||||
Price: trades[i].Price,
|
||||
AverageExecutedPrice: trades[i].Price,
|
||||
Pair: currency.NewPairWithDelimiter(
|
||||
trades[i].BaseCurrency,
|
||||
trades[i].QuoteCurrency,
|
||||
format.Delimiter),
|
||||
})
|
||||
format.Delimiter,
|
||||
),
|
||||
}
|
||||
detail.InferCostsAndTimes()
|
||||
orders = append(orders, detail)
|
||||
}
|
||||
|
||||
order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
|
||||
|
||||
Reference in New Issue
Block a user