[Mod]change code naming

This commit is contained in:
vn.py 2019-04-24 14:16:18 +08:00
parent b990ae7758
commit 12987aebe0

View File

@ -360,8 +360,8 @@ class FemasTdApi(TdApi):
self.gateway = gateway self.gateway = gateway
self.gateway_name = gateway.gateway_name self.gateway_name = gateway.gateway_name
self.reqid = int(10e5) self.reqid = 0
self.localID = int(10e5 + 8888) self.localid = int(10e5 + 8888)
self.connect_status = False self.connect_status = False
self.login_status = False self.login_status = False
@ -393,11 +393,11 @@ class FemasTdApi(TdApi):
"""""" """"""
if not error["ErrorID"]: if not error["ErrorID"]:
if data["MaxOrderLocalID"]: if data["MaxOrderLocalID"]:
self.localID = max( self.localid = int(data["MaxOrderLocalID"])
self.localID, int(data["MaxOrderLocalID"])
) # 目前最大本地报单号
self.login_status = True self.login_status = True
self.gateway.write_log("交易服务器登录成功") self.gateway.write_log("交易服务器登录成功")
self.reqid += 1 self.reqid += 1
self.reqQryInstrument({}, self.reqid) self.reqQryInstrument({}, self.reqid)
else: else:
@ -541,7 +541,7 @@ class FemasTdApi(TdApi):
Callback of order status update. Callback of order status update.
""" """
# 更新最大报单编号 # 更新最大报单编号
self.localID = max(self.localID, int( self.localid = max(self.localid, int(
data["UserOrderLocalID"])) # 检查并增加本地报单编号 data["UserOrderLocalID"])) # 检查并增加本地报单编号
symbol = data["InstrumentID"] symbol = data["InstrumentID"]
@ -637,8 +637,9 @@ class FemasTdApi(TdApi):
""" """
Send new order. Send new order.
""" """
self.localID += 1 self.localid += 1
strLocalID = str(self.localID).rjust(12, "0") orderid = str(self.localid).rjust(12, "0")
femas_req = { femas_req = {
"InstrumentID": req.symbol, "InstrumentID": req.symbol,
"ExchangeID": str(req.exchange).split(".")[1], "ExchangeID": str(req.exchange).split(".")[1],
@ -650,7 +651,7 @@ class FemasTdApi(TdApi):
"OrderPriceType": ORDERTYPE_VT2FEMAS.get(req.type, ""), "OrderPriceType": ORDERTYPE_VT2FEMAS.get(req.type, ""),
"Direction": DIRECTION_VT2FEMAS.get(req.direction, ""), "Direction": DIRECTION_VT2FEMAS.get(req.direction, ""),
"OffsetFlag": OFFSET_VT2FEMAS.get(req.offset, ""), "OffsetFlag": OFFSET_VT2FEMAS.get(req.offset, ""),
"UserOrderLocalID": strLocalID, "UserOrderLocalID": orderid,
"HedgeFlag": USTP_FTDC_CHF_Speculation, "HedgeFlag": USTP_FTDC_CHF_Speculation,
"ForceCloseReason": USTP_FTDC_FCR_NotForceClose, "ForceCloseReason": USTP_FTDC_FCR_NotForceClose,
"IsAutoSuspend": 0, "IsAutoSuspend": 0,
@ -671,8 +672,6 @@ class FemasTdApi(TdApi):
self.reqid += 1 self.reqid += 1
self.reqOrderInsert(femas_req, self.reqid) self.reqOrderInsert(femas_req, self.reqid)
orderid = femas_req["UserOrderLocalID"]
req.volume = femas_req["Volume"]
order = req.create_order_data(orderid, self.gateway_name) order = req.create_order_data(orderid, self.gateway_name)
self.gateway.on_order(order) self.gateway.on_order(order)
@ -682,13 +681,14 @@ class FemasTdApi(TdApi):
""" """
Cancel existing order. Cancel existing order.
""" """
self.localID += 1 self.localid += 1
strLocalID = str(self.localID) orderid = str(self.localid).rjust(12, "0")
femas_req = { femas_req = {
"InstrumentID": req.symbol, "InstrumentID": req.symbol,
"ExchangeID": str(req.exchange).split(".")[1], "ExchangeID": str(req.exchange).split(".")[1],
"UserOrderLocalID": req.orderid, "UserOrderLocalID": req.orderid,
"UserOrderActionLocalID": strLocalID, "UserOrderActionLocalID": orderid,
"ActionFlag": USTP_FTDC_AF_Delete, "ActionFlag": USTP_FTDC_AF_Delete,
"BrokerID": self.brokerid, "BrokerID": self.brokerid,
"InvestorID": self.userid, "InvestorID": self.userid,