From db317a2447f6c8fbfcab17691d58ab3401301475 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 3 Oct 2019 09:47:37 +1000 Subject: [PATCH] Engine: Dispatch service (#346) * Added dispatch service * Added orderbook streaming capabilities * Assigned correct orderbook.base exchange name * Fixed Requested niterinos Add in cli orderbook QA tool to gctcli Add exchange orderbook streaming * Add ticker streaming support through dispatch package * Added in some more info on error returns for orderbook.go * fix linter issues * Fix some issues * Update * Fix requested * move dispatch out of exchanges folder to its own independant folder * Fix requested * change orderbook string to tickers * Limit orderbooks to 50 and made dispatch system more stateless in operation * lower cases for update/retrieve/sub exchange name * Adds in asset validation and lower case conversion on cli * Remove comment * Moved timer to a higher scope so its not constantly initialised just reset per instance and removed returning unused channel on error * Rm unused release function in dispatch.go Reset timer and bleed buffered timer chan if needed in dispatch.go Added in ticker.Stop() and timer.Stop() functions for worker routine return in dispatch.go Index aggregated bid and ask functions for orderbook.go Added in dummy slice for wsorderbook_test.go * Moved drain to above Reset so potential race would not occur in dispatch.go Fix various linter issues dispatch.go * Fix some issues * change to start/stop service, added in service state change via cli, updated logger * fix requested * Add worker amount init spawning * fix linter issues * Fix more linter issues * More fixes * Fix race issue on releasing pipe channel on a close after shutting down dispatcher system * Moved all types to dispatch_types.go && remove panic * Moved types into serperate file && improve test coverage * RM unnecessary select case for draining channel && fixed error string * Added orderbook_types file and improved code coverage * gofmt file * reinstated select cases on drain because I am silly * Remove error for drop worker * Added more test cases * not checking error issue fix * remove func causing race in test, this has required protection via an exported function * set Gemini websocket orderbook exchange name --- cmd/gctcli/commands.go | 448 +++++++ cmd/gctcli/main.go | 4 + cmd/gctcli/validation.go | 6 + dispatch/dispatch.go | 357 +++++ dispatch/dispatch_test.go | 307 +++++ dispatch/dispatch_types.go | 88 ++ dispatch/mux.go | 77 ++ engine/engine.go | 17 + engine/engine_types.go | 4 + engine/events_test.go | 12 - engine/helpers.go | 7 + engine/routines.go | 96 -- engine/rpcserver.go | 206 ++- exchanges/anx/anx_test.go | 4 +- exchanges/binance/binance_websocket.go | 1 + exchanges/bitfinex/bitfinex_websocket.go | 2 + exchanges/bitmex/bitmex_websocket.go | 2 + exchanges/bitstamp/bitstamp_websocket.go | 1 + .../coinbasepro/coinbasepro_websocket.go | 1 + exchanges/coinut/coinut_websocket.go | 1 + exchanges/gateio/gateio_websocket.go | 1 + exchanges/gemini/gemini_websocket.go | 1 + exchanges/hitbtc/hitbtc_websocket.go | 1 + exchanges/orderbook/orderbook.go | 360 ++--- exchanges/orderbook/orderbook_test.go | 245 ++-- exchanges/orderbook/orderbook_types.go | 69 + exchanges/poloniex/poloniex_websocket.go | 1 + exchanges/ticker/ticker.go | 304 +++-- exchanges/ticker/ticker_test.go | 280 ++-- exchanges/ticker/ticker_types.go | 57 + .../websocket/wsorderbook/wsorderbook.go | 14 + .../websocket/wsorderbook/wsorderbook_test.go | 81 +- exchanges/zb/zb_websocket.go | 1 + gctrpc/rpc.pb.go | 1162 +++++++++++++---- gctrpc/rpc.pb.gw.go | 331 ++++- gctrpc/rpc.proto | 44 + gctrpc/rpc.swagger.json | 207 +++ go.mod | 7 +- go.sum | 9 +- logger/logger_setup.go | 1 + logger/sublogger_types.go | 1 + main.go | 3 + 42 files changed, 3802 insertions(+), 1019 deletions(-) create mode 100644 dispatch/dispatch.go create mode 100644 dispatch/dispatch_test.go create mode 100644 dispatch/dispatch_types.go create mode 100644 dispatch/mux.go create mode 100644 exchanges/orderbook/orderbook_types.go create mode 100644 exchanges/ticker/ticker_types.go diff --git a/cmd/gctcli/commands.go b/cmd/gctcli/commands.go index 943009a0..ddcc043b 100644 --- a/cmd/gctcli/commands.go +++ b/cmd/gctcli/commands.go @@ -4,7 +4,11 @@ import ( "context" "errors" "fmt" + "os" + "os/exec" + "runtime" "strconv" + "strings" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" @@ -544,6 +548,11 @@ func getTicker(c *cli.Context) error { assetType = c.Args().Get(2) } + assetType = strings.ToLower(assetType) + if !validAsset(assetType) { + return errInvalidAsset + } + conn, err := setupClient() if err != nil { return err @@ -652,6 +661,11 @@ func getOrderbook(c *cli.Context) error { assetType = c.Args().Get(2) } + assetType = strings.ToLower(assetType) + if !validAsset(assetType) { + return errInvalidAsset + } + conn, err := setupClient() if err != nil { return err @@ -1066,6 +1080,11 @@ func getOrders(c *cli.Context) error { assetType = c.Args().Get(1) } + assetType = strings.ToLower(assetType) + if !validAsset(assetType) { + return errInvalidAsset + } + if c.IsSet("pair") { currencyPair = c.String("pair") } else { @@ -1559,6 +1578,11 @@ func cancelOrder(c *cli.Context) error { assetType = c.String("asset_type") } + assetType = strings.ToLower(assetType) + if !validAsset(assetType) { + return errInvalidAsset + } + if c.IsSet("wallet_address") { walletAddress = c.String("wallet_address") } @@ -1782,6 +1806,11 @@ func addEvent(c *cli.Context) error { assetType = c.String("asset_type") } + assetType = strings.ToLower(assetType) + if !validAsset(assetType) { + return errInvalidAsset + } + if c.IsSet("action") { action = c.String("action") } else { @@ -2172,6 +2201,11 @@ func getExchangePairs(c *cli.Context) error { asset = c.Args().Get(1) } + asset = strings.ToLower(asset) + if !validAsset(asset) { + return errInvalidAsset + } + conn, err := setupClient() if err != nil { return err @@ -2249,6 +2283,11 @@ func enableExchangePair(c *cli.Context) error { asset = c.Args().Get(2) } + asset = strings.ToLower(asset) + if !validAsset(asset) { + return errInvalidAsset + } + conn, err := setupClient() if err != nil { return err @@ -2332,6 +2371,11 @@ func disableExchangePair(c *cli.Context) error { asset = c.Args().Get(2) } + asset = strings.ToLower(asset) + if !validAsset(asset) { + return errInvalidAsset + } + conn, err := setupClient() if err != nil { return err @@ -2357,3 +2401,407 @@ func disableExchangePair(c *cli.Context) error { jsonOutput(result) return nil } + +var getOrderbookStreamCommand = cli.Command{ + Name: "getorderbookstream", + Usage: "gets the orderbook stream for a specific currency pair and exchange", + ArgsUsage: " ", + Action: getOrderbookStream, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "exchange", + Usage: "the exchange to get the orderbook from", + }, + cli.StringFlag{ + Name: "pair", + Usage: "currency pair", + }, + cli.StringFlag{ + Name: "asset", + Usage: "the asset type of the currency pair", + }, + }, +} + +func getOrderbookStream(c *cli.Context) error { + if c.NArg() == 0 && c.NumFlags() == 0 { + cli.ShowCommandHelp(c, "getorderbookstream") + return nil + } + + var exchangeName string + var pair string + var assetType string + + if c.IsSet("exchange") { + exchangeName = c.String("exchange") + } else { + exchangeName = c.Args().First() + } + + if !validExchange(exchangeName) { + return errInvalidExchange + } + + if c.IsSet("pair") { + pair = c.String("pair") + } else { + pair = c.Args().Get(1) + } + + if !validPair(pair) { + return errInvalidPair + } + + if c.IsSet("asset") { + assetType = c.String("asset") + } else { + assetType = c.Args().Get(2) + } + + assetType = strings.ToLower(assetType) + + if !validAsset(assetType) { + return errInvalidAsset + } + + conn, err := setupClient() + if err != nil { + return err + } + defer conn.Close() + + p := currency.NewPairDelimiter(pair, pairDelimiter) + + client := gctrpc.NewGoCryptoTraderClient(conn) + result, err := client.GetOrderbookStream(context.Background(), + &gctrpc.GetOrderbookStreamRequest{ + Exchange: exchangeName, + Pair: &gctrpc.CurrencyPair{ + Base: p.Base.String(), + Quote: p.Quote.String(), + Delimiter: p.Delimiter, + }, + AssetType: assetType, + }, + ) + + if err != nil { + return err + } + + for { + resp, err := result.Recv() + if err != nil { + return err + } + + err = clearScreen() + if err != nil { + return err + } + + fmt.Printf("Orderbook stream for %s %s:\n\n", exchangeName, + resp.Pair.String()) + fmt.Println("\t\tBids\t\t\t\tAsks") + fmt.Println() + + bidLen := len(resp.Bids) - 1 + askLen := len(resp.Asks) - 1 + + var maxLen int + if bidLen >= askLen { + maxLen = bidLen + } else { + maxLen = askLen + } + + for i := 0; i < maxLen; i++ { + var bidAmount, bidPrice float64 + if i <= bidLen { + bidAmount = resp.Bids[i].Amount + bidPrice = resp.Bids[i].Price + } + + var askAmount, askPrice float64 + if i <= askLen { + askAmount = resp.Asks[i].Amount + askPrice = resp.Asks[i].Price + } + + fmt.Printf("%f %s @ %f %s\t\t%f %s @ %f %s\n", + bidAmount, + resp.Pair.Base, + bidPrice, + resp.Pair.Quote, + askAmount, + resp.Pair.Base, + askPrice, + resp.Pair.Quote) + + if i >= 49 { + // limits orderbook display output + break + } + } + } +} + +var getExchangeOrderbookStreamCommand = cli.Command{ + Name: "getexchangeorderbookstream", + Usage: "gets a stream for all orderbooks associated with an exchange", + ArgsUsage: "", + Action: getExchangeOrderbookStream, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "exchange", + Usage: "the exchange to get the orderbook from", + }, + }, +} + +func getExchangeOrderbookStream(c *cli.Context) error { + if c.NArg() == 0 && c.NumFlags() == 0 { + cli.ShowCommandHelp(c, "getexchangeorderbookstream") + return nil + } + + var exchangeName string + if c.IsSet("exchange") { + exchangeName = c.String("exchange") + } else { + exchangeName = c.Args().First() + } + + if !validExchange(exchangeName) { + return errInvalidExchange + } + + conn, err := setupClient() + if err != nil { + return err + } + defer conn.Close() + + client := gctrpc.NewGoCryptoTraderClient(conn) + result, err := client.GetExchangeOrderbookStream(context.Background(), + &gctrpc.GetExchangeOrderbookStreamRequest{ + Exchange: exchangeName, + }) + + if err != nil { + return err + } + + for { + resp, err := result.Recv() + if err != nil { + return err + } + + err = clearScreen() + if err != nil { + return err + } + + fmt.Printf("Orderbook streamed for %s %s", + exchangeName, + resp.Pair.String()) + } +} + +var getTickerStreamCommand = cli.Command{ + Name: "gettickerstream", + Usage: "gets the ticker stream for a specific currency pair and exchange", + ArgsUsage: " ", + Action: getTickerStream, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "exchange", + Usage: "the exchange to get the ticker from", + }, + cli.StringFlag{ + Name: "pair", + Usage: "currency pair", + }, + cli.StringFlag{ + Name: "asset", + Usage: "the asset type of the currency pair", + }, + }, +} + +func getTickerStream(c *cli.Context) error { + if c.NArg() == 0 && c.NumFlags() == 0 { + cli.ShowCommandHelp(c, "gettickerstream") + return nil + } + + var exchangeName string + var pair string + var assetType string + + if c.IsSet("exchange") { + exchangeName = c.String("exchange") + } else { + exchangeName = c.Args().First() + } + + if !validExchange(exchangeName) { + return errInvalidExchange + } + + if c.IsSet("pair") { + pair = c.String("pair") + } else { + pair = c.Args().Get(1) + } + + if !validPair(pair) { + return errInvalidPair + } + + if c.IsSet("asset") { + assetType = c.String("asset") + } else { + assetType = c.Args().Get(2) + } + + assetType = strings.ToLower(assetType) + + if !validAsset(assetType) { + return errInvalidAsset + } + + conn, err := setupClient() + if err != nil { + return err + } + defer conn.Close() + + p := currency.NewPairDelimiter(pair, pairDelimiter) + + client := gctrpc.NewGoCryptoTraderClient(conn) + result, err := client.GetTickerStream(context.Background(), + &gctrpc.GetTickerStreamRequest{ + Exchange: exchangeName, + Pair: &gctrpc.CurrencyPair{ + Base: p.Base.String(), + Quote: p.Quote.String(), + Delimiter: p.Delimiter, + }, + AssetType: assetType, + }, + ) + + if err != nil { + return err + } + + for { + resp, err := result.Recv() + if err != nil { + return err + } + + err = clearScreen() + if err != nil { + return err + } + + fmt.Printf("Ticker stream for %s %s:\n", exchangeName, + resp.Pair.String()) + fmt.Println() + + fmt.Printf("LAST: %f\n HIGH: %f\n LOW: %f\n BID: %f\n ASK: %f\n VOLUME: %f\n PRICEATH: %f\n LASTUPDATED: %d\n", + resp.Last, + resp.High, + resp.Low, + resp.Bid, + resp.Ask, + resp.Volume, + resp.PriceAth, + resp.LastUpdated) + } +} + +var getExchangeTickerStreamCommand = cli.Command{ + Name: "getexchangetickerstream", + Usage: "gets a stream for all tickers associated with an exchange", + ArgsUsage: "", + Action: getExchangeTickerStream, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "exchange", + Usage: "the exchange to get the ticker from", + }, + }, +} + +func getExchangeTickerStream(c *cli.Context) error { + if c.NArg() == 0 && c.NumFlags() == 0 { + cli.ShowCommandHelp(c, "getexchangetickerstream") + return nil + } + + var exchangeName string + if c.IsSet("exchange") { + exchangeName = c.String("exchange") + } else { + exchangeName = c.Args().First() + } + + if !validExchange(exchangeName) { + return errInvalidExchange + } + + conn, err := setupClient() + if err != nil { + return err + } + defer conn.Close() + + client := gctrpc.NewGoCryptoTraderClient(conn) + result, err := client.GetExchangeTickerStream(context.Background(), + &gctrpc.GetExchangeTickerStreamRequest{ + Exchange: exchangeName, + }) + + if err != nil { + return err + } + + for { + resp, err := result.Recv() + if err != nil { + return err + } + + fmt.Printf("Ticker stream for %s %s:\n", + exchangeName, + resp.Pair.String()) + + fmt.Printf("LAST: %f HIGH: %f LOW: %f BID: %f ASK: %f VOLUME: %f PRICEATH: %f LASTUPDATED: %d\n", + resp.Last, + resp.High, + resp.Low, + resp.Bid, + resp.Ask, + resp.Volume, + resp.PriceAth, + resp.LastUpdated) + } +} + +func clearScreen() error { + switch runtime.GOOS { + case "windows": + cmd := exec.Command("cmd", "/c", "cls") + cmd.Stdout = os.Stdout + return cmd.Run() + default: + cmd := exec.Command("clear") + cmd.Stdout = os.Stdout + return cmd.Run() + } +} diff --git a/cmd/gctcli/main.go b/cmd/gctcli/main.go index afe0316d..31e4fe17 100644 --- a/cmd/gctcli/main.go +++ b/cmd/gctcli/main.go @@ -128,6 +128,10 @@ func main() { getExchangePairsCommand, enableExchangePairCommand, disableExchangePairCommand, + getOrderbookStreamCommand, + getExchangeOrderbookStreamCommand, + getTickerStreamCommand, + getExchangeTickerStreamCommand, } err := app.Run(os.Args) diff --git a/cmd/gctcli/validation.go b/cmd/gctcli/validation.go index fd3202b0..fd308b06 100644 --- a/cmd/gctcli/validation.go +++ b/cmd/gctcli/validation.go @@ -5,11 +5,13 @@ import ( "strings" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" + "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) var ( errInvalidPair = errors.New("invalid currency pair supplied") errInvalidExchange = errors.New("invalid exchange supplied") + errInvalidAsset = errors.New("invalid asset supplied") ) func validPair(pair string) bool { @@ -19,3 +21,7 @@ func validPair(pair string) bool { func validExchange(exch string) bool { return exchange.IsSupported(exch) } + +func validAsset(i string) bool { + return asset.IsValid(asset.Item(i)) +} diff --git a/dispatch/dispatch.go b/dispatch/dispatch.go new file mode 100644 index 00000000..8fb8b096 --- /dev/null +++ b/dispatch/dispatch.go @@ -0,0 +1,357 @@ +package dispatch + +import ( + "errors" + "fmt" + "sync" + "sync/atomic" + "time" + + "github.com/gofrs/uuid" + log "github.com/thrasher-corp/gocryptotrader/logger" +) + +func init() { + dispatcher = &Dispatcher{ + routes: make(map[uuid.UUID][]chan interface{}), + jobs: make(chan *job, DefaultJobBuffer), + outbound: sync.Pool{ + New: func() interface{} { + // Create unbuffered channel for data pass + return make(chan interface{}) + }, + }, + } +} + +// Start starts the dispatch system by spawning workers and allocating memory +func Start(workers int64) error { + if dispatcher == nil { + return errors.New(errNotInitialised) + } + + mtx.Lock() + defer mtx.Unlock() + return dispatcher.start(workers) +} + +// Stop attempts to stop the dispatch service, this will close all pipe channels +// flush job list and drop all workers +func Stop() error { + if dispatcher == nil { + return errors.New(errNotInitialised) + } + + log.Debugln(log.DispatchMgr, "Dispatch manager shutting down...") + + mtx.Lock() + defer mtx.Unlock() + return dispatcher.stop() +} + +// IsRunning checks to see if the dispatch service is running +func IsRunning() bool { + if dispatcher == nil { + return false + } + + return dispatcher.isRunning() +} + +// DropWorker drops a worker routine +func DropWorker() error { + if dispatcher == nil { + return errors.New(errNotInitialised) + } + + dispatcher.dropWorker() + return nil +} + +// SpawnWorker starts a new worker routine +func SpawnWorker() error { + if dispatcher == nil { + return errors.New(errNotInitialised) + } + return dispatcher.spawnWorker() +} + +// start compares atomic running value, sets defaults, overides with +// configuration, then spawns workers +func (d *Dispatcher) start(workers int64) error { + if atomic.LoadUint32(&d.running) == 1 { + return errors.New(errAlreadyStarted) + } + + if workers < 1 { + log.Warn(log.DispatchMgr, + "Dispatcher: workers cannot be zero using default values") + workers = DefaultMaxWorkers + } + + d.maxWorkers = workers + d.shutdown = make(chan *sync.WaitGroup) + + if atomic.LoadInt64(&d.count) != 0 { + return errors.New("dispatcher leaked workers found") + } + + for i := int64(0); i < d.maxWorkers; i++ { + err := d.spawnWorker() + if err != nil { + return err + } + } + + atomic.SwapUint32(&d.running, 1) + return nil +} + +// stop stops the service and shuts down all worker routines +func (d *Dispatcher) stop() error { + if !atomic.CompareAndSwapUint32(&d.running, 1, 0) { + return errors.New(errCannotShutdown) + } + close(d.shutdown) + ch := make(chan struct{}) + timer := time.NewTimer(1 * time.Second) + defer func() { + if !timer.Stop() { + select { + case <-timer.C: + default: + } + } + }() + go func(ch chan struct{}) { d.wg.Wait(); ch <- struct{}{} }(ch) + select { + case <-ch: + // close all routes + for key := range d.routes { + for i := range d.routes[key] { + close(d.routes[key][i]) + } + + d.routes[key] = nil + } + + for len(d.jobs) != 0 { // drain jobs channel for old data + <-d.jobs + } + + log.Debugln(log.DispatchMgr, "Dispatch manager shutdown.") + + return nil + case <-timer.C: + return errors.New(errShutdownRoutines) + } +} + +// isRunning returns if the dispatch system is running +func (d *Dispatcher) isRunning() bool { + return atomic.LoadUint32(&d.running) == 1 +} + +// dropWorker deallocates a worker routine +func (d *Dispatcher) dropWorker() { + wg := sync.WaitGroup{} + wg.Add(1) + d.shutdown <- &wg + wg.Wait() +} + +// spawnWorker allocates a new worker for job processing +func (d *Dispatcher) spawnWorker() error { + if atomic.LoadInt64(&d.count) >= d.maxWorkers { + return errors.New("dispatcher cannot spawn more workers; ceiling reached") + } + var spawnWg sync.WaitGroup + spawnWg.Add(1) + go d.relayer(&spawnWg) + spawnWg.Wait() + return nil +} + +// Relayer routine relays communications across the defined routes +func (d *Dispatcher) relayer(i *sync.WaitGroup) { + atomic.AddInt64(&d.count, 1) + d.wg.Add(1) + timeout := time.NewTimer(0) + i.Done() + for { + select { + case j := <-d.jobs: + d.rMtx.RLock() + if _, ok := d.routes[j.ID]; !ok { + d.rMtx.RUnlock() + continue + } + // Channel handshake timeout feature if a channel is blocked for any + // period of time due to an issue with the receiving routine. + // This will wait on channel then fall over to the next route when + // the timer actuates and continue over the route list. Have to + // iterate across full length of routes so every routine can get + // their new info, cannot be buffered as we dont want to have an old + // orderbook etc contained in a buffered channel when a routine + // actually is ready for a receive. + // TODO: Need to consider optimal timer length + for i := range d.routes[j.ID] { + if !timeout.Stop() { // Stop timer before reset + // Drain channel if timer has already actuated + select { + case <-timeout.C: + default: + } + } + + timeout.Reset(DefaultHandshakeTimeout) + select { + case d.routes[j.ID][i] <- j.Data: + case <-timeout.C: + } + } + d.rMtx.RUnlock() + + case v := <-d.shutdown: + if !timeout.Stop() { + select { + case <-timeout.C: + default: + } + } + atomic.AddInt64(&d.count, -1) + if v != nil { + v.Done() + } + d.wg.Done() + return + } + } +} + +// publish relays data to the subscribed subsystems +func (d *Dispatcher) publish(id uuid.UUID, data interface{}) error { + if data == nil { + return errors.New("dispatcher data cannot be nil") + } + + if id == (uuid.UUID{}) { + return errors.New("dispatcher uuid not set") + } + + if atomic.LoadUint32(&d.running) == 0 { + return nil + } + + // Create a new job to publish + newJob := &job{ + Data: data, + ID: id, + } + + // Push job on stack here + select { + case d.jobs <- newJob: + default: + return fmt.Errorf("dispatcher buffer at max capacity [%d] current worker count [%d], spawn more workers via --dispatchworkers=x", + len(d.jobs), + atomic.LoadInt64(&d.count)) + } + + return nil +} + +// Subscribe subscribes a system and returns a communication chan, this does not +// ensure initial push. If your routine is out of sync with heartbeat and the +// system does not get a change, its up to you to in turn get initial state. +func (d *Dispatcher) subscribe(id uuid.UUID) (chan interface{}, error) { + if atomic.LoadUint32(&d.running) == 0 { + return nil, errors.New(errNotInitialised) + } + + // Read lock to read route list + d.rMtx.RLock() + _, ok := d.routes[id] + d.rMtx.RUnlock() + if !ok { + return nil, errors.New("dispatcher uuid not found in route list") + } + + // Get an unused channel from the channel pool + unusedChan := d.outbound.Get().(chan interface{}) + + // Lock for writing to the route list + d.rMtx.Lock() + d.routes[id] = append(d.routes[id], unusedChan) + d.rMtx.Unlock() + + return unusedChan, nil +} + +// Unsubscribe unsubs a routine from the dispatcher +func (d *Dispatcher) unsubscribe(id uuid.UUID, usedChan chan interface{}) error { + if atomic.LoadUint32(&d.running) == 0 { + // reference will already be released in the stop function + return nil + } + + // Read lock to read route list + d.rMtx.RLock() + _, ok := d.routes[id] + d.rMtx.RUnlock() + if !ok { + return errors.New("dispatcher uuid does not reference any channels") + } + + // Lock for write to delete references + d.rMtx.Lock() + for i := range d.routes[id] { + if d.routes[id][i] != usedChan { + continue + } + // Delete individual reference + d.routes[id][i] = d.routes[id][len(d.routes[id])-1] + d.routes[id][len(d.routes[id])-1] = nil + d.routes[id] = d.routes[id][:len(d.routes[id])-1] + + d.rMtx.Unlock() + + // Drain and put the used chan back in pool; only if it is not closed. + select { + case _, ok := <-usedChan: + if !ok { + return nil + } + default: + } + + d.outbound.Put(usedChan) + return nil + } + d.rMtx.Unlock() + return errors.New("dispatcher channel not found in uuid reference slice") +} + +// GetNewID returns a new ID +func (d *Dispatcher) getNewID() (uuid.UUID, error) { + // Generate new uuid + newID, err := uuid.NewV4() + if err != nil { + return uuid.UUID{}, err + } + + // Check to see if it already exists + d.rMtx.RLock() + _, ok := d.routes[newID] + d.rMtx.RUnlock() + if ok { + return newID, errors.New("dispatcher collision detected, uuid already exists") + } + + // Write the key into system + d.rMtx.Lock() + d.routes[newID] = nil + d.rMtx.Unlock() + + return newID, nil +} diff --git a/dispatch/dispatch_test.go b/dispatch/dispatch_test.go new file mode 100644 index 00000000..e526e3e2 --- /dev/null +++ b/dispatch/dispatch_test.go @@ -0,0 +1,307 @@ +package dispatch + +import ( + "fmt" + "os" + "sync" + "testing" + + "github.com/gofrs/uuid" +) + +var mux *Mux + +func TestMain(m *testing.M) { + err := Start(DefaultMaxWorkers) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + cpyDispatch = dispatcher + mux = GetNewMux() + cpyMux = mux + os.Exit(m.Run()) +} + +var cpyDispatch *Dispatcher +var cpyMux *Mux + +func TestDispatcher(t *testing.T) { + dispatcher = nil + err := Stop() + if err == nil { + t.Error("error cannot be nil") + } + + err = Start(10) + if err == nil { + t.Error("error cannot be nil") + } + + if IsRunning() { + t.Error("should be false") + } + + err = DropWorker() + if err == nil { + t.Error("error cannot be nil") + } + + err = SpawnWorker() + if err == nil { + t.Error("error cannot be nil") + } + + dispatcher = cpyDispatch + + if !IsRunning() { + t.Error("should be true") + } + + err = Start(10) + if err == nil { + t.Error("error cannot be nil") + } + + err = DropWorker() + if err != nil { + t.Error(err) + } + + err = DropWorker() + if err != nil { + t.Error(err) + } + + err = SpawnWorker() + if err != nil { + t.Error(err) + } + + err = SpawnWorker() + if err != nil { + t.Error(err) + } + + err = SpawnWorker() + if err == nil { + t.Error("error cannot be nil") + } + + err = Stop() + if err != nil { + t.Error(err) + } + + err = Stop() + if err == nil { + t.Error("error cannot be nil") + } + + err = Start(0) + if err != nil { + t.Error(err) + } + + payload := "something" + + err = dispatcher.publish(uuid.UUID{}, &payload) + if err == nil { + t.Error("error cannot be nil") + } + + err = dispatcher.publish(uuid.UUID{}, nil) + if err == nil { + t.Error("error cannot be nil") + } + + id, errrrrrrrr := dispatcher.getNewID() + if errrrrrrrr != nil { + t.Error(errrrrrrrr) + } + + err = dispatcher.publish(id, &payload) + if err != nil { + t.Error(err) + } + + err = dispatcher.stop() + if err != nil { + t.Error(err) + } + + err = dispatcher.publish(id, &payload) + if err != nil { + t.Error(err) + } + + _, err = dispatcher.subscribe(id) + if err == nil { + t.Error("error cannot be nil") + } + + err = dispatcher.start(10) + if err != nil { + t.Error(err) + } + + someID, err := uuid.NewV4() + if err != nil { + t.Error(err) + } + + _, err = dispatcher.subscribe(someID) + if err == nil { + t.Error("error cannot be nil") + } + + randomChan := make(chan interface{}) + err = dispatcher.unsubscribe(someID, randomChan) + if err == nil { + t.Error(err) + } + + err = dispatcher.unsubscribe(id, randomChan) + if err == nil { + t.Error(err) + } + + close(randomChan) + err = dispatcher.unsubscribe(id, randomChan) + if err == nil { + t.Error(err) + } +} + +func TestMux(t *testing.T) { + mux = nil + _, err := mux.Subscribe(uuid.UUID{}) + if err == nil { + t.Error("error cannot be nil") + } + + err = mux.Unsubscribe(uuid.UUID{}, nil) + if err == nil { + t.Error("error cannot be nil") + } + + err = mux.Publish(nil, nil) + if err == nil { + t.Error("error cannot be nil") + } + + _, err = mux.GetID() + if err == nil { + t.Error("error cannot be nil") + } + mux = cpyMux + + err = mux.Publish(nil, nil) + if err == nil { + t.Error("error cannot be nil") + } + + payload := "string" + id, err := uuid.NewV4() + if err != nil { + t.Error(err) + } + + err = mux.Publish([]uuid.UUID{id}, &payload) + if err != nil { + t.Error(err) + } + + _, err = mux.Subscribe(uuid.UUID{}) + if err == nil { + t.Error("error cannot be nil") + } + + _, err = mux.Subscribe(id) + if err == nil { + t.Error("error cannot be nil") + } +} + +func TestSubscribe(t *testing.T) { + itemID, err := mux.GetID() + if err != nil { + t.Fatal(err) + } + + var pipes []Pipe + for i := 0; i < 1000; i++ { + newPipe, err := mux.Subscribe(itemID) + if err != nil { + t.Error(err) + } + pipes = append(pipes, newPipe) + } + + for i := range pipes { + err := pipes[i].Release() + if err != nil { + t.Error(err) + } + } +} + +func TestPublish(t *testing.T) { + itemID, err := mux.GetID() + if err != nil { + t.Fatal(err) + } + + pipe, err := mux.Subscribe(itemID) + if err != nil { + t.Error(err) + } + + var wg sync.WaitGroup + wg.Add(1) + go func(wg *sync.WaitGroup) { + wg.Done() + for { + _, ok := <-pipe.C + if !ok { + pErr := pipe.Release() + if pErr != nil { + t.Error(pErr) + } + wg.Done() + return + } + } + }(&wg) + wg.Wait() + wg.Add(1) + mainPayload := "PAYLOAD" + for i := 0; i < 100; i++ { + errMux := mux.Publish([]uuid.UUID{itemID}, &mainPayload) + if errMux != nil { + t.Error(errMux) + } + } + + // Shut down dispatch system + err = Stop() + if err != nil { + t.Fatal(err) + } + wg.Wait() +} + +func BenchmarkSubscribe(b *testing.B) { + newID, err := mux.GetID() + if err != nil { + b.Error(err) + } + + for n := 0; n < b.N; n++ { + _, err := mux.Subscribe(newID) + if err != nil { + b.Error(err) + } + } +} diff --git a/dispatch/dispatch_types.go b/dispatch/dispatch_types.go new file mode 100644 index 00000000..b52bb42f --- /dev/null +++ b/dispatch/dispatch_types.go @@ -0,0 +1,88 @@ +package dispatch + +import ( + "sync" + "time" + + "github.com/gofrs/uuid" +) + +const ( + // DefaultJobBuffer defines a maxiumum amount of jobs allowed in channel + DefaultJobBuffer = 100 + + // DefaultMaxWorkers is the package default worker ceiling amount + DefaultMaxWorkers = 10 + + // DefaultHandshakeTimeout defines a workers max length of time to wait on a + // an unbuffered channel for a receiver before moving on to next route + DefaultHandshakeTimeout = 200 * time.Nanosecond + + errNotInitialised = "dispatcher not initialised" + errAlreadyStarted = "dispatcher already started" + errCannotShutdown = "dispatcher cannot shutdown, already stopped" + errShutdownRoutines = "dispatcher did not shutdown properly, routines failed to close" +) + +// dispatcher is our main in memory instance with a stop/start mtx below +var dispatcher *Dispatcher +var mtx sync.Mutex + +// Dispatcher defines an internal subsystem communication/change state publisher +type Dispatcher struct { + // routes refers to a subystem uuid ticket map with associated publish + // channels, a relayer will be given a unique id through its job channel, + // then publish the data across the full registered channels for that uuid. + // See relayer() method below. + routes map[uuid.UUID][]chan interface{} + + // rMtx protects the routes variable ensuring acceptable read/write access + rMtx sync.RWMutex + + // Persistent buffered job queue for relayers + jobs chan *job + + // Dynamic channel pool; returns an unbuffered channel for routes map + outbound sync.Pool + + // MaxWorkers defines max worker ceiling + maxWorkers int64 + + // Atomic values ----------------------- + // Worker counter + count int64 + // Dispatch status + running uint32 + + // Unbufferd shutdown chan, sync wg for ensuring concurrency when only + // dropping a single relayer routine + shutdown chan *sync.WaitGroup + + // Relayer shutdown tracking + wg sync.WaitGroup +} + +// job defines a relaying job associated with a ticket which allows routing to +// routines that require specific data +type job struct { + Data interface{} + ID uuid.UUID +} + +// Mux defines a new multiplexor for the dispatch system, these a generated +// per subsystem +type Mux struct { + // Reference to the main running dispatch service + d *Dispatcher + sync.RWMutex +} + +// Pipe defines an outbound object to the desired routine +type Pipe struct { + // Channel to get all our lovely informations + C chan interface{} + // ID to tracked system + id uuid.UUID + // Reference to multiplexor + m *Mux +} diff --git a/dispatch/mux.go b/dispatch/mux.go new file mode 100644 index 00000000..1c741e67 --- /dev/null +++ b/dispatch/mux.go @@ -0,0 +1,77 @@ +package dispatch + +import ( + "errors" + "reflect" + + "github.com/gofrs/uuid" +) + +// GetNewMux returns a new multiplexor to track subsystem updates +func GetNewMux() *Mux { + return &Mux{d: dispatcher} +} + +// Subscribe takes in a package defined signature element pointing to an ID set +// and returns the associated pipe +func (m *Mux) Subscribe(id uuid.UUID) (Pipe, error) { + if m == nil { + return Pipe{}, errors.New("mux is nil") + } + + if id == (uuid.UUID{}) { + return Pipe{}, errors.New("id not set") + } + + ch, err := m.d.subscribe(id) + if err != nil { + return Pipe{}, err + } + + return Pipe{C: ch, id: id, m: m}, nil +} + +// Unsubscribe returns channel to the pool for the full signature set +func (m *Mux) Unsubscribe(id uuid.UUID, ch chan interface{}) error { + if m == nil { + return errors.New("mux is nil") + } + return m.d.unsubscribe(id, ch) +} + +// Publish takes in a persistent memory address and dispatches changes to +// required pipes. Data should be of *type. +func (m *Mux) Publish(ids []uuid.UUID, data interface{}) error { + if m == nil { + return errors.New("mux is nil") + } + + if data == nil { + return errors.New("data payload is nil") + } + + cpy := reflect.ValueOf(data).Elem().Interface() + + for i := range ids { + // Create copy to not interfere with stored value + err := m.d.publish(ids[i], &cpy) + if err != nil { + return err + } + } + return nil +} + +// GetID gets a lovely new ID +func (m *Mux) GetID() (uuid.UUID, error) { + if m == nil { + return uuid.UUID{}, errors.New("mux is nil") + } + + return m.d.getNewID() +} + +// Release returns the channel to the communications pool to be reused +func (p *Pipe) Release() error { + return p.m.Unsubscribe(p.id, p.C) +} diff --git a/engine/engine.go b/engine/engine.go index c369be51..a35ac444 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -11,6 +11,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/currency" "github.com/thrasher-corp/gocryptotrader/currency/coinmarketcap" + "github.com/thrasher-corp/gocryptotrader/dispatch" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/request" log "github.com/thrasher-corp/gocryptotrader/logger" @@ -111,6 +112,7 @@ func ValidateSettings(b *Engine, s *Settings) { b.Settings.EnablePortfolioManager = s.EnablePortfolioManager b.Settings.EnableCoinmarketcapAnalysis = s.EnableCoinmarketcapAnalysis b.Settings.EnableDatabaseManager = s.EnableDatabaseManager + b.Settings.EnableDispatcher = s.EnableDispatcher // TO-DO: FIXME if flag.Lookup("grpc") != nil { @@ -203,6 +205,7 @@ func ValidateSettings(b *Engine, s *Settings) { } b.Settings.GlobalHTTPProxy = s.GlobalHTTPProxy + b.Settings.DispatchMaxWorkerAmount = s.DispatchMaxWorkerAmount } // PrintSettings returns the engine settings @@ -230,6 +233,8 @@ func PrintSettings(s *Settings) { log.Debugf(log.Global, "\t Enable orderbook syncing: %v", s.EnableOrderbookSyncing) log.Debugf(log.Global, "\t Enable websocket routine: %v\n", s.EnableWebsocketRoutine) log.Debugf(log.Global, "\t Enable NTP client: %v", s.EnableNTPClient) + log.Debugf(log.Global, "\t Enable dispatcher: %v", s.EnableDispatcher) + log.Debugf(log.Global, "\t Dispatch package max worker amount: %d", s.DispatchMaxWorkerAmount) log.Debugf(log.Global, "- FOREX SETTINGS:") log.Debugf(log.Global, "\t Enable currency conveter: %v", s.EnableCurrencyConverter) log.Debugf(log.Global, "\t Enable currency layer: %v", s.EnableCurrencyLayer) @@ -266,6 +271,12 @@ func (e *Engine) Start() error { } } + if e.Settings.EnableDispatcher { + if err := dispatch.Start(e.Settings.DispatchMaxWorkerAmount); err != nil { + log.Errorf(log.DispatchMgr, "Dispatcher unable to start: %v", err) + } + } + // Sets up internet connectivity monitor if e.Settings.EnableConnectivityMonitor { if err := e.ConnectionManager.Start(); err != nil { @@ -436,6 +447,12 @@ func (e *Engine) Stop() { } } + if dispatch.IsRunning() { + if err := dispatch.Stop(); err != nil { + log.Errorf(log.DispatchMgr, "Dispatch system unable to stop. Error: %v", err) + } + } + if !e.Settings.EnableDryRun { err := e.Config.SaveConfig(e.Settings.ConfigFile, false) if err != nil { diff --git a/engine/engine_types.go b/engine/engine_types.go index 42cffb37..0372df9a 100644 --- a/engine/engine_types.go +++ b/engine/engine_types.go @@ -61,4 +61,8 @@ type Settings struct { ExchangeHTTPTimeout time.Duration ExchangeHTTPUserAgent string ExchangeHTTPProxy string + + // Dispatch system settings + EnableDispatcher bool + DispatchMaxWorkerAmount int64 } diff --git a/engine/events_test.go b/engine/events_test.go index 9563d9cf..cc771af4 100644 --- a/engine/events_test.go +++ b/engine/events_test.go @@ -149,12 +149,6 @@ func TestProcessTicker(t *testing.T) { }, } - // this will throw an err with an unpopulated ticker - ticker.Tickers = nil - if r := e.processTicker(); r { - t.Error("unexpected result") - } - // now populate it with a 0 entry tick := ticker.Price{ Pair: currency.NewPair(currency.BTC, currency.USD), @@ -222,12 +216,6 @@ func TestProcessOrderbook(t *testing.T) { }, } - // this will throw an err with an unpopulated orderbook - orderbook.Orderbooks = nil - if r := e.processOrderbook(); r { - t.Error("unexpected result") - } - // now populate it with a 0 entry o := orderbook.Base{ Pair: currency.NewPair(currency.BTC, currency.USD), diff --git a/engine/helpers.go b/engine/helpers.go index b5865226..65b9822a 100644 --- a/engine/helpers.go +++ b/engine/helpers.go @@ -19,6 +19,7 @@ import ( "github.com/pquerna/otp/totp" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/dispatch" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" @@ -42,6 +43,7 @@ func GetSubsystemsStatus() map[string]bool { systems["grpc_proxy"] = Bot.Settings.EnableGRPCProxy systems["deprecated_rpc"] = Bot.Settings.EnableDeprecatedRPC systems["websocket_rpc"] = Bot.Settings.EnableWebsocketRPC + systems["dispatch"] = dispatch.IsRunning() return systems } @@ -106,6 +108,11 @@ func SetSubsystem(subsys string, enable bool) error { Bot.ExchangeCurrencyPairManager.Start() } Bot.ExchangeCurrencyPairManager.Stop() + case "dispatch": + if enable { + return dispatch.Start(Bot.Settings.DispatchMaxWorkerAmount) + } + return dispatch.Stop() } return errors.New("subsystem not found") } diff --git a/engine/routines.go b/engine/routines.go index bcbc6902..16320491 100644 --- a/engine/routines.go +++ b/engine/routines.go @@ -9,7 +9,6 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" - exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" "github.com/thrasher-corp/gocryptotrader/exchanges/stats" @@ -186,101 +185,6 @@ func relayWebsocketEvent(result interface{}, event, assetType, exchangeName stri } } -// TickerUpdaterRoutine fetches and updates the ticker for all enabled -// currency pairs and exchanges -func TickerUpdaterRoutine() { - log.Debugln(log.Ticker, "Starting ticker updater routine.") - var wg sync.WaitGroup - for { - wg.Add(len(Bot.Exchanges)) - for x := range Bot.Exchanges { - go func(x int, wg *sync.WaitGroup) { - defer wg.Done() - - if Bot.Exchanges[x] == nil || !Bot.Exchanges[x].SupportsREST() { - return - } - - exchangeName := Bot.Exchanges[x].GetName() - supportsBatching := Bot.Exchanges[x].SupportsRESTTickerBatchUpdates() - assetTypes := Bot.Exchanges[x].GetAssetTypes() - - processTicker := func(exch exchange.IBotExchange, update bool, c currency.Pair, assetType asset.Item) { - var result ticker.Price - var err error - if update { - result, err = exch.UpdateTicker(c, assetType) - } else { - result, err = exch.FetchTicker(c, assetType) - } - printTickerSummary(&result, c, assetType, exchangeName, err) - if err == nil { - if Bot.Config.RemoteControl.WebsocketRPC.Enabled { - relayWebsocketEvent(result, "ticker_update", assetType.String(), exchangeName) - } - } - } - - for y := range assetTypes { - enabledCurrencies := Bot.Exchanges[x].GetEnabledPairs(assetTypes[y]) - for z := range enabledCurrencies { - if supportsBatching && z > 0 { - processTicker(Bot.Exchanges[x], false, enabledCurrencies[z], assetTypes[y]) - continue - } - processTicker(Bot.Exchanges[x], true, enabledCurrencies[z], assetTypes[y]) - } - } - }(x, &wg) - } - wg.Wait() - log.Debugln(log.Ticker, "All enabled currency tickers fetched.") - time.Sleep(time.Second * 10) - } -} - -// OrderbookUpdaterRoutine fetches and updates the orderbooks for all enabled -// currency pairs and exchanges -func OrderbookUpdaterRoutine() { - log.Debugln(log.OrderBook, "Starting orderbook updater routine.") - var wg sync.WaitGroup - for { - wg.Add(len(Bot.Exchanges)) - for x := range Bot.Exchanges { - go func(x int, wg *sync.WaitGroup) { - defer wg.Done() - - if Bot.Exchanges[x] == nil || !Bot.Exchanges[x].SupportsREST() { - return - } - - exchangeName := Bot.Exchanges[x].GetName() - assetTypes := Bot.Exchanges[x].GetAssetTypes() - - processOrderbook := func(exch exchange.IBotExchange, c currency.Pair, assetType asset.Item) { - result, err := exch.UpdateOrderbook(c, assetType) - printOrderbookSummary(&result, c, assetType, exchangeName, err) - if err == nil { - if Bot.Config.RemoteControl.WebsocketRPC.Enabled { - relayWebsocketEvent(result, "orderbook_update", assetType.String(), exchangeName) - } - } - } - - for y := range assetTypes { - enabledCurrencies := Bot.Exchanges[x].GetEnabledPairs(assetTypes[y]) - for z := range enabledCurrencies { - processOrderbook(Bot.Exchanges[x], enabledCurrencies[z], assetTypes[y]) - } - } - }(x, &wg) - } - wg.Wait() - log.Debugln(log.OrderBook, "All enabled currency orderbooks fetched.") - time.Sleep(time.Second * 10) - } -} - // WebsocketRoutine Initial routine management system for websocket func WebsocketRoutine() { if Bot.Settings.Verbose { diff --git a/engine/rpcserver.go b/engine/rpcserver.go index 79d79975..4e6cd048 100644 --- a/engine/rpcserver.go +++ b/engine/rpcserver.go @@ -17,6 +17,8 @@ import ( "github.com/thrasher-corp/gocryptotrader/currency" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" + "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" + "github.com/thrasher-corp/gocryptotrader/exchanges/ticker" "github.com/thrasher-corp/gocryptotrader/gctrpc" "github.com/thrasher-corp/gocryptotrader/gctrpc/auth" log "github.com/thrasher-corp/gocryptotrader/logger" @@ -27,6 +29,13 @@ import ( "google.golang.org/grpc/metadata" ) +const ( + errExchangeNameUnset = "exchange name unset" + errCurrencyPairUnset = "currency pair unset" + errAssetTypeUnset = "asset type unset" + errDispatchSystem = "dispatch system offline" +) + // RPCServer struct type RPCServer struct{} @@ -953,5 +962,200 @@ func (s *RPCServer) DisableExchangePair(ctx context.Context, r *gctrpc.ExchangeP err = GetExchangeByName(r.Exchange).GetBase().CurrencyPairs.DisablePair( asset.Item(r.AssetType), p) return &gctrpc.GenericExchangeNameResponse{}, err - +} + +// GetOrderbookStream streams the requested updated orderbook +func (s *RPCServer) GetOrderbookStream(r *gctrpc.GetOrderbookStreamRequest, stream gctrpc.GoCryptoTrader_GetOrderbookStreamServer) error { + if r.Exchange == "" { + return errors.New(errExchangeNameUnset) + } + + if r.Pair.String() == "" { + return errors.New(errCurrencyPairUnset) + } + + if r.AssetType == "" { + return errors.New(errAssetTypeUnset) + } + + p := currency.NewPairFromStrings(r.Pair.Base, r.Pair.Quote) + + pipe, err := orderbook.SubscribeOrderbook(r.Exchange, p, asset.Item(r.AssetType)) + if err != nil { + return err + } + + defer pipe.Release() + + for { + data, ok := <-pipe.C + if !ok { + return errors.New(errDispatchSystem) + } + + ob := (*data.(*interface{})).(orderbook.Base) + var bids, asks []*gctrpc.OrderbookItem + for i := range ob.Bids { + bids = append(bids, &gctrpc.OrderbookItem{ + Amount: ob.Bids[i].Amount, + Price: ob.Bids[i].Price, + Id: ob.Bids[i].ID, + }) + } + for i := range ob.Asks { + asks = append(asks, &gctrpc.OrderbookItem{ + Amount: ob.Asks[i].Amount, + Price: ob.Asks[i].Price, + Id: ob.Asks[i].ID, + }) + } + err := stream.Send(&gctrpc.OrderbookResponse{ + Pair: &gctrpc.CurrencyPair{Base: ob.Pair.Base.String(), + Quote: ob.Pair.Quote.String()}, + Bids: bids, + Asks: asks, + AssetType: ob.AssetType.String(), + }) + if err != nil { + return err + } + } +} + +// GetExchangeOrderbookStream streams all orderbooks associated with an exchange +func (s *RPCServer) GetExchangeOrderbookStream(r *gctrpc.GetExchangeOrderbookStreamRequest, stream gctrpc.GoCryptoTrader_GetExchangeOrderbookStreamServer) error { + if r.Exchange == "" { + return errors.New(errExchangeNameUnset) + } + + pipe, err := orderbook.SubscribeToExchangeOrderbooks(r.Exchange) + if err != nil { + return err + } + + defer pipe.Release() + + for { + data, ok := <-pipe.C + if !ok { + return errors.New(errDispatchSystem) + } + + ob := (*data.(*interface{})).(orderbook.Base) + var bids, asks []*gctrpc.OrderbookItem + for i := range ob.Bids { + bids = append(bids, &gctrpc.OrderbookItem{ + Amount: ob.Bids[i].Amount, + Price: ob.Bids[i].Price, + Id: ob.Bids[i].ID, + }) + } + for i := range ob.Asks { + asks = append(asks, &gctrpc.OrderbookItem{ + Amount: ob.Asks[i].Amount, + Price: ob.Asks[i].Price, + Id: ob.Asks[i].ID, + }) + } + err := stream.Send(&gctrpc.OrderbookResponse{ + Pair: &gctrpc.CurrencyPair{Base: ob.Pair.Base.String(), + Quote: ob.Pair.Quote.String()}, + Bids: bids, + Asks: asks, + AssetType: ob.AssetType.String(), + }) + if err != nil { + return err + } + } +} + +// GetTickerStream streams the requested updated ticker +func (s *RPCServer) GetTickerStream(r *gctrpc.GetTickerStreamRequest, stream gctrpc.GoCryptoTrader_GetTickerStreamServer) error { + if r.Exchange == "" { + return errors.New(errExchangeNameUnset) + } + + if r.Pair.String() == "" { + return errors.New(errCurrencyPairUnset) + } + + if r.AssetType == "" { + return errors.New(errAssetTypeUnset) + } + + p := currency.NewPairFromStrings(r.Pair.Base, r.Pair.Quote) + + pipe, err := ticker.SubscribeTicker(r.Exchange, p, asset.Item(r.AssetType)) + if err != nil { + return err + } + + defer pipe.Release() + + for { + data, ok := <-pipe.C + if !ok { + return errors.New(errDispatchSystem) + } + t := (*data.(*interface{})).(ticker.Price) + + err := stream.Send(&gctrpc.TickerResponse{ + Pair: &gctrpc.CurrencyPair{ + Base: t.Pair.Base.String(), + Quote: t.Pair.Quote.String(), + Delimiter: t.Pair.Delimiter}, + LastUpdated: t.LastUpdated.Unix(), + Last: t.Last, + High: t.High, + Low: t.Low, + Bid: t.Bid, + Ask: t.Ask, + Volume: t.Volume, + PriceAth: t.PriceATH, + }) + if err != nil { + return err + } + } +} + +// GetExchangeTickerStream streams all tickers associated with an exchange +func (s *RPCServer) GetExchangeTickerStream(r *gctrpc.GetExchangeTickerStreamRequest, stream gctrpc.GoCryptoTrader_GetExchangeTickerStreamServer) error { + if r.Exchange == "" { + return errors.New(errExchangeNameUnset) + } + + pipe, err := ticker.SubscribeToExchangeTickers(r.Exchange) + if err != nil { + return err + } + + defer pipe.Release() + + for { + data, ok := <-pipe.C + if !ok { + return errors.New(errDispatchSystem) + } + t := (*data.(*interface{})).(ticker.Price) + + err := stream.Send(&gctrpc.TickerResponse{ + Pair: &gctrpc.CurrencyPair{ + Base: t.Pair.Base.String(), + Quote: t.Pair.Quote.String(), + Delimiter: t.Pair.Delimiter}, + LastUpdated: t.LastUpdated.Unix(), + Last: t.Last, + High: t.High, + Low: t.Low, + Bid: t.Bid, + Ask: t.Ask, + Volume: t.Volume, + PriceAth: t.PriceATH, + }) + if err != nil { + return err + } + } } diff --git a/exchanges/anx/anx_test.go b/exchanges/anx/anx_test.go index a583247c..85519f1d 100644 --- a/exchanges/anx/anx_test.go +++ b/exchanges/anx/anx_test.go @@ -387,7 +387,7 @@ func TestUpdateOrderbook(t *testing.T) { Quote: currency.USD} _, err := a.UpdateOrderbook(q, "spot") - if err != nil { - t.Fatalf("Update for orderbook failed: %v", err) + if err == nil { + t.Fatalf("error cannot be nil as the endpoint returns no orderbook information") } } diff --git a/exchanges/binance/binance_websocket.go b/exchanges/binance/binance_websocket.go index ec48658b..72715f16 100644 --- a/exchanges/binance/binance_websocket.go +++ b/exchanges/binance/binance_websocket.go @@ -247,6 +247,7 @@ func (b *Binance) SeedLocalCache(p currency.Pair) error { newOrderBook.LastUpdated = time.Unix(orderbookNew.LastUpdateID, 0) newOrderBook.Pair = p newOrderBook.AssetType = asset.Spot + newOrderBook.ExchangeName = b.GetName() return b.Websocket.Orderbook.LoadSnapshot(&newOrderBook) } diff --git a/exchanges/bitfinex/bitfinex_websocket.go b/exchanges/bitfinex/bitfinex_websocket.go index b9b5f569..b0381e36 100644 --- a/exchanges/bitfinex/bitfinex_websocket.go +++ b/exchanges/bitfinex/bitfinex_websocket.go @@ -482,6 +482,8 @@ func (b *Bitfinex) WsInsertSnapshot(p currency.Pair, assetType asset.Item, books newOrderBook.AssetType = assetType newOrderBook.Bids = bid newOrderBook.Pair = p + newOrderBook.ExchangeName = b.GetName() + err := b.Websocket.Orderbook.LoadSnapshot(&newOrderBook) if err != nil { return fmt.Errorf("bitfinex.go error - %s", err) diff --git a/exchanges/bitmex/bitmex_websocket.go b/exchanges/bitmex/bitmex_websocket.go index 3524550c..0c82fffc 100644 --- a/exchanges/bitmex/bitmex_websocket.go +++ b/exchanges/bitmex/bitmex_websocket.go @@ -361,6 +361,8 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPai newOrderBook.Bids = bids newOrderBook.AssetType = assetType newOrderBook.Pair = currencyPair + newOrderBook.ExchangeName = b.GetName() + err := b.Websocket.Orderbook.LoadSnapshot(&newOrderBook) if err != nil { return fmt.Errorf("bitmex_websocket.go process orderbook error - %s", diff --git a/exchanges/bitstamp/bitstamp_websocket.go b/exchanges/bitstamp/bitstamp_websocket.go index 5260dfd2..67d6c619 100644 --- a/exchanges/bitstamp/bitstamp_websocket.go +++ b/exchanges/bitstamp/bitstamp_websocket.go @@ -247,6 +247,7 @@ func (b *Bitstamp) seedOrderBook() error { newOrderBook.Bids = bids newOrderBook.Pair = p[x] newOrderBook.AssetType = asset.Spot + newOrderBook.ExchangeName = b.GetName() err = b.Websocket.Orderbook.LoadSnapshot(&newOrderBook) if err != nil { diff --git a/exchanges/coinbasepro/coinbasepro_websocket.go b/exchanges/coinbasepro/coinbasepro_websocket.go index ff34058e..f0a9764e 100644 --- a/exchanges/coinbasepro/coinbasepro_websocket.go +++ b/exchanges/coinbasepro/coinbasepro_websocket.go @@ -216,6 +216,7 @@ func (c *CoinbasePro) ProcessSnapshot(snapshot *WebsocketOrderbookSnapshot) erro pair := currency.NewPairFromString(snapshot.ProductID) base.AssetType = asset.Spot base.Pair = pair + base.ExchangeName = c.GetName() err := c.Websocket.Orderbook.LoadSnapshot(&base) if err != nil { diff --git a/exchanges/coinut/coinut_websocket.go b/exchanges/coinut/coinut_websocket.go index d12e03aa..ecb067c9 100644 --- a/exchanges/coinut/coinut_websocket.go +++ b/exchanges/coinut/coinut_websocket.go @@ -288,6 +288,7 @@ func (c *COINUT) WsProcessOrderbookSnapshot(ob *WsOrderbookSnapshot) error { c.GetPairFormat(asset.Spot, true), ) newOrderBook.AssetType = asset.Spot + newOrderBook.ExchangeName = c.GetName() return c.Websocket.Orderbook.LoadSnapshot(&newOrderBook) } diff --git a/exchanges/gateio/gateio_websocket.go b/exchanges/gateio/gateio_websocket.go index 8bcb8b76..fe04587f 100644 --- a/exchanges/gateio/gateio_websocket.go +++ b/exchanges/gateio/gateio_websocket.go @@ -237,6 +237,7 @@ func (g *Gateio) WsHandleData() { newOrderBook.Bids = bids newOrderBook.AssetType = asset.Spot newOrderBook.Pair = currency.NewPairFromString(c) + newOrderBook.ExchangeName = g.GetName() err = g.Websocket.Orderbook.LoadSnapshot(&newOrderBook) if err != nil { diff --git a/exchanges/gemini/gemini_websocket.go b/exchanges/gemini/gemini_websocket.go index 9d47d9c2..42a2392e 100644 --- a/exchanges/gemini/gemini_websocket.go +++ b/exchanges/gemini/gemini_websocket.go @@ -282,6 +282,7 @@ func (g *Gemini) wsProcessUpdate(result WsMarketUpdateResponse, pair currency.Pa newOrderBook.Bids = bids newOrderBook.AssetType = asset.Spot newOrderBook.Pair = pair + newOrderBook.ExchangeName = g.GetName() err := g.Websocket.Orderbook.LoadSnapshot(&newOrderBook) if err != nil { g.Websocket.DataHandler <- err diff --git a/exchanges/hitbtc/hitbtc_websocket.go b/exchanges/hitbtc/hitbtc_websocket.go index 5cfda89a..f8cfe0c3 100644 --- a/exchanges/hitbtc/hitbtc_websocket.go +++ b/exchanges/hitbtc/hitbtc_websocket.go @@ -250,6 +250,7 @@ func (h *HitBTC) WsProcessOrderbookSnapshot(ob WsOrderbook) error { newOrderBook.Bids = bids newOrderBook.AssetType = asset.Spot newOrderBook.Pair = p + newOrderBook.ExchangeName = h.GetName() err := h.Websocket.Orderbook.LoadSnapshot(&newOrderBook) if err != nil { diff --git a/exchanges/orderbook/orderbook.go b/exchanges/orderbook/orderbook.go index 8c471e91..2bdb4567 100644 --- a/exchanges/orderbook/orderbook.go +++ b/exchanges/orderbook/orderbook.go @@ -2,235 +2,259 @@ package orderbook import ( "errors" + "fmt" "sort" - "sync" + "strings" "time" + "github.com/gofrs/uuid" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/dispatch" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) -// const values for orderbook package -const ( - errExchangeOrderbookNotFound = "orderbook for exchange does not exist" - errPairNotSet = "orderbook currency pair not set" - errAssetTypeNotSet = "orderbook asset type not set" - errBaseCurrencyNotFound = "orderbook base currency not found" - errQuoteCurrencyNotFound = "orderbook quote currency not found" -) - -// Vars for the orderbook package -var ( - Orderbooks []Orderbook - m sync.Mutex -) - -// Item stores the amount and price values -type Item struct { - Amount float64 - Price float64 - ID int64 +// Get checks and returns the orderbook given an exchange name and currency pair +// if it exists +func Get(exchange string, p currency.Pair, a asset.Item) (Base, error) { + o, err := service.Retrieve(exchange, p, a) + if err != nil { + return Base{}, err + } + return *o, nil } -// Base holds the fields for the orderbook base -type Base struct { - Pair currency.Pair `json:"pair"` - Bids []Item `json:"bids"` - Asks []Item `json:"asks"` - LastUpdated time.Time `json:"lastUpdated"` - AssetType asset.Item `json:"assetType"` - ExchangeName string `json:"exchangeName"` +// SubscribeOrderbook subcribes to an orderbook and returns a communication +// channel to stream orderbook data updates +func SubscribeOrderbook(exchange string, p currency.Pair, a asset.Item) (dispatch.Pipe, error) { + exchange = strings.ToLower(exchange) + service.RLock() + defer service.RUnlock() + book, ok := service.Books[exchange][p.Base.Item][p.Quote.Item][a] + if !ok { + return dispatch.Pipe{}, fmt.Errorf("orderbook item not found for %s %s %s", + exchange, + p, + a) + } + + return service.mux.Subscribe(book.Main) } -// Orderbook holds the orderbook information for a currency pair and type -type Orderbook struct { - Orderbook map[*currency.Item]map[*currency.Item]map[asset.Item]Base - ExchangeName string +// SubscribeToExchangeOrderbooks subcribes to all orderbooks on an exchange +func SubscribeToExchangeOrderbooks(exchange string) (dispatch.Pipe, error) { + exchange = strings.ToLower(exchange) + service.RLock() + defer service.RUnlock() + id, ok := service.Exchange[exchange] + if !ok { + return dispatch.Pipe{}, fmt.Errorf("%s exchange orderbooks not found", + exchange) + } + + return service.mux.Subscribe(id) } -type byOBPrice []Item +// Update stores orderbook data +func (s *Service) Update(b *Base) error { + var ids []uuid.UUID -func (a byOBPrice) Len() int { return len(a) } -func (a byOBPrice) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a byOBPrice) Less(i, j int) bool { return a[i].Price < a[j].Price } - -// Verify ensures that the orderbook items are correctly sorted -// Bids should always go from a high price to a low price and -// asks should always go from a low price to a higher price -func (o *Base) Verify() { - var lastPrice float64 - var sortBids, sortAsks bool - for x := range o.Bids { - if lastPrice != 0 && o.Bids[x].Price >= lastPrice { - sortBids = true - break + s.Lock() + switch { + case s.Books[b.ExchangeName] == nil: + s.Books[b.ExchangeName] = make(map[*currency.Item]map[*currency.Item]map[asset.Item]*Book) + s.Books[b.ExchangeName][b.Pair.Base.Item] = make(map[*currency.Item]map[asset.Item]*Book) + s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item] = make(map[asset.Item]*Book) + err := s.SetNewData(b) + if err != nil { + s.Unlock() + return err } - lastPrice = o.Bids[x].Price - } - lastPrice = 0 - for x := range o.Asks { - if lastPrice != 0 && o.Asks[x].Price <= lastPrice { - sortAsks = true - break + case s.Books[b.ExchangeName][b.Pair.Base.Item] == nil: + s.Books[b.ExchangeName][b.Pair.Base.Item] = make(map[*currency.Item]map[asset.Item]*Book) + s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item] = make(map[asset.Item]*Book) + err := s.SetNewData(b) + if err != nil { + s.Unlock() + return err } - lastPrice = o.Asks[x].Price + + case s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item] == nil: + s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item] = make(map[asset.Item]*Book) + err := s.SetNewData(b) + if err != nil { + s.Unlock() + return err + } + + case s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item][b.AssetType] == nil: + err := s.SetNewData(b) + if err != nil { + s.Unlock() + return err + } + + default: + s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item][b.AssetType].b.Bids = b.Bids + s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item][b.AssetType].b.Asks = b.Asks + s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item][b.AssetType].b.LastUpdated = b.LastUpdated + ids = s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item][b.AssetType].Assoc + ids = append(ids, s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item][b.AssetType].Main) + } + s.Unlock() + return s.mux.Publish(ids, b) +} + +// SetNewData sets new data +func (s *Service) SetNewData(b *Base) error { + ids, err := s.GetAssociations(b) + if err != nil { + return err + } + singleID, err := s.mux.GetID() + if err != nil { + return err } - if sortBids { - sort.Sort(sort.Reverse(byOBPrice(o.Bids))) + s.Books[b.ExchangeName][b.Pair.Base.Item][b.Pair.Quote.Item][b.AssetType] = &Book{b: b, + Main: singleID, + Assoc: ids} + return nil +} + +// GetAssociations links a singular book with it's dispatch associations +func (s *Service) GetAssociations(b *Base) ([]uuid.UUID, error) { + if b == nil { + return nil, errors.New("orderbook is nil") } - if sortAsks { - sort.Sort((byOBPrice(o.Asks))) + var ids []uuid.UUID + exchangeID, ok := s.Exchange[b.ExchangeName] + if !ok { + var err error + exchangeID, err = s.mux.GetID() + if err != nil { + return nil, err + } + s.Exchange[b.ExchangeName] = exchangeID } + ids = append(ids, exchangeID) + return ids, nil +} + +// Retrieve gets orderbook data from the slice +func (s *Service) Retrieve(exchange string, p currency.Pair, a asset.Item) (*Base, error) { + exchange = strings.ToLower(exchange) + s.RLock() + defer s.RUnlock() + if s.Books[exchange] == nil { + return nil, fmt.Errorf("no orderbooks for %s exchange", exchange) + } + + if s.Books[exchange][p.Base.Item] == nil { + return nil, fmt.Errorf("no orderbooks associated with base currency %s", + p.Base) + } + + if s.Books[exchange][p.Base.Item][p.Quote.Item] == nil { + return nil, fmt.Errorf("no orderbooks associated with quote currency %s", + p.Quote) + } + + if s.Books[exchange][p.Base.Item][p.Quote.Item][a] == nil { + return nil, fmt.Errorf("no orderbooks associated with asset type %s", + a) + } + + return s.Books[exchange][p.Base.Item][p.Quote.Item][a].b, nil } // TotalBidsAmount returns the total amount of bids and the total orderbook // bids value -func (o *Base) TotalBidsAmount() (amountCollated, total float64) { - for _, x := range o.Bids { - amountCollated += x.Amount - total += x.Amount * x.Price +func (b *Base) TotalBidsAmount() (amountCollated, total float64) { + for x := range b.Bids { + amountCollated += b.Bids[x].Amount + total += b.Bids[x].Amount * b.Bids[x].Price } return amountCollated, total } // TotalAsksAmount returns the total amount of asks and the total orderbook // asks value -func (o *Base) TotalAsksAmount() (amountCollated, total float64) { - for _, x := range o.Asks { - amountCollated += x.Amount - total += x.Amount * x.Price +func (b *Base) TotalAsksAmount() (amountCollated, total float64) { + for y := range b.Asks { + amountCollated += b.Asks[y].Amount + total += b.Asks[y].Amount * b.Asks[y].Price } return amountCollated, total } // Update updates the bids and asks -func (o *Base) Update(bids, asks []Item) { - o.Bids = bids - o.Asks = asks - o.LastUpdated = time.Now() +func (b *Base) Update(bids, asks []Item) { + b.Bids = bids + b.Asks = asks + b.LastUpdated = time.Now() } -// Get checks and returns the orderbook given an exchange name and currency pair -// if it exists -func Get(exchange string, p currency.Pair, orderbookType asset.Item) (Base, error) { - orderbook, err := GetByExchange(exchange) - if err != nil { - return Base{}, err - } - - if !BaseCurrencyExists(exchange, p.Base) { - return Base{}, errors.New(errBaseCurrencyNotFound) - } - - if !QuoteCurrencyExists(exchange, p) { - return Base{}, errors.New(errQuoteCurrencyNotFound) - } - - return orderbook.Orderbook[p.Base.Item][p.Quote.Item][orderbookType], nil -} - -// GetByExchange returns an exchange orderbook -func GetByExchange(exchange string) (*Orderbook, error) { - m.Lock() - defer m.Unlock() - for x := range Orderbooks { - if Orderbooks[x].ExchangeName == exchange { - return &Orderbooks[x], nil +// Verify ensures that the orderbook items are correctly sorted +// Bids should always go from a high price to a low price and +// asks should always go from a low price to a higher price +func (b *Base) Verify() { + var lastPrice float64 + var sortBids, sortAsks bool + for x := range b.Bids { + if lastPrice != 0 && b.Bids[x].Price >= lastPrice { + sortBids = true + break } + lastPrice = b.Bids[x].Price } - return nil, errors.New(errExchangeOrderbookNotFound) -} -// BaseCurrencyExists checks to see if the base currency of the orderbook map -// exists -func BaseCurrencyExists(exchange string, currency currency.Code) bool { - m.Lock() - defer m.Unlock() - for _, y := range Orderbooks { - if y.ExchangeName == exchange { - if _, ok := y.Orderbook[currency.Item]; ok { - return true - } + lastPrice = 0 + for x := range b.Asks { + if lastPrice != 0 && b.Asks[x].Price <= lastPrice { + sortAsks = true + break } + lastPrice = b.Asks[x].Price } - return false -} -// QuoteCurrencyExists checks to see if the quote currency of the orderbook -// map exists -func QuoteCurrencyExists(exchange string, p currency.Pair) bool { - m.Lock() - defer m.Unlock() - for _, y := range Orderbooks { - if y.ExchangeName == exchange { - if _, ok := y.Orderbook[p.Base.Item]; ok { - if _, ok := y.Orderbook[p.Base.Item][p.Quote.Item]; ok { - return true - } - } - } + if sortBids { + sort.Sort(sort.Reverse(byOBPrice(b.Bids))) } - return false -} -// CreateNewOrderbook creates a new orderbook -func CreateNewOrderbook(exchangeName string, orderbookNew *Base, orderbookType asset.Item) *Orderbook { - m.Lock() - defer m.Unlock() - orderbook := Orderbook{} - orderbook.ExchangeName = exchangeName - orderbook.Orderbook = make(map[*currency.Item]map[*currency.Item]map[asset.Item]Base) - a := make(map[*currency.Item]map[asset.Item]Base) - b := make(map[asset.Item]Base) - b[orderbookType] = *orderbookNew - a[orderbookNew.Pair.Quote.Item] = b - orderbook.Orderbook[orderbookNew.Pair.Base.Item] = a - Orderbooks = append(Orderbooks, orderbook) - return &orderbook + if sortAsks { + sort.Sort((byOBPrice(b.Asks))) + } } // Process processes incoming orderbooks, creating or updating the orderbook // list -func (o *Base) Process() error { - if o.Pair.IsEmpty() { +func (b *Base) Process() error { + if b.ExchangeName == "" { + return errors.New(errExchangeNameUnset) + } + + b.ExchangeName = strings.ToLower(b.ExchangeName) + + if b.Pair.IsEmpty() { return errors.New(errPairNotSet) } - if o.AssetType == "" { + if b.AssetType.String() == "" { return errors.New(errAssetTypeNotSet) } - if o.LastUpdated.IsZero() { - o.LastUpdated = time.Now() + if len(b.Asks) == 0 && len(b.Bids) == 0 { + return errors.New(errNoOrderbook) } - o.Verify() - - orderbook, err := GetByExchange(o.ExchangeName) - if err != nil { - CreateNewOrderbook(o.ExchangeName, o, o.AssetType) - return nil + if b.LastUpdated.IsZero() { + b.LastUpdated = time.Now() } - if BaseCurrencyExists(o.ExchangeName, o.Pair.Base) { - m.Lock() - a := make(map[asset.Item]Base) - a[o.AssetType] = *o - orderbook.Orderbook[o.Pair.Base.Item][o.Pair.Quote.Item] = a - m.Unlock() - return nil - } + b.Verify() - m.Lock() - a := make(map[*currency.Item]map[asset.Item]Base) - b := make(map[asset.Item]Base) - b[o.AssetType] = *o - a[o.Pair.Quote.Item] = b - orderbook.Orderbook[o.Pair.Base.Item] = a - m.Unlock() - return nil + return service.Update(b) } diff --git a/exchanges/orderbook/orderbook_test.go b/exchanges/orderbook/orderbook_test.go index 4944a504..03db6595 100644 --- a/exchanges/orderbook/orderbook_test.go +++ b/exchanges/orderbook/orderbook_test.go @@ -1,16 +1,139 @@ package orderbook import ( + "log" "math/rand" + "os" "strconv" "sync" "testing" "time" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/dispatch" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) +func TestMain(m *testing.M) { + err := dispatch.Start(1) + if err != nil { + log.Fatal(err) + } + + cpyMux = service.mux + + os.Exit(m.Run()) +} + +var cpyMux *dispatch.Mux + +func TestSubscribeOrderbook(t *testing.T) { + _, err := SubscribeOrderbook("", currency.Pair{}, asset.Item("")) + if err == nil { + t.Error("error cannot be nil") + } + + p := currency.NewPair(currency.BTC, currency.USD) + + b := Base{ + Pair: p, + AssetType: asset.Spot, + } + + err = b.Process() + if err == nil { + t.Error("error cannot be nil") + } + + b.ExchangeName = "SubscribeOBTest" + + err = b.Process() + if err == nil { + t.Error("error cannot be nil") + } + + b.Bids = []Item{{}} + + err = b.Process() + if err != nil { + t.Error("test failed - process error", err) + } + + _, err = SubscribeOrderbook("SubscribeOBTest", p, asset.Spot) + if err != nil { + t.Error("error cannot be nil") + } + + // process redundant update + err = b.Process() + if err != nil { + t.Error("test failed - process error", err) + } +} + +func TestUpdateBooks(t *testing.T) { + p := currency.NewPair(currency.BTC, currency.USD) + + b := Base{ + Pair: p, + AssetType: asset.Spot, + ExchangeName: "UpdateTest", + } + + service.mux = nil + + err := service.Update(&b) + if err == nil { + t.Error("error cannot be nil") + } + + b.Pair.Base = currency.CYC + err = service.Update(&b) + if err == nil { + t.Error("error cannot be nil") + } + + b.Pair.Quote = currency.ENAU + err = service.Update(&b) + if err == nil { + t.Error("error cannot be nil") + } + + b.AssetType = "unicorns" + err = service.Update(&b) + if err == nil { + t.Error("error cannot be nil") + } + + service.mux = cpyMux +} + +func TestSubscribeToExchangeOrderbooks(t *testing.T) { + _, err := SubscribeToExchangeOrderbooks("") + if err == nil { + t.Error("error cannot be nil") + } + + p := currency.NewPair(currency.BTC, currency.USD) + + b := Base{ + Pair: p, + AssetType: asset.Spot, + ExchangeName: "SubscribeToExchangeOrderbooks", + Bids: []Item{{}}, + } + + err = b.Process() + if err != nil { + t.Error("test failed:", err) + } + + _, err = SubscribeToExchangeOrderbooks("SubscribeToExchangeOrderbooks") + if err != nil { + t.Error(err) + } +} + func TestVerify(t *testing.T) { t.Parallel() b := Base{ @@ -95,13 +218,18 @@ func TestUpdate(t *testing.T) { func TestGetOrderbook(t *testing.T) { c := currency.NewPairFromStrings("BTC", "USD") - base := Base{ - Pair: c, - Asks: []Item{{Price: 100, Amount: 10}}, - Bids: []Item{{Price: 200, Amount: 10}}, + base := &Base{ + Pair: c, + Asks: []Item{{Price: 100, Amount: 10}}, + Bids: []Item{{Price: 200, Amount: 10}}, + ExchangeName: "Exchange", + AssetType: asset.Spot, } - CreateNewOrderbook("Exchange", &base, asset.Spot) + err := base.Process() + if err != nil { + t.Fatal(err) + } result, err := Get("Exchange", c, asset.Spot) if err != nil { @@ -128,83 +256,37 @@ func TestGetOrderbook(t *testing.T) { if err == nil { t.Fatal("Test failed. TestGetOrderbook retrieved non-existent orderbook using invalid second currency") } -} -func TestGetOrderbookByExchange(t *testing.T) { - currency := currency.NewPairFromStrings("BTC", "USD") - base := Base{ - Pair: currency, - Asks: []Item{{Price: 100, Amount: 10}}, - Bids: []Item{{Price: 200, Amount: 10}}, - } - - CreateNewOrderbook("Exchange", &base, asset.Spot) - - _, err := GetByExchange("Exchange") + base.Pair = newCurrency + err = base.Process() if err != nil { - t.Fatalf("Test failed. TestGetOrderbookByExchange failed to get orderbook. Error %s", - err) + t.Error(err) } - _, err = GetByExchange("nonexistent") + _, err = Get("Exchange", newCurrency, "meowCats") if err == nil { - t.Fatal("Test failed. TestGetOrderbookByExchange retrieved non-existent orderbook") - } -} - -func TestFirstCurrencyExists(t *testing.T) { - c := currency.NewPairFromStrings("BTC", "AUD") - base := Base{ - Pair: c, - Asks: []Item{{Price: 100, Amount: 10}}, - Bids: []Item{{Price: 200, Amount: 10}}, - } - - CreateNewOrderbook("Exchange", &base, asset.Spot) - - if !BaseCurrencyExists("Exchange", c.Base) { - t.Fatal("Test failed. TestFirstCurrencyExists expected first currency doesn't exist") - } - - var item = currency.NewCode("blah") - if BaseCurrencyExists("Exchange", item) { - t.Fatal("Test failed. TestFirstCurrencyExists unexpected first currency exists") - } -} - -func TestSecondCurrencyExists(t *testing.T) { - c := currency.NewPairFromStrings("BTC", "USD") - base := Base{ - Pair: c, - Asks: []Item{{Price: 100, Amount: 10}}, - Bids: []Item{{Price: 200, Amount: 10}}, - } - - CreateNewOrderbook("Exchange", &base, asset.Spot) - - if !QuoteCurrencyExists("Exchange", c) { - t.Fatal("Test failed. TestSecondCurrencyExists expected first currency doesn't exist") - } - - c.Quote = currency.NewCode("blah") - if QuoteCurrencyExists("Exchange", c) { - t.Fatal("Test failed. TestSecondCurrencyExists unexpected first currency exists") + t.Error("error cannot be nil") } } func TestCreateNewOrderbook(t *testing.T) { c := currency.NewPairFromStrings("BTC", "USD") - base := Base{ - Pair: c, - Asks: []Item{{Price: 100, Amount: 10}}, - Bids: []Item{{Price: 200, Amount: 10}}, + base := &Base{ + Pair: c, + Asks: []Item{{Price: 100, Amount: 10}}, + Bids: []Item{{Price: 200, Amount: 10}}, + ExchangeName: "testCreateNewOrderbook", + AssetType: asset.Spot, } - CreateNewOrderbook("Exchange", &base, asset.Spot) - - result, err := Get("Exchange", c, asset.Spot) + err := base.Process() if err != nil { - t.Fatal("Test failed. TestCreateNewOrderbook failed to create new orderbook") + t.Fatal(err) + } + + result, err := Get("testCreateNewOrderbook", c, asset.Spot) + if err != nil { + t.Fatal("Test failed. TestCreateNewOrderbook failed to create new orderbook", err) } if !result.Pair.Equal(c) { @@ -223,12 +305,11 @@ func TestCreateNewOrderbook(t *testing.T) { } func TestProcessOrderbook(t *testing.T) { - Orderbooks = []Orderbook{} c := currency.NewPairFromStrings("BTC", "USD") base := Base{ Asks: []Item{{Price: 100, Amount: 10}}, Bids: []Item{{Price: 200, Amount: 10}}, - ExchangeName: "Exchange", + ExchangeName: "ProcessOrderbook", } // test for empty pair @@ -251,7 +332,7 @@ func TestProcessOrderbook(t *testing.T) { if err != nil { t.Error("unexpcted result: ", err) } - result, err := Get("Exchange", c, asset.Spot) + result, err := Get("ProcessOrderbook", c, asset.Spot) if err != nil { t.Fatal("Test failed. TestProcessOrderbook failed to create new orderbook") } @@ -266,7 +347,7 @@ func TestProcessOrderbook(t *testing.T) { if err != nil { t.Error("Test Failed - Process() error", err) } - result, err = Get("Exchange", c, asset.Spot) + result, err = Get("ProcessOrderbook", c, asset.Spot) if err != nil { t.Fatal("Test failed. TestProcessOrderbook failed to retrieve new orderbook") } @@ -281,7 +362,7 @@ func TestProcessOrderbook(t *testing.T) { if err != nil { t.Error("Test Failed - Process() error", err) } - result, err = Get("Exchange", c, asset.Spot) + result, err = Get("ProcessOrderbook", c, asset.Spot) if err != nil { t.Fatal("Test failed. TestProcessOrderbook failed to retrieve new orderbook") } @@ -296,7 +377,7 @@ func TestProcessOrderbook(t *testing.T) { t.Error("Test Failed - Process() error", err) } - result, err = Get("Exchange", c, "monthly") + result, err = Get("ProcessOrderbook", c, "monthly") if err != nil { t.Fatal("Test failed. TestProcessOrderbook failed to retrieve new orderbook") } @@ -408,3 +489,17 @@ func TestProcessOrderbook(t *testing.T) { wg.Wait() } + +func TestSetNewData(t *testing.T) { + err := service.SetNewData(nil) + if err == nil { + t.Error("error cannot be nil ") + } +} + +func TestGetAssociations(t *testing.T) { + _, err := service.GetAssociations(nil) + if err == nil { + t.Error("error cannot be nil ") + } +} diff --git a/exchanges/orderbook/orderbook_types.go b/exchanges/orderbook/orderbook_types.go new file mode 100644 index 00000000..56260dbe --- /dev/null +++ b/exchanges/orderbook/orderbook_types.go @@ -0,0 +1,69 @@ +package orderbook + +import ( + "sync" + "time" + + "github.com/gofrs/uuid" + "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/dispatch" + "github.com/thrasher-corp/gocryptotrader/exchanges/asset" +) + +// const values for orderbook package +const ( + errExchangeNameUnset = "orderbook exchange name not set" + errPairNotSet = "orderbook currency pair not set" + errAssetTypeNotSet = "orderbook asset type not set" + errNoOrderbook = "orderbook bids and asks are empty" +) + +// Vars for the orderbook package +var ( + service *Service +) + +func init() { + service = new(Service) + service.mux = dispatch.GetNewMux() + service.Books = make(map[string]map[*currency.Item]map[*currency.Item]map[asset.Item]*Book) + service.Exchange = make(map[string]uuid.UUID) +} + +// Book defines an orderbook with its links to different dispatch outputs +type Book struct { + b *Base + Main uuid.UUID + Assoc []uuid.UUID +} + +// Service holds orderbook information for each individual exchange +type Service struct { + Books map[string]map[*currency.Item]map[*currency.Item]map[asset.Item]*Book + Exchange map[string]uuid.UUID + mux *dispatch.Mux + sync.RWMutex +} + +// Item stores the amount and price values +type Item struct { + Amount float64 + Price float64 + ID int64 +} + +// Base holds the fields for the orderbook base +type Base struct { + Pair currency.Pair `json:"pair"` + Bids []Item `json:"bids"` + Asks []Item `json:"asks"` + LastUpdated time.Time `json:"lastUpdated"` + AssetType asset.Item `json:"assetType"` + ExchangeName string `json:"exchangeName"` +} + +type byOBPrice []Item + +func (a byOBPrice) Len() int { return len(a) } +func (a byOBPrice) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a byOBPrice) Less(i, j int) bool { return a[i].Price < a[j].Price } diff --git a/exchanges/poloniex/poloniex_websocket.go b/exchanges/poloniex/poloniex_websocket.go index 50962417..79008dda 100644 --- a/exchanges/poloniex/poloniex_websocket.go +++ b/exchanges/poloniex/poloniex_websocket.go @@ -329,6 +329,7 @@ func (p *Poloniex) WsProcessOrderbookSnapshot(ob []interface{}, symbol string) e newOrderBook.Bids = bids newOrderBook.AssetType = asset.Spot newOrderBook.Pair = currency.NewPairFromString(symbol) + newOrderBook.ExchangeName = p.GetName() return p.Websocket.Orderbook.LoadSnapshot(&newOrderBook) } diff --git a/exchanges/ticker/ticker.go b/exchanges/ticker/ticker.go index 4087f31d..8b77f602 100644 --- a/exchanges/ticker/ticker.go +++ b/exchanges/ticker/ticker.go @@ -3,191 +3,205 @@ package ticker import ( "errors" "fmt" - "strconv" "strings" - "sync" "time" + "github.com/gofrs/uuid" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/dispatch" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) -// const values for the ticker package -const ( - errExchangeTickerNotFound = "ticker for exchange does not exist" - errPairNotSet = "ticker currency pair not set" - errAssetTypeNotSet = "ticker asset type not set" - errBaseCurrencyNotFound = "ticker base currency not found" - errQuoteCurrencyNotFound = "ticker quote currency not found" -) - -// Vars for the ticker package -var ( - Tickers []Ticker - m sync.Mutex -) - -// Price struct stores the currency pair and pricing information -type Price struct { - Last float64 `json:"Last"` - High float64 `json:"High"` - Low float64 `json:"Low"` - Bid float64 `json:"Bid"` - Ask float64 `json:"Ask"` - Volume float64 `json:"Volume"` - QuoteVolume float64 `json:"QuoteVolume"` - PriceATH float64 `json:"PriceATH"` - Open float64 `json:"Open"` - Close float64 `json:"Close"` - Pair currency.Pair `json:"Pair"` - LastUpdated time.Time +func init() { + service = new(Service) + service.Tickers = make(map[string]map[*currency.Item]map[*currency.Item]map[asset.Item]*Ticker) + service.Exchange = make(map[string]uuid.UUID) + service.mux = dispatch.GetNewMux() } -// Ticker struct holds the ticker information for a currency pair and type -type Ticker struct { - Price map[string]map[string]map[string]Price - ExchangeName string -} +// SubscribeTicker subcribes to a ticker and returns a communication channel to +// stream new ticker updates +func SubscribeTicker(exchange string, p currency.Pair, a asset.Item) (dispatch.Pipe, error) { + exchange = strings.ToLower(exchange) + service.RLock() + defer service.RUnlock() -// PriceToString returns the string version of a stored price field -func (t *Ticker) PriceToString(p currency.Pair, priceType string, tickerType asset.Item) string { - priceType = strings.ToLower(priceType) - - switch priceType { - case "last": - return strconv.FormatFloat(t.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()].Last, 'f', -1, 64) - case "high": - return strconv.FormatFloat(t.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()].High, 'f', -1, 64) - case "low": - return strconv.FormatFloat(t.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()].Low, 'f', -1, 64) - case "bid": - return strconv.FormatFloat(t.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()].Bid, 'f', -1, 64) - case "ask": - return strconv.FormatFloat(t.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()].Ask, 'f', -1, 64) - case "volume": - return strconv.FormatFloat(t.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()].Volume, 'f', -1, 64) - case "ath": - return strconv.FormatFloat(t.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()].PriceATH, 'f', -1, 64) - default: - return "" + tick, ok := service.Tickers[exchange][p.Base.Item][p.Quote.Item][a] + if !ok { + return dispatch.Pipe{}, fmt.Errorf("ticker item not found for %s %s %s", + exchange, + p, + a) } + + return service.mux.Subscribe(tick.Main) +} + +// SubscribeToExchangeTickers subcribes to all tickers on an exchange +func SubscribeToExchangeTickers(exchange string) (dispatch.Pipe, error) { + exchange = strings.ToLower(exchange) + service.RLock() + defer service.RUnlock() + id, ok := service.Exchange[exchange] + if !ok { + return dispatch.Pipe{}, fmt.Errorf("%s exchange tickers not found", + exchange) + } + + return service.mux.Subscribe(id) } // GetTicker checks and returns a requested ticker if it exists func GetTicker(exchange string, p currency.Pair, tickerType asset.Item) (Price, error) { - ticker, err := GetTickerByExchange(exchange) - if err != nil { - return Price{}, err + exchange = strings.ToLower(exchange) + service.RLock() + defer service.RUnlock() + if service.Tickers[exchange] == nil { + return Price{}, fmt.Errorf("no tickers for %s exchange", exchange) } - if !BaseCurrencyExists(exchange, p.Base) { - return Price{}, errors.New(errBaseCurrencyNotFound) + if service.Tickers[exchange][p.Base.Item] == nil { + return Price{}, fmt.Errorf("no tickers associated with base currency %s", + p.Base) } - if !QuoteCurrencyExists(exchange, p) { - return Price{}, errors.New(errQuoteCurrencyNotFound) + if service.Tickers[exchange][p.Base.Item][p.Quote.Item] == nil { + return Price{}, fmt.Errorf("no tickers associated with quote currency %s", + p.Quote) } - return ticker.Price[p.Base.Upper().String()][p.Quote.Upper().String()][tickerType.String()], nil -} - -// GetTickerByExchange returns an exchange Ticker -func GetTickerByExchange(exchange string) (*Ticker, error) { - m.Lock() - defer m.Unlock() - for x := range Tickers { - if Tickers[x].ExchangeName == exchange { - return &Tickers[x], nil - } + if service.Tickers[exchange][p.Base.Item][p.Quote.Item][tickerType] == nil { + return Price{}, fmt.Errorf("no tickers associated with asset type %s", + tickerType) } - return nil, errors.New(errExchangeTickerNotFound) -} -// BaseCurrencyExists checks to see if the base currency of the ticker map -// exists -func BaseCurrencyExists(exchange string, currency currency.Code) bool { - m.Lock() - defer m.Unlock() - for _, y := range Tickers { - if y.ExchangeName == exchange { - if _, ok := y.Price[currency.Upper().String()]; ok { - return true - } - } - } - return false -} - -// QuoteCurrencyExists checks to see if the quote currency of the ticker map -// exists -func QuoteCurrencyExists(exchange string, p currency.Pair) bool { - m.Lock() - defer m.Unlock() - for _, y := range Tickers { - if y.ExchangeName == exchange { - if _, ok := y.Price[p.Base.Upper().String()]; ok { - if _, ok := y.Price[p.Base.Upper().String()][p.Quote.Upper().String()]; ok { - return true - } - } - } - } - return false -} - -// CreateNewTicker creates a new Ticker -func CreateNewTicker(exchangeName string, tickerNew *Price, tickerType asset.Item) Ticker { - m.Lock() - defer m.Unlock() - ticker := Ticker{} - ticker.ExchangeName = exchangeName - ticker.Price = make(map[string]map[string]map[string]Price) - a := make(map[string]map[string]Price) - b := make(map[string]Price) - b[tickerType.String()] = *tickerNew - a[tickerNew.Pair.Quote.Upper().String()] = b - ticker.Price[tickerNew.Pair.Base.Upper().String()] = a - Tickers = append(Tickers, ticker) - return ticker + return service.Tickers[exchange][p.Base.Item][p.Quote.Item][tickerType].Price, nil } // ProcessTicker processes incoming tickers, creating or updating the Tickers // list func ProcessTicker(exchangeName string, tickerNew *Price, assetType asset.Item) error { + if exchangeName == "" { + return fmt.Errorf(errExchangeNameUnset) + } + + tickerNew.ExchangeName = strings.ToLower(exchangeName) + if tickerNew.Pair.IsEmpty() { - return fmt.Errorf("%v %v", exchangeName, errPairNotSet) + return fmt.Errorf("%s %s", exchangeName, errPairNotSet) } if assetType == "" { - return fmt.Errorf("%v %v %v", exchangeName, tickerNew.Pair.String(), errAssetTypeNotSet) + return fmt.Errorf("%s %s %s", exchangeName, + tickerNew.Pair, + errAssetTypeNotSet) } + tickerNew.AssetType = assetType + if tickerNew.LastUpdated.IsZero() { tickerNew.LastUpdated = time.Now() } - ticker, err := GetTickerByExchange(exchangeName) + return service.Update(tickerNew) +} + +// Update updates ticker price +func (s *Service) Update(p *Price) error { + var ids []uuid.UUID + + s.Lock() + switch { + case s.Tickers[p.ExchangeName] == nil: + s.Tickers[p.ExchangeName] = make(map[*currency.Item]map[*currency.Item]map[asset.Item]*Ticker) + s.Tickers[p.ExchangeName][p.Pair.Base.Item] = make(map[*currency.Item]map[asset.Item]*Ticker) + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item] = make(map[asset.Item]*Ticker) + err := s.SetItemID(p) + if err != nil { + s.Unlock() + return err + } + + case s.Tickers[p.ExchangeName][p.Pair.Base.Item] == nil: + s.Tickers[p.ExchangeName][p.Pair.Base.Item] = make(map[*currency.Item]map[asset.Item]*Ticker) + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item] = make(map[asset.Item]*Ticker) + err := s.SetItemID(p) + if err != nil { + s.Unlock() + return err + } + + case s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item] == nil: + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item] = make(map[asset.Item]*Ticker) + err := s.SetItemID(p) + if err != nil { + s.Unlock() + return err + } + + case s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType] == nil: + err := s.SetItemID(p) + if err != nil { + s.Unlock() + return err + } + + default: + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Last = p.Last + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].High = p.High + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Low = p.Low + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Bid = p.Bid + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Ask = p.Ask + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Volume = p.Volume + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].QuoteVolume = p.QuoteVolume + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].PriceATH = p.PriceATH + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Open = p.Open + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Close = p.Close + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].LastUpdated = p.LastUpdated + ids = s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Assoc + ids = append(ids, s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType].Main) + } + s.Unlock() + return s.mux.Publish(ids, p) +} + +// SetItemID retrieves and sets dispatch mux publish IDs +func (s *Service) SetItemID(p *Price) error { + if p == nil { + return errors.New(errTickerPriceIsNil) + } + + ids, err := s.GetAssociations(p) if err != nil { - CreateNewTicker(exchangeName, tickerNew, assetType) - return nil + return err + } + singleID, err := s.mux.GetID() + if err != nil { + return err } - if BaseCurrencyExists(exchangeName, tickerNew.Pair.Base) { - m.Lock() - a := make(map[string]Price) - a[assetType.String()] = *tickerNew - ticker.Price[tickerNew.Pair.Base.Upper().String()][tickerNew.Pair.Quote.Upper().String()] = a - m.Unlock() - return nil - } - - m.Lock() - - a := make(map[string]map[string]Price) - b := make(map[string]Price) - b[assetType.String()] = *tickerNew - a[tickerNew.Pair.Quote.Upper().String()] = b - ticker.Price[tickerNew.Pair.Base.Upper().String()] = a - m.Unlock() + s.Tickers[p.ExchangeName][p.Pair.Base.Item][p.Pair.Quote.Item][p.AssetType] = &Ticker{Price: *p, + Main: singleID, + Assoc: ids} return nil } + +// GetAssociations links a singular book with it's dispatch associations +func (s *Service) GetAssociations(p *Price) ([]uuid.UUID, error) { + if p == nil || *p == (Price{}) { + return nil, errors.New(errTickerPriceIsNil) + } + var ids []uuid.UUID + exchangeID, ok := s.Exchange[p.ExchangeName] + if !ok { + var err error + exchangeID, err = s.mux.GetID() + if err != nil { + return nil, err + } + s.Exchange[p.ExchangeName] = exchangeID + } + + ids = append(ids, exchangeID) + return ids, nil +} diff --git a/exchanges/ticker/ticker_test.go b/exchanges/ticker/ticker_test.go index 29d1e7c2..91e6c9ab 100644 --- a/exchanges/ticker/ticker_test.go +++ b/exchanges/ticker/ticker_test.go @@ -1,55 +1,94 @@ package ticker import ( + "log" "math/rand" - "reflect" + "os" "strconv" "sync" "testing" "time" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/dispatch" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) -func TestPriceToString(t *testing.T) { - newPair := currency.NewPairFromStrings("BTC", "USD") - priceStruct := Price{ - Pair: newPair, - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, +func TestMain(m *testing.M) { + err := dispatch.Start(1) + if err != nil { + log.Fatal(err) } - newTicker := CreateNewTicker("ANX", &priceStruct, asset.Spot) + cpyMux = service.mux - if newTicker.PriceToString(newPair, "last", asset.Spot) != "1200" { - t.Error("Test Failed - ticker PriceToString last value is incorrect") + os.Exit(m.Run()) +} + +var cpyMux *dispatch.Mux + +func TestSubscribeTicker(t *testing.T) { + _, err := SubscribeTicker("", currency.Pair{}, asset.Item("")) + if err == nil { + t.Error("error cannot be nil") } - if newTicker.PriceToString(newPair, "high", asset.Spot) != "1298" { - t.Error("Test Failed - ticker PriceToString high value is incorrect") + + p := currency.NewPair(currency.BTC, currency.USD) + + // force error + service.mux = nil + err = ProcessTicker("subscribetest", &Price{Pair: p}, asset.Spot) + if err == nil { + t.Error("error cannot be nil") } - if newTicker.PriceToString(newPair, "low", asset.Spot) != "1148" { - t.Error("Test Failed - ticker PriceToString low value is incorrect") + + sillyP := p + sillyP.Base = currency.GALA_NEO + err = ProcessTicker("subscribetest", &Price{Pair: sillyP}, asset.Spot) + if err == nil { + t.Error("error cannot be nil") } - if newTicker.PriceToString(newPair, "bid", asset.Spot) != "1195" { - t.Error("Test Failed - ticker PriceToString bid value is incorrect") + + sillyP.Quote = currency.AAA + err = ProcessTicker("subscribetest", &Price{Pair: sillyP}, asset.Spot) + if err == nil { + t.Error("error cannot be nil") } - if newTicker.PriceToString(newPair, "ask", asset.Spot) != "1220" { - t.Error("Test Failed - ticker PriceToString ask value is incorrect") + + err = ProcessTicker("subscribetest", &Price{Pair: sillyP}, "silly") + if err == nil { + t.Error("error cannot be nil") } - if newTicker.PriceToString(newPair, "volume", asset.Spot) != "5" { - t.Error("Test Failed - ticker PriceToString volume value is incorrect") + // reinstate mux + service.mux = cpyMux + + err = ProcessTicker("subscribetest", &Price{Pair: p}, asset.Spot) + if err != nil { + t.Error("error cannot be nil") } - if newTicker.PriceToString(newPair, "ath", asset.Spot) != "1337" { - t.Error("Test Failed - ticker PriceToString ath value is incorrect") + + _, err = SubscribeTicker("subscribetest", p, asset.Spot) + if err != nil { + t.Error("cannot subscribe to ticker", err) } - if newTicker.PriceToString(newPair, "obtuse", asset.Spot) != "" { - t.Error("Test Failed - ticker PriceToString obtuse value is incorrect") +} + +func TestSubscribeToExchangeTickers(t *testing.T) { + _, err := SubscribeToExchangeTickers("") + if err == nil { + t.Error("error cannot be nil") + } + + p := currency.NewPair(currency.BTC, currency.USD) + + err = ProcessTicker("subscribeExchangeTest", &Price{Pair: p}, asset.Spot) + if err != nil { + t.Error(err) + } + + _, err = SubscribeToExchangeTickers("subscribeExchangeTest") + if err != nil { + t.Error("error cannot be nil", err) } } @@ -111,142 +150,25 @@ func TestGetTicker(t *testing.T) { if tickerPrice.PriceATH != 9001 { t.Error("Test Failed - ticker tickerPrice.PriceATH value is incorrect") } -} -func TestGetTickerByExchange(t *testing.T) { - newPair := currency.NewPairFromStrings("BTC", "USD") - priceStruct := Price{ - Pair: newPair, - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + _, err = GetTicker("bitfinex", newPair, "meowCats") + if err == nil { + t.Error("Test Failed - Ticker GetTicker error cannot be nil") } - anxTicker := CreateNewTicker("ANX", &priceStruct, asset.Spot) - Tickers = append(Tickers, anxTicker) - - tickerPtr, err := GetTickerByExchange("ANX") + err = ProcessTicker("bitfinex", &priceStruct, "meowCats") if err != nil { - t.Errorf("Test Failed - GetTickerByExchange init error: %s", err) - } - if tickerPtr.ExchangeName != "ANX" { - t.Error("Test Failed - GetTickerByExchange ExchangeName value is incorrect") - } -} - -func TestBaseCurrencyExists(t *testing.T) { - newPair := currency.NewPairFromStrings("BTC", "USD") - priceStruct := Price{ - Pair: newPair, - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + t.Fatal("Test failed. ProcessTicker error", err) } - alphaTicker := CreateNewTicker("alphapoint", &priceStruct, asset.Spot) - Tickers = append(Tickers, alphaTicker) - - if !BaseCurrencyExists("alphapoint", currency.BTC) { - t.Error("Test Failed - BaseCurrencyExists1 value return is incorrect") - } - if BaseCurrencyExists("alphapoint", currency.NewCode("CATS")) { - t.Error("Test Failed - BaseCurrencyExists2 value return is incorrect") - } -} - -func TestQuoteCurrencyExists(t *testing.T) { - t.Parallel() - - newPair := currency.NewPairFromStrings("BTC", "USD") - priceStruct := Price{ - Pair: newPair, - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, - } - - bitstampTicker := CreateNewTicker("bitstamp", &priceStruct, asset.Spot) - Tickers = append(Tickers, bitstampTicker) - - if !QuoteCurrencyExists("bitstamp", newPair) { - t.Error("Test Failed - QuoteCurrencyExists1 value return is incorrect") - } - - newPair.Quote = currency.NewCode("DOGS") - if QuoteCurrencyExists("bitstamp", newPair) { - t.Error("Test Failed - QuoteCurrencyExists2 value return is incorrect") - } -} - -func TestCreateNewTicker(t *testing.T) { - const float64Type = "float64" - newPair := currency.NewPairFromStrings("BTC", "USD") - priceStruct := Price{ - Pair: newPair, - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, - } - - newTicker := CreateNewTicker("ANX", &priceStruct, asset.Spot) - - if reflect.ValueOf(newTicker).NumField() != 2 { - t.Error("Test Failed - ticker CreateNewTicker struct change/or updated") - } - if reflect.TypeOf(newTicker.ExchangeName).String() != "string" { - t.Error("Test Failed - ticker CreateNewTicker.ExchangeName value is not a string") - } - if newTicker.ExchangeName != "ANX" { - t.Error("Test Failed - ticker CreateNewTicker.ExchangeName value is not ANX") - } - - if !newTicker.Price[currency.BTC.Upper().String()][currency.USD.Upper().String()][asset.Spot.String()].Pair.Equal(newPair) { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Pair.Pair().String() value is not expected 'BTCUSD'") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].Ask).String() != float64Type { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Ask value is not a float64") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].Bid).String() != float64Type { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Bid value is not a float64") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].Pair).String() != "currency.Pair" { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].CurrencyPair value is not a currency.Pair") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].High).String() != float64Type { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].High value is not a float64") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].Last).String() != float64Type { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Last value is not a float64") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].Low).String() != float64Type { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Low value is not a float64") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].PriceATH).String() != float64Type { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].PriceATH value is not a float64") - } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"][asset.Spot.String()].Volume).String() != float64Type { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Volume value is not a float64") + // process update again + err = ProcessTicker("bitfinex", &priceStruct, "meowCats") + if err != nil { + t.Fatal("Test failed. ProcessTicker error", err) } } func TestProcessTicker(t *testing.T) { // non-appending function to tickers - Tickers = []Ticker{} exchName := "bitstamp" newPair := currency.NewPairFromStrings("BTC", "USD") priceStruct := Price{ @@ -259,8 +181,13 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers PriceATH: 1337, } + err := ProcessTicker("", &priceStruct, asset.Spot) + if err == nil { + t.Fatal("empty exchange should throw an err") + } + // test for empty pair - err := ProcessTicker(exchName, &priceStruct, asset.Spot) + err = ProcessTicker(exchName, &priceStruct, asset.Spot) if err == nil { t.Fatal("empty pair should throw an err") } @@ -389,5 +316,44 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers } } wg.Wait() - +} + +func TestSetItemID(t *testing.T) { + err := service.SetItemID(nil) + if err == nil { + t.Error("error cannot be nil") + } + + err = service.SetItemID(&Price{}) + if err == nil { + t.Error("error cannot be nil") + } + + p := currency.NewPair(currency.CYC, currency.CYG) + + service.mux = nil + err = service.SetItemID(&Price{Pair: p, ExchangeName: "SetItemID"}) + if err == nil { + t.Error("error cannot be nil") + } + + service.mux = cpyMux +} + +func TestGetAssociation(t *testing.T) { + _, err := service.GetAssociations(nil) + if err == nil { + t.Error("error cannot be nil ") + } + + p := currency.NewPair(currency.CYC, currency.CYG) + + service.mux = nil + + _, err = service.GetAssociations(&Price{Pair: p, ExchangeName: "GetAssociation"}) + if err == nil { + t.Error("error cannot be nil ") + } + + service.mux = cpyMux } diff --git a/exchanges/ticker/ticker_types.go b/exchanges/ticker/ticker_types.go new file mode 100644 index 00000000..ba37ed11 --- /dev/null +++ b/exchanges/ticker/ticker_types.go @@ -0,0 +1,57 @@ +package ticker + +import ( + "sync" + "time" + + "github.com/gofrs/uuid" + "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/dispatch" + "github.com/thrasher-corp/gocryptotrader/exchanges/asset" +) + +// const values for the ticker package +const ( + errExchangeNameUnset = "ticker exchange name not set" + errPairNotSet = "ticker currency pair not set" + errAssetTypeNotSet = "ticker asset type not set" + errTickerPriceIsNil = "ticker price is nil" +) + +// Vars for the ticker package +var ( + service *Service +) + +// Service holds ticker information for each individual exchange +type Service struct { + Tickers map[string]map[*currency.Item]map[*currency.Item]map[asset.Item]*Ticker + Exchange map[string]uuid.UUID + mux *dispatch.Mux + sync.RWMutex +} + +// Price struct stores the currency pair and pricing information +type Price struct { + Last float64 `json:"Last"` + High float64 `json:"High"` + Low float64 `json:"Low"` + Bid float64 `json:"Bid"` + Ask float64 `json:"Ask"` + Volume float64 `json:"Volume"` + QuoteVolume float64 `json:"QuoteVolume"` + PriceATH float64 `json:"PriceATH"` + Open float64 `json:"Open"` + Close float64 `json:"Close"` + Pair currency.Pair `json:"Pair"` + ExchangeName string `json:"exchangeName"` + AssetType asset.Item `json:"assetType"` + LastUpdated time.Time +} + +// Ticker struct holds the ticker information for a currency pair and type +type Ticker struct { + Price + Main uuid.UUID + Assoc []uuid.UUID +} diff --git a/exchanges/websocket/wsorderbook/wsorderbook.go b/exchanges/websocket/wsorderbook/wsorderbook.go index 3446ddbd..2422b921 100644 --- a/exchanges/websocket/wsorderbook/wsorderbook.go +++ b/exchanges/websocket/wsorderbook/wsorderbook.go @@ -1,6 +1,7 @@ package wsorderbook import ( + "errors" "fmt" "sort" "sync" @@ -205,6 +206,19 @@ func (w *WebsocketOrderbookLocal) LoadSnapshot(newOrderbook *orderbook.Base) err if len(newOrderbook.Asks) == 0 || len(newOrderbook.Bids) == 0 { return fmt.Errorf("%v snapshot ask and bids are nil", w.exchangeName) } + + if newOrderbook.Pair.IsEmpty() { + return errors.New("websocket orderbook pair unset") + } + + if newOrderbook.AssetType.String() == "" { + return errors.New("websocket orderbook asset type unset") + } + + if newOrderbook.ExchangeName == "" { + return errors.New("websocket orderbook exchange name unset") + } + w.m.Lock() defer w.m.Unlock() if w.ob == nil { diff --git a/exchanges/websocket/wsorderbook/wsorderbook_test.go b/exchanges/websocket/wsorderbook/wsorderbook_test.go index acc00095..8c0c09db 100644 --- a/exchanges/websocket/wsorderbook/wsorderbook_test.go +++ b/exchanges/websocket/wsorderbook/wsorderbook_test.go @@ -26,6 +26,7 @@ const ( func createSnapshot() (obl *WebsocketOrderbookLocal, curr currency.Pair, asks, bids []orderbook.Item, err error) { var snapShot1 orderbook.Base + snapShot1.ExchangeName = exchangeName curr = currency.NewPairFromString("BTCUSD") asks = []orderbook.Item{ {Price: 4000, Amount: 1, ID: 6}, @@ -37,19 +38,28 @@ func createSnapshot() (obl *WebsocketOrderbookLocal, curr currency.Pair, asks, b snapShot1.Bids = bids snapShot1.AssetType = asset.Spot snapShot1.Pair = curr - obl = &WebsocketOrderbookLocal{} + obl = &WebsocketOrderbookLocal{exchangeName: exchangeName} err = obl.LoadSnapshot(&snapShot1) return } -// BenchmarkBufferPerformance demonstrates buffer more performant than multi process calls +// BenchmarkBufferPerformance demonstrates buffer more performant than multi +// process calls func BenchmarkBufferPerformance(b *testing.B) { obl, curr, asks, bids, err := createSnapshot() if err != nil { b.Fatal(err) } - obl.exchangeName = exchangeName obl.sortBuffer = true + cp := currency.NewPairFromString("BTCUSD") + // This is to ensure we do not send in zero orderbook info to our main book + // in orderbook.go, orderbooks should not be zero even after an update. + dummyItem := orderbook.Item{ + Amount: 1333337, + Price: 1337.1337, + ID: 1337, + } + obl.ob[cp][asset.Spot].Bids = append(obl.ob[cp][asset.Spot].Bids, dummyItem) update := &WebsocketOrderbookUpdate{ Bids: bids, Asks: asks, @@ -74,7 +84,6 @@ func BenchmarkBufferSortingPerformance(b *testing.B) { if err != nil { b.Fatal(err) } - obl.exchangeName = exchangeName obl.sortBuffer = true obl.bufferEnabled = true obl.obBufferLimit = 5 @@ -96,13 +105,22 @@ func BenchmarkBufferSortingPerformance(b *testing.B) { } } -// BenchmarkNoBufferPerformance demonstrates orderbook process less performant than buffer +// BenchmarkNoBufferPerformance demonstrates orderbook process less performant +// than buffer func BenchmarkNoBufferPerformance(b *testing.B) { obl, curr, asks, bids, err := createSnapshot() if err != nil { b.Fatal(err) } - obl.exchangeName = exchangeName + cp := currency.NewPairFromString("BTCUSD") + // This is to ensure we do not send in zero orderbook info to our main book + // in orderbook.go, orderbooks should not be zero even after an update. + dummyItem := orderbook.Item{ + Amount: 1333337, + Price: 1337.1337, + ID: 1337, + } + obl.ob[cp][asset.Spot].Bids = append(obl.ob[cp][asset.Spot].Bids, dummyItem) update := &WebsocketOrderbookUpdate{ Bids: bids, Asks: asks, @@ -127,7 +145,6 @@ func TestHittingTheBuffer(t *testing.T) { if err != nil { t.Fatal(err) } - obl.exchangeName = exchangeName obl.bufferEnabled = true obl.obBufferLimit = 5 for i := 0; i < len(itemArray); i++ { @@ -146,10 +163,12 @@ func TestHittingTheBuffer(t *testing.T) { } if len(obl.ob[curr][asset.Spot].Asks) != 3 { t.Log(obl.ob[curr][asset.Spot]) - t.Errorf("expected 3 entries, received: %v", len(obl.ob[curr][asset.Spot].Asks)) + t.Errorf("expected 3 entries, received: %v", + len(obl.ob[curr][asset.Spot].Asks)) } if len(obl.ob[curr][asset.Spot].Bids) != 3 { - t.Errorf("expected 3 entries, received: %v", len(obl.ob[curr][asset.Spot].Bids)) + t.Errorf("expected 3 entries, received: %v", + len(obl.ob[curr][asset.Spot].Bids)) } } @@ -159,7 +178,6 @@ func TestInsertWithIDs(t *testing.T) { if err != nil { t.Fatal(err) } - obl.exchangeName = exchangeName obl.bufferEnabled = true obl.updateEntriesByID = true obl.obBufferLimit = 5 @@ -179,10 +197,12 @@ func TestInsertWithIDs(t *testing.T) { } } if len(obl.ob[curr][asset.Spot].Asks) != 6 { - t.Errorf("expected 6 entries, received: %v", len(obl.ob[curr][asset.Spot].Asks)) + t.Errorf("expected 6 entries, received: %v", + len(obl.ob[curr][asset.Spot].Asks)) } if len(obl.ob[curr][asset.Spot].Bids) != 6 { - t.Errorf("expected 6 entries, received: %v", len(obl.ob[curr][asset.Spot].Bids)) + t.Errorf("expected 6 entries, received: %v", + len(obl.ob[curr][asset.Spot].Bids)) } } @@ -192,7 +212,6 @@ func TestSortIDs(t *testing.T) { if err != nil { t.Fatal(err) } - obl.exchangeName = exchangeName obl.bufferEnabled = true obl.sortBufferByUpdateIDs = true obl.sortBuffer = true @@ -212,10 +231,12 @@ func TestSortIDs(t *testing.T) { } } if len(obl.ob[curr][asset.Spot].Asks) != 3 { - t.Errorf("expected 6 entries, received: %v", len(obl.ob[curr][asset.Spot].Asks)) + t.Errorf("expected 3 entries, received: %v", + len(obl.ob[curr][asset.Spot].Asks)) } if len(obl.ob[curr][asset.Spot].Bids) != 3 { - t.Errorf("expected 6 entries, received: %v", len(obl.ob[curr][asset.Spot].Bids)) + t.Errorf("expected 3 entries, received: %v", + len(obl.ob[curr][asset.Spot].Bids)) } } @@ -225,7 +246,16 @@ func TestDeleteWithIDs(t *testing.T) { if err != nil { t.Fatal(err) } - obl.exchangeName = exchangeName + + cp := currency.NewPairFromString("BTCUSD") + // This is to ensure we do not send in zero orderbook info to our main book + // in orderbook.go, orderbooks should not be zero even after an update. + dummyItem := orderbook.Item{ + Amount: 1333337, + Price: 1337.1337, + ID: 1337, + } + obl.ob[cp][asset.Spot].Bids = append(obl.ob[cp][asset.Spot].Bids, dummyItem) obl.updateEntriesByID = true for i := 0; i < len(itemArray); i++ { asks := itemArray[i] @@ -243,10 +273,12 @@ func TestDeleteWithIDs(t *testing.T) { } } if len(obl.ob[curr][asset.Spot].Asks) != 0 { - t.Errorf("expected 0 entries, received: %v", len(obl.ob[curr][asset.Spot].Asks)) + t.Errorf("expected 0 entries, received: %v", + len(obl.ob[curr][asset.Spot].Asks)) } - if len(obl.ob[curr][asset.Spot].Bids) != 0 { - t.Errorf("expected 0 entries, received: %v", len(obl.ob[curr][asset.Spot].Bids)) + if len(obl.ob[curr][asset.Spot].Bids) != 1 { + t.Errorf("expected 1 entries, received: %v", + len(obl.ob[curr][asset.Spot].Bids)) } } @@ -256,7 +288,6 @@ func TestUpdateWithIDs(t *testing.T) { if err != nil { t.Fatal(err) } - obl.exchangeName = exchangeName obl.updateEntriesByID = true for i := 0; i < len(itemArray); i++ { asks := itemArray[i] @@ -288,11 +319,10 @@ func TestOutOfOrderIDs(t *testing.T) { if err != nil { t.Fatal(err) } - outOFOrderIDs := []int64{2, 1, 5, 3, 4, 6} + outOFOrderIDs := []int64{2, 1, 5, 3, 4, 6, 7} if itemArray[0][0].Price != 1000 { t.Errorf("expected sorted price to be 3000, received: %v", itemArray[1][0].Price) } - obl.exchangeName = exchangeName obl.bufferEnabled = true obl.sortBuffer = true obl.obBufferLimit = 5 @@ -366,7 +396,8 @@ func TestRunUpdateWithoutAnyUpdates(t *testing.T) { if err == nil { t.Fatal("expected an error running update with no snapshot loaded") } - if err.Error() != fmt.Sprintf("%v cannot have bids and ask targets both nil", exchangeName) { + if err.Error() != fmt.Sprintf("%v cannot have bids and ask targets both nil", + exchangeName) { t.Fatal("expected nil asks and bids error") } } @@ -395,6 +426,7 @@ func TestRunSnapshotWithNoData(t *testing.T) { func TestLoadSnapshot(t *testing.T) { var obl WebsocketOrderbookLocal var snapShot1 orderbook.Base + snapShot1.ExchangeName = "SnapshotWithOverride" curr := currency.NewPairFromString("BTCUSD") asks := []orderbook.Item{ {Price: 4000, Amount: 1, ID: 8}, @@ -432,6 +464,7 @@ func TestFlushCache(t *testing.T) { func TestInsertingSnapShots(t *testing.T) { var obl WebsocketOrderbookLocal var snapShot1 orderbook.Base + snapShot1.ExchangeName = "WSORDERBOOKTEST1" asks := []orderbook.Item{ {Price: 6000, Amount: 1, ID: 1}, {Price: 6001, Amount: 0.5, ID: 2}, @@ -469,6 +502,7 @@ func TestInsertingSnapShots(t *testing.T) { t.Fatal(err) } var snapShot2 orderbook.Base + snapShot2.ExchangeName = "WSORDERBOOKTEST2" asks = []orderbook.Item{ {Price: 51, Amount: 1, ID: 1}, {Price: 52, Amount: 0.5, ID: 2}, @@ -506,6 +540,7 @@ func TestInsertingSnapShots(t *testing.T) { t.Fatal(err) } var snapShot3 orderbook.Base + snapShot3.ExchangeName = "WSORDERBOOKTEST3" asks = []orderbook.Item{ {Price: 511, Amount: 1, ID: 1}, {Price: 52, Amount: 0.5, ID: 2}, diff --git a/exchanges/zb/zb_websocket.go b/exchanges/zb/zb_websocket.go index f52c0aed..0ac6d2ec 100644 --- a/exchanges/zb/zb_websocket.go +++ b/exchanges/zb/zb_websocket.go @@ -142,6 +142,7 @@ func (z *ZB) WsHandleData() { newOrderBook.Bids = bids newOrderBook.AssetType = asset.Spot newOrderBook.Pair = cPair + newOrderBook.ExchangeName = z.GetName() err = z.Websocket.Orderbook.LoadSnapshot(&newOrderBook) if err != nil { diff --git a/gctrpc/rpc.pb.go b/gctrpc/rpc.pb.go index 71453f7f..b44758ea 100644 --- a/gctrpc/rpc.pb.go +++ b/gctrpc/rpc.pb.go @@ -9,6 +9,8 @@ import ( proto "github.com/golang/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" math "math" ) @@ -4714,6 +4716,194 @@ func (m *ExchangePairRequest) GetPair() *CurrencyPair { return nil } +type GetOrderbookStreamRequest struct { + Exchange string `protobuf:"bytes,1,opt,name=exchange,proto3" json:"exchange,omitempty"` + Pair *CurrencyPair `protobuf:"bytes,2,opt,name=pair,proto3" json:"pair,omitempty"` + AssetType string `protobuf:"bytes,3,opt,name=asset_type,json=assetType,proto3" json:"asset_type,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetOrderbookStreamRequest) Reset() { *m = GetOrderbookStreamRequest{} } +func (m *GetOrderbookStreamRequest) String() string { return proto.CompactTextString(m) } +func (*GetOrderbookStreamRequest) ProtoMessage() {} +func (*GetOrderbookStreamRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{92} +} + +func (m *GetOrderbookStreamRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetOrderbookStreamRequest.Unmarshal(m, b) +} +func (m *GetOrderbookStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetOrderbookStreamRequest.Marshal(b, m, deterministic) +} +func (m *GetOrderbookStreamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetOrderbookStreamRequest.Merge(m, src) +} +func (m *GetOrderbookStreamRequest) XXX_Size() int { + return xxx_messageInfo_GetOrderbookStreamRequest.Size(m) +} +func (m *GetOrderbookStreamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetOrderbookStreamRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetOrderbookStreamRequest proto.InternalMessageInfo + +func (m *GetOrderbookStreamRequest) GetExchange() string { + if m != nil { + return m.Exchange + } + return "" +} + +func (m *GetOrderbookStreamRequest) GetPair() *CurrencyPair { + if m != nil { + return m.Pair + } + return nil +} + +func (m *GetOrderbookStreamRequest) GetAssetType() string { + if m != nil { + return m.AssetType + } + return "" +} + +type GetExchangeOrderbookStreamRequest struct { + Exchange string `protobuf:"bytes,1,opt,name=exchange,proto3" json:"exchange,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetExchangeOrderbookStreamRequest) Reset() { *m = GetExchangeOrderbookStreamRequest{} } +func (m *GetExchangeOrderbookStreamRequest) String() string { return proto.CompactTextString(m) } +func (*GetExchangeOrderbookStreamRequest) ProtoMessage() {} +func (*GetExchangeOrderbookStreamRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{93} +} + +func (m *GetExchangeOrderbookStreamRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetExchangeOrderbookStreamRequest.Unmarshal(m, b) +} +func (m *GetExchangeOrderbookStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetExchangeOrderbookStreamRequest.Marshal(b, m, deterministic) +} +func (m *GetExchangeOrderbookStreamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetExchangeOrderbookStreamRequest.Merge(m, src) +} +func (m *GetExchangeOrderbookStreamRequest) XXX_Size() int { + return xxx_messageInfo_GetExchangeOrderbookStreamRequest.Size(m) +} +func (m *GetExchangeOrderbookStreamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetExchangeOrderbookStreamRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetExchangeOrderbookStreamRequest proto.InternalMessageInfo + +func (m *GetExchangeOrderbookStreamRequest) GetExchange() string { + if m != nil { + return m.Exchange + } + return "" +} + +type GetTickerStreamRequest struct { + Exchange string `protobuf:"bytes,1,opt,name=exchange,proto3" json:"exchange,omitempty"` + Pair *CurrencyPair `protobuf:"bytes,2,opt,name=pair,proto3" json:"pair,omitempty"` + AssetType string `protobuf:"bytes,3,opt,name=asset_type,json=assetType,proto3" json:"asset_type,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetTickerStreamRequest) Reset() { *m = GetTickerStreamRequest{} } +func (m *GetTickerStreamRequest) String() string { return proto.CompactTextString(m) } +func (*GetTickerStreamRequest) ProtoMessage() {} +func (*GetTickerStreamRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{94} +} + +func (m *GetTickerStreamRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetTickerStreamRequest.Unmarshal(m, b) +} +func (m *GetTickerStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetTickerStreamRequest.Marshal(b, m, deterministic) +} +func (m *GetTickerStreamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTickerStreamRequest.Merge(m, src) +} +func (m *GetTickerStreamRequest) XXX_Size() int { + return xxx_messageInfo_GetTickerStreamRequest.Size(m) +} +func (m *GetTickerStreamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetTickerStreamRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTickerStreamRequest proto.InternalMessageInfo + +func (m *GetTickerStreamRequest) GetExchange() string { + if m != nil { + return m.Exchange + } + return "" +} + +func (m *GetTickerStreamRequest) GetPair() *CurrencyPair { + if m != nil { + return m.Pair + } + return nil +} + +func (m *GetTickerStreamRequest) GetAssetType() string { + if m != nil { + return m.AssetType + } + return "" +} + +type GetExchangeTickerStreamRequest struct { + Exchange string `protobuf:"bytes,1,opt,name=exchange,proto3" json:"exchange,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetExchangeTickerStreamRequest) Reset() { *m = GetExchangeTickerStreamRequest{} } +func (m *GetExchangeTickerStreamRequest) String() string { return proto.CompactTextString(m) } +func (*GetExchangeTickerStreamRequest) ProtoMessage() {} +func (*GetExchangeTickerStreamRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{95} +} + +func (m *GetExchangeTickerStreamRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetExchangeTickerStreamRequest.Unmarshal(m, b) +} +func (m *GetExchangeTickerStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetExchangeTickerStreamRequest.Marshal(b, m, deterministic) +} +func (m *GetExchangeTickerStreamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetExchangeTickerStreamRequest.Merge(m, src) +} +func (m *GetExchangeTickerStreamRequest) XXX_Size() int { + return xxx_messageInfo_GetExchangeTickerStreamRequest.Size(m) +} +func (m *GetExchangeTickerStreamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetExchangeTickerStreamRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetExchangeTickerStreamRequest proto.InternalMessageInfo + +func (m *GetExchangeTickerStreamRequest) GetExchange() string { + if m != nil { + return m.Exchange + } + return "" +} + func init() { proto.RegisterType((*GetInfoRequest)(nil), "gctrpc.GetInfoRequest") proto.RegisterType((*GetInfoResponse)(nil), "gctrpc.GetInfoResponse") @@ -4821,296 +5011,309 @@ func init() { proto.RegisterType((*GetExchangePairsResponse)(nil), "gctrpc.GetExchangePairsResponse") proto.RegisterMapType((map[string]*PairsSupported)(nil), "gctrpc.GetExchangePairsResponse.SupportedAssetsEntry") proto.RegisterType((*ExchangePairRequest)(nil), "gctrpc.ExchangePairRequest") + proto.RegisterType((*GetOrderbookStreamRequest)(nil), "gctrpc.GetOrderbookStreamRequest") + proto.RegisterType((*GetExchangeOrderbookStreamRequest)(nil), "gctrpc.GetExchangeOrderbookStreamRequest") + proto.RegisterType((*GetTickerStreamRequest)(nil), "gctrpc.GetTickerStreamRequest") + proto.RegisterType((*GetExchangeTickerStreamRequest)(nil), "gctrpc.GetExchangeTickerStreamRequest") } func init() { proto.RegisterFile("rpc.proto", fileDescriptor_77a6da22d6a3feb1) } var fileDescriptor_77a6da22d6a3feb1 = []byte{ - // 4537 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x7b, 0xcd, 0x6f, 0x1c, 0x57, - 0x72, 0x38, 0x66, 0x38, 0x22, 0x39, 0x35, 0x43, 0x72, 0xf8, 0xf8, 0x35, 0x1a, 0x92, 0xa2, 0xd4, - 0x5e, 0xc9, 0x92, 0xd7, 0xa6, 0x6c, 0x59, 0xbf, 0xdf, 0x3a, 0xeb, 0xcd, 0x26, 0x34, 0x2d, 0x73, - 0x15, 0x7b, 0x2d, 0xa6, 0xa9, 0x95, 0x00, 0x6f, 0xe0, 0x4e, 0x73, 0xfa, 0x71, 0xd8, 0x51, 0x4f, - 0x77, 0xbb, 0xbb, 0x87, 0xd4, 0x38, 0x01, 0x02, 0x18, 0x48, 0x90, 0x53, 0x72, 0x58, 0x04, 0xd8, - 0x43, 0x4e, 0x39, 0x06, 0xc8, 0x25, 0xc8, 0x29, 0x87, 0x45, 0xae, 0x41, 0x8e, 0xb9, 0xe4, 0x0f, - 0x08, 0x72, 0x4b, 0x02, 0x04, 0xc8, 0x25, 0xa7, 0xe0, 0xd5, 0xfb, 0xe8, 0xf7, 0xba, 0x7b, 0x86, - 0xa3, 0x5d, 0xad, 0x2f, 0x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0x46, 0x59, 0xb2, 0xb8, 0x7a, 0x85, 0xc5, 0xdd, 0x83, 0xc6, 0xa9, 0xef, 0xb1, 0x9c, - 0x8d, 0xe9, 0x75, 0x43, 0x92, 0x33, 0xd6, 0x61, 0x23, 0x0a, 0x43, 0x75, 0xd3, 0x17, 0x69, 0xb7, - 0x31, 0x15, 0x95, 0xa1, 0x94, 0xce, 0xc3, 0xb5, 0xf2, 0x79, 0x30, 0x75, 0x39, 0x5f, 0xd4, 0x25, - 0x8f, 0x56, 0x15, 0x6d, 0x65, 0x79, 0x7d, 0x80, 0x1c, 0x38, 0x75, 0x5b, 0x7f, 0x03, 0x20, 0x52, - 0x98, 0xc2, 0xfe, 0xae, 0x97, 0x84, 0x56, 0x26, 0xa8, 0x21, 0x5b, 0x9f, 0x62, 0xa8, 0xa1, 0x33, - 0x17, 0xca, 0x7f, 0x60, 0xd0, 0xe4, 0xb6, 0x48, 0x4a, 0x34, 0x53, 0x83, 0xd8, 0xfb, 0x48, 0xec, - 0xa0, 0xdf, 0x67, 0x5b, 0xaf, 0x25, 0xe6, 0x53, 0xef, 0xf0, 0x67, 0xb0, 0x20, 0x66, 0x08, 0xb3, - 0xe0, 0x08, 0x75, 0xdf, 0x23, 0x1f, 0x02, 0x68, 0xf7, 0x10, 0x5f, 0xd7, 0xb6, 0x94, 0x41, 0x4c, - 0x92, 0xd6, 0x80, 0xec, 0x34, 0x74, 0xeb, 0x0c, 0xd6, 0x2a, 0x50, 0x98, 0x28, 0x2a, 0xad, 0x16, - 0xa2, 0xc8, 0x6f, 0xb2, 0x07, 0xad, 0x2c, 0xca, 0xdc, 0xc0, 0xc9, 0x6f, 0x88, 0x9a, 0x0d, 0x08, - 0x7a, 0xc6, 0x20, 0xe8, 0xa0, 0xa2, 0x80, 0x5b, 0x2e, 0x73, 0x50, 0x51, 0xe0, 0x59, 0x2e, 0x06, - 0x5e, 0xc6, 0xa2, 0x85, 0x0a, 0xa7, 0x6d, 0xd9, 0x77, 0x61, 0xd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x3b, 0x0b, 0xfc, 0x90, 0x32, 0xb6, 0x42, 0x98, 0x29, 0xda, 0x9f, 0x2c, 0x83, 0xc9, 0x69, 0xae, - 0xc4, 0xe9, 0xc7, 0xb0, 0xfa, 0x24, 0xac, 0x60, 0x24, 0xc9, 0xd5, 0xa6, 0x91, 0xab, 0x97, 0xc8, - 0xfd, 0x08, 0xda, 0x9a, 0xe0, 0x29, 0xf9, 0x00, 0x9a, 0x42, 0x46, 0x95, 0x28, 0xf4, 0x94, 0x37, - 0x28, 0xad, 0xd0, 0xce, 0x91, 0xad, 0x9f, 0xd7, 0xa0, 0x95, 0x4b, 0x96, 0x92, 0x87, 0x70, 0x8d, - 0xa9, 0x5b, 0x52, 0xb9, 0xa1, 0xa8, 0xe4, 0x38, 0xfb, 0xf8, 0x2f, 0x8f, 0x0b, 0x39, 0x72, 0xef, - 0x04, 0x20, 0x07, 0x56, 0x84, 0x75, 0xf7, 0xcd, 0xb0, 0xee, 0x7a, 0x99, 0xaa, 0x14, 0x4d, 0x8b, - 0xec, 0xfe, 0xb9, 0xc1, 0xd2, 0xbd, 0x0a, 0x63, 0x11, 0x36, 0xf8, 0x0e, 0xb4, 0xf8, 0x59, 0x60, - 0x1e, 0x40, 0x0a, 0xdc, 0xce, 0x4b, 0x1b, 0x7e, 0x68, 0x03, 0x9e, 0x0d, 0x1c, 0x27, 0xef, 0xc1, - 0x12, 0x0a, 0xeb, 0x44, 0x5c, 0x21, 0xe2, 0x60, 0x9b, 0x13, 0xda, 0x88, 0x22, 0x54, 0x46, 0x62, - 0xd8, 0x30, 0xa6, 0x38, 0x29, 0x17, 0x41, 0x5c, 0x52, 0x3f, 0xd0, 0x42, 0xe9, 0x49, 0x52, 0x72, - 0x65, 0x09, 0x82, 0x62, 0x8c, 0xab, 0x6e, 0xad, 0x5f, 0x1e, 0x21, 0xf7, 0xa1, 0x2d, 0x38, 0xa2, - 0x66, 0xc4, 0x15, 0x67, 0xca, 0xd8, 0xe2, 0x13, 0x11, 0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4, 0x61, 0x9c, 0xbd, 0xa0, 0x0d, 0xe3, 0x6c, 0x96, 0x03, 0x25, 0x94, - 0x3f, 0x14, 0xe0, 0x7b, 0xd7, 0x22, 0x1a, 0x5d, 0x5b, 0x02, 0x9f, 0xfa, 0x43, 0x7c, 0x0d, 0x13, - 0xc5, 0xed, 0x26, 0xb7, 0x58, 0xfe, 0x95, 0xa7, 0x69, 0xa0, 0xa7, 0x69, 0x79, 0x52, 0xd7, 0x32, - 0x92, 0xba, 0x3d, 0x68, 0x45, 0x31, 0x0d, 0x1d, 0x91, 0x62, 0xb7, 0x79, 0xf4, 0xc0, 0x40, 0xcf, - 0x10, 0x22, 0x4a, 0x26, 0xa8, 0xf3, 0x74, 0x96, 0xbc, 0xd4, 0x54, 0x4c, 0xbd, 0xa8, 0x18, 0x99, - 0x08, 0xce, 0x5d, 0x95, 0x08, 0x5a, 0x07, 0x18, 0x15, 0x4b, 0xc6, 0xc2, 0x7c, 0xde, 0x86, 0x79, - 0x54, 0x93, 0xb4, 0x9c, 0x75, 0x23, 0x8d, 0x11, 0x46, 0x61, 0x0b, 0x1c, 0xeb, 0x47, 0xf8, 0x86, - 0x88, 0x43, 0xb3, 0x88, 0x7e, 0x1d, 0x16, 0xf9, 0xae, 0x28, 0xab, 0x59, 0xc0, 0xef, 0xc7, 0x9e, - 0xf5, 0xaf, 0x35, 0x20, 0x27, 0xa3, 0xd3, 0xa1, 0x3f, 0x3b, 0xb5, 0xd9, 0x13, 0x74, 0x02, 0x0d, - 0x34, 0x13, 0x6e, 0x8e, 0xf8, 0xbb, 0x60, 0x21, 0x8d, 0xa2, 0x85, 0xe4, 0xdb, 0x79, 0xad, 0x3a, - 0x47, 0x9f, 0xd7, 0x37, 0x9f, 0xb9, 0xf8, 0xc0, 0xa7, 0x61, 0xe6, 0x88, 0x62, 0x0b, 0x73, 0xf1, - 0x08, 0x78, 0xec, 0x59, 0x27, 0xb0, 0x66, 0xac, 0x4c, 0x68, 0xfa, 0x16, 0xb4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, 0xf0, 0xff, 0x55, 0x74, 0x54, 0x18, - 0x73, 0x67, 0x6b, 0xa9, 0xf8, 0xb5, 0x76, 0x49, 0x7c, 0x0d, 0x6b, 0xba, 0x68, 0xdf, 0x66, 0xd6, - 0xff, 0xe0, 0xe7, 0x77, 0x60, 0xf9, 0x28, 0xe2, 0x0e, 0xf3, 0x29, 0xf3, 0x13, 0x09, 0x79, 0x02, - 0x0b, 0xa2, 0x41, 0x95, 0x6c, 0x96, 0x3a, 0x56, 0x51, 0xb4, 0xde, 0xd6, 0x84, 0x4e, 0x56, 0x6b, - 0xed, 0x9b, 0x7f, 0xf9, 0xb7, 0x9f, 0xd5, 0x97, 0x48, 0xeb, 0xfe, 0xc5, 0x7b, 0xf7, 0x07, 0x34, - 0x43, 0x83, 0x3c, 0x87, 0x25, 0xa3, 0xa7, 0x90, 0xec, 0x18, 0x7d, 0x81, 0x85, 0x56, 0xc3, 0xde, - 0xee, 0xd4, 0xae, 0x41, 0xab, 0x87, 0x2c, 0xd6, 0x09, 0x11, 0x2c, 0x52, 0x44, 0xe1, 0x84, 0xbf, - 0x82, 0x95, 0x47, 0x58, 0xa9, 0x54, 0x54, 0xc9, 0x5e, 0x4e, 0xad, 0xb2, 0x57, 0xb2, 0x77, 0x73, - 0x32, 0x82, 0xe0, 0xb8, 0x8d, 0x1c, 0x37, 0xc8, 0x1a, 0xe3, 0xc8, 0x2b, 0xa1, 0xaa, 0x47, 0x91, - 0xa4, 0xd0, 0x11, 0xdd, 0x57, 0xaf, 0x95, 0xe7, 0x0e, 0xf2, 0xdc, 0x24, 0xeb, 0x8c, 0xa7, 0xc7, - 0x19, 0xe4, 0x4c, 0x23, 0x2c, 0xb4, 0xe8, 0xdd, 0x82, 0xe4, 0xc6, 0xc4, 0x36, 0x42, 0xce, 0x72, - 0xef, 0x8a, 0x36, 0x43, 0x73, 0x95, 0x03, 0xca, 0x70, 0x55, 0xa7, 0x21, 0xf9, 0x19, 0x3f, 0x7d, - 0x95, 0x7d,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72, - 0x8a, 0xc4, 0x78, 0x33, 0xd6, 0x7f, 0x08, 0x6b, 0x85, 0xdc, 0xfb, 0x35, 0xf1, 0x36, 0xcc, 0xb9, - 0x90, 0x78, 0x0b, 0xe6, 0xa7, 0xf3, 0xf8, 0xb7, 0xf2, 0xef, 0xff, 0x5f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xcb, 0x7f, 0xc6, 0x31, 0x5e, 0x3f, 0x00, 0x00, + // 4676 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x3c, 0x4d, 0x6f, 0x1c, 0x57, + 0x72, 0xe8, 0x21, 0x45, 0x72, 0x6a, 0x86, 0xe4, 0xf0, 0xf1, 0x6b, 0x34, 0x24, 0x45, 0xa9, 0xb5, + 0x92, 0x25, 0xad, 0x4d, 0xd9, 0xb2, 0x92, 0x75, 0xd6, 0xce, 0x6e, 0x68, 0x5a, 0xe6, 0x2a, 0xf6, + 0x5a, 0x4c, 0x53, 0x2b, 0x01, 0xde, 0xc0, 0x93, 0xe6, 0xf4, 0xe3, 0xb0, 0xa3, 0x9e, 0xee, 0x76, + 0x77, 0x0f, 0x29, 0x3a, 0x09, 0xb2, 0x30, 0x90, 0x20, 0x08, 0x82, 0xe4, 0xb0, 0x08, 0x90, 0x43, + 0x4e, 0x39, 0x06, 0xc8, 0x25, 0xc8, 0x29, 0x87, 0x45, 0xae, 0x41, 0x8e, 0xb9, 0xe4, 0x07, 0x04, + 0xb9, 0x25, 0x01, 0x02, 0xe4, 0x92, 0x53, 0xf0, 0xea, 0x7d, 0xf4, 0x7b, 0xdd, 0x3d, 0xc3, 0xe1, + 0xae, 0xac, 0xbd, 0xd8, 0xd3, 0xf5, 0xea, 0x55, 0xd5, 0xab, 0x57, 0xaf, 0x5e, 0x55, 0xbd, 0xa2, + 0xa0, 0x9e, 0xc4, 0xbd, 0x9d, 0x38, 0x89, 0xb2, 0x88, 0x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0x28, 0x30, 0xce, 0x20, 0x37, 0x61, 0x5e, 0x5e, 0xe7, 0x1c, 0x8d, 0x8b, 0xd4, + 0x14, 0x40, 0x44, 0xb2, 0xbf, 0x9e, 0x36, 0x54, 0x67, 0x04, 0x16, 0x04, 0xa6, 0x43, 0x57, 0x85, + 0x15, 0xf8, 0x5b, 0x37, 0x84, 0x9a, 0x79, 0x1d, 0xb4, 0x61, 0xf6, 0x94, 0x26, 0x47, 0x51, 0x4a, + 0x31, 0x66, 0x98, 0x73, 0xe4, 0x27, 0x13, 0x64, 0x98, 0xfa, 0x61, 0xbf, 0x9b, 0xba, 0xa1, 0x77, + 0x14, 0xbd, 0xc4, 0x08, 0x61, 0xce, 0x69, 0x22, 0xf0, 0x90, 0xc3, 0xc8, 0x0d, 0x68, 0x9e, 0x64, + 0x59, 0xdc, 0x65, 0xa1, 0x4b, 0x34, 0xcc, 0x44, 0x40, 0xd0, 0x60, 0xb0, 0xa7, 0x1c, 0xc4, 0x0e, + 0x36, 0xa2, 0x0c, 0x53, 0x9a, 0xb8, 0x7d, 0x1a, 0x66, 0xed, 0x19, 0x7e, 0xb0, 0x19, 0xf4, 0x47, + 0x12, 0x48, 0xb6, 0x00, 0x10, 0x2d, 0x4e, 0xa2, 0x97, 0xe7, 0xed, 0x59, 0x6e, 0x7a, 0x0c, 0x72, + 0xc0, 0x00, 0x4c, 0x7f, 0x47, 0x6e, 0x4a, 0x65, 0xe8, 0xe1, 0xd3, 0xb4, 0x3d, 0xc7, 0xf5, 0xc7, + 0xc0, 0x7b, 0x0a, 0x4a, 0xba, 0x2c, 0xee, 0x10, 0x5a, 0xef, 0xba, 0x69, 0x4a, 0xb3, 0xb4, 0x5d, + 0x47, 0x03, 0x7a, 0x58, 0x61, 0x40, 0x85, 0xf8, 0x43, 0xcc, 0xdb, 0xc5, 0x69, 0x2a, 0xfe, 0x30, + 0xa0, 0x2c, 0xde, 0x72, 0x87, 0xd9, 0x09, 0x0d, 0x33, 0x76, 0x7b, 0x30, 0x26, 0xb1, 0xdf, 0x06, + 0xd4, 0x4d, 0xcb, 0x18, 0xd8, 0x8d, 0xfd, 0xce, 0xe7, 0x2c, 0xb8, 0x28, 0x53, 0xad, 0x30, 0xc1, + 0x37, 0x4d, 0x57, 0xb2, 0x26, 0x85, 0x35, 0xed, 0x48, 0x37, 0xcd, 0x33, 0x68, 0xed, 0xd3, 0xec, + 0xa9, 0xdf, 0x7b, 0x41, 0x93, 0x09, 0x8c, 0x92, 0xdc, 0x81, 0x69, 0x66, 0x51, 0x82, 0xc1, 0x8a, + 0xba, 0x09, 0x45, 0xc4, 0xc6, 0x18, 0x39, 0x88, 0xc1, 0xf6, 0x02, 0x35, 0xd7, 0xcd, 0xce, 0x63, + 0x6e, 0x17, 0x75, 0xa7, 0x8e, 0x90, 0xa7, 0xe7, 0x31, 0xb5, 0x9f, 0x41, 0x53, 0x9f, 0xc4, 0x9c, + 0x86, 0x47, 0x03, 0x7f, 0xe0, 0x67, 0x34, 0x91, 0x4e, 0x43, 0x01, 0x98, 0x3d, 0xb2, 0x2d, 0x12, + 0x76, 0x8c, 0xbf, 0xd9, 0x79, 0xfb, 0x72, 0x18, 0x65, 0x92, 0x36, 0xff, 0xb0, 0xff, 0xb2, 0x06, + 0x0b, 0x72, 0x39, 0xc2, 0x98, 0xa5, 0xcc, 0xd6, 0x85, 0x32, 0xdf, 0x80, 0x66, 0xe0, 0xa6, 0x59, + 0x77, 0x18, 0x7b, 0xae, 0x0c, 0x6d, 0xa6, 0x9c, 0x06, 0x83, 0xfd, 0x88, 0x83, 0x98, 0x45, 0xcb, + 0xc8, 0x15, 0xcf, 0x96, 0xe0, 0xde, 0xec, 0xe9, 0x8b, 0x21, 0x30, 0xcd, 0xe6, 0xa0, 0xb5, 0x5b, + 0x0e, 0xfe, 0x66, 0xb0, 0x13, 0xbf, 0x7f, 0x82, 0xd6, 0x6d, 0x39, 0xf8, 0x9b, 0xed, 0x60, 0x10, + 0x9d, 0xa1, 0x2d, 0x5b,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, 0xba, 0xe9, 0x8b, 0xb4, + 0x3d, 0x3d, 0x16, 0x95, 0xa1, 0x94, 0xce, 0xc3, 0x95, 0xf2, 0x79, 0x30, 0x75, 0x39, 0x53, 0xd4, + 0x25, 0x8f, 0x56, 0x15, 0x6d, 0x65, 0x79, 0x3d, 0x80, 0x1c, 0x38, 0x76, 0x5b, 0x7f, 0x0d, 0x20, + 0x52, 0x98, 0xc2, 0xfe, 0xae, 0x96, 0x84, 0x56, 0x26, 0xa8, 0x21, 0xdb, 0x9f, 0x60, 0xa8, 0xa1, + 0x33, 0x17, 0xca, 0x7f, 0x60, 0xd0, 0xe4, 0xb6, 0x48, 0x4a, 0x34, 0x53, 0x83, 0xd8, 0xbb, 0x48, + 0x6c, 0xb7, 0xd7, 0x63, 0x5b, 0xaf, 0x25, 0xe6, 0x63, 0xef, 0xf0, 0x67, 0x30, 0x2b, 0x66, 0x08, + 0xb3, 0xe0, 0x08, 0x35, 0xdf, 0x23, 0xef, 0x03, 0x68, 0xf7, 0x10, 0x5f, 0xd7, 0x86, 0x94, 0x41, + 0x4c, 0x92, 0xd6, 0x80, 0xec, 0x34, 0x74, 0xfb, 0x18, 0x96, 0x2b, 0x50, 0x98, 0x28, 0x2a, 0xad, + 0x16, 0xa2, 0xc8, 0x6f, 0xb2, 0x0d, 0x8d, 0x2c, 0xca, 0xdc, 0xa0, 0x9b, 0xdf, 0x10, 0x96, 0x03, + 0x08, 0x7a, 0xc6, 0x20, 0xe8, 0xa0, 0xa2, 0x80, 0x5b, 0x2e, 0x73, 0x50, 0x51, 0xe0, 0xd9, 0x2e, + 0x06, 0x5e, 0xc6, 0xa2, 0x85, 0x0a, 0xc7, 0x6d, 0xd9, 0xb7, 0x61, 0xce, 0xe5, 0x53, 0xe4, 0xc2, + 0x16, 0x0b, 0x0b, 0x73, 0x14, 0x82, 0x4d, 0xf0, 0x06, 0xda, 0x8b, 0xc2, 0x63, 0xbf, 0x2f, 0xad, + 0xe3, 0x0d, 0x74, 0x56,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, 0x03, 0x31, 0xb3, 0x24, 0xfc, 0x9b, 0x0c, 0xe5, 0x05, + 0x2a, 0x6a, 0x87, 0x93, 0xa5, 0x48, 0x37, 0x90, 0xf1, 0x86, 0xbd, 0x56, 0x4e, 0x91, 0x18, 0x6f, + 0xc6, 0xfa, 0xf7, 0x60, 0xb9, 0x90, 0x7b, 0xbf, 0x22, 0xde, 0x86, 0x39, 0x17, 0x12, 0x6f, 0xc9, + 0x3c, 0xc3, 0x3c, 0xb8, 0x50, 0x10, 0x24, 0x37, 0xaa, 0xf2, 0x0d, 0xa3, 0xde, 0x36, 0x2e, 0xf3, + 0x11, 0xf7, 0x06, 0x59, 0x2b, 0xa5, 0x23, 0x48, 0xe1, 0x6d, 0x8b, 0xfc, 0x99, 0x85, 0x6d, 0xf0, + 0x23, 0xea, 0x91, 0xe4, 0x6e, 0x55, 0xc2, 0x7b, 0x69, 0x31, 0x84, 0x3f, 0x21, 0xd7, 0x8a, 0x59, + 0x71, 0x49, 0x9c, 0x13, 0xac, 0x40, 0xe8, 0x55, 0x45, 0x23, 0x27, 0xaf, 0x28, 0x37, 0x8e, 0x4c, + 0x5a, 0x8b, 0xa9, 0xb8, 0xc8, 0x3a, 0x25, 0xa7, 0x9f, 0x98, 0x7f, 0xec, 0x6a, 0xb0, 0xbc, 0x5d, + 0xb1, 0xea, 0xcb, 0xb0, 0xbe, 0x89, 0xac, 0xb7, 0xc8, 0x46, 0x61, 0xbd, 0x99, 0x21, 0xc2, 0xd1, + 0x0c, 0xfe, 0xf3, 0x14, 0xef, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xa4, 0xbf, 0x47, + 0xd1, 0x42, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -5168,6 +5371,10 @@ type GoCryptoTraderClient interface { GetExchangePairs(ctx context.Context, in *GetExchangePairsRequest, opts ...grpc.CallOption) (*GetExchangePairsResponse, error) EnableExchangePair(ctx context.Context, in *ExchangePairRequest, opts ...grpc.CallOption) (*GenericExchangeNameResponse, error) DisableExchangePair(ctx context.Context, in *ExchangePairRequest, opts ...grpc.CallOption) (*GenericExchangeNameResponse, error) + GetOrderbookStream(ctx context.Context, in *GetOrderbookStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetOrderbookStreamClient, error) + GetExchangeOrderbookStream(ctx context.Context, in *GetExchangeOrderbookStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetExchangeOrderbookStreamClient, error) + GetTickerStream(ctx context.Context, in *GetTickerStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetTickerStreamClient, error) + GetExchangeTickerStream(ctx context.Context, in *GetExchangeTickerStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetExchangeTickerStreamClient, error) } type goCryptoTraderClient struct { @@ -5565,6 +5772,134 @@ func (c *goCryptoTraderClient) DisableExchangePair(ctx context.Context, in *Exch return out, nil } +func (c *goCryptoTraderClient) GetOrderbookStream(ctx context.Context, in *GetOrderbookStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetOrderbookStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_GoCryptoTrader_serviceDesc.Streams[0], "/gctrpc.GoCryptoTrader/GetOrderbookStream", opts...) + if err != nil { + return nil, err + } + x := &goCryptoTraderGetOrderbookStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GoCryptoTrader_GetOrderbookStreamClient interface { + Recv() (*OrderbookResponse, error) + grpc.ClientStream +} + +type goCryptoTraderGetOrderbookStreamClient struct { + grpc.ClientStream +} + +func (x *goCryptoTraderGetOrderbookStreamClient) Recv() (*OrderbookResponse, error) { + m := new(OrderbookResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *goCryptoTraderClient) GetExchangeOrderbookStream(ctx context.Context, in *GetExchangeOrderbookStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetExchangeOrderbookStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_GoCryptoTrader_serviceDesc.Streams[1], "/gctrpc.GoCryptoTrader/GetExchangeOrderbookStream", opts...) + if err != nil { + return nil, err + } + x := &goCryptoTraderGetExchangeOrderbookStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GoCryptoTrader_GetExchangeOrderbookStreamClient interface { + Recv() (*OrderbookResponse, error) + grpc.ClientStream +} + +type goCryptoTraderGetExchangeOrderbookStreamClient struct { + grpc.ClientStream +} + +func (x *goCryptoTraderGetExchangeOrderbookStreamClient) Recv() (*OrderbookResponse, error) { + m := new(OrderbookResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *goCryptoTraderClient) GetTickerStream(ctx context.Context, in *GetTickerStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetTickerStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_GoCryptoTrader_serviceDesc.Streams[2], "/gctrpc.GoCryptoTrader/GetTickerStream", opts...) + if err != nil { + return nil, err + } + x := &goCryptoTraderGetTickerStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GoCryptoTrader_GetTickerStreamClient interface { + Recv() (*TickerResponse, error) + grpc.ClientStream +} + +type goCryptoTraderGetTickerStreamClient struct { + grpc.ClientStream +} + +func (x *goCryptoTraderGetTickerStreamClient) Recv() (*TickerResponse, error) { + m := new(TickerResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *goCryptoTraderClient) GetExchangeTickerStream(ctx context.Context, in *GetExchangeTickerStreamRequest, opts ...grpc.CallOption) (GoCryptoTrader_GetExchangeTickerStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_GoCryptoTrader_serviceDesc.Streams[3], "/gctrpc.GoCryptoTrader/GetExchangeTickerStream", opts...) + if err != nil { + return nil, err + } + x := &goCryptoTraderGetExchangeTickerStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GoCryptoTrader_GetExchangeTickerStreamClient interface { + Recv() (*TickerResponse, error) + grpc.ClientStream +} + +type goCryptoTraderGetExchangeTickerStreamClient struct { + grpc.ClientStream +} + +func (x *goCryptoTraderGetExchangeTickerStreamClient) Recv() (*TickerResponse, error) { + m := new(TickerResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // GoCryptoTraderServer is the server API for GoCryptoTrader service. type GoCryptoTraderServer interface { GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) @@ -5610,6 +5945,156 @@ type GoCryptoTraderServer interface { GetExchangePairs(context.Context, *GetExchangePairsRequest) (*GetExchangePairsResponse, error) EnableExchangePair(context.Context, *ExchangePairRequest) (*GenericExchangeNameResponse, error) DisableExchangePair(context.Context, *ExchangePairRequest) (*GenericExchangeNameResponse, error) + GetOrderbookStream(*GetOrderbookStreamRequest, GoCryptoTrader_GetOrderbookStreamServer) error + GetExchangeOrderbookStream(*GetExchangeOrderbookStreamRequest, GoCryptoTrader_GetExchangeOrderbookStreamServer) error + GetTickerStream(*GetTickerStreamRequest, GoCryptoTrader_GetTickerStreamServer) error + GetExchangeTickerStream(*GetExchangeTickerStreamRequest, GoCryptoTrader_GetExchangeTickerStreamServer) error +} + +// UnimplementedGoCryptoTraderServer can be embedded to have forward compatible implementations. +type UnimplementedGoCryptoTraderServer struct { +} + +func (*UnimplementedGoCryptoTraderServer) GetInfo(ctx context.Context, req *GetInfoRequest) (*GetInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetSubsystems(ctx context.Context, req *GetSubsystemsRequest) (*GetSusbsytemsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSubsystems not implemented") +} +func (*UnimplementedGoCryptoTraderServer) EnableSubsystem(ctx context.Context, req *GenericSubsystemRequest) (*GenericSubsystemResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EnableSubsystem not implemented") +} +func (*UnimplementedGoCryptoTraderServer) DisableSubsystem(ctx context.Context, req *GenericSubsystemRequest) (*GenericSubsystemResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DisableSubsystem not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetRPCEndpoints(ctx context.Context, req *GetRPCEndpointsRequest) (*GetRPCEndpointsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRPCEndpoints not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetCommunicationRelayers(ctx context.Context, req *GetCommunicationRelayersRequest) (*GetCommunicationRelayersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCommunicationRelayers not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetExchanges(ctx context.Context, req *GetExchangesRequest) (*GetExchangesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetExchanges not implemented") +} +func (*UnimplementedGoCryptoTraderServer) DisableExchange(ctx context.Context, req *GenericExchangeNameRequest) (*GenericExchangeNameResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DisableExchange not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetExchangeInfo(ctx context.Context, req *GenericExchangeNameRequest) (*GetExchangeInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetExchangeInfo not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetExchangeOTPCode(ctx context.Context, req *GenericExchangeNameRequest) (*GetExchangeOTPReponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetExchangeOTPCode not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetExchangeOTPCodes(ctx context.Context, req *GetExchangeOTPsRequest) (*GetExchangeOTPsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetExchangeOTPCodes not implemented") +} +func (*UnimplementedGoCryptoTraderServer) EnableExchange(ctx context.Context, req *GenericExchangeNameRequest) (*GenericExchangeNameResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EnableExchange not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetTicker(ctx context.Context, req *GetTickerRequest) (*TickerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTicker not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetTickers(ctx context.Context, req *GetTickersRequest) (*GetTickersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTickers not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetOrderbook(ctx context.Context, req *GetOrderbookRequest) (*OrderbookResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOrderbook not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetOrderbooks(ctx context.Context, req *GetOrderbooksRequest) (*GetOrderbooksResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOrderbooks not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetAccountInfo(ctx context.Context, req *GetAccountInfoRequest) (*GetAccountInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAccountInfo not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetConfig(ctx context.Context, req *GetConfigRequest) (*GetConfigResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetConfig not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetPortfolio(ctx context.Context, req *GetPortfolioRequest) (*GetPortfolioResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPortfolio not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetPortfolioSummary(ctx context.Context, req *GetPortfolioSummaryRequest) (*GetPortfolioSummaryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPortfolioSummary not implemented") +} +func (*UnimplementedGoCryptoTraderServer) AddPortfolioAddress(ctx context.Context, req *AddPortfolioAddressRequest) (*AddPortfolioAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddPortfolioAddress not implemented") +} +func (*UnimplementedGoCryptoTraderServer) RemovePortfolioAddress(ctx context.Context, req *RemovePortfolioAddressRequest) (*RemovePortfolioAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemovePortfolioAddress not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetForexProviders(ctx context.Context, req *GetForexProvidersRequest) (*GetForexProvidersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetForexProviders not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetForexRates(ctx context.Context, req *GetForexRatesRequest) (*GetForexRatesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetForexRates not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetOrders(ctx context.Context, req *GetOrdersRequest) (*GetOrdersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOrders not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetOrder(ctx context.Context, req *GetOrderRequest) (*OrderDetails, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOrder not implemented") +} +func (*UnimplementedGoCryptoTraderServer) SubmitOrder(ctx context.Context, req *SubmitOrderRequest) (*SubmitOrderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitOrder not implemented") +} +func (*UnimplementedGoCryptoTraderServer) SimulateOrder(ctx context.Context, req *SimulateOrderRequest) (*SimulateOrderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SimulateOrder not implemented") +} +func (*UnimplementedGoCryptoTraderServer) WhaleBomb(ctx context.Context, req *WhaleBombRequest) (*SimulateOrderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WhaleBomb not implemented") +} +func (*UnimplementedGoCryptoTraderServer) CancelOrder(ctx context.Context, req *CancelOrderRequest) (*CancelOrderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CancelOrder not implemented") +} +func (*UnimplementedGoCryptoTraderServer) CancelAllOrders(ctx context.Context, req *CancelAllOrdersRequest) (*CancelAllOrdersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CancelAllOrders not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetEvents(ctx context.Context, req *GetEventsRequest) (*GetEventsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetEvents not implemented") +} +func (*UnimplementedGoCryptoTraderServer) AddEvent(ctx context.Context, req *AddEventRequest) (*AddEventResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddEvent not implemented") +} +func (*UnimplementedGoCryptoTraderServer) RemoveEvent(ctx context.Context, req *RemoveEventRequest) (*RemoveEventResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveEvent not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetCryptocurrencyDepositAddresses(ctx context.Context, req *GetCryptocurrencyDepositAddressesRequest) (*GetCryptocurrencyDepositAddressesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCryptocurrencyDepositAddresses not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetCryptocurrencyDepositAddress(ctx context.Context, req *GetCryptocurrencyDepositAddressRequest) (*GetCryptocurrencyDepositAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCryptocurrencyDepositAddress not implemented") +} +func (*UnimplementedGoCryptoTraderServer) WithdrawCryptocurrencyFunds(ctx context.Context, req *WithdrawCurrencyRequest) (*WithdrawResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawCryptocurrencyFunds not implemented") +} +func (*UnimplementedGoCryptoTraderServer) WithdrawFiatFunds(ctx context.Context, req *WithdrawCurrencyRequest) (*WithdrawResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawFiatFunds not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetLoggerDetails(ctx context.Context, req *GetLoggerDetailsRequest) (*GetLoggerDetailsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetLoggerDetails not implemented") +} +func (*UnimplementedGoCryptoTraderServer) SetLoggerDetails(ctx context.Context, req *SetLoggerDetailsRequest) (*GetLoggerDetailsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetLoggerDetails not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetExchangePairs(ctx context.Context, req *GetExchangePairsRequest) (*GetExchangePairsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetExchangePairs not implemented") +} +func (*UnimplementedGoCryptoTraderServer) EnableExchangePair(ctx context.Context, req *ExchangePairRequest) (*GenericExchangeNameResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EnableExchangePair not implemented") +} +func (*UnimplementedGoCryptoTraderServer) DisableExchangePair(ctx context.Context, req *ExchangePairRequest) (*GenericExchangeNameResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DisableExchangePair not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetOrderbookStream(req *GetOrderbookStreamRequest, srv GoCryptoTrader_GetOrderbookStreamServer) error { + return status.Errorf(codes.Unimplemented, "method GetOrderbookStream not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetExchangeOrderbookStream(req *GetExchangeOrderbookStreamRequest, srv GoCryptoTrader_GetExchangeOrderbookStreamServer) error { + return status.Errorf(codes.Unimplemented, "method GetExchangeOrderbookStream not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetTickerStream(req *GetTickerStreamRequest, srv GoCryptoTrader_GetTickerStreamServer) error { + return status.Errorf(codes.Unimplemented, "method GetTickerStream not implemented") +} +func (*UnimplementedGoCryptoTraderServer) GetExchangeTickerStream(req *GetExchangeTickerStreamRequest, srv GoCryptoTrader_GetExchangeTickerStreamServer) error { + return status.Errorf(codes.Unimplemented, "method GetExchangeTickerStream not implemented") } func RegisterGoCryptoTraderServer(s *grpc.Server, srv GoCryptoTraderServer) { @@ -6390,6 +6875,90 @@ func _GoCryptoTrader_DisableExchangePair_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _GoCryptoTrader_GetOrderbookStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetOrderbookStreamRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GoCryptoTraderServer).GetOrderbookStream(m, &goCryptoTraderGetOrderbookStreamServer{stream}) +} + +type GoCryptoTrader_GetOrderbookStreamServer interface { + Send(*OrderbookResponse) error + grpc.ServerStream +} + +type goCryptoTraderGetOrderbookStreamServer struct { + grpc.ServerStream +} + +func (x *goCryptoTraderGetOrderbookStreamServer) Send(m *OrderbookResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _GoCryptoTrader_GetExchangeOrderbookStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetExchangeOrderbookStreamRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GoCryptoTraderServer).GetExchangeOrderbookStream(m, &goCryptoTraderGetExchangeOrderbookStreamServer{stream}) +} + +type GoCryptoTrader_GetExchangeOrderbookStreamServer interface { + Send(*OrderbookResponse) error + grpc.ServerStream +} + +type goCryptoTraderGetExchangeOrderbookStreamServer struct { + grpc.ServerStream +} + +func (x *goCryptoTraderGetExchangeOrderbookStreamServer) Send(m *OrderbookResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _GoCryptoTrader_GetTickerStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetTickerStreamRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GoCryptoTraderServer).GetTickerStream(m, &goCryptoTraderGetTickerStreamServer{stream}) +} + +type GoCryptoTrader_GetTickerStreamServer interface { + Send(*TickerResponse) error + grpc.ServerStream +} + +type goCryptoTraderGetTickerStreamServer struct { + grpc.ServerStream +} + +func (x *goCryptoTraderGetTickerStreamServer) Send(m *TickerResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _GoCryptoTrader_GetExchangeTickerStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetExchangeTickerStreamRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GoCryptoTraderServer).GetExchangeTickerStream(m, &goCryptoTraderGetExchangeTickerStreamServer{stream}) +} + +type GoCryptoTrader_GetExchangeTickerStreamServer interface { + Send(*TickerResponse) error + grpc.ServerStream +} + +type goCryptoTraderGetExchangeTickerStreamServer struct { + grpc.ServerStream +} + +func (x *goCryptoTraderGetExchangeTickerStreamServer) Send(m *TickerResponse) error { + return x.ServerStream.SendMsg(m) +} + var _GoCryptoTrader_serviceDesc = grpc.ServiceDesc{ ServiceName: "gctrpc.GoCryptoTrader", HandlerType: (*GoCryptoTraderServer)(nil), @@ -6567,6 +7136,27 @@ var _GoCryptoTrader_serviceDesc = grpc.ServiceDesc{ Handler: _GoCryptoTrader_DisableExchangePair_Handler, }, }, - Streams: []grpc.StreamDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetOrderbookStream", + Handler: _GoCryptoTrader_GetOrderbookStream_Handler, + ServerStreams: true, + }, + { + StreamName: "GetExchangeOrderbookStream", + Handler: _GoCryptoTrader_GetExchangeOrderbookStream_Handler, + ServerStreams: true, + }, + { + StreamName: "GetTickerStream", + Handler: _GoCryptoTrader_GetTickerStream_Handler, + ServerStreams: true, + }, + { + StreamName: "GetExchangeTickerStream", + Handler: _GoCryptoTrader_GetExchangeTickerStream_Handler, + ServerStreams: true, + }, + }, Metadata: "rpc.proto", } diff --git a/gctrpc/rpc.pb.gw.go b/gctrpc/rpc.pb.gw.go index 37957646..958df2af 100644 --- a/gctrpc/rpc.pb.gw.go +++ b/gctrpc/rpc.pb.gw.go @@ -9,13 +9,13 @@ It translates gRPC into RESTful JSON APIs. package gctrpc import ( + "context" "io" "net/http" "github.com/golang/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/utilities" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" @@ -54,7 +54,10 @@ func request_GoCryptoTrader_EnableSubsystem_0(ctx context.Context, marshaler run var protoReq GenericSubsystemRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_EnableSubsystem_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_EnableSubsystem_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -71,7 +74,10 @@ func request_GoCryptoTrader_DisableSubsystem_0(ctx context.Context, marshaler ru var protoReq GenericSubsystemRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_DisableSubsystem_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_DisableSubsystem_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -106,7 +112,10 @@ func request_GoCryptoTrader_GetExchanges_0(ctx context.Context, marshaler runtim var protoReq GetExchangesRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetExchanges_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchanges_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -140,7 +149,10 @@ func request_GoCryptoTrader_GetExchangeInfo_0(ctx context.Context, marshaler run var protoReq GenericExchangeNameRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetExchangeInfo_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchangeInfo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -157,7 +169,10 @@ func request_GoCryptoTrader_GetExchangeOTPCode_0(ctx context.Context, marshaler var protoReq GenericExchangeNameRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetExchangeOTPCode_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchangeOTPCode_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -252,7 +267,10 @@ func request_GoCryptoTrader_GetAccountInfo_0(ctx context.Context, marshaler runt var protoReq GetAccountInfoRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetAccountInfo_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetAccountInfo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -578,7 +596,10 @@ func request_GoCryptoTrader_GetLoggerDetails_0(ctx context.Context, marshaler ru var protoReq GetLoggerDetailsRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetLoggerDetails_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetLoggerDetails_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -655,6 +676,118 @@ func request_GoCryptoTrader_DisableExchangePair_0(ctx context.Context, marshaler } +var ( + filter_GoCryptoTrader_GetOrderbookStream_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_GoCryptoTrader_GetOrderbookStream_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (GoCryptoTrader_GetOrderbookStreamClient, runtime.ServerMetadata, error) { + var protoReq GetOrderbookStreamRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetOrderbookStream_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + stream, err := client.GetOrderbookStream(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil + +} + +var ( + filter_GoCryptoTrader_GetExchangeOrderbookStream_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_GoCryptoTrader_GetExchangeOrderbookStream_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (GoCryptoTrader_GetExchangeOrderbookStreamClient, runtime.ServerMetadata, error) { + var protoReq GetExchangeOrderbookStreamRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchangeOrderbookStream_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + stream, err := client.GetExchangeOrderbookStream(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil + +} + +var ( + filter_GoCryptoTrader_GetTickerStream_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_GoCryptoTrader_GetTickerStream_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (GoCryptoTrader_GetTickerStreamClient, runtime.ServerMetadata, error) { + var protoReq GetTickerStreamRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetTickerStream_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + stream, err := client.GetTickerStream(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil + +} + +var ( + filter_GoCryptoTrader_GetExchangeTickerStream_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_GoCryptoTrader_GetExchangeTickerStream_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (GoCryptoTrader_GetExchangeTickerStreamClient, runtime.ServerMetadata, error) { + var protoReq GetExchangeTickerStreamRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchangeTickerStream_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + stream, err := client.GetExchangeTickerStream(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil + +} + // RegisterGoCryptoTraderHandlerFromEndpoint is same as RegisterGoCryptoTraderHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterGoCryptoTraderHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { @@ -1553,95 +1686,183 @@ func RegisterGoCryptoTraderHandlerClient(ctx context.Context, mux *runtime.Serve }) + mux.Handle("GET", pattern_GoCryptoTrader_GetOrderbookStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GoCryptoTrader_GetOrderbookStream_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_GoCryptoTrader_GetOrderbookStream_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_GoCryptoTrader_GetExchangeOrderbookStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GoCryptoTrader_GetExchangeOrderbookStream_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_GoCryptoTrader_GetExchangeOrderbookStream_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_GoCryptoTrader_GetTickerStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GoCryptoTrader_GetTickerStream_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_GoCryptoTrader_GetTickerStream_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_GoCryptoTrader_GetExchangeTickerStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GoCryptoTrader_GetExchangeTickerStream_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_GoCryptoTrader_GetExchangeTickerStream_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_GoCryptoTrader_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getinfo"}, "")) + pattern_GoCryptoTrader_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getinfo"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetSubsystems_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getsusbsystems"}, "")) + pattern_GoCryptoTrader_GetSubsystems_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getsusbsystems"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_EnableSubsystem_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "enablesubsystem"}, "")) + pattern_GoCryptoTrader_EnableSubsystem_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "enablesubsystem"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_DisableSubsystem_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "disablesubsystem"}, "")) + pattern_GoCryptoTrader_DisableSubsystem_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "disablesubsystem"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetRPCEndpoints_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getrpcendpoints"}, "")) + pattern_GoCryptoTrader_GetRPCEndpoints_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getrpcendpoints"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetCommunicationRelayers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getcommunicationrelayers"}, "")) + pattern_GoCryptoTrader_GetCommunicationRelayers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getcommunicationrelayers"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetExchanges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchanges"}, "")) + pattern_GoCryptoTrader_GetExchanges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchanges"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_DisableExchange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "disableexchange"}, "")) + pattern_GoCryptoTrader_DisableExchange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "disableexchange"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetExchangeInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeinfo"}, "")) + pattern_GoCryptoTrader_GetExchangeInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeinfo"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetExchangeOTPCode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeotp"}, "")) + pattern_GoCryptoTrader_GetExchangeOTPCode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeotp"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetExchangeOTPCodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeotps"}, "")) + pattern_GoCryptoTrader_GetExchangeOTPCodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeotps"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_EnableExchange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "enableexchange"}, "")) + pattern_GoCryptoTrader_EnableExchange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "enableexchange"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetTicker_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getticker"}, "")) + pattern_GoCryptoTrader_GetTicker_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getticker"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetTickers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "gettickers"}, "")) + pattern_GoCryptoTrader_GetTickers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "gettickers"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetOrderbook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorderbook"}, "")) + pattern_GoCryptoTrader_GetOrderbook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorderbook"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetOrderbooks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorderbooks"}, "")) + pattern_GoCryptoTrader_GetOrderbooks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorderbooks"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetAccountInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getaccountinfo"}, "")) + pattern_GoCryptoTrader_GetAccountInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getaccountinfo"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getconfig"}, "")) + pattern_GoCryptoTrader_GetConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getconfig"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetPortfolio_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getportfolio"}, "")) + pattern_GoCryptoTrader_GetPortfolio_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getportfolio"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetPortfolioSummary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getportfoliosummary"}, "")) + pattern_GoCryptoTrader_GetPortfolioSummary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getportfoliosummary"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_AddPortfolioAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "addportfolioaddress"}, "")) + pattern_GoCryptoTrader_AddPortfolioAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "addportfolioaddress"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_RemovePortfolioAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "removeportfolioaddress"}, "")) + pattern_GoCryptoTrader_RemovePortfolioAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "removeportfolioaddress"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetForexProviders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getforexproviders"}, "")) + pattern_GoCryptoTrader_GetForexProviders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getforexproviders"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetForexRates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getforexrates"}, "")) + pattern_GoCryptoTrader_GetForexRates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getforexrates"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorders"}, "")) + pattern_GoCryptoTrader_GetOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorders"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorder"}, "")) + pattern_GoCryptoTrader_GetOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorder"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_SubmitOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "submitorder"}, "")) + pattern_GoCryptoTrader_SubmitOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "submitorder"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_SimulateOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "simulateorder"}, "")) + pattern_GoCryptoTrader_SimulateOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "simulateorder"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_WhaleBomb_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "whalebomb"}, "")) + pattern_GoCryptoTrader_WhaleBomb_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "whalebomb"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_CancelOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cancelorder"}, "")) + pattern_GoCryptoTrader_CancelOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cancelorder"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_CancelAllOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cancelallorders"}, "")) + pattern_GoCryptoTrader_CancelAllOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cancelallorders"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetEvents_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getevents"}, "")) + pattern_GoCryptoTrader_GetEvents_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getevents"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_AddEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "addevent"}, "")) + pattern_GoCryptoTrader_AddEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "addevent"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_RemoveEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "removeevent"}, "")) + pattern_GoCryptoTrader_RemoveEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "removeevent"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetCryptocurrencyDepositAddresses_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getcryptodepositaddresses"}, "")) + pattern_GoCryptoTrader_GetCryptocurrencyDepositAddresses_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getcryptodepositaddresses"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetCryptocurrencyDepositAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getcryptodepositaddress"}, "")) + pattern_GoCryptoTrader_GetCryptocurrencyDepositAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getcryptodepositaddress"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_WithdrawCryptocurrencyFunds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "withdrawcryptofunds"}, "")) + pattern_GoCryptoTrader_WithdrawCryptocurrencyFunds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "withdrawcryptofunds"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_WithdrawFiatFunds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "withdrawfiatfunds"}, "")) + pattern_GoCryptoTrader_WithdrawFiatFunds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "withdrawfiatfunds"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetLoggerDetails_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getloggerdetails"}, "")) + pattern_GoCryptoTrader_GetLoggerDetails_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getloggerdetails"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_SetLoggerDetails_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "setloggerdetails"}, "")) + pattern_GoCryptoTrader_SetLoggerDetails_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "setloggerdetails"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_GetExchangePairs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangepairs"}, "")) + pattern_GoCryptoTrader_GetExchangePairs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangepairs"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_EnableExchangePair_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "enableexchangepair"}, "")) + pattern_GoCryptoTrader_EnableExchangePair_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "enableexchangepair"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_GoCryptoTrader_DisableExchangePair_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "disableexchangepair"}, "")) + pattern_GoCryptoTrader_DisableExchangePair_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "disableexchangepair"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_GoCryptoTrader_GetOrderbookStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getorderbookstream"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_GoCryptoTrader_GetExchangeOrderbookStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeorderbookstream"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_GoCryptoTrader_GetTickerStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getTickerstream"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_GoCryptoTrader_GetExchangeTickerStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangetickerstream"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1730,4 +1951,12 @@ var ( forward_GoCryptoTrader_EnableExchangePair_0 = runtime.ForwardResponseMessage forward_GoCryptoTrader_DisableExchangePair_0 = runtime.ForwardResponseMessage + + forward_GoCryptoTrader_GetOrderbookStream_0 = runtime.ForwardResponseStream + + forward_GoCryptoTrader_GetExchangeOrderbookStream_0 = runtime.ForwardResponseStream + + forward_GoCryptoTrader_GetTickerStream_0 = runtime.ForwardResponseStream + + forward_GoCryptoTrader_GetExchangeTickerStream_0 = runtime.ForwardResponseStream ) diff --git a/gctrpc/rpc.proto b/gctrpc/rpc.proto index 33c4cbdb..9e25a8f9 100644 --- a/gctrpc/rpc.proto +++ b/gctrpc/rpc.proto @@ -489,6 +489,26 @@ message ExchangePairRequest { CurrencyPair pair = 3; } +message GetOrderbookStreamRequest { + string exchange = 1; + CurrencyPair pair = 2; + string asset_type = 3; +} + +message GetExchangeOrderbookStreamRequest { + string exchange = 1; +} + +message GetTickerStreamRequest { + string exchange = 1; + CurrencyPair pair = 2; + string asset_type = 3; +} + +message GetExchangeTickerStreamRequest { + string exchange = 1; +} + service GoCryptoTrader { rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) { option (google.api.http) = { @@ -771,4 +791,28 @@ service GoCryptoTrader { body: "*" }; } + + rpc GetOrderbookStream(GetOrderbookStreamRequest) returns (stream OrderbookResponse) { + option (google.api.http) = { + get: "/v1/getorderbookstream" + }; + } + + rpc GetExchangeOrderbookStream(GetExchangeOrderbookStreamRequest) returns (stream OrderbookResponse) { + option (google.api.http) = { + get: "/v1/getexchangeorderbookstream" + }; + } + + rpc GetTickerStream(GetTickerStreamRequest) returns (stream TickerResponse) { + option (google.api.http) = { + get: "/v1/getTickerstream" + }; + } + + rpc GetExchangeTickerStream(GetExchangeTickerStreamRequest) returns (stream TickerResponse) { + option (google.api.http) = { + get: "/v1/getexchangetickerstream" + }; + } } diff --git a/gctrpc/rpc.swagger.json b/gctrpc/rpc.swagger.json index f1759936..ac1504b8 100644 --- a/gctrpc/rpc.swagger.json +++ b/gctrpc/rpc.swagger.json @@ -271,6 +271,54 @@ ] } }, + "/v1/getTickerstream": { + "get": { + "operationId": "GetTickerStream", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "$ref": "#/x-stream-definitions/gctrpcTickerResponse" + } + } + }, + "parameters": [ + { + "name": "exchange", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "pair.delimiter", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "pair.base", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "pair.quote", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "asset_type", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "GoCryptoTrader" + ] + } + }, "/v1/getaccountinfo": { "get": { "operationId": "GetAccountInfo", @@ -419,6 +467,30 @@ ] } }, + "/v1/getexchangeorderbookstream": { + "get": { + "operationId": "GetExchangeOrderbookStream", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "$ref": "#/x-stream-definitions/gctrpcOrderbookResponse" + } + } + }, + "parameters": [ + { + "name": "exchange", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "GoCryptoTrader" + ] + } + }, "/v1/getexchangeotp": { "get": { "operationId": "GetExchangeOTPCode", @@ -510,6 +582,30 @@ ] } }, + "/v1/getexchangetickerstream": { + "get": { + "operationId": "GetExchangeTickerStream", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "$ref": "#/x-stream-definitions/gctrpcTickerResponse" + } + } + }, + "parameters": [ + { + "name": "exchange", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "GoCryptoTrader" + ] + } + }, "/v1/getforexproviders": { "get": { "operationId": "GetForexProviders", @@ -650,6 +746,54 @@ ] } }, + "/v1/getorderbookstream": { + "get": { + "operationId": "GetOrderbookStream", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "$ref": "#/x-stream-definitions/gctrpcOrderbookResponse" + } + } + }, + "parameters": [ + { + "name": "exchange", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "pair.delimiter", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "pair.base", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "pair.quote", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "asset_type", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "GoCryptoTrader" + ] + } + }, "/v1/getorders": { "post": { "operationId": "GetOrders", @@ -2175,6 +2319,69 @@ "type": "string" } } + }, + "protobufAny": { + "type": "object", + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "type": "string", + "format": "byte" + } + } + }, + "runtimeStreamError": { + "type": "object", + "properties": { + "grpc_code": { + "type": "integer", + "format": "int32" + }, + "http_code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "http_status": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + }, + "x-stream-definitions": { + "gctrpcOrderbookResponse": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/gctrpcOrderbookResponse" + }, + "error": { + "$ref": "#/definitions/runtimeStreamError" + } + }, + "title": "Stream result of gctrpcOrderbookResponse" + }, + "gctrpcTickerResponse": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/gctrpcTickerResponse" + }, + "error": { + "$ref": "#/definitions/runtimeStreamError" + } + }, + "title": "Stream result of gctrpcTickerResponse" } } } diff --git a/go.mod b/go.mod index 38ee1c2f..21c7d742 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/thrasher-corp/gocryptotrader go 1.12 require ( + github.com/cockroachdb/apd v1.1.0 // indirect github.com/gofrs/uuid v3.2.0+incompatible github.com/gogo/protobuf v1.2.1 // indirect github.com/golang/protobuf v1.3.1 @@ -11,16 +12,18 @@ require ( github.com/gorilla/websocket v1.4.0 github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 github.com/grpc-ecosystem/grpc-gateway v1.9.2 + github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect github.com/jackc/pgx v3.5.0+incompatible github.com/jmoiron/sqlx v1.2.0 github.com/mattn/go-sqlite3 v1.11.0 github.com/pkg/errors v0.8.1 // indirect github.com/pquerna/otp v1.2.0 - github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b + github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect + github.com/shopspring/decimal v0.0.0-20190905144223-a36b5d85f337 // indirect github.com/toorop/go-pusher v0.0.0-20180521062818-4521e2eb39fb github.com/urfave/cli v1.20.0 golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 - golang.org/x/net v0.0.0-20190606173856-1492cefac77f + golang.org/x/net v0.0.0-20190606173856-1492cefac77f // indirect google.golang.org/genproto v0.0.0-20190605220351-eb0b1bdb6ae6 google.golang.org/grpc v1.21.1 ) diff --git a/go.sum b/go.sum index 9473d911..89e90902 100644 --- a/go.sum +++ b/go.sum @@ -4,9 +4,12 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI= github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= @@ -29,6 +32,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmo github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/grpc-gateway v1.9.2 h1:S+ef0492XaIknb8LMjcwgW2i3cNTzDYMmDrOThOJNWc= github.com/grpc-ecosystem/grpc-gateway v1.9.2/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc= +github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= github.com/jackc/pgx v3.5.0+incompatible h1:BRJ4G3UPtvml5R1ey0biqqGuYUGayMYekm3woO75orY= github.com/jackc/pgx v3.5.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA= @@ -40,6 +45,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q= @@ -53,6 +59,8 @@ github.com/pquerna/otp v1.2.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/shopspring/decimal v0.0.0-20190905144223-a36b5d85f337 h1:Da9XEUfFxgyDOqUfwgoTDcWzmnlOnCGi6i4iPS+8Fbw= +github.com/shopspring/decimal v0.0.0-20190905144223-a36b5d85f337/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -61,7 +69,6 @@ github.com/toorop/go-pusher v0.0.0-20180521062818-4521e2eb39fb/go.mod h1:VTLqNCX github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/logger/logger_setup.go b/logger/logger_setup.go index 14ac5a07..05887001 100644 --- a/logger/logger_setup.go +++ b/logger/logger_setup.go @@ -146,6 +146,7 @@ func init() { TimeMgr = registerNewSubLogger("timekeeper") WebsocketMgr = registerNewSubLogger("websocket") EventMgr = registerNewSubLogger("event") + DispatchMgr = registerNewSubLogger("dispatch") ExchangeSys = registerNewSubLogger("exchange") GRPCSys = registerNewSubLogger("grpc") diff --git a/logger/sublogger_types.go b/logger/sublogger_types.go index 362e34d5..7bbb027f 100644 --- a/logger/sublogger_types.go +++ b/logger/sublogger_types.go @@ -15,6 +15,7 @@ var ( TimeMgr *subLogger WebsocketMgr *subLogger EventMgr *subLogger + DispatchMgr *subLogger ExchangeSys *subLogger GRPCSys *subLogger diff --git a/main.go b/main.go index e2f2e77f..f30243d8 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/core" mg "github.com/thrasher-corp/gocryptotrader/database/migration" + "github.com/thrasher-corp/gocryptotrader/dispatch" "github.com/thrasher-corp/gocryptotrader/engine" "github.com/thrasher-corp/gocryptotrader/exchanges/request" log "github.com/thrasher-corp/gocryptotrader/logger" @@ -48,6 +49,8 @@ func main() { flag.BoolVar(&settings.EnableDatabaseManager, "databasemanager", true, "enables database manager") flag.DurationVar(&settings.EventManagerDelay, "eventmanagerdelay", time.Duration(0), "sets the event managers sleep delay between event checking") flag.BoolVar(&settings.EnableNTPClient, "ntpclient", true, "enables the NTP client to check system clock drift") + flag.BoolVar(&settings.EnableDispatcher, "dispatch", true, "enables the dispatch system") + flag.Int64Var(&settings.DispatchMaxWorkerAmount, "dispatchworkers", dispatch.DefaultMaxWorkers, "sets the dispatch package max worker generation limit") // Forex provider settings flag.BoolVar(&settings.EnableCurrencyConverter, "currencyconverter", false, "overrides config and sets up foreign exchange Currency Converter")