加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
strategyManualUI.py 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
MoYuqing 提交于 2024-07-05 16:43 . 添加订单被执行的显示
from PyQt6 import QtCore, QtWidgets, uic
import os
import backtrader as bt
from logger_module import logger
class StrategyManualUI(QtWidgets.QWidget):
def __init__(self, controller, parent = None):
super(StrategyManualUI, self).__init__()
self.controller = controller
self.cerebro = controller.cerebro
self.manualStrategy = None
self.parent = parent
# It does not finish by a "/"
self.current_dir_path = os.path.dirname(os.path.realpath(__file__))
uic.loadUi( self.current_dir_path + "/ui/strategyManual.ui", self)
self.buyPB = self.findChild(QtWidgets.QPushButton, "buyPB")
self.buyPB.clicked.connect(self.buy)
self.sellPB = self.findChild(QtWidgets.QPushButton, "sellPB")
self.sellPB.clicked.connect(self.sell)
self.priceLB = self.findChild(QtWidgets.QLabel, "label_4")
# Run button
self.runBacktestBtn = self.findChild(QtWidgets.QPushButton, "runBacktestBtn")
self.runBacktestBtn.clicked.connect(controller.updateCsvData)
def buy(self):
s = self.priceLB.text()
lines = s.splitlines()
first_line = lines[0]
price = float(first_line)
logger.info(price)
self.manualStrategy.buy(exectype=bt.Order.Limit, price = price*1.1)
pass
def sell(self):
s = self.priceLB.text()
lines = s.splitlines()
first_line = lines[0]
price = float(first_line)
self.manualStrategy.sell(exectype=bt.Order.Limit, price= price/1.1)
pass
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化