[增强] 增加期货合约保证金比率

This commit is contained in:
msincenselee 2019-12-28 14:41:08 +08:00
parent 2cca2aab9c
commit baea2a48e1
2 changed files with 5 additions and 0 deletions

View File

@ -601,6 +601,10 @@ class CtpTdApi(TdApi):
pricetick=data["PriceTick"], pricetick=data["PriceTick"],
gateway_name=self.gateway_name 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 # For option only
if contract.product == Product.OPTION: if contract.product == Product.OPTION:

View File

@ -252,6 +252,7 @@ class ContractData(BaseData):
product: Product product: Product
size: int size: int
pricetick: float pricetick: float
margin_rate: float = 0.1 # 保证金比率
min_volume: float = 1 # minimum trading volume of the contract min_volume: float = 1 # minimum trading volume of the contract
stop_supported: bool = False # whether server supports stop order stop_supported: bool = False # whether server supports stop order