Ejemplo n.º 1
0
 def slot_login(self):
     #server = str(self.ui.lineEditEtradeServerName.text())
     server = self.server
     port = 20001
     servertype = self.servertype
     showcerterror = 1
     user = str(self.ui.lineEditId.text())
     password = str(self.ui.lineEditPassword.text())
     certpw = str(self.ui.lineEditEtradeServerName.text())
     
     if user == '':
         user = ''
         password = ''
     if self._XASession == None:
         self._XASession = px.XASession()
     self._XASession.observer = proxy(self)
     self._XASession.ConnectServer(server,port)
     #print 'connect server'
     ret = self._XASession.Login(user,password,certpw,servertype,showcerterror)
             
             
     px.XASessionEvents.session = self._XASession
     self._XASession.flag = True
     while self._XASession.flag:
         pythoncom.PumpWaitingMessages()
Ejemplo n.º 2
0
    def initXing(self, XASession=None):
        if XASession != None:
            self.XASession = XASession
            if self.XASession.IsConnected() and self.XASession.GetAccountListCount():
                self.accountlist = self.XASession.GetAccountList()
            return

        self.XASession = px.XASession()

        login_form = LoginForm(self, proxy(self.XASession))
        login_form.show()
        login_form.exec_()

        if self.XASession.IsConnected() and self.XASession.GetAccountListCount():
            self.accountlist = self.XASession.GetAccountList()
            print self.accountlist
Ejemplo n.º 3
0
    def initXing(self, XASession=None):
        if not isinstance(XASession, px.XASession):
            self.XASession = px.XASession()
            myform = LoginForm(self, proxy(self.XASession))
            myform.show()
            myform.exec_()
        else:
            self.XASession = XASession

        if self.XASession.IsConnected() and self.XASession.GetAccountListCount(
        ):
            self.accountlist = self.XASession.GetAccountList()
            self.servername = self.XASession.GetServerName()
            print self.accountlist
        else:
            print 'Not IsConnected or No Account'
Ejemplo n.º 4
0
if __name__ == '__main__':
    import PyQt4.QtGui as QtGui
    import PyQt4.QtCore as QtCore
    print 'main: start'
    app = QtGui.QApplication(sys.argv)

    viewer = ConsoleViewer()
    server = 'demo.etrade.co.kr'
    port = 20001
    servertype = 1  #demo server
    showcerterror = 1
    user = '******'
    password = '******'
    certpw = ''
    _XASession = px.XASession()
    _XASession.observer = viewer
    _XASession.ConnectServer(server, port)
    _XASession.Login(user, password, certpw, servertype, showcerterror)

    while _XASession.flag:
        PumpWaitingMessages()

    accountlist = _XASession.GetAccountList()
    print accountlist

    _t0414viewer = t0414Viewer()

    _XAQuery_t0424 = px.XAQuery_t0424()
    _XAQuery_t0424.observer = _t0414viewer
    _XAQuery_t0424.SetFieldData('t0424InBlock', 'accno', 0, accountlist[1])
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        # QtGui.QWidget.__init__(self,parent)
        super(MainForm, self).__init__(parent)

        # demo
        # order_port = 6001
        # exec_report_port = 7001
        # accountindex = 1
        # db_path = 'C:/Python/ZeroTrader_Test/ZeroOMS/orderlist_db/'

        # real
        # order_port = 6000
        # exec_report_port = 7000
        # accountindex = 0
        # db_path = 'C:/Python/ZeroTrader/ZeroOMS/orderlist_db/'

        self.order_port = 6001
        self.exec_report_port = 7001
        self.accountindex = 1
        # self.db_path = 'C:/Python/AQTrader/OrderManager/orderlist_db/'
        self.db_path = './orderlist_db/'

        self.initUI()

        self.ctimer = QtCore.QTimer()
        self.ctimer.start(1000)
        self.ctimer.timeout.connect(self.ctimerUpdate)
        self.autotimer = QtCore.QTimer()
        self.autotimer.start(20000)
        self.autotimer.timeout.connect(self.autotimer_update)
        self.xingTimer = QtCore.QTimer()
        self.xingTimer.timeout.connect(self.xingTimerUpdate)
        
        self.FuturesOptionTAQFeederLst = []
        self.EquityTAQFeederLst = []
        
        self.XASession_observer = XingXASessionUpdate(proxy(self.status_xi))
        self.XASession = px.XASession()
        self.XASession.Attach(self.XASession_observer)
        self.accountlist = []
        self.servername = ''

        now_dt = dt.datetime.now()

        if now_dt.hour >= 7 and now_dt.hour < 17:
            self.exchange_code = 'KRX'
        else:
            self.exchange_code = 'EUREX'
        logger.info("exchange_code: %s" % self.exchange_code)

        self.initDB()
        self.initThread()
        self.initExpireDateUtil()

        logger.info('Start ZeroOMS')

        self.set_auto = False
        try:
            with open('auto_config', 'r') as f:
                auto_config = json.load(f)
                if auto_config['setauto']:
                    print auto_config
                    self.set_auto = True
                    self.slot_AutoStartXing(auto_config)
                f.close()
        except IOError:
            logger.info('not found auto_config file')
        pass