From c414f561f6d37d2e23c3c3e13decac9e3841168f Mon Sep 17 00:00:00 2001 From: nanoric Date: Fri, 15 Mar 2019 03:07:01 -0400 Subject: [PATCH] =?UTF-8?q?[Add]=20BaseGateway:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0on=5Fxxxx?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E5=BF=85=E9=A1=BB=E4=B8=BA=E5=B8=B8?= =?UTF-8?q?=E9=87=8F=E7=9A=84=E8=A6=81=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/gateway.py b/vnpy/trader/gateway.py index 598120c3..2442f990 100644 --- a/vnpy/trader/gateway.py +++ b/vnpy/trader/gateway.py @@ -36,6 +36,8 @@ class BaseGateway(ABC): # How to implement a gateway: + --- + ## Basics A gateway should satisfies: * this class should be thread-safe: * all methods should be thread-safe @@ -44,10 +46,12 @@ class BaseGateway(ABC): * satisfies all requirements written in docstring for every method and callbacks. * automatically reconnect if connection lost. - methods must implements: + --- + ## methods must implements: all @abstractmethod - callbacks must response manually: + --- + ## callbacks must response manually: * on_tick * on_trade * on_order @@ -55,6 +59,13 @@ class BaseGateway(ABC): * on_account * on_contract + All the XxxData passed to callback should be constant, which means that + the object should not be modified after passing to on_xxxx. + So if you use a cache to store reference of data, use copy.copy to create a new object + before passing that data into on_xxxx + + + """ # Fields required in setting dict for connect function.