mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 15:11:07 +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:
@@ -692,12 +692,12 @@ func (b *Bithumb) GetActiveOrders(ctx context.Context, req *order.GetOrdersReque
|
||||
continue
|
||||
}
|
||||
|
||||
orderDate := time.Unix(resp.Data[i].OrderDate, 0)
|
||||
orderDetail := order.Detail{
|
||||
Amount: resp.Data[i].Units,
|
||||
Exchange: b.Name,
|
||||
ExecutedAmount: resp.Data[i].Units - resp.Data[i].UnitsRemaining,
|
||||
ID: resp.Data[i].OrderID,
|
||||
Date: orderDate,
|
||||
Date: resp.Data[i].OrderDate.Time(),
|
||||
Price: resp.Data[i].Price,
|
||||
RemainingAmount: resp.Data[i].UnitsRemaining,
|
||||
Status: order.Active,
|
||||
@@ -750,14 +750,14 @@ func (b *Bithumb) GetOrderHistory(ctx context.Context, req *order.GetOrdersReque
|
||||
continue
|
||||
}
|
||||
|
||||
orderDate := time.Unix(resp.Data[i].OrderDate, 0)
|
||||
orderDetail := order.Detail{
|
||||
Amount: resp.Data[i].Units,
|
||||
ExecutedAmount: resp.Data[i].Units - resp.Data[i].UnitsRemaining,
|
||||
RemainingAmount: resp.Data[i].UnitsRemaining,
|
||||
Exchange: b.Name,
|
||||
ID: resp.Data[i].OrderID,
|
||||
Date: orderDate,
|
||||
Date: resp.Data[i].OrderDate.Time(),
|
||||
Price: resp.Data[i].Price,
|
||||
RemainingAmount: resp.Data[i].UnitsRemaining,
|
||||
Pair: currency.NewPairWithDelimiter(resp.Data[i].OrderCurrency,
|
||||
resp.Data[i].PaymentCurrency,
|
||||
format.Delimiter),
|
||||
@@ -769,6 +769,7 @@ func (b *Bithumb) GetOrderHistory(ctx context.Context, req *order.GetOrdersReque
|
||||
orderDetail.Side = order.Sell
|
||||
}
|
||||
|
||||
orderDetail.InferCostsAndTimes()
|
||||
orders = append(orders, orderDetail)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user