Example #1
0
    def on_session_historicalDataRequest(self, params):
        """ Called when a request for historical data is made.

        @param params historical data request parameters
        @return None
        """
        requestId = params['tickerId']
        root = self.invisibleRootItem
        requests = [r.requestId for r in root.children]
        if requestId in requests:
            logging.warn('Ignoring duplicate hist data request %s', requestId)
            return
        row = root.childCount()
        self.beginInsertRows(QModelIndex(), row, row)
        root.append(RequestItem.fromRequest(params, self.session, root))
        self.endInsertRows()
Example #2
0
    def on_session_historicalDataRequest(self, params):
        """ Called when a request for historical data is made.

        @param params historical data request parameters
        @return None
        """
        requestId = params['tickerId']
        root = self.invisibleRootItem
        requests = [r.requestId for r in root.children]
        if requestId in requests:
            logging.warn('Ignoring duplicate hist data request %s', requestId)
            return
        row = root.childCount()
        self.beginInsertRows(QModelIndex(), row, row)
        root.append(RequestItem.fromRequest(params, self.session, root))
        self.endInsertRows()
Example #3
0
            try:
                if self.requestAccount.isChecked():
                    session.requestAccount()
                if self.requestTickers.isChecked():
                    session.requestTickers()
                if self.requestOrders.isChecked():
                    session.requestOrders()
            except (Exception, ), exc:
                QMessageBox.critical(self, 'Session Error', str(exc))
            else:
                self.serverVersionEdit.setText(
                    str(session.connection.serverVersion()))
                self.connectionTimeEdit.setText(
                    session.connection.TwsConnectionTime())
        else:
            logging.warn('Exception during connect')
            port = self.portNumberSpin.value()
            if port == session.specialPortNo:
                port = 7496
            host = self.hostNameEdit.text()
            text = 'Unable to connect.\n\nEnsure TWS is running'
            text += ' on %s and is configured to accept socket ' % host
            text += 'connections on port %s.' % port
            QMessageBox.critical(self, 'Connection Error', text)
            self.setConnectControlsEnabled(True, False)

    @pyqtSignature('')
    def on_connectButton_clicked(self):
        """ Connects the session to the broker.

        """