From baea2a48e1b879fd19683d79eed42037d2505b91 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Sat, 28 Dec 2019 14:41:08 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=A2=9E=E5=BC=BA]=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9C=9F=E8=B4=A7=E5=90=88=E7=BA=A6=E4=BF=9D=E8=AF=81=E9=87=91?= =?UTF-8?q?=E6=AF=94=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/gateway/ctp/ctp_gateway.py | 4 ++++ vnpy/trader/object.py | 1 + 2 files changed, 5 insertions(+) diff --git a/vnpy/gateway/ctp/ctp_gateway.py b/vnpy/gateway/ctp/ctp_gateway.py index f346a30d..50ae6c08 100644 --- a/vnpy/gateway/ctp/ctp_gateway.py +++ b/vnpy/gateway/ctp/ctp_gateway.py @@ -601,6 +601,10 @@ class CtpTdApi(TdApi): pricetick=data["PriceTick"], gateway_name=self.gateway_name ) + # 保证金费率 + contract.margin_rate = max(data.get('LongMarginRatio', 0), data.get('ShortMarginRatio', 0)) + if contract.margin_rate == 0: + contract.margin_rate = 0.1 # For option only if contract.product == Product.OPTION: diff --git a/vnpy/trader/object.py b/vnpy/trader/object.py index 01f5738b..5c1b2e32 100644 --- a/vnpy/trader/object.py +++ b/vnpy/trader/object.py @@ -252,6 +252,7 @@ class ContractData(BaseData): product: Product size: int pricetick: float + margin_rate: float = 0.1 # 保证金比率 min_volume: float = 1 # minimum trading volume of the contract stop_supported: bool = False # whether server supports stop order