From f0590678dfb6f0412f8c791710dfaca28830155f Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 7 Nov 2019 14:31:24 +0800 Subject: [PATCH] [Mod] cache subscribe market data request before websocket api is connected --- vnpy/gateway/coinbase/coinbase_gateway.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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连接断开")