LTSDEMO加入了登录时,行情和交易使用不同密码的功能

This commit is contained in:
WOLF 2015-05-11 09:34:26 +08:00
parent da1fb95ebf
commit e851cf8a76
6 changed files with 36 additions and 20 deletions

5
.gitignore vendored
View File

@ -25,4 +25,7 @@ Release/
*.con *.con
# visual studio # visual studio
*.opensdf *.opensdf
# 本地持久化文件
*.vn

View File

@ -1,6 +1,11 @@
# vn.py # vn.py
基于python的开源交易平台开发框架 基于python的开源交易平台开发框架
## vn.py框架交流群
QQ群号262656087
相关问题在这个里面问的答复最快。
## 2015/4/24项目状态## ## 2015/4/24项目状态##
发布了基于vn.ctp的Demo在vn.demo/ctpdemo文件夹下可用于CTP柜台期货公司的手动交易。 发布了基于vn.ctp的Demo在vn.demo/ctpdemo文件夹下可用于CTP柜台期货公司的手动交易。

View File

@ -54,7 +54,7 @@ class DemoMdApi(MdApi):
self.__setSubscribed = set() self.__setSubscribed = set()
# 初始化.con文件的保存目录为\mdconnection注意这个目录必须已存在否则会报错 # 初始化.con文件的保存目录为\mdconnection注意这个目录必须已存在否则会报错
self.createFtdcMdApi(os.getcwd() + '\\mdconnection\\') self.createFtdcMdApi(os.getcwd() + '\\mdconnection\\')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onFrontConnected(self): def onFrontConnected(self):

View File

@ -44,10 +44,10 @@ class MainEngine:
self.ee.register(EVENT_INSTRUMENT, self.insertInstrument) self.ee.register(EVENT_INSTRUMENT, self.insertInstrument)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def login(self, userid, password, brokerid, mdAddress, tdAddress): def login(self, userid, mdPassword, tdPassword, brokerid, mdAddress, tdAddress):
"""登陆""" """登陆"""
self.md.login(mdAddress, userid, password, brokerid) self.md.login(mdAddress, userid, mdPassword, brokerid)
self.td.login(tdAddress, userid, password, brokerid) self.td.login(tdAddress, userid, tdPassword, brokerid)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def subscribe(self, instrumentid, exchangeid): def subscribe(self, instrumentid, exchangeid):

View File

@ -450,7 +450,7 @@ class OrderMonitor(QtGui.QTableWidget):
self.dictOrderData[orderref] = data self.dictOrderData[orderref] = data
# 如果之前已经收到过这个账户的数据, 则直接更新 # 如果之前已经收到过这个订单的数据, 则直接更新
if orderref in self.dictOrder: if orderref in self.dictOrder:
d = self.dictOrder[orderref] d = self.dictOrder[orderref]
@ -646,12 +646,14 @@ class LoginWidget(QtGui.QDialog):
# 设置组件 # 设置组件
labelUserID = QtGui.QLabel(u'账号:') labelUserID = QtGui.QLabel(u'账号:')
labelPassword = QtGui.QLabel(u'密码:') labelMdPassword = QtGui.QLabel(u'行情密码:')
labelTdPassword = QtGui.QLabel(u'交易密码:')
labelMdAddress = QtGui.QLabel(u'行情服务器:') labelMdAddress = QtGui.QLabel(u'行情服务器:')
labelTdAddress = QtGui.QLabel(u'交易服务器:') labelTdAddress = QtGui.QLabel(u'交易服务器:')
self.editUserID = QtGui.QLineEdit() self.editUserID = QtGui.QLineEdit()
self.editPassword = QtGui.QLineEdit() self.editMdPassword = QtGui.QLineEdit()
self.editTdPassword = QtGui.QLineEdit()
self.editMdAddress = QtGui.QLineEdit() self.editMdAddress = QtGui.QLineEdit()
self.editTdAddress = QtGui.QLineEdit() self.editTdAddress = QtGui.QLineEdit()
@ -670,14 +672,16 @@ class LoginWidget(QtGui.QDialog):
grid = QtGui.QGridLayout() grid = QtGui.QGridLayout()
grid.addWidget(labelUserID, 0, 0) grid.addWidget(labelUserID, 0, 0)
grid.addWidget(labelPassword, 1, 0) grid.addWidget(labelMdPassword, 1, 0)
grid.addWidget(labelMdAddress, 2, 0) grid.addWidget(labelTdPassword, 2, 0)
grid.addWidget(labelTdAddress, 3, 0) grid.addWidget(labelMdAddress, 3, 0)
grid.addWidget(labelTdAddress, 4, 0)
grid.addWidget(self.editUserID, 0, 1) grid.addWidget(self.editUserID, 0, 1)
grid.addWidget(self.editPassword, 1, 1) grid.addWidget(self.editMdPassword, 1, 1)
grid.addWidget(self.editMdAddress, 2, 1) grid.addWidget(self.editTdPassword, 2, 1)
grid.addWidget(self.editTdAddress, 3, 1) grid.addWidget(self.editMdAddress, 3, 1)
grid.addLayout(buttonHBox, 4, 0, 1, 2) grid.addWidget(self.editTdAddress, 4, 1)
grid.addLayout(buttonHBox, 5, 0, 1, 2)
self.setLayout(grid) self.setLayout(grid)
@ -685,12 +689,13 @@ class LoginWidget(QtGui.QDialog):
def login(self): def login(self):
"""登录""" """登录"""
userid = str(self.editUserID.text()) userid = str(self.editUserID.text())
password = str(self.editPassword.text()) mdPassword = str(self.editMdPassword.text())
tdPassword = str(self.editTdPassword.text())
mdAddress = str(self.editMdAddress.text()) mdAddress = str(self.editMdAddress.text())
tdAddress = str(self.editTdAddress.text()) tdAddress = str(self.editTdAddress.text())
brokerid = '2011' brokerid = '2011'
self.__mainEngine.login(userid, password, brokerid, mdAddress, tdAddress) self.__mainEngine.login(userid, mdPassword, tdPassword, brokerid, mdAddress, tdAddress)
self.close() self.close()
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -701,12 +706,14 @@ class LoginWidget(QtGui.QDialog):
try: try:
setting = f['login'] setting = f['login']
userid = setting['userid'] userid = setting['userid']
password = setting['password'] mdPassword = setting['mdPassword']
tdPassword = setting['tdPassword']
mdAddress = setting['mdAddress'] mdAddress = setting['mdAddress']
tdAddress = setting['tdAddress'] tdAddress = setting['tdAddress']
self.editUserID.setText(userid) self.editUserID.setText(userid)
self.editPassword.setText(password) self.editMdPassword.setText(mdPassword)
self.editTdPassword.setText(tdPassword)
self.editMdAddress.setText(mdAddress) self.editMdAddress.setText(mdAddress)
self.editTdAddress.setText(tdAddress) self.editTdAddress.setText(tdAddress)
except KeyError: except KeyError:
@ -719,7 +726,8 @@ class LoginWidget(QtGui.QDialog):
"""保存数据""" """保存数据"""
setting = {} setting = {}
setting['userid'] = str(self.editUserID.text()) setting['userid'] = str(self.editUserID.text())
setting['password'] = str(self.editPassword.text()) setting['mdPassword'] = str(self.editMdPassword.text())
setting['tdPassword'] = str(self.editTdPassword.text())
setting['mdAddress'] = str(self.editMdAddress.text()) setting['mdAddress'] = str(self.editMdAddress.text())
setting['tdAddress'] = str(self.editTdAddress.text()) setting['tdAddress'] = str(self.editTdAddress.text())

Binary file not shown.