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:
Ryan O'Hara-Reid
2022-05-06 12:27:21 +10:00
committed by GitHub
parent d735effc8e
commit cdcc9630de
60 changed files with 1375 additions and 802 deletions

View File

@@ -7,7 +7,6 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
)
// WsResponse is a generalised response data structure which will defer
@@ -48,7 +47,7 @@ type WsOrderbooks struct {
// WsOrderbook defines a singular orderbook tranche
type WsOrderbook struct {
Symbol currency.Pair `json:"symbol"`
OrderSide order.Side `json:"orderType"`
OrderSide string `json:"orderType"`
Price float64 `json:"price,string"`
Quantity float64 `json:"quantity,string"`
Total int32 `json:"total,string"`

View File

@@ -702,7 +702,8 @@ func (b *Bithumb) GetActiveOrders(ctx context.Context, req *order.GetOrdersReque
var orders []order.Detail
for x := range req.Pairs {
resp, err := b.GetOrders(ctx, "", "", "1000", "", req.Pairs[x].Base.String())
var resp Orders
resp, err = b.GetOrders(ctx, "", "", "1000", "", req.Pairs[x].Base.String())
if err != nil {
return nil, err
}
@@ -737,8 +738,11 @@ func (b *Bithumb) GetActiveOrders(ctx context.Context, req *order.GetOrdersReque
}
order.FilterOrdersBySide(&orders, req.Side)
order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
order.FilterOrdersByCurrencies(&orders, req.Pairs)
err = order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
if err != nil {
log.Errorf(log.ExchangeSys, "%s %v", b.Name, err)
}
order.FilterOrdersByPairs(&orders, req.Pairs)
return orders, nil
}
@@ -760,7 +764,8 @@ func (b *Bithumb) GetOrderHistory(ctx context.Context, req *order.GetOrdersReque
var orders []order.Detail
for x := range req.Pairs {
resp, err := b.GetOrders(ctx, "", "", "1000", "", req.Pairs[x].Base.String())
var resp Orders
resp, err = b.GetOrders(ctx, "", "", "1000", "", req.Pairs[x].Base.String())
if err != nil {
return nil, err
}
@@ -795,8 +800,11 @@ func (b *Bithumb) GetOrderHistory(ctx context.Context, req *order.GetOrdersReque
}
order.FilterOrdersBySide(&orders, req.Side)
order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
order.FilterOrdersByCurrencies(&orders, req.Pairs)
err = order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)
if err != nil {
log.Errorf(log.ExchangeSys, "%s %v", b.Name, err)
}
order.FilterOrdersByPairs(&orders, req.Pairs)
return orders, nil
}