mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 23:16:53 +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:
@@ -420,6 +420,11 @@ func (o *OKGroup) GetOrderInfo(ctx context.Context, orderID string, pair currenc
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
|
||||
side, err := order.StringToOrderSide(mOrder.Side)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
resp = order.Detail{
|
||||
Amount: mOrder.Size,
|
||||
Pair: p,
|
||||
@@ -427,7 +432,7 @@ func (o *OKGroup) GetOrderInfo(ctx context.Context, orderID string, pair currenc
|
||||
Date: mOrder.Timestamp,
|
||||
ExecutedAmount: mOrder.FilledSize,
|
||||
Status: status,
|
||||
Side: order.Side(mOrder.Side),
|
||||
Side: side,
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@@ -523,14 +528,24 @@ func (o *OKGroup) GetActiveOrders(ctx context.Context, req *order.GetOrdersReque
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
var side order.Side
|
||||
side, err = order.StringToOrderSide(spotOpenOrders[i].Side)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
var orderType order.Type
|
||||
orderType, err = order.StringToOrderType(spotOpenOrders[i].Type)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
resp = append(resp, order.Detail{
|
||||
ID: spotOpenOrders[i].OrderID,
|
||||
Price: spotOpenOrders[i].Price,
|
||||
Amount: spotOpenOrders[i].Size,
|
||||
Pair: req.Pairs[x],
|
||||
Exchange: o.Name,
|
||||
Side: order.Side(spotOpenOrders[i].Side),
|
||||
Type: order.Type(spotOpenOrders[i].Type),
|
||||
Side: side,
|
||||
Type: orderType,
|
||||
ExecutedAmount: spotOpenOrders[i].FilledSize,
|
||||
Date: spotOpenOrders[i].Timestamp,
|
||||
Status: status,
|
||||
@@ -569,6 +584,16 @@ func (o *OKGroup) GetOrderHistory(ctx context.Context, req *order.GetOrdersReque
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
var side order.Side
|
||||
side, err = order.StringToOrderSide(spotOrders[i].Side)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
var orderType order.Type
|
||||
orderType, err = order.StringToOrderType(spotOrders[i].Type)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys, "%s %v", o.Name, err)
|
||||
}
|
||||
detail := order.Detail{
|
||||
ID: spotOrders[i].OrderID,
|
||||
Price: spotOrders[i].Price,
|
||||
@@ -578,8 +603,8 @@ func (o *OKGroup) GetOrderHistory(ctx context.Context, req *order.GetOrdersReque
|
||||
RemainingAmount: spotOrders[i].Size - spotOrders[i].FilledSize,
|
||||
Pair: req.Pairs[x],
|
||||
Exchange: o.Name,
|
||||
Side: order.Side(spotOrders[i].Side),
|
||||
Type: order.Type(spotOrders[i].Type),
|
||||
Side: side,
|
||||
Type: orderType,
|
||||
Date: spotOrders[i].Timestamp,
|
||||
Status: status,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user