mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 15:11:07 +00:00
order: slight optimizations (#917)
* order: slight optimizations * orders: add benchmarks, small optimize and change order side to uin8 for comparitive optimizations. * orders: continue to convert string type -> uint * orders/backtester: interim move type to orders package, later can expand or deprecate. * orders: handle errors * orders: optimize filters and remove error returns when its clearly not needed * orders: remove log call * backtester: zero value check * orders/futures: zero value -> flag * linter: fix * linter: more fixes * linters: rides again * glorious: nits * common: Add zero value unix check for time values; also addresses glorious nits * glorious scott: nits Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -684,13 +684,18 @@ func (b *BTSE) GetOrderInfo(ctx context.Context, orderID string, pair currency.P
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%s GetOrderInfo unable to parse time: %s\n", b.Name, err)
|
||||
}
|
||||
var orderSide order.Side
|
||||
orderSide, err = order.StringToOrderSide(th[i].Side)
|
||||
if err != nil {
|
||||
return order.Detail{}, err
|
||||
}
|
||||
od.Trades = append(od.Trades, order.TradeHistory{
|
||||
Timestamp: createdAt,
|
||||
TID: th[i].TradeID,
|
||||
Price: th[i].Price,
|
||||
Amount: th[i].Size,
|
||||
Exchange: b.Name,
|
||||
Side: order.Side(th[i].Side),
|
||||
Side: orderSide,
|
||||
Fee: th[i].FeeAmount,
|
||||
})
|
||||
}
|
||||
@@ -854,13 +859,18 @@ func (b *BTSE) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest)
|
||||
b.Name,
|
||||
err)
|
||||
}
|
||||
var orderSide order.Side
|
||||
orderSide, err = order.StringToOrderSide(fills[i].Side)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
openOrder.Trades = append(openOrder.Trades, order.TradeHistory{
|
||||
Timestamp: createdAt,
|
||||
TID: fills[i].TradeID,
|
||||
Price: fills[i].Price,
|
||||
Amount: fills[i].Size,
|
||||
Exchange: b.Name,
|
||||
Side: order.Side(fills[i].Side),
|
||||
Side: orderSide,
|
||||
Fee: fills[i].FeeAmount,
|
||||
})
|
||||
}
|
||||
@@ -869,7 +879,10 @@ func (b *BTSE) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest)
|
||||
}
|
||||
|
||||
order.FilterOrdersByType(&orders, req.Type)
|
||||
order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
|
||||
err := order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", b.Name, err)
|
||||
}
|
||||
order.FilterOrdersBySide(&orders, req.Side)
|
||||
return orders, nil
|
||||
}
|
||||
@@ -914,6 +927,11 @@ func (b *BTSE) GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetO
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", b.Name, err)
|
||||
}
|
||||
var orderSide order.Side
|
||||
orderSide, err = order.StringToOrderSide(currentOrder[y].Side)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orderTime := time.UnixMilli(currentOrder[y].Timestamp)
|
||||
tempOrder := order.Detail{
|
||||
ID: currentOrder[y].OrderID,
|
||||
@@ -925,7 +943,7 @@ func (b *BTSE) GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetO
|
||||
ExecutedAmount: currentOrder[y].FilledSize,
|
||||
RemainingAmount: currentOrder[y].Size - currentOrder[y].FilledSize,
|
||||
Date: orderTime,
|
||||
Side: order.Side(currentOrder[y].Side),
|
||||
Side: orderSide,
|
||||
Status: orderStatus,
|
||||
Pair: orderDeref.Pairs[x],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user