forked from Skinok/backtrader-pyqt-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrategyTesterUI.py
47 lines (29 loc) · 1.5 KB
/
strategyTesterUI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from PyQt5 import QtCore, QtWidgets, uic
import os
class StrategyTesterUI(QtWidgets.QWidget):
def __init__(self, controller):
super(StrategyTesterUI, self).__init__()
self.controller = controller
# It does not finish by a "/"
self.current_dir_path = os.path.dirname(os.path.realpath(__file__))
uic.loadUi( self.current_dir_path + "/ui/strategyTester.ui", self)
self.runBacktestPB = self.findChild(QtWidgets.QPushButton, "runBacktestPB")
self.runBacktestPB.clicked.connect(self.run)
self.runningStratPB = self.findChild(QtWidgets.QProgressBar, "runningStratPB")
self.strategyNameCB = self.findChild(QtWidgets.QComboBox, "strategyNameCB")
self.strategyNameCB.currentIndexChanged.connect(self.strategyNameActivated)
self.runBacktestPB.setEnabled(False)
def initialize(self):
# adding list of items to combo box
self.strategyNames = list(QtCore.QDir(self.current_dir_path + "/strategies").entryList(QtCore.QDir.Files))
# Remove straty .py file name
self.strategyBaseName = []
for stratName in self.strategyNames:
self.strategyBaseName.append(QtCore.QFileInfo(stratName).baseName())
self.strategyNameCB.addItems(self.strategyBaseName)
pass
def run(self):
self.controller.run()
def strategyNameActivated(self):
stratBaseName = self.strategyNameCB.currentText()
self.controller.addStrategy(stratBaseName)