mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 07:26:47 +00:00
exchanges/websocket: Expose Trades/Fills feed through data channel (#814)
* Expose trade feed websocket exchange data through data channel Most relevant to applications that import GCT as a lib, this allows them to (through configuration, disabled by default) receive trade data through the data channel similarly to the orderbook feed. * exchanges: allow exposure of trade websocket feed through data channel * Expose fill feed websocket abstracted exchange data through data channel * exchanges: allow exposure of fill websocket feed through data channel
This commit is contained in:
@@ -145,11 +145,22 @@ func (w *Websocket) Setup(s *WebsocketSetup) error {
|
||||
w.Wg = new(sync.WaitGroup)
|
||||
w.SetCanUseAuthenticatedEndpoints(s.ExchangeConfig.API.AuthenticatedWebsocketSupport)
|
||||
|
||||
return w.Orderbook.Setup(s.ExchangeConfig,
|
||||
if err := w.Orderbook.Setup(s.ExchangeConfig,
|
||||
s.SortBuffer,
|
||||
s.SortBufferByUpdateIDs,
|
||||
s.UpdateEntriesByID,
|
||||
w.DataHandler); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
w.Trade.Setup(w.exchangeName,
|
||||
s.TradeFeed,
|
||||
w.DataHandler)
|
||||
|
||||
w.Fills.Setup(s.FillsFeed,
|
||||
w.DataHandler)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetupNewConnection sets up an auth or unauth streaming connection
|
||||
|
||||
@@ -6,8 +6,10 @@ import (
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/fill"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/protocol"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/stream/buffer"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/trade"
|
||||
)
|
||||
|
||||
// Websocket functionality list and state consts
|
||||
@@ -72,6 +74,12 @@ type Websocket struct {
|
||||
// Orderbook is a local buffer of orderbooks
|
||||
Orderbook buffer.Orderbook
|
||||
|
||||
// Trade is a notifier of occurring trades
|
||||
Trade trade.Trade
|
||||
|
||||
// Fills is a notifier of occurring fills
|
||||
Fills fill.Fills
|
||||
|
||||
// trafficAlert monitors if there is a halt in traffic throughput
|
||||
TrafficAlert chan struct{}
|
||||
// ReadMessageErrors will received all errors from ws.ReadMessage() and
|
||||
@@ -100,6 +108,9 @@ type WebsocketSetup struct {
|
||||
SortBuffer bool
|
||||
SortBufferByUpdateIDs bool
|
||||
UpdateEntriesByID bool
|
||||
TradeFeed bool
|
||||
// Fill data config values
|
||||
FillsFeed bool
|
||||
}
|
||||
|
||||
// WebsocketConnection contains all the data needed to send a message to a WS
|
||||
|
||||
Reference in New Issue
Block a user