diff --git a/vnpy/gateway/coinbase/coinbase_gateway.py b/vnpy/gateway/coinbase/coinbase_gateway.py index 1730eb72..9ed871cd 100644 --- a/vnpy/gateway/coinbase/coinbase_gateway.py +++ b/vnpy/gateway/coinbase/coinbase_gateway.py @@ -198,6 +198,7 @@ class CoinbaseWebsocketApi(WebsocketClient): } self.orderbooks = {} + self.subscribed = {} def connect( self, @@ -223,6 +224,10 @@ class CoinbaseWebsocketApi(WebsocketClient): def subscribe(self, req: SubscribeRequest): """""" + self.subscribed[req.symbol] = req + if not self._active: + return + symbol = req.symbol exchange = req.exchange @@ -259,6 +264,9 @@ class CoinbaseWebsocketApi(WebsocketClient): """ self.gateway.write_log("Websocket API连接成功") + for req in self.subscribed.values(): + self.subscribe(req) + def on_disconnected(self): """""" self.gateway.write_log("Websocket API连接断开")