mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-29 15:10:37 +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:
@@ -1195,10 +1195,20 @@ func (s *RPCServer) SubmitOrder(ctx context.Context, r *gctrpc.SubmitOrderReques
|
||||
return nil, err
|
||||
}
|
||||
|
||||
side, err := order.StringToOrderSide(r.Side)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
oType, err := order.StringToOrderType(r.OrderType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
submission := &order.Submit{
|
||||
Pair: p,
|
||||
Side: order.Side(r.Side),
|
||||
Type: order.Type(r.OrderType),
|
||||
Side: side,
|
||||
Type: oType,
|
||||
Amount: r.Amount,
|
||||
Price: r.Price,
|
||||
ClientID: r.ClientId,
|
||||
@@ -1362,12 +1372,18 @@ func (s *RPCServer) CancelOrder(ctx context.Context, r *gctrpc.CancelOrderReques
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var side order.Side
|
||||
side, err = order.StringToOrderSide(r.Side)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = s.OrderManager.Cancel(ctx,
|
||||
&order.Cancel{
|
||||
Exchange: r.Exchange,
|
||||
AccountID: r.AccountId,
|
||||
ID: r.OrderId,
|
||||
Side: order.Side(r.Side),
|
||||
Side: side,
|
||||
WalletAddress: r.WalletAddress,
|
||||
Pair: p,
|
||||
AssetType: a,
|
||||
@@ -1402,6 +1418,12 @@ func (s *RPCServer) CancelBatchOrders(ctx context.Context, r *gctrpc.CancelBatch
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var side order.Side
|
||||
side, err = order.StringToOrderSide(r.Side)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
status := make(map[string]string)
|
||||
orders := strings.Split(r.OrdersId, ",")
|
||||
request := make([]order.Cancel, len(orders))
|
||||
@@ -1411,7 +1433,7 @@ func (s *RPCServer) CancelBatchOrders(ctx context.Context, r *gctrpc.CancelBatch
|
||||
request[x] = order.Cancel{
|
||||
AccountID: r.AccountId,
|
||||
ID: orderID,
|
||||
Side: order.Side(r.Side),
|
||||
Side: side,
|
||||
WalletAddress: r.WalletAddress,
|
||||
Pair: pair,
|
||||
AssetType: assetType,
|
||||
|
||||
Reference in New Issue
Block a user