mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 23:16:54 +00:00
gctrpc/ordermanager/binance: Add new getManagedOrders command and various improvements (#712)
* first draft of getmanaged orders RPC call * - ClientIDs for binance, especially spot asset - applied old ClientOrderId for cancelled orders - added clientOrderId to GCTRPC * added tests for Matchfilter and GetManagedOrders * smaller fixes * comment fix added getFilteredOrders to store changed store mutex to RWMutex smaller fixes * fixed bug in Detail Copy and added test * fixes for Scotts review * processSubmittedOrder was missing clientOrderId * changed: TestGetOrdersFiltered expanded fixed: warning, where variable name collided with package name fixed: used req.AssetType in binance_wrapper.go Co-authored-by: Mark Dzulko <81071907+Mark-numus@users.noreply.github.com>
This commit is contained in:
@@ -359,6 +359,58 @@ func (d *Detail) UpdateOrderFromModify(m *Modify) {
|
||||
}
|
||||
}
|
||||
|
||||
// MatchFilter will return true if a detail matches the filter criteria
|
||||
// empty elements are ignored
|
||||
func (d *Detail) MatchFilter(f *Filter) bool {
|
||||
if f.Exchange != "" && !strings.EqualFold(d.Exchange, f.Exchange) {
|
||||
return false
|
||||
}
|
||||
if f.AssetType != "" && d.AssetType != f.AssetType {
|
||||
return false
|
||||
}
|
||||
if !f.Pair.IsEmpty() && !d.Pair.Equal(f.Pair) {
|
||||
return false
|
||||
}
|
||||
if f.ID != "" && d.ID != f.ID {
|
||||
return false
|
||||
}
|
||||
if f.Type != "" && f.Type != AnyType && d.Type != f.Type {
|
||||
return false
|
||||
}
|
||||
if f.Side != "" && f.Side != AnySide && d.Side != f.Side {
|
||||
return false
|
||||
}
|
||||
if f.Status != "" && f.Status != AnyStatus && d.Status != f.Status {
|
||||
return false
|
||||
}
|
||||
if f.ClientOrderID != "" && d.ClientOrderID != f.ClientOrderID {
|
||||
return false
|
||||
}
|
||||
if f.ClientID != "" && d.ClientID != f.ClientID {
|
||||
return false
|
||||
}
|
||||
if f.InternalOrderID != "" && d.InternalOrderID != f.InternalOrderID {
|
||||
return false
|
||||
}
|
||||
if f.AccountID != "" && d.AccountID != f.AccountID {
|
||||
return false
|
||||
}
|
||||
if f.WalletAddress != "" && d.WalletAddress != f.WalletAddress {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Copy will return a copy of Detail
|
||||
func (d *Detail) Copy() Detail {
|
||||
c := *d
|
||||
if len(d.Trades) > 0 {
|
||||
c.Trades = make([]TradeHistory, len(d.Trades))
|
||||
copy(c.Trades, d.Trades)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// String implements the stringer interface
|
||||
func (t Type) String() string {
|
||||
return string(t)
|
||||
@@ -462,16 +514,12 @@ func FilterOrdersByCurrencies(orders *[]Detail, currencies []currency.Pair) {
|
||||
|
||||
var filteredOrders []Detail
|
||||
for i := range *orders {
|
||||
matchFound := false
|
||||
for _, c := range currencies {
|
||||
if !matchFound && (*orders)[i].Pair.EqualIncludeReciprocal(c) {
|
||||
matchFound = true
|
||||
if (*orders)[i].Pair.EqualIncludeReciprocal(c) {
|
||||
filteredOrders = append(filteredOrders, (*orders)[i])
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if matchFound {
|
||||
filteredOrders = append(filteredOrders, (*orders)[i])
|
||||
}
|
||||
}
|
||||
|
||||
*orders = filteredOrders
|
||||
|
||||
Reference in New Issue
Block a user