def __init__(self): #======================================================================= # Main Layout Initialization #======================================================================= QWidget.__init__(self) self.ui = Ui_DashboardWindow() self.ui.setupUi(self) self.docky = QDockWidget() self.tab_view = QTabWidget() self.ui.main_layout.addWidget(self.tab_view) #======================================================================= # Preferences Initialization #======================================================================= self.tables = {} self.preferences = Preferences(self) self.ui.actionPreferences.triggered.connect(self.preferences.exec_) #======================================================================= # DataFeed Initialization #======================================================================= self.ui.actionAdd_CSV.triggered.connect(self.addBroker) self.ui.actionAdd_DukasCopy.triggered.connect(self.addDukas) self.ui.actionPlay.toggled.connect(self.play) #======================================================================= # Main Loop Initialization #======================================================================= self.analyze = WRB() self.loop = QTimer(self) self.loop.timeout.connect(lambda: self.analyze.main_loop())
class HxScDashboard(QMainWindow): def __init__(self): #======================================================================= # Main Layout Initialization #======================================================================= QWidget.__init__(self) self.ui = Ui_DashboardWindow() self.ui.setupUi(self) self.docky = QDockWidget() self.tab_view = QTabWidget() self.ui.main_layout.addWidget(self.tab_view) #======================================================================= # Preferences Initialization #======================================================================= self.tables = {} self.preferences = Preferences(self) self.ui.actionPreferences.triggered.connect(self.preferences.exec_) #======================================================================= # DataFeed Initialization #======================================================================= self.ui.actionAdd_CSV.triggered.connect(self.addBroker) self.ui.actionAdd_DukasCopy.triggered.connect(self.addDukas) self.ui.actionPlay.toggled.connect(self.play) #======================================================================= # Main Loop Initialization #======================================================================= self.analyze = WRB() self.loop = QTimer(self) self.loop.timeout.connect(lambda: self.analyze.main_loop()) def addPage(self, broker, cross_1, cross_2): hbox = QVBoxLayout() self.tables[broker] = { cross_1: TableBox(cross_1), cross_2: TableBox(cross_2) } hbox.addWidget(self.tables[broker][cross_1]) hbox.addWidget(self.tables[broker][cross_2]) layout = QWidget() layout.setLayout(hbox) self.tab_view.addTab(layout, broker) self.updateTable() def addBroker(self): self.dialog = Page_Dialog(self) self.dialog.ui.cross_1_button.clicked.connect( lambda: self.openFileDialog('cross_1')) self.dialog.ui.cross_2_button.clicked.connect( lambda: self.openFileDialog('cross_2')) self.dialog.ui.ok_button.clicked.connect(self.addDatabase) self.dialog.exec_() def addDukas(self): self.dukas = DukasDialog(self) self.dukas.exec_() def openFileDialog(self, cross): if cross == 'cross_1': self.tmp_path_1 = QFileDialog().getOpenFileName( self, 'Open file', '/home') if self.dialog.ui.cross_1.text() == 'Main_Symbol': name = self.tmp_path_1.split('/')[-1].split('.')[0] self.dialog.ui.cross_1.setText(name) if cross == 'cross_2': self.tmp_path_2 = QFileDialog().getOpenFileName( self, 'Open file', '/home') if self.dialog.ui.cross_2.text() == 'Sister_Symbol': name = self.tmp_path_2.split('/')[-1].split('.')[0] self.dialog.ui.cross_2.setText(name) def addDatabase(self): self.dialog.close() broker_name = self.dialog.ui.broker_name.text() cross_1 = self.dialog.ui.cross_1.text() cross_2 = self.dialog.ui.cross_2.text() mirror = self.dialog.ui.mirror_sister.isChecked() if not broker_name in Candle.db: Candle.db[broker_name] = {} if not cross_1 in Candle.db[broker_name]: Candle.db[broker_name][cross_1] = { 'path': '{0}.csv'.format(cross_1), 'mirror': False, 'quote': {} } Candle.db[broker_name][cross_1]['quote'] = [] Candle.db[broker_name][cross_1]['signal'] = { 'WRB': [], 'ZONE': [], 'AJCTR': [], 'APAOR': [], 'STR': [], 'FVB': [] } Candle.db[broker_name][cross_2] = { 'path': '{0}.csv'.format(cross_1), 'mirror': mirror, 'quote': {} } Candle.db[broker_name][cross_2]['quote'] = [] Candle.db[broker_name][cross_2]['signal'] = { 'WRB': [], 'ZONE': [], 'AJCTR': [], 'APAOR': [], 'STR': [], 'FVB': [] } self.addPage(broker_name, cross_1, cross_2) self.updateQuote() def updateQuote(self): format = '%Y-%m-%d %H:%M:%S' for broker in list(Candle.db.keys()): for symbol, path in Candle.db[broker]['path'].items(): with open(path, 'rt') as textfile: quote = list(csv.reader(textfile, delimiter=';')) quote.reverse() # Check data if not Candle.db[broker][symbol]['mirror']: Candle.db[broker][symbol]['quote'].append( (roundTime( datetime.datetime.strptime(row[0], format)), float(row[1]), float(row[2]), float(row[3]), float(row[4]), float(row[5]))) else: Candle.db[broker][symbol]['quote'].append( (roundTime( datetime.datetime.strptime(row[0], format)), float(row[1]), float(row[5]), float(row[4]), float(row[3]), float(row[2]))) def updateTable(self): table = self.tables['dukas']['EURUSD'].table item = QTableWidgetItem() item.setTextAlignment(Qt.AlignCenter | Qt.AlignVCenter) item.setText('sexsex') table.setItem(3, 3, item) def play(self): if not self.loop.isActive(): self.analyze.main_loop() self.loop.start(1000 * 60) else: self.loop.stop()
class HxScDashboard(QMainWindow): def __init__(self): #======================================================================= # Main Layout Initialization #======================================================================= QWidget.__init__(self) self.ui = Ui_DashboardWindow() self.ui.setupUi(self) self.docky = QDockWidget() self.tab_view = QTabWidget() self.ui.main_layout.addWidget(self.tab_view) #======================================================================= # Preferences Initialization #======================================================================= self.tables = {} self.preferences = Preferences(self) self.ui.actionPreferences.triggered.connect(self.preferences.exec_) #======================================================================= # DataFeed Initialization #======================================================================= self.ui.actionAdd_CSV.triggered.connect(self.addBroker) self.ui.actionAdd_DukasCopy.triggered.connect(self.addDukas) self.ui.actionPlay.toggled.connect(self.play) #======================================================================= # Main Loop Initialization #======================================================================= self.analyze = WRB() self.loop = QTimer(self) self.loop.timeout.connect(lambda: self.analyze.main_loop()) def addPage(self, broker, cross_1, cross_2): hbox = QVBoxLayout() self.tables[broker] = {cross_1: TableBox(cross_1), cross_2: TableBox(cross_2)} hbox.addWidget(self.tables[broker][cross_1]) hbox.addWidget(self.tables[broker][cross_2]) layout = QWidget() layout.setLayout(hbox) self.tab_view.addTab(layout, broker) self.updateTable() def addBroker(self): self.dialog = Page_Dialog(self) self.dialog.ui.cross_1_button.clicked.connect(lambda: self.openFileDialog('cross_1')) self.dialog.ui.cross_2_button.clicked.connect(lambda: self.openFileDialog('cross_2')) self.dialog.ui.ok_button.clicked.connect(self.addDatabase) self.dialog.exec_() def addDukas(self): self.dukas = DukasDialog(self) self.dukas.exec_() def openFileDialog(self, cross): if cross == 'cross_1': self.tmp_path_1 = QFileDialog().getOpenFileName(self, 'Open file', '/home') if self.dialog.ui.cross_1.text() == 'Main_Symbol': name = self.tmp_path_1.split('/')[-1].split('.')[0] self.dialog.ui.cross_1.setText(name) if cross == 'cross_2': self.tmp_path_2 = QFileDialog().getOpenFileName(self, 'Open file', '/home') if self.dialog.ui.cross_2.text() == 'Sister_Symbol': name = self.tmp_path_2.split('/')[-1].split('.')[0] self.dialog.ui.cross_2.setText(name) def addDatabase(self): self.dialog.close() broker_name = self.dialog.ui.broker_name.text() cross_1 = self.dialog.ui.cross_1.text() cross_2 = self.dialog.ui.cross_2.text() mirror = self.dialog.ui.mirror_sister.isChecked() if not broker_name in Candle.db: Candle.db[broker_name] = {} if not cross_1 in Candle.db[broker_name]: Candle.db[broker_name][cross_1] = {'path': '{0}.csv'.format(cross_1), 'mirror': False, 'quote': {}} Candle.db[broker_name][cross_1]['quote'] = [] Candle.db[broker_name][cross_1]['signal'] = {'WRB': [], 'ZONE': [], 'AJCTR': [], 'APAOR': [], 'STR': [], 'FVB': []} Candle.db[broker_name][cross_2] = {'path': '{0}.csv'.format(cross_1), 'mirror': mirror, 'quote': {}} Candle.db[broker_name][cross_2]['quote'] = [] Candle.db[broker_name][cross_2]['signal'] = {'WRB': [], 'ZONE': [], 'AJCTR': [], 'APAOR': [], 'STR': [], 'FVB': []} self.addPage(broker_name, cross_1, cross_2) self.updateQuote() def updateQuote(self): format = '%Y-%m-%d %H:%M:%S' for broker in list(Candle.db.keys()): for symbol, path in Candle.db[broker]['path'].items(): with open(path, 'rt') as textfile: quote = list(csv.reader(textfile, delimiter=';')) quote.reverse() # Check data if not Candle.db[broker][symbol]['mirror']: Candle.db[broker][symbol]['quote'].append((roundTime(datetime.datetime.strptime(row[0], format)), float(row[1]), float(row[2]), float(row[3]), float(row[4]), float(row[5]))) else: Candle.db[broker][symbol]['quote'].append((roundTime(datetime.datetime.strptime(row[0], format)), float(row[1]), float(row[5]), float(row[4]), float(row[3]), float(row[2]))) def updateTable(self): table = self.tables['dukas']['EURUSD'].table item = QTableWidgetItem() item.setTextAlignment(Qt.AlignCenter | Qt.AlignVCenter) item.setText('sexsex') table.setItem(3, 3, item) def play(self): if not self.loop.isActive(): self.analyze.main_loop() self.loop.start(1000 * 60) else: self.loop.stop()