[Add]增加IB接口对现货贵金属的支持

This commit is contained in:
vn.py 2018-01-04 11:38:42 +08:00
parent 48cfae3222
commit d98163f034
2 changed files with 5 additions and 2 deletions

View File

@ -69,6 +69,7 @@ productClassMap[PRODUCT_FUTURES] = 'FUT'
productClassMap[PRODUCT_OPTION] = 'OPT'
productClassMap[PRODUCT_FOREX] = 'CASH'
productClassMap[PRODUCT_INDEX] = 'IND'
productClassMap[PRODUCT_SPOT] = 'CMDTY'
productClassMapReverse = {v:k for k,v in productClassMap.items()}
# 期权类型映射
@ -363,7 +364,8 @@ class IbWrapper(IbApi):
tick.__setattr__(key, price)
# IB的外汇行情没有成交价和时间通过本地计算生成同时立即推送
if self.tickProductDict[tickerId] == PRODUCT_FOREX:
p = self.tickProductDict[tickerId]
if p == PRODUCT_FOREX or p == PRODUCT_SPOT:
tick.lastPrice = (tick.bidPrice1 + tick.askPrice1) / 2
dt = datetime.now()
tick.time = dt.strftime('%H:%M:%S.%f')

View File

@ -697,7 +697,8 @@ class TradingWidget(QtWidgets.QFrame):
PRODUCT_EQUITY,
PRODUCT_FUTURES,
PRODUCT_OPTION,
PRODUCT_FOREX]
PRODUCT_FOREX,
PRODUCT_SPOT]
gatewayList = ['']