mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 15:10:59 +00:00
orders: add Filter() method to GetOrdersRequest and force FilteredOrders return type on wrapper functions (#1055)
* orders: filter options return on validate * exchanges: force filter usage by wrapper return type and shift method functionality * exchanges: update tests and fix err shadow * exchanges: shadowland * exchanges: more shadow land spookyness * glorious: nits and ftx upgrade * linter: fix * orders: preserve unpopulated fields through filtering operation * glorious: nits Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -445,6 +445,7 @@ func TestGetActiveOrders(t *testing.T) {
|
||||
},
|
||||
Type: order.AnyType,
|
||||
AssetType: asset.Spot,
|
||||
Side: order.AnySide,
|
||||
}
|
||||
|
||||
_, err := b.GetActiveOrders(context.Background(), &getOrdersRequest)
|
||||
@@ -461,6 +462,7 @@ func TestGetOrderHistory(t *testing.T) {
|
||||
var getOrdersRequest = order.GetOrdersRequest{
|
||||
Type: order.AnyType,
|
||||
AssetType: asset.Spot,
|
||||
Side: order.AnySide,
|
||||
}
|
||||
_, err := b.GetOrderHistory(context.Background(), &getOrdersRequest)
|
||||
if err != nil {
|
||||
|
||||
@@ -778,8 +778,9 @@ func (b *BTSE) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdr
|
||||
}
|
||||
|
||||
// GetActiveOrders retrieves any orders that are active/open
|
||||
func (b *BTSE) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
func (b *BTSE) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest) (order.FilteredOrders, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -882,14 +883,7 @@ func (b *BTSE) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest)
|
||||
orders = append(orders, openOrder)
|
||||
}
|
||||
}
|
||||
|
||||
order.FilterOrdersByType(&orders, req.Type)
|
||||
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
|
||||
return req.Filter(b.Name, orders), nil
|
||||
}
|
||||
|
||||
func matchType(input int, required order.Type) bool {
|
||||
@@ -901,8 +895,9 @@ func matchType(input int, required order.Type) bool {
|
||||
|
||||
// GetOrderHistory retrieves account order information
|
||||
// Can Limit response to specific order status
|
||||
func (b *BTSE) GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error) {
|
||||
if err := getOrdersRequest.Validate(); err != nil {
|
||||
func (b *BTSE) GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) (order.FilteredOrders, error) {
|
||||
err := getOrdersRequest.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -956,7 +951,7 @@ func (b *BTSE) GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetO
|
||||
resp = append(resp, tempOrder)
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
return getOrdersRequest.Filter(b.Name, resp), nil
|
||||
}
|
||||
|
||||
// GetFeeByType returns an estimate of fee based on type of transaction
|
||||
|
||||
Reference in New Issue
Block a user