修改了ctpGate的代码,想实现保证金和手续费的查询:
def queryMarginRate(self):
"""查询保证金率"""
self.reqid += 1
req = {
"BrokerID": self.brokerid,
"InvestorID": self.userid,
"InstrumentID": 'rb1910',
"HedgeFlag": THOST_FTDC_HF_Speculation,
}
self.reqQryInstrumentMarginRate(req, self.reqid)
def onRspQryInstrumentMarginRate(self, data: dict, error: dict, reqid: int, last: bool):
"""保证金回调"""
for k, v in data.items():
print(k, ':', v)
def queryCommissionRate(self):
"""手续费查询"""
self.reqid += 1
req = {
"BrokerID": self.brokerid,
"InvestorID": self.userid,
"InstrumentID": 'rb1910',
# "HedgeFlag": THOST_FTDC_HF_Speculation,
# "ExchangeID":'SHFE'
}
self.reqQryInstrumentCommissionRate(req, self.reqid)
def onRspQryInstrumentCommissionRate(self, data: dict, error: dict, reqid: int, last: bool):
"""手续费回调"""
for k, v in data.items():
print(k, ':', v)
目前的情况是保证金可以查询出来,手续费不行。用得都是光大期货的ta和md address。
不知道是手续费的字典参数不对,还是说回调方法不太对。
求大神们指导!