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:
Mark Dzulko
2021-07-20 02:27:16 +02:00
committed by GitHub
parent 6182dd6fbc
commit e1eceeafe8
19 changed files with 1061 additions and 313 deletions

View File

@@ -1356,6 +1356,97 @@ func getOrders(c *cli.Context) error {
return nil
}
var getManagedOrdersCommand = &cli.Command{
Name: "getmanagedorders",
Usage: "gets the current orders from the order manager",
ArgsUsage: "<exchange> <asset> <pair>",
Action: getManagedOrders,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to get orders for",
},
&cli.StringFlag{
Name: "asset",
Usage: "the asset type to get orders for",
},
&cli.StringFlag{
Name: "pair",
Usage: "the currency pair to get orders for",
},
},
}
func getManagedOrders(c *cli.Context) error {
if c.NArg() == 0 && c.NumFlags() == 0 {
return cli.ShowCommandHelp(c, "getmanagedorders")
}
var exchangeName string
var assetType string
var currencyPair string
if c.IsSet("exchange") {
exchangeName = c.String("exchange")
} else {
exchangeName = c.Args().First()
}
if !validExchange(exchangeName) {
return errInvalidExchange
}
if c.IsSet("asset") {
assetType = c.String("asset")
} else {
assetType = c.Args().Get(1)
}
assetType = strings.ToLower(assetType)
if !validAsset(assetType) {
return errInvalidAsset
}
if c.IsSet("pair") {
currencyPair = c.String("pair")
} else {
currencyPair = c.Args().Get(2)
}
if !validPair(currencyPair) {
return errInvalidPair
}
p, err := currency.NewPairDelimiter(currencyPair, pairDelimiter)
if err != nil {
return err
}
var conn *grpc.ClientConn
conn, err = setupClient()
if err != nil {
return err
}
defer conn.Close()
client := gctrpc.NewGoCryptoTraderClient(conn)
result, err := client.GetManagedOrders(context.Background(), &gctrpc.GetOrdersRequest{
Exchange: exchangeName,
AssetType: assetType,
Pair: &gctrpc.CurrencyPair{
Delimiter: p.Delimiter,
Base: p.Base.String(),
Quote: p.Quote.String(),
},
})
if err != nil {
return err
}
jsonOutput(result)
return nil
}
var getOrderCommand = &cli.Command{
Name: "getorder",
Usage: "gets the specified order info",

View File

@@ -118,6 +118,7 @@ func main() {
getForexProvidersCommand,
getForexRatesCommand,
getOrdersCommand,
getManagedOrdersCommand,
getOrderCommand,
submitOrderCommand,
simulateOrderCommand,

View File

@@ -379,15 +379,28 @@ func (m *OrderManager) GetOrdersSnapshot(s order.Status) ([]order.Detail, time.T
if v[i].LastUpdated.After(latestUpdate) {
latestUpdate = v[i].LastUpdated
}
cpy := *v[i]
os = append(os, cpy)
os = append(os, *v[i])
}
}
return os, latestUpdate
}
// GetOrdersFiltered returns a snapshot of all orders in the order store.
// Filtering is applied based on the order.Filter unless entries are empty
func (m *OrderManager) GetOrdersFiltered(f *order.Filter) ([]order.Detail, error) {
if m == nil {
return nil, fmt.Errorf("order manager %w", ErrNilSubsystem)
}
if f == nil {
return nil, fmt.Errorf("order manager, GetOrdersFiltered: Filter is nil")
}
if atomic.LoadInt32(&m.started) == 0 {
return nil, fmt.Errorf("order manager %w", ErrSubSystemNotStarted)
}
return m.orderStore.getFilteredOrders(f)
}
// processSubmittedOrder adds a new order to the manager
func (m *OrderManager) processSubmittedOrder(newOrder *order.Submit, result order.SubmitResponse) (*OrderSubmitResponse, error) {
if !result.IsOrderPlaced {
@@ -439,6 +452,7 @@ func (m *OrderManager) processSubmittedOrder(newOrder *order.Submit, result orde
ID: result.OrderID,
AccountID: newOrder.AccountID,
ClientID: newOrder.ClientID,
ClientOrderID: newOrder.ClientOrderID,
WalletAddress: newOrder.WalletAddress,
Type: newOrder.Type,
Side: newOrder.Side,
@@ -661,8 +675,8 @@ func (s *store) upsert(od *order.Detail) error {
// getByExchange returns orders by exchange
func (s *store) getByExchange(exchange string) ([]*order.Detail, error) {
s.m.Lock()
defer s.m.Unlock()
s.m.RLock()
defer s.m.RUnlock()
r, ok := s.Orders[strings.ToLower(exchange)]
if !ok {
return nil, ErrExchangeNotFound
@@ -673,8 +687,8 @@ func (s *store) getByExchange(exchange string) ([]*order.Detail, error) {
// getByInternalOrderID will search all orders for our internal orderID
// and return the order
func (s *store) getByInternalOrderID(internalOrderID string) (*order.Detail, error) {
s.m.Lock()
defer s.m.Unlock()
s.m.RLock()
defer s.m.RUnlock()
for _, v := range s.Orders {
for x := range v {
if v[x].InternalOrderID == internalOrderID {
@@ -690,8 +704,8 @@ func (s *store) exists(det *order.Detail) bool {
if det == nil {
return false
}
s.m.Lock()
defer s.m.Unlock()
s.m.RLock()
defer s.m.RUnlock()
r, ok := s.Orders[strings.ToLower(det.Exchange)]
if !ok {
return false
@@ -736,3 +750,35 @@ func (s *store) add(det *order.Detail) error {
return nil
}
// getFilteredOrders returns a filtered copy of the orders
func (s *store) getFilteredOrders(f *order.Filter) ([]order.Detail, error) {
if f == nil {
return nil, errors.New("filter is nil")
}
s.m.RLock()
defer s.m.RUnlock()
var os []order.Detail
// optimization if Exchange is filtered
if f.Exchange != "" {
if e, ok := s.Orders[strings.ToLower(f.Exchange)]; ok {
for i := range e {
if !e[i].MatchFilter(f) {
continue
}
os = append(os, e[i].Copy())
}
}
} else {
for _, e := range s.Orders {
for i := range e {
if !e[i].MatchFilter(f) {
continue
}
os = append(os, e[i].Copy())
}
}
}
return os, nil
}

View File

@@ -559,3 +559,65 @@ func TestProcessOrders(t *testing.T) {
m := OrdersSetup(t)
m.processOrders()
}
func TestGetOrdersFiltered(t *testing.T) {
m := OrdersSetup(t)
_, err := m.GetOrdersFiltered(nil)
if err == nil {
t.Error("Expected error from nil filter")
}
orders := []order.Detail{
{
Exchange: testExchange,
ID: "Test1",
},
{
Exchange: testExchange,
ID: "Test2",
},
}
for i := range orders {
if err = m.orderStore.add(&orders[i]); err != nil {
t.Error(err)
}
}
res, err := m.GetOrdersFiltered(&order.Filter{ID: "Test2"})
if err != nil {
t.Error(err)
}
if len(res) != 1 {
t.Errorf("Expected 1 result, got: %d", len(res))
}
}
func Test_getFilteredOrders(t *testing.T) {
m := OrdersSetup(t)
_, err := m.orderStore.getFilteredOrders(nil)
if err == nil {
t.Error("Error expected when Filter is nil")
}
orders := []order.Detail{
{
Exchange: testExchange,
ID: "Test1",
},
{
Exchange: testExchange,
ID: "Test2",
},
}
for i := range orders {
if err = m.orderStore.add(&orders[i]); err != nil {
t.Error(err)
}
}
res, err := m.orderStore.getFilteredOrders(&order.Filter{ID: "Test1"})
if err != nil {
t.Error(err)
}
if len(res) != 1 {
t.Errorf("Expected 1 result, got: %d", len(res))
}
}

View File

@@ -36,7 +36,7 @@ type orderManagerConfig struct {
// store holds all orders by exchange
type store struct {
m sync.Mutex
m sync.RWMutex
Orders map[string][]*order.Detail
commsManager iCommsManager
exchangeManager iExchangeManager

View File

@@ -944,6 +944,90 @@ func (s *RPCServer) GetOrders(_ context.Context, r *gctrpc.GetOrdersRequest) (*g
return &gctrpc.GetOrdersResponse{Orders: orders}, nil
}
// GetManagedOrders returns all orders from the Order Manager for the provided exchange,
// asset type and currency pair
func (s *RPCServer) GetManagedOrders(_ context.Context, r *gctrpc.GetOrdersRequest) (*gctrpc.GetOrdersResponse, error) {
if r == nil {
return nil, errInvalidArguments
}
a, err := asset.New(r.AssetType)
if err != nil {
return nil, err
}
if r.Pair == nil {
return nil, errCurrencyPairUnset
}
cp := currency.NewPairWithDelimiter(
r.Pair.Base,
r.Pair.Quote,
r.Pair.Delimiter)
exch := s.GetExchangeByName(r.Exchange)
err = checkParams(r.Exchange, exch, a, cp)
if err != nil {
return nil, err
}
var resp []order.Detail
filter := order.Filter{
Exchange: exch.GetName(),
Pair: cp,
AssetType: a,
}
resp, err = s.OrderManager.GetOrdersFiltered(&filter)
if err != nil {
return nil, err
}
var orders []*gctrpc.OrderDetails
for x := range resp {
var trades []*gctrpc.TradeHistory
for i := range resp[x].Trades {
t := &gctrpc.TradeHistory{
Id: resp[x].Trades[i].TID,
Price: resp[x].Trades[i].Price,
Amount: resp[x].Trades[i].Amount,
Exchange: r.Exchange,
AssetType: a.String(),
OrderSide: resp[x].Trades[i].Side.String(),
Fee: resp[x].Trades[i].Fee,
Total: resp[x].Trades[i].Total,
}
if !resp[x].Trades[i].Timestamp.IsZero() {
t.CreationTime = resp[x].Trades[i].Timestamp.Unix()
}
trades = append(trades, t)
}
o := &gctrpc.OrderDetails{
Exchange: r.Exchange,
Id: resp[x].ID,
ClientOrderId: resp[x].ClientOrderID,
BaseCurrency: resp[x].Pair.Base.String(),
QuoteCurrency: resp[x].Pair.Quote.String(),
AssetType: resp[x].AssetType.String(),
OrderSide: resp[x].Side.String(),
OrderType: resp[x].Type.String(),
Status: resp[x].Status.String(),
Price: resp[x].Price,
Amount: resp[x].Amount,
OpenVolume: resp[x].Amount - resp[x].ExecutedAmount,
Fee: resp[x].Fee,
Cost: resp[x].Cost,
Trades: trades,
}
if !resp[x].Date.IsZero() {
o.CreationTime = resp[x].Date.Unix()
}
if !resp[x].LastUpdated.IsZero() {
o.UpdateTime = resp[x].LastUpdated.Unix()
}
orders = append(orders, o)
}
return &gctrpc.GetOrdersResponse{Orders: orders}, nil
}
// GetOrder returns order information based on exchange and order ID
func (s *RPCServer) GetOrder(_ context.Context, r *gctrpc.GetOrderRequest) (*gctrpc.OrderDetails, error) {
if r == nil {
@@ -1001,6 +1085,7 @@ func (s *RPCServer) GetOrder(_ context.Context, r *gctrpc.GetOrderRequest) (*gct
return &gctrpc.OrderDetails{
Exchange: result.Exchange,
Id: result.ID,
ClientOrderId: result.ClientOrderID,
BaseCurrency: result.Pair.Base.String(),
QuoteCurrency: result.Pair.Quote.String(),
AssetType: result.AssetType.String(),
@@ -1043,14 +1128,15 @@ func (s *RPCServer) SubmitOrder(_ context.Context, r *gctrpc.SubmitOrderRequest)
}
submission := &order.Submit{
Pair: p,
Side: order.Side(r.Side),
Type: order.Type(r.OrderType),
Amount: r.Amount,
Price: r.Price,
ClientID: r.ClientId,
Exchange: r.Exchange,
AssetType: a,
Pair: p,
Side: order.Side(r.Side),
Type: order.Type(r.OrderType),
Amount: r.Amount,
Price: r.Price,
ClientID: r.ClientId,
ClientOrderID: r.ClientId,
Exchange: r.Exchange,
AssetType: a,
}
resp, err := s.OrderManager.Submit(submission)
@@ -1196,7 +1282,8 @@ func (s *RPCServer) CancelOrder(_ context.Context, r *gctrpc.CancelOrderRequest)
return nil, err
}
err = exch.CancelOrder(&order.Cancel{
err = s.OrderManager.Cancel(&order.Cancel{
Exchange: r.Exchange,
AccountID: r.AccountId,
ID: r.OrderId,
Side: order.Side(r.Side),

View File

@@ -1590,3 +1590,101 @@ func TestGetDataHistoryJobSummary(t *testing.T) {
t.Errorf("received %v, expected %v", nil, "result summaries slice")
}
}
func TestGetManagedOrders(t *testing.T) {
exchName := "Binance"
engerino := &Engine{}
em := SetupExchangeManager()
exch, err := em.NewExchangeByName(exchName)
if err != nil {
t.Fatal(err)
}
exch.SetDefaults()
b := exch.GetBase()
cp := currency.NewPair(currency.BTC, currency.USDT)
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
b.CurrencyPairs.Pairs[asset.Spot] = &currency.PairStore{
Available: currency.Pairs{cp},
Enabled: currency.Pairs{cp},
AssetEnabled: convert.BoolPtr(true),
ConfigFormat: &currency.PairFormat{Uppercase: true},
RequestFormat: &currency.PairFormat{Uppercase: true}}
em.Add(exch)
var wg sync.WaitGroup
om, err := SetupOrderManager(em, engerino.CommunicationsManager, &wg, false)
if !errors.Is(err, nil) {
t.Errorf("received '%v', expected '%v'", err, nil)
}
err = om.Start()
if !errors.Is(err, nil) {
t.Errorf("received '%v', expected '%v'", err, nil)
}
s := RPCServer{Engine: &Engine{ExchangeManager: em, OrderManager: om}}
p := &gctrpc.CurrencyPair{
Delimiter: "-",
Base: currency.BTC.String(),
Quote: currency.USDT.String(),
}
_, err = s.GetManagedOrders(context.Background(), nil)
if !errors.Is(err, errInvalidArguments) {
t.Errorf("received '%v', expected '%v'", err, errInvalidArguments)
}
_, err = s.GetManagedOrders(context.Background(), &gctrpc.GetOrdersRequest{
AssetType: asset.Spot.String(),
Pair: p,
})
if !errors.Is(err, errExchangeNotLoaded) {
t.Errorf("received '%v', expected '%v'", errExchangeNotLoaded, err)
}
_, err = s.GetManagedOrders(context.Background(), &gctrpc.GetOrdersRequest{
Exchange: exchName,
AssetType: asset.Spot.String(),
})
if !errors.Is(err, errCurrencyPairUnset) {
t.Errorf("received '%v', expected '%v'", err, errCurrencyPairUnset)
}
_, err = s.GetManagedOrders(context.Background(), &gctrpc.GetOrdersRequest{
Exchange: exchName,
Pair: p,
})
if !errors.Is(err, asset.ErrNotSupported) {
t.Errorf("received '%v', expected '%v'", err, asset.ErrNotSupported)
}
o := order.Detail{
Price: 100000,
Amount: 0.002,
Exchange: "Binance",
InternalOrderID: "",
ID: "",
ClientOrderID: "",
AccountID: "",
ClientID: "",
WalletAddress: "",
Type: order.Limit,
Side: "SELL",
Status: order.New,
AssetType: asset.Spot,
Pair: currency.NewPair(currency.BTC, currency.USDT),
}
err = om.Add(&o)
if err != nil {
t.Errorf("Error: %v", err)
}
oo, err := s.GetManagedOrders(context.Background(), &gctrpc.GetOrdersRequest{
Exchange: exchName,
AssetType: "spot",
Pair: p,
})
if err != nil {
t.Errorf("non expected Error: %v", err)
} else if oo == nil || len(oo.GetOrders()) != 1 {
t.Errorf("unexpected order result: %v", oo)
}
}

View File

@@ -526,7 +526,7 @@ func (b *Binance) newOrder(api string, o *NewOrderRequest, resp *NewOrderRespons
}
if o.NewClientOrderID != "" {
params.Set("newClientOrderID", o.NewClientOrderID)
params.Set("newClientOrderId", o.NewClientOrderID)
}
if o.StopPrice != 0 {

View File

@@ -2498,7 +2498,7 @@ func TestWsOrderExecutionReport(t *testing.T) {
Amount: 0.00028400,
Exchange: "Binance",
ID: "5340845958",
ClientID: "c4wyKsIhoAaittTYlIVLqk",
ClientOrderID: "c4wyKsIhoAaittTYlIVLqk",
Side: order.Buy,
Type: order.Limit,
Status: order.New,

View File

@@ -240,6 +240,10 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
if err != nil {
return err
}
clientOrderID := data.Data.ClientOrderID
if oStatus == order.Cancelled {
clientOrderID = data.Data.CancelledClientOrderID
}
b.Websocket.DataHandler <- &order.Detail{
Price: data.Data.Price,
Amount: data.Data.Quantity,
@@ -253,7 +257,7 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
AssetType: a,
Date: data.Data.OrderCreationTime,
Pair: p,
ClientID: data.Data.ClientOrderID,
ClientOrderID: clientOrderID,
}
return nil
case "listStatus":

View File

@@ -805,12 +805,13 @@ func (b *Binance) SubmitOrder(s *order.Submit) (order.SubmitResponse, error) {
}
var orderRequest = NewOrderRequest{
Symbol: s.Pair,
Side: sideType,
Price: s.Price,
Quantity: s.Amount,
TradeType: requestParamsOrderType,
TimeInForce: timeInForce,
Symbol: s.Pair,
Side: sideType,
Price: s.Price,
Quantity: s.Amount,
TradeType: requestParamsOrderType,
TimeInForce: timeInForce,
NewClientOrderID: s.ClientOrderID,
}
response, err := b.NewOrder(&orderRequest)
if err != nil {
@@ -864,14 +865,14 @@ func (b *Binance) SubmitOrder(s *order.Submit) (order.SubmitResponse, error) {
default:
return submitOrderResponse, errors.New("invalid type, check api docs for updates")
}
order, err := b.FuturesNewOrder(s.Pair, reqSide,
o, err := b.FuturesNewOrder(s.Pair, reqSide,
"", oType, "GTC", "",
s.ClientOrderID, "", "",
s.Amount, s.Price, 0, 0, 0, s.ReduceOnly)
if err != nil {
return submitOrderResponse, err
}
submitOrderResponse.OrderID = strconv.FormatInt(order.OrderID, 10)
submitOrderResponse.OrderID = strconv.FormatInt(o.OrderID, 10)
submitOrderResponse.IsOrderPlaced = true
case asset.USDTMarginedFutures:
var reqSide string
@@ -1050,6 +1051,7 @@ func (b *Binance) GetOrderInfo(orderID string, pair currency.Pair, assetType ass
Amount: resp.OrigQty,
Exchange: b.Name,
ID: strconv.FormatInt(resp.OrderID, 10),
ClientOrderID: resp.ClientOrderID,
Side: orderSide,
Type: orderType,
Pair: pair,
@@ -1191,17 +1193,18 @@ func (b *Binance) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail,
orderSide := order.Side(strings.ToUpper(resp[x].Side))
orderType := order.Type(strings.ToUpper(resp[x].Type))
orders = append(orders, order.Detail{
Amount: resp[x].OrigQty,
Date: resp[x].Time,
Exchange: b.Name,
ID: strconv.FormatInt(resp[x].OrderID, 10),
Side: orderSide,
Type: orderType,
Price: resp[x].Price,
Status: order.Status(resp[x].Status),
Pair: req.Pairs[i],
AssetType: asset.Spot,
LastUpdated: resp[x].UpdateTime,
Amount: resp[x].OrigQty,
Date: resp[x].Time,
Exchange: b.Name,
ID: strconv.FormatInt(resp[x].OrderID, 10),
ClientOrderID: resp[x].ClientOrderID,
Side: orderSide,
Type: orderType,
Price: resp[x].Price,
Status: order.Status(resp[x].Status),
Pair: req.Pairs[i],
AssetType: req.AssetType,
LastUpdated: resp[x].UpdateTime,
})
}
case asset.CoinMarginedFutures:

View File

@@ -2,6 +2,7 @@ package order
import (
"errors"
"reflect"
"strings"
"testing"
"time"
@@ -277,6 +278,12 @@ func TestFilterOrdersByCurrencies(t *testing.T) {
t.Errorf("Orders failed to be filtered. Expected %v, received %v", 1, len(orders))
}
currencies = []currency.Pair{currency.NewPair(currency.USD, currency.BTC)}
FilterOrdersByCurrencies(&orders, currencies)
if len(orders) != 1 {
t.Errorf("Reverse Orders failed to be filtered. Expected %v, received %v", 1, len(orders))
}
currencies = []currency.Pair{}
FilterOrdersByCurrencies(&orders, currencies)
if len(orders) != 1 {
@@ -1100,3 +1107,129 @@ func TestValidationOnOrderTypes(t *testing.T) {
t.Fatal("unexpected error")
}
}
func TestMatchFilter(t *testing.T) {
filters := map[int]Filter{
0: {},
1: {Exchange: "Binance"},
2: {InternalOrderID: "1234"},
3: {ID: "2222"},
4: {ClientOrderID: "3333"},
5: {ClientID: "4444"},
6: {WalletAddress: "5555"},
7: {Type: AnyType},
8: {Type: Limit},
9: {Side: AnySide},
10: {Side: Sell},
11: {Status: AnyStatus},
12: {Status: New},
13: {AssetType: asset.Spot},
14: {Pair: currency.NewPair(currency.BTC, currency.USD)},
15: {Exchange: "Binance", Type: Limit, Status: New},
16: {Exchange: "Binance", Type: AnyType},
17: {AccountID: "8888"},
}
orders := map[int]Detail{
0: {},
1: {Exchange: "Binance"},
2: {InternalOrderID: "1234"},
3: {ID: "2222"},
4: {ClientOrderID: "3333"},
5: {ClientID: "4444"},
6: {WalletAddress: "5555"},
7: {Type: AnyType},
8: {Type: Limit},
9: {Side: AnySide},
10: {Side: Sell},
11: {Status: AnyStatus},
12: {Status: New},
13: {AssetType: asset.Spot},
14: {Pair: currency.NewPair(currency.BTC, currency.USD)},
15: {Exchange: "Binance", Type: Limit, Status: New},
16: {AccountID: "8888"},
}
// empty filter tests
emptyFilter := filters[0]
for _, o := range orders {
if !o.MatchFilter(&emptyFilter) {
t.Error("empty filter should match everything")
}
}
tests := map[int]struct {
f Filter
o Detail
expRes bool
}{
0: {filters[1], orders[1], true},
1: {filters[1], orders[0], false},
2: {filters[2], orders[2], true},
3: {filters[2], orders[3], false},
4: {filters[3], orders[3], true},
5: {filters[3], orders[4], false},
6: {filters[4], orders[4], true},
7: {filters[4], orders[5], false},
8: {filters[5], orders[5], true},
9: {filters[5], orders[6], false},
10: {filters[6], orders[6], true},
11: {filters[6], orders[7], false},
12: {filters[7], orders[7], true},
13: {filters[7], orders[8], true},
14: {filters[7], orders[9], true},
15: {filters[8], orders[7], false},
16: {filters[8], orders[8], true},
17: {filters[8], orders[9], false},
18: {filters[9], orders[9], true},
19: {filters[9], orders[10], true},
20: {filters[9], orders[11], true},
21: {filters[10], orders[10], true},
22: {filters[10], orders[11], false},
23: {filters[10], orders[9], false},
24: {filters[11], orders[11], true},
25: {filters[11], orders[12], true},
26: {filters[11], orders[10], true},
27: {filters[12], orders[12], true},
28: {filters[12], orders[13], false},
29: {filters[12], orders[11], false},
30: {filters[13], orders[13], true},
31: {filters[13], orders[12], false},
32: {filters[14], orders[14], true},
33: {filters[14], orders[13], false},
34: {filters[15], orders[15], true},
35: {filters[16], orders[15], true},
36: {filters[17], orders[16], true},
37: {filters[17], orders[15], false},
}
// specific tests
for num, tt := range tests {
if tt.o.MatchFilter(&tt.f) != tt.expRes {
t.Errorf("tests[%v] failed", num)
}
}
}
func TestDetail_Copy(t *testing.T) {
d := []Detail{
{
Exchange: "Binance",
},
{
Exchange: "Binance",
Trades: []TradeHistory{
{Price: 1},
},
},
}
for i := range d {
r := d[i].Copy()
if !reflect.DeepEqual(d[i], r) {
t.Errorf("[%d] Copy does not contain same elements, expected: %v\ngot:%v", i, d[i], r)
}
if len(d[i].Trades) > 0 {
if &d[i].Trades[0] == &r.Trades[0] {
t.Errorf("[%d]Trades point to the same data elements", i)
}
}
}
}

View File

@@ -151,6 +151,23 @@ type Detail struct {
Trades []TradeHistory
}
// Filter contains all properties an order can be filtered for
// empty strings indicate to ignore the property otherwise all need to match
type Filter struct {
Exchange string
InternalOrderID string
ID string
ClientOrderID string
AccountID string
ClientID string
WalletAddress string
Type Type
Side Side
Status Status
AssetType asset.Item
Pair currency.Pair
}
// Cancel contains all properties that may be required
// to cancel an order on an exchange
// Each exchange has their own requirements, so not all fields

View File

@@ -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

View File

@@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.15.1
// protoc-gen-go v1.27.1
// protoc v3.17.3
// source: rpc.proto
package gctrpc
import (
proto "github.com/golang/protobuf/proto"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
@@ -23,10 +22,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type GetInfoRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -11019,8 +11014,8 @@ var file_rpc_proto_rawDesc = []byte{
0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x64, 0x61,
0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x44,
0x61, 0x74, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x65, 0x32, 0x98,
0x4e, 0x0a, 0x0e, 0x47, 0x6f, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x54, 0x72, 0x61, 0x64, 0x65,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x65, 0x32, 0x82,
0x4f, 0x0a, 0x0e, 0x47, 0x6f, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x54, 0x72, 0x61, 0x64, 0x65,
0x72, 0x12, 0x4f, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67,
0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65,
@@ -11645,11 +11640,17 @@ var file_rpc_proto_rawDesc = []byte{
0x74, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79,
0x4a, 0x6f, 0x62, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x76, 0x31,
0x2f, 0x67, 0x65, 0x74, 0x64, 0x61, 0x74, 0x61, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x6a,
0x6f, 0x62, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x68, 0x72, 0x61, 0x73, 0x68, 0x65, 0x72,
0x2d, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x67, 0x6f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x74, 0x72,
0x61, 0x64, 0x65, 0x72, 0x2f, 0x67, 0x63, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
0x6f, 0x62, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x68, 0x0a, 0x10, 0x47, 0x65, 0x74,
0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x12, 0x18, 0x2e,
0x67, 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x67, 0x63, 0x74, 0x72, 0x70, 0x63,
0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x14, 0x2f, 0x76, 0x31, 0x2f,
0x67, 0x65, 0x74, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73,
0x3a, 0x01, 0x2a, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x74, 0x68, 0x72, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2d, 0x63, 0x6f, 0x72, 0x70, 0x2f,
0x67, 0x6f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x74, 0x72, 0x61, 0x64, 0x65, 0x72, 0x2f, 0x67,
0x63, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -12013,93 +12014,95 @@ var file_rpc_proto_depIdxs = []int32{
147, // 173: gctrpc.GoCryptoTrader.DeleteDataHistoryJob:input_type -> gctrpc.GetDataHistoryJobDetailsRequest
151, // 174: gctrpc.GoCryptoTrader.GetDataHistoryJobsBetween:input_type -> gctrpc.GetDataHistoryJobsBetweenRequest
147, // 175: gctrpc.GoCryptoTrader.GetDataHistoryJobSummary:input_type -> gctrpc.GetDataHistoryJobDetailsRequest
1, // 176: gctrpc.GoCryptoTrader.GetInfo:output_type -> gctrpc.GetInfoResponse
7, // 177: gctrpc.GoCryptoTrader.GetSubsystems:output_type -> gctrpc.GetSusbsytemsResponse
127, // 178: gctrpc.GoCryptoTrader.EnableSubsystem:output_type -> gctrpc.GenericResponse
127, // 179: gctrpc.GoCryptoTrader.DisableSubsystem:output_type -> gctrpc.GenericResponse
10, // 180: gctrpc.GoCryptoTrader.GetRPCEndpoints:output_type -> gctrpc.GetRPCEndpointsResponse
4, // 181: gctrpc.GoCryptoTrader.GetCommunicationRelayers:output_type -> gctrpc.GetCommunicationRelayersResponse
13, // 182: gctrpc.GoCryptoTrader.GetExchanges:output_type -> gctrpc.GetExchangesResponse
127, // 183: gctrpc.GoCryptoTrader.DisableExchange:output_type -> gctrpc.GenericResponse
19, // 184: gctrpc.GoCryptoTrader.GetExchangeInfo:output_type -> gctrpc.GetExchangeInfoResponse
14, // 185: gctrpc.GoCryptoTrader.GetExchangeOTPCode:output_type -> gctrpc.GetExchangeOTPReponse
16, // 186: gctrpc.GoCryptoTrader.GetExchangeOTPCodes:output_type -> gctrpc.GetExchangeOTPsResponse
127, // 187: gctrpc.GoCryptoTrader.EnableExchange:output_type -> gctrpc.GenericResponse
22, // 188: gctrpc.GoCryptoTrader.GetTicker:output_type -> gctrpc.TickerResponse
25, // 189: gctrpc.GoCryptoTrader.GetTickers:output_type -> gctrpc.GetTickersResponse
28, // 190: gctrpc.GoCryptoTrader.GetOrderbook:output_type -> gctrpc.OrderbookResponse
31, // 191: gctrpc.GoCryptoTrader.GetOrderbooks:output_type -> gctrpc.GetOrderbooksResponse
35, // 192: gctrpc.GoCryptoTrader.GetAccountInfo:output_type -> gctrpc.GetAccountInfoResponse
35, // 193: gctrpc.GoCryptoTrader.UpdateAccountInfo:output_type -> gctrpc.GetAccountInfoResponse
35, // 194: gctrpc.GoCryptoTrader.GetAccountInfoStream:output_type -> gctrpc.GetAccountInfoResponse
37, // 195: gctrpc.GoCryptoTrader.GetConfig:output_type -> gctrpc.GetConfigResponse
40, // 196: gctrpc.GoCryptoTrader.GetPortfolio:output_type -> gctrpc.GetPortfolioResponse
47, // 197: gctrpc.GoCryptoTrader.GetPortfolioSummary:output_type -> gctrpc.GetPortfolioSummaryResponse
127, // 198: gctrpc.GoCryptoTrader.AddPortfolioAddress:output_type -> gctrpc.GenericResponse
127, // 199: gctrpc.GoCryptoTrader.RemovePortfolioAddress:output_type -> gctrpc.GenericResponse
52, // 200: gctrpc.GoCryptoTrader.GetForexProviders:output_type -> gctrpc.GetForexProvidersResponse
55, // 201: gctrpc.GoCryptoTrader.GetForexRates:output_type -> gctrpc.GetForexRatesResponse
59, // 202: gctrpc.GoCryptoTrader.GetOrders:output_type -> gctrpc.GetOrdersResponse
56, // 203: gctrpc.GoCryptoTrader.GetOrder:output_type -> gctrpc.OrderDetails
63, // 204: gctrpc.GoCryptoTrader.SubmitOrder:output_type -> gctrpc.SubmitOrderResponse
65, // 205: gctrpc.GoCryptoTrader.SimulateOrder:output_type -> gctrpc.SimulateOrderResponse
65, // 206: gctrpc.GoCryptoTrader.WhaleBomb:output_type -> gctrpc.SimulateOrderResponse
127, // 207: gctrpc.GoCryptoTrader.CancelOrder:output_type -> gctrpc.GenericResponse
69, // 208: gctrpc.GoCryptoTrader.CancelBatchOrders:output_type -> gctrpc.CancelBatchOrdersResponse
71, // 209: gctrpc.GoCryptoTrader.CancelAllOrders:output_type -> gctrpc.CancelAllOrdersResponse
74, // 210: gctrpc.GoCryptoTrader.GetEvents:output_type -> gctrpc.GetEventsResponse
76, // 211: gctrpc.GoCryptoTrader.AddEvent:output_type -> gctrpc.AddEventResponse
127, // 212: gctrpc.GoCryptoTrader.RemoveEvent:output_type -> gctrpc.GenericResponse
79, // 213: gctrpc.GoCryptoTrader.GetCryptocurrencyDepositAddresses:output_type -> gctrpc.GetCryptocurrencyDepositAddressesResponse
81, // 214: gctrpc.GoCryptoTrader.GetCryptocurrencyDepositAddress:output_type -> gctrpc.GetCryptocurrencyDepositAddressResponse
84, // 215: gctrpc.GoCryptoTrader.WithdrawFiatFunds:output_type -> gctrpc.WithdrawResponse
84, // 216: gctrpc.GoCryptoTrader.WithdrawCryptocurrencyFunds:output_type -> gctrpc.WithdrawResponse
86, // 217: gctrpc.GoCryptoTrader.WithdrawalEventByID:output_type -> gctrpc.WithdrawalEventByIDResponse
89, // 218: gctrpc.GoCryptoTrader.WithdrawalEventsByExchange:output_type -> gctrpc.WithdrawalEventsByExchangeResponse
89, // 219: gctrpc.GoCryptoTrader.WithdrawalEventsByDate:output_type -> gctrpc.WithdrawalEventsByExchangeResponse
96, // 220: gctrpc.GoCryptoTrader.GetLoggerDetails:output_type -> gctrpc.GetLoggerDetailsResponse
96, // 221: gctrpc.GoCryptoTrader.SetLoggerDetails:output_type -> gctrpc.GetLoggerDetailsResponse
99, // 222: gctrpc.GoCryptoTrader.GetExchangePairs:output_type -> gctrpc.GetExchangePairsResponse
127, // 223: gctrpc.GoCryptoTrader.SetExchangePair:output_type -> gctrpc.GenericResponse
28, // 224: gctrpc.GoCryptoTrader.GetOrderbookStream:output_type -> gctrpc.OrderbookResponse
28, // 225: gctrpc.GoCryptoTrader.GetExchangeOrderbookStream:output_type -> gctrpc.OrderbookResponse
22, // 226: gctrpc.GoCryptoTrader.GetTickerStream:output_type -> gctrpc.TickerResponse
22, // 227: gctrpc.GoCryptoTrader.GetExchangeTickerStream:output_type -> gctrpc.TickerResponse
106, // 228: gctrpc.GoCryptoTrader.GetAuditEvent:output_type -> gctrpc.GetAuditEventResponse
127, // 229: gctrpc.GoCryptoTrader.GCTScriptExecute:output_type -> gctrpc.GenericResponse
127, // 230: gctrpc.GoCryptoTrader.GCTScriptUpload:output_type -> gctrpc.GenericResponse
126, // 231: gctrpc.GoCryptoTrader.GCTScriptReadScript:output_type -> gctrpc.GCTScriptQueryResponse
125, // 232: gctrpc.GoCryptoTrader.GCTScriptStatus:output_type -> gctrpc.GCTScriptStatusResponse
126, // 233: gctrpc.GoCryptoTrader.GCTScriptQuery:output_type -> gctrpc.GCTScriptQueryResponse
127, // 234: gctrpc.GoCryptoTrader.GCTScriptStop:output_type -> gctrpc.GenericResponse
127, // 235: gctrpc.GoCryptoTrader.GCTScriptStopAll:output_type -> gctrpc.GenericResponse
125, // 236: gctrpc.GoCryptoTrader.GCTScriptListAll:output_type -> gctrpc.GCTScriptStatusResponse
127, // 237: gctrpc.GoCryptoTrader.GCTScriptAutoLoadToggle:output_type -> gctrpc.GenericResponse
112, // 238: gctrpc.GoCryptoTrader.GetHistoricCandles:output_type -> gctrpc.GetHistoricCandlesResponse
127, // 239: gctrpc.GoCryptoTrader.SetExchangeAsset:output_type -> gctrpc.GenericResponse
127, // 240: gctrpc.GoCryptoTrader.SetAllExchangePairs:output_type -> gctrpc.GenericResponse
127, // 241: gctrpc.GoCryptoTrader.UpdateExchangeSupportedPairs:output_type -> gctrpc.GenericResponse
132, // 242: gctrpc.GoCryptoTrader.GetExchangeAssets:output_type -> gctrpc.GetExchangeAssetsResponse
134, // 243: gctrpc.GoCryptoTrader.WebsocketGetInfo:output_type -> gctrpc.WebsocketGetInfoResponse
127, // 244: gctrpc.GoCryptoTrader.WebsocketSetEnabled:output_type -> gctrpc.GenericResponse
138, // 245: gctrpc.GoCryptoTrader.WebsocketGetSubscriptions:output_type -> gctrpc.WebsocketGetSubscriptionsResponse
127, // 246: gctrpc.GoCryptoTrader.WebsocketSetProxy:output_type -> gctrpc.GenericResponse
127, // 247: gctrpc.GoCryptoTrader.WebsocketSetURL:output_type -> gctrpc.GenericResponse
109, // 248: gctrpc.GoCryptoTrader.GetRecentTrades:output_type -> gctrpc.SavedTradesResponse
109, // 249: gctrpc.GoCryptoTrader.GetHistoricTrades:output_type -> gctrpc.SavedTradesResponse
109, // 250: gctrpc.GoCryptoTrader.GetSavedTrades:output_type -> gctrpc.SavedTradesResponse
112, // 251: gctrpc.GoCryptoTrader.ConvertTradesToCandles:output_type -> gctrpc.GetHistoricCandlesResponse
143, // 252: gctrpc.GoCryptoTrader.FindMissingSavedCandleIntervals:output_type -> gctrpc.FindMissingIntervalsResponse
143, // 253: gctrpc.GoCryptoTrader.FindMissingSavedTradeIntervals:output_type -> gctrpc.FindMissingIntervalsResponse
127, // 254: gctrpc.GoCryptoTrader.SetExchangeTradeProcessing:output_type -> gctrpc.GenericResponse
146, // 255: gctrpc.GoCryptoTrader.UpsertDataHistoryJob:output_type -> gctrpc.UpsertDataHistoryJobResponse
148, // 256: gctrpc.GoCryptoTrader.GetDataHistoryJobDetails:output_type -> gctrpc.DataHistoryJob
150, // 257: gctrpc.GoCryptoTrader.GetActiveDataHistoryJobs:output_type -> gctrpc.DataHistoryJobs
127, // 258: gctrpc.GoCryptoTrader.DeleteDataHistoryJob:output_type -> gctrpc.GenericResponse
150, // 259: gctrpc.GoCryptoTrader.GetDataHistoryJobsBetween:output_type -> gctrpc.DataHistoryJobs
148, // 260: gctrpc.GoCryptoTrader.GetDataHistoryJobSummary:output_type -> gctrpc.DataHistoryJob
176, // [176:261] is the sub-list for method output_type
91, // [91:176] is the sub-list for method input_type
58, // 176: gctrpc.GoCryptoTrader.GetManagedOrders:input_type -> gctrpc.GetOrdersRequest
1, // 177: gctrpc.GoCryptoTrader.GetInfo:output_type -> gctrpc.GetInfoResponse
7, // 178: gctrpc.GoCryptoTrader.GetSubsystems:output_type -> gctrpc.GetSusbsytemsResponse
127, // 179: gctrpc.GoCryptoTrader.EnableSubsystem:output_type -> gctrpc.GenericResponse
127, // 180: gctrpc.GoCryptoTrader.DisableSubsystem:output_type -> gctrpc.GenericResponse
10, // 181: gctrpc.GoCryptoTrader.GetRPCEndpoints:output_type -> gctrpc.GetRPCEndpointsResponse
4, // 182: gctrpc.GoCryptoTrader.GetCommunicationRelayers:output_type -> gctrpc.GetCommunicationRelayersResponse
13, // 183: gctrpc.GoCryptoTrader.GetExchanges:output_type -> gctrpc.GetExchangesResponse
127, // 184: gctrpc.GoCryptoTrader.DisableExchange:output_type -> gctrpc.GenericResponse
19, // 185: gctrpc.GoCryptoTrader.GetExchangeInfo:output_type -> gctrpc.GetExchangeInfoResponse
14, // 186: gctrpc.GoCryptoTrader.GetExchangeOTPCode:output_type -> gctrpc.GetExchangeOTPReponse
16, // 187: gctrpc.GoCryptoTrader.GetExchangeOTPCodes:output_type -> gctrpc.GetExchangeOTPsResponse
127, // 188: gctrpc.GoCryptoTrader.EnableExchange:output_type -> gctrpc.GenericResponse
22, // 189: gctrpc.GoCryptoTrader.GetTicker:output_type -> gctrpc.TickerResponse
25, // 190: gctrpc.GoCryptoTrader.GetTickers:output_type -> gctrpc.GetTickersResponse
28, // 191: gctrpc.GoCryptoTrader.GetOrderbook:output_type -> gctrpc.OrderbookResponse
31, // 192: gctrpc.GoCryptoTrader.GetOrderbooks:output_type -> gctrpc.GetOrderbooksResponse
35, // 193: gctrpc.GoCryptoTrader.GetAccountInfo:output_type -> gctrpc.GetAccountInfoResponse
35, // 194: gctrpc.GoCryptoTrader.UpdateAccountInfo:output_type -> gctrpc.GetAccountInfoResponse
35, // 195: gctrpc.GoCryptoTrader.GetAccountInfoStream:output_type -> gctrpc.GetAccountInfoResponse
37, // 196: gctrpc.GoCryptoTrader.GetConfig:output_type -> gctrpc.GetConfigResponse
40, // 197: gctrpc.GoCryptoTrader.GetPortfolio:output_type -> gctrpc.GetPortfolioResponse
47, // 198: gctrpc.GoCryptoTrader.GetPortfolioSummary:output_type -> gctrpc.GetPortfolioSummaryResponse
127, // 199: gctrpc.GoCryptoTrader.AddPortfolioAddress:output_type -> gctrpc.GenericResponse
127, // 200: gctrpc.GoCryptoTrader.RemovePortfolioAddress:output_type -> gctrpc.GenericResponse
52, // 201: gctrpc.GoCryptoTrader.GetForexProviders:output_type -> gctrpc.GetForexProvidersResponse
55, // 202: gctrpc.GoCryptoTrader.GetForexRates:output_type -> gctrpc.GetForexRatesResponse
59, // 203: gctrpc.GoCryptoTrader.GetOrders:output_type -> gctrpc.GetOrdersResponse
56, // 204: gctrpc.GoCryptoTrader.GetOrder:output_type -> gctrpc.OrderDetails
63, // 205: gctrpc.GoCryptoTrader.SubmitOrder:output_type -> gctrpc.SubmitOrderResponse
65, // 206: gctrpc.GoCryptoTrader.SimulateOrder:output_type -> gctrpc.SimulateOrderResponse
65, // 207: gctrpc.GoCryptoTrader.WhaleBomb:output_type -> gctrpc.SimulateOrderResponse
127, // 208: gctrpc.GoCryptoTrader.CancelOrder:output_type -> gctrpc.GenericResponse
69, // 209: gctrpc.GoCryptoTrader.CancelBatchOrders:output_type -> gctrpc.CancelBatchOrdersResponse
71, // 210: gctrpc.GoCryptoTrader.CancelAllOrders:output_type -> gctrpc.CancelAllOrdersResponse
74, // 211: gctrpc.GoCryptoTrader.GetEvents:output_type -> gctrpc.GetEventsResponse
76, // 212: gctrpc.GoCryptoTrader.AddEvent:output_type -> gctrpc.AddEventResponse
127, // 213: gctrpc.GoCryptoTrader.RemoveEvent:output_type -> gctrpc.GenericResponse
79, // 214: gctrpc.GoCryptoTrader.GetCryptocurrencyDepositAddresses:output_type -> gctrpc.GetCryptocurrencyDepositAddressesResponse
81, // 215: gctrpc.GoCryptoTrader.GetCryptocurrencyDepositAddress:output_type -> gctrpc.GetCryptocurrencyDepositAddressResponse
84, // 216: gctrpc.GoCryptoTrader.WithdrawFiatFunds:output_type -> gctrpc.WithdrawResponse
84, // 217: gctrpc.GoCryptoTrader.WithdrawCryptocurrencyFunds:output_type -> gctrpc.WithdrawResponse
86, // 218: gctrpc.GoCryptoTrader.WithdrawalEventByID:output_type -> gctrpc.WithdrawalEventByIDResponse
89, // 219: gctrpc.GoCryptoTrader.WithdrawalEventsByExchange:output_type -> gctrpc.WithdrawalEventsByExchangeResponse
89, // 220: gctrpc.GoCryptoTrader.WithdrawalEventsByDate:output_type -> gctrpc.WithdrawalEventsByExchangeResponse
96, // 221: gctrpc.GoCryptoTrader.GetLoggerDetails:output_type -> gctrpc.GetLoggerDetailsResponse
96, // 222: gctrpc.GoCryptoTrader.SetLoggerDetails:output_type -> gctrpc.GetLoggerDetailsResponse
99, // 223: gctrpc.GoCryptoTrader.GetExchangePairs:output_type -> gctrpc.GetExchangePairsResponse
127, // 224: gctrpc.GoCryptoTrader.SetExchangePair:output_type -> gctrpc.GenericResponse
28, // 225: gctrpc.GoCryptoTrader.GetOrderbookStream:output_type -> gctrpc.OrderbookResponse
28, // 226: gctrpc.GoCryptoTrader.GetExchangeOrderbookStream:output_type -> gctrpc.OrderbookResponse
22, // 227: gctrpc.GoCryptoTrader.GetTickerStream:output_type -> gctrpc.TickerResponse
22, // 228: gctrpc.GoCryptoTrader.GetExchangeTickerStream:output_type -> gctrpc.TickerResponse
106, // 229: gctrpc.GoCryptoTrader.GetAuditEvent:output_type -> gctrpc.GetAuditEventResponse
127, // 230: gctrpc.GoCryptoTrader.GCTScriptExecute:output_type -> gctrpc.GenericResponse
127, // 231: gctrpc.GoCryptoTrader.GCTScriptUpload:output_type -> gctrpc.GenericResponse
126, // 232: gctrpc.GoCryptoTrader.GCTScriptReadScript:output_type -> gctrpc.GCTScriptQueryResponse
125, // 233: gctrpc.GoCryptoTrader.GCTScriptStatus:output_type -> gctrpc.GCTScriptStatusResponse
126, // 234: gctrpc.GoCryptoTrader.GCTScriptQuery:output_type -> gctrpc.GCTScriptQueryResponse
127, // 235: gctrpc.GoCryptoTrader.GCTScriptStop:output_type -> gctrpc.GenericResponse
127, // 236: gctrpc.GoCryptoTrader.GCTScriptStopAll:output_type -> gctrpc.GenericResponse
125, // 237: gctrpc.GoCryptoTrader.GCTScriptListAll:output_type -> gctrpc.GCTScriptStatusResponse
127, // 238: gctrpc.GoCryptoTrader.GCTScriptAutoLoadToggle:output_type -> gctrpc.GenericResponse
112, // 239: gctrpc.GoCryptoTrader.GetHistoricCandles:output_type -> gctrpc.GetHistoricCandlesResponse
127, // 240: gctrpc.GoCryptoTrader.SetExchangeAsset:output_type -> gctrpc.GenericResponse
127, // 241: gctrpc.GoCryptoTrader.SetAllExchangePairs:output_type -> gctrpc.GenericResponse
127, // 242: gctrpc.GoCryptoTrader.UpdateExchangeSupportedPairs:output_type -> gctrpc.GenericResponse
132, // 243: gctrpc.GoCryptoTrader.GetExchangeAssets:output_type -> gctrpc.GetExchangeAssetsResponse
134, // 244: gctrpc.GoCryptoTrader.WebsocketGetInfo:output_type -> gctrpc.WebsocketGetInfoResponse
127, // 245: gctrpc.GoCryptoTrader.WebsocketSetEnabled:output_type -> gctrpc.GenericResponse
138, // 246: gctrpc.GoCryptoTrader.WebsocketGetSubscriptions:output_type -> gctrpc.WebsocketGetSubscriptionsResponse
127, // 247: gctrpc.GoCryptoTrader.WebsocketSetProxy:output_type -> gctrpc.GenericResponse
127, // 248: gctrpc.GoCryptoTrader.WebsocketSetURL:output_type -> gctrpc.GenericResponse
109, // 249: gctrpc.GoCryptoTrader.GetRecentTrades:output_type -> gctrpc.SavedTradesResponse
109, // 250: gctrpc.GoCryptoTrader.GetHistoricTrades:output_type -> gctrpc.SavedTradesResponse
109, // 251: gctrpc.GoCryptoTrader.GetSavedTrades:output_type -> gctrpc.SavedTradesResponse
112, // 252: gctrpc.GoCryptoTrader.ConvertTradesToCandles:output_type -> gctrpc.GetHistoricCandlesResponse
143, // 253: gctrpc.GoCryptoTrader.FindMissingSavedCandleIntervals:output_type -> gctrpc.FindMissingIntervalsResponse
143, // 254: gctrpc.GoCryptoTrader.FindMissingSavedTradeIntervals:output_type -> gctrpc.FindMissingIntervalsResponse
127, // 255: gctrpc.GoCryptoTrader.SetExchangeTradeProcessing:output_type -> gctrpc.GenericResponse
146, // 256: gctrpc.GoCryptoTrader.UpsertDataHistoryJob:output_type -> gctrpc.UpsertDataHistoryJobResponse
148, // 257: gctrpc.GoCryptoTrader.GetDataHistoryJobDetails:output_type -> gctrpc.DataHistoryJob
150, // 258: gctrpc.GoCryptoTrader.GetActiveDataHistoryJobs:output_type -> gctrpc.DataHistoryJobs
127, // 259: gctrpc.GoCryptoTrader.DeleteDataHistoryJob:output_type -> gctrpc.GenericResponse
150, // 260: gctrpc.GoCryptoTrader.GetDataHistoryJobsBetween:output_type -> gctrpc.DataHistoryJobs
148, // 261: gctrpc.GoCryptoTrader.GetDataHistoryJobSummary:output_type -> gctrpc.DataHistoryJob
59, // 262: gctrpc.GoCryptoTrader.GetManagedOrders:output_type -> gctrpc.GetOrdersResponse
177, // [177:263] is the sub-list for method output_type
91, // [91:177] is the sub-list for method input_type
91, // [91:91] is the sub-list for extension type_name
91, // [91:91] is the sub-list for extension extendee
0, // [0:91] is the sub-list for field type_name

File diff suppressed because it is too large Load Diff

View File

@@ -1454,4 +1454,10 @@ service GoCryptoTrader {
get: "/v1/getdatahistoryjobsummary"
};
}
rpc GetManagedOrders (GetOrdersRequest) returns (GetOrdersResponse) {
option (google.api.http) = {
post: "/v1/getmanagedorders"
body: "*"
};
}
}

View File

@@ -1667,6 +1667,38 @@
]
}
},
"/v1/getmanagedorders": {
"post": {
"operationId": "GoCryptoTrader_GetManagedOrders",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcGetOrdersResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/runtimeError"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/gctrpcGetOrdersRequest"
}
}
],
"tags": [
"GoCryptoTrader"
]
}
},
"/v1/getorder": {
"post": {
"operationId": "GoCryptoTrader_GetOrder",

View File

@@ -103,6 +103,7 @@ type GoCryptoTraderClient interface {
DeleteDataHistoryJob(ctx context.Context, in *GetDataHistoryJobDetailsRequest, opts ...grpc.CallOption) (*GenericResponse, error)
GetDataHistoryJobsBetween(ctx context.Context, in *GetDataHistoryJobsBetweenRequest, opts ...grpc.CallOption) (*DataHistoryJobs, error)
GetDataHistoryJobSummary(ctx context.Context, in *GetDataHistoryJobDetailsRequest, opts ...grpc.CallOption) (*DataHistoryJob, error)
GetManagedOrders(ctx context.Context, in *GetOrdersRequest, opts ...grpc.CallOption) (*GetOrdersResponse, error)
}
type goCryptoTraderClient struct {
@@ -1016,6 +1017,15 @@ func (c *goCryptoTraderClient) GetDataHistoryJobSummary(ctx context.Context, in
return out, nil
}
func (c *goCryptoTraderClient) GetManagedOrders(ctx context.Context, in *GetOrdersRequest, opts ...grpc.CallOption) (*GetOrdersResponse, error) {
out := new(GetOrdersResponse)
err := c.cc.Invoke(ctx, "/gctrpc.GoCryptoTrader/GetManagedOrders", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GoCryptoTraderServer is the server API for GoCryptoTrader service.
// All implementations must embed UnimplementedGoCryptoTraderServer
// for forward compatibility
@@ -1105,6 +1115,7 @@ type GoCryptoTraderServer interface {
DeleteDataHistoryJob(context.Context, *GetDataHistoryJobDetailsRequest) (*GenericResponse, error)
GetDataHistoryJobsBetween(context.Context, *GetDataHistoryJobsBetweenRequest) (*DataHistoryJobs, error)
GetDataHistoryJobSummary(context.Context, *GetDataHistoryJobDetailsRequest) (*DataHistoryJob, error)
GetManagedOrders(context.Context, *GetOrdersRequest) (*GetOrdersResponse, error)
mustEmbedUnimplementedGoCryptoTraderServer()
}
@@ -1367,6 +1378,9 @@ func (UnimplementedGoCryptoTraderServer) GetDataHistoryJobsBetween(context.Conte
func (UnimplementedGoCryptoTraderServer) GetDataHistoryJobSummary(context.Context, *GetDataHistoryJobDetailsRequest) (*DataHistoryJob, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetDataHistoryJobSummary not implemented")
}
func (UnimplementedGoCryptoTraderServer) GetManagedOrders(context.Context, *GetOrdersRequest) (*GetOrdersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetManagedOrders not implemented")
}
func (UnimplementedGoCryptoTraderServer) mustEmbedUnimplementedGoCryptoTraderServer() {}
// UnsafeGoCryptoTraderServer may be embedded to opt out of forward compatibility for this service.
@@ -2928,6 +2942,24 @@ func _GoCryptoTrader_GetDataHistoryJobSummary_Handler(srv interface{}, ctx conte
return interceptor(ctx, in, info, handler)
}
func _GoCryptoTrader_GetManagedOrders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetOrdersRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GoCryptoTraderServer).GetManagedOrders(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gctrpc.GoCryptoTrader/GetManagedOrders",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GoCryptoTraderServer).GetManagedOrders(ctx, req.(*GetOrdersRequest))
}
return interceptor(ctx, in, info, handler)
}
// GoCryptoTrader_ServiceDesc is the grpc.ServiceDesc for GoCryptoTrader service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -3251,6 +3283,10 @@ var GoCryptoTrader_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetDataHistoryJobSummary",
Handler: _GoCryptoTrader_GetDataHistoryJobSummary_Handler,
},
{
MethodName: "GetManagedOrders",
Handler: _GoCryptoTrader_GetManagedOrders_Handler,
},
},
Streams: []grpc.StreamDesc{
{