コード例 #1
0
    def initStrategyManager(self):
        """初始化策略管理组件界面"""
        w = QtGui.QWidget()
        vbox = QtGui.QVBoxLayout()

        for name in self.ctaEngine.strategyDict.keys():
            p = self.ctaEngine.strategyDict[name]
            if p.className == 'tradeTest':
                strategyManager = CtaStrategyManager(self.ctaEngine,
                                                     self.eventEngine, name,
                                                     p.className, '', '',
                                                     p.longsymbol,
                                                     p.shortsymbol)
            elif p.className == 'CtpAndIB':
                strategyManager = CtaStrategyManager(self.ctaEngine,
                                                     self.eventEngine, name,
                                                     p.className, '', '',
                                                     p.longsymbol,
                                                     p.shortsymbol)
            else:
                strategyManager = CtaStrategyManager(self.ctaEngine,
                                                     self.eventEngine, name,
                                                     p.className, p.direction,
                                                     p.vtSymbol, '', '')
            vbox.addWidget(strategyManager)

        vbox.addStretch()

        w.setLayout(vbox)
        self.scrollArea.setWidget(w)
コード例 #2
0
    def __init__(self,
                 name=None,
                 direction=None,
                 vtSymbol=None,
                 CtaEngineManager=None):
        super(ParamWindow2, self).__init__()
        self.resize(350, 480)
        self.ce = CtaEngineManager
        self.saveButton = QtGui.QPushButton(u"保存", self)
        self.cancelButton = QtGui.QPushButton(u"取消", self)
        self.setWindowTitle(u"参数")
        self.vtSymbol = vtSymbol
        self.setting = {}
        self.paramters = {}
        self.strategyName = ""
        self.name = name
        self.firstSave = True
        self.fileName = ""
        if name != "":
            self.fileName = "parameter_" + name + ".json"
        path = os.path.abspath(os.path.dirname(__file__))
        self.fileName = os.path.join(path, self.fileName)

        self.center()
        self.onInit()
コード例 #3
0
	def initUi(self):

		vbox = QtGui.QVBoxLayout()

		vline = QtGui.QHBoxLayout()
		vline.setSpacing(2)
		btnTickAll = QtGui.QPushButton(u"全部记录Tick", self)
		btnBarAll = QtGui.QPushButton(u'全部记录Bar', self)
		btnSaveAll = QtGui.QPushButton(u'保存设置(重启后生效)', self)
		btnTickAll.clicked.connect(self.selectAllTick)
		btnBarAll.clicked.connect(self.selectAllBar)
		btnSaveAll.clicked.connect(self.saveSetting)

		vline.addWidget(btnTickAll)
		vline.addWidget(btnBarAll)
		vline.addWidget(btnSaveAll)

		vbox.addLayout(vline)

		self.qTreeView = QTreeView()
		self.model = TreeModel()
		self.qTreeView.setModel(self.model)
		self.qTreeView.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
		self.qTreeView.setItemDelegateForColumn(1, CheckBoxDelegate(self))
		self.qTreeView.setItemDelegateForColumn(2, CheckBoxDelegate(self))
		self.qTreeView.setItemDelegateForColumn(3, CheckBoxDelegate(self))
		self.qTreeView.setItemDelegateForColumn(5, ComboDelegate(self, ["CTP", "LTS", "XTP", "FEMAS", "XSPEED", "QDP",
		                                                                "KSOTP", "KSGOLD", "SGIT"]))

		vbox.addWidget(self.qTreeView)
		self.setLayout(vbox)
コード例 #4
0
 def initCells(self):
     """初始化单元格"""
     
     l = ctaTaskPool.taskPool.allTask.items()
     self.setRowCount(len(l))
     row = 0
     
     for name, task in l:            
         cellTaskName  = QtGui.QTableWidgetItem(name)
         cellTaskTime  = QtGui.QTableWidgetItem(str(task.runTM))
         cellTaskRunM  = QtGui.QTableWidgetItem(task.runmode)
         cellStrCls    = QtGui.QTableWidgetItem(task.setting.get('className'))
         buttonActive  = TaskActiveButton(name)
         buttonParam   = TaskParamButton(name)
         buttonDisplay = TaskDisplayButton(name)
         buttonLog     = TaskLogButton(name)
         
         self.setItem(row, 0, cellTaskName)
         self.setItem(row, 1, cellStrCls)
         self.setItem(row, 2, cellTaskTime)
         self.setItem(row, 3, cellTaskRunM)
         self.setCellWidget(row, 4, buttonActive)
         self.setCellWidget(row, 5, buttonParam)
         self.setCellWidget(row, 6, buttonLog)
         self.setCellWidget(row, 7, buttonDisplay)
         
         self.buttonActiveDict[name] = buttonActive
         row += 1
コード例 #5
0
    def __init__(self, analysisEngine):  # 初始化方法
        QtGui.QWidget.__init__(self)  # 调用父类初始化方法
        self.setWindowTitle('NetCurve')  # 设置窗口标题
        self.path = os.getcwd() + '/ctaLogFile/ctaPosFile'
        # self.path = os.getcwd() + '/statement/netSource'
        self.analysisEngine = analysisEngine
        #        self.resize(300,200)        # 设置窗口大小
        gridlayout = QtGui.QGridLayout()  # 创建布局组件

        self.cbAccount = QtGui.QComboBox()
        self.cbContract = QtGui.QComboBox()
        self.buttonStart = QtGui.QPushButton()
        self.lineedit = QtGui.QLineEdit('1000000')

        self.labelAcct = QtGui.QLabel(u'账户')
        self.labelCon = QtGui.QLabel(u'标的')
        self.labelAmount = QtGui.QLabel(u'初始金额')
        self.labelEvaluate = QtGui.QLabel()

        tree = lambda: collections.defaultdict(tree)
        self.dataList = tree()
        self.fileName = []

        self.loadAllPosFile()
        self.cbAccount.addItems(
            [k for k in self.groupByPosFile('name').keys()])
        self.cbContract.addItems(
            [k for k in self.groupByPosFile('contract').keys()])
コード例 #6
0
    def initStrategyManager(self):
        """初始化策略管理组件界面"""
        w = QtGui.QWidget()
        hbox = QtGui.QHBoxLayout()

        for name in self.ctaEngine.strategyDict.keys():
            strategyManager = CtaStrategyManager(self.ctaEngine,
                                                 self.eventEngine, name)
            hbox.addWidget(strategyManager)

        w.setLayout(hbox)
        self.scrollArea.setWidget(w)
コード例 #7
0
ファイル: uiDrWidget.py プロジェクト: freefrom/fTrade
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(text.DATA_RECORDER)

        # 记录合约配置监控
        tickLabel = QtGui.QLabel(text.TICK_RECORD)
        self.tickTable = QtGui.QTableWidget()
        self.tickTable.setColumnCount(2)
        self.tickTable.verticalHeader().setVisible(False)
        self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.tickTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.tickTable.setAlternatingRowColors(True)
        self.tickTable.setHorizontalHeaderLabels(
            [text.CONTRACT_SYMBOL, text.GATEWAY])

        barLabel = QtGui.QLabel(text.BAR_RECORD)
        self.barTable = QtGui.QTableWidget()
        self.barTable.setColumnCount(2)
        self.barTable.verticalHeader().setVisible(False)
        self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.barTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.barTable.setAlternatingRowColors(True)
        self.barTable.setHorizontalHeaderLabels(
            [text.CONTRACT_SYMBOL, text.GATEWAY])

        activeLabel = QtGui.QLabel(text.DOMINANT_CONTRACT)
        self.activeTable = QtGui.QTableWidget()
        self.activeTable.setColumnCount(2)
        self.activeTable.verticalHeader().setVisible(False)
        self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.activeTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.activeTable.setAlternatingRowColors(True)
        self.activeTable.setHorizontalHeaderLabels(
            [text.DOMINANT_SYMBOL, text.CONTRACT_SYMBOL])

        # 日志监控
        self.logMonitor = QtGui.QTextEdit()
        self.logMonitor.setReadOnly(True)
        self.logMonitor.setMinimumHeight(600)

        # 设置布局
        grid = QtGui.QGridLayout()

        grid.addWidget(tickLabel, 0, 0)
        grid.addWidget(barLabel, 0, 1)
        grid.addWidget(activeLabel, 0, 2)
        grid.addWidget(self.tickTable, 1, 0)
        grid.addWidget(self.barTable, 1, 1)
        grid.addWidget(self.activeTable, 1, 2)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(grid)
        vbox.addWidget(self.logMonitor)
        self.setLayout(vbox)
コード例 #8
0
    def initStrategyManager(self):
        """初始化策略管理组件界面"""
        w = QtGui.QWidget()
        vbox = QtGui.QVBoxLayout()

        for name in self.chanlunEngine.strategyDict.keys():
            strategyManager = ChanlunStrategyManager(self.chanlunEngine,
                                                     self.eventEngine, name)
            vbox.addWidget(strategyManager)

        vbox.addStretch()

        w.setLayout(vbox)
        self.scrollArea.setWidget(w)
コード例 #9
0
ファイル: uiDrWidget.py プロジェクト: noke8868/vnpy
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'行情数据记录工具')

        # 记录合约配置监控
        tickLabel = QtGui.QLabel(u'Tick记录')
        self.tickTable = QtGui.QTableWidget()
        self.tickTable.setColumnCount(2)
        self.tickTable.verticalHeader().setVisible(False)
        self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.tickTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.tickTable.setAlternatingRowColors(True)
        self.tickTable.setHorizontalHeaderLabels([u'合约代码', u'接口'])

        barLabel = QtGui.QLabel(u'Bar记录')
        self.barTable = QtGui.QTableWidget()
        self.barTable.setColumnCount(2)
        self.barTable.verticalHeader().setVisible(False)
        self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.barTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.barTable.setAlternatingRowColors(True)
        self.barTable.setHorizontalHeaderLabels([u'合约代码', u'接口'])

        activeLabel = QtGui.QLabel(u'主力合约')
        self.activeTable = QtGui.QTableWidget()
        self.activeTable.setColumnCount(2)
        self.activeTable.verticalHeader().setVisible(False)
        self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.activeTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.activeTable.setAlternatingRowColors(True)
        self.activeTable.setHorizontalHeaderLabels([u'主力代码', u'合约代码'])

        # 日志监控
        self.logMonitor = QtGui.QTextEdit()
        self.logMonitor.setReadOnly(True)
        self.logMonitor.setMinimumHeight(300)

        # 设置布局
        grid = QtGui.QGridLayout()

        grid.addWidget(tickLabel, 0, 0)
        grid.addWidget(barLabel, 0, 1)
        grid.addWidget(activeLabel, 0, 2)
        grid.addWidget(self.tickTable, 1, 0)
        grid.addWidget(self.barTable, 1, 1)
        grid.addWidget(self.activeTable, 1, 2)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(grid)
        vbox.addWidget(self.logMonitor)
        self.setLayout(vbox)
コード例 #10
0
 def initStrategyManager(self):
     """初始化策略管理组件界面"""        
     w = QtGui.QWidget()
     vbox = QtGui.QVBoxLayout()
     
     for name in self.ctaEngine.strategyDict.keys():
         # 为每一个策略实例,创建对应的管理组件实例
         strategyManager = CtaStrategyManager(self.ctaEngine, self.eventEngine, name)
         vbox.addWidget(strategyManager)
         sleep(0.2)
     
     vbox.addStretch()
     
     w.setLayout(vbox)
     self.scrollArea.setWidget(w)   
コード例 #11
0
ファイル: uiCtaWidget.py プロジェクト: lijielife/vnTrader
    def __init__(self, l, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        console = MyConsole(self, l)
        console.setMinimumSize(350, 700)

        scroll = QtGui.QScrollArea()
        scroll.setWidget(console)
        scroll.setAutoFillBackground(True)
        scroll.setWidgetResizable(True)
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(scroll)
        self.setLayout(vbox)

        self.initUI()
コード例 #12
0
    def updateData(self, data):
        """更新数据"""
        if not self.inited:
            # 设置标题

            self.setColumnCount(len(data))
            self.setHorizontalHeaderLabels(data.keys())

            # 新增数据
            col = 0
            for k, v in data.items():
                cell = QtGui.QTableWidgetItem(unicode(v))
                self.keyCellDict[k] = cell
                self.setItem(0, col, cell)
                col += 1
            
            self.inited = True
        else:
            # 更新数据
            for k, v in data.items():
                cell = self.keyCellDict[k]
                cell.setText(unicode(v))

        #cell.setBackgroundColor()

        # 调整表格宽度为自适应
        self.resizeColumnsToContents()
        self.resizeRowsToContents()
コード例 #13
0
ファイル: uiChanlunWidget.py プロジェクト: yue8000/chanlun
 def generatePicture(self):
     ## pre-computing a QPicture object allows paint() to run much more quickly,
     ## rather than re-drawing the shapes every time.
     self.picture = QtGui.QPicture()
     p = QtGui.QPainter(self.picture)
     p.setPen(pg.mkPen(color='w', width=0.4))  # 0.4 means w*2
     # w = (self.data[1][0] - self.data[0][0]) / 3.
     w = 0.2
     for (t, open, close, min, max) in self.data:
         p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
         if open > close:
             p.setBrush(pg.mkBrush('g'))
         else:
             p.setBrush(pg.mkBrush('r'))
         p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
     p.end()
コード例 #14
0
ファイル: uiCtaWidget.py プロジェクト: hong142101/CTPTrader
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(CTA_STRATEGY)

        # 按钮
        startAllButton = QtGui.QPushButton(START_ALL)
        stopAllButton = QtGui.QPushButton(STOP_ALL)
        savePositionButton = QtGui.QPushButton(SAVE_POSITION_DATA)

        startAllButton.clicked.connect(self.startAll)
        stopAllButton.clicked.connect(self.stopAll)
        # savePositionButton.clicked.connect(self.ctaEngine.savePosition)

        # 滚动区域,放置所有的CtaStrategyManager
        self.scrollArea = QtGui.QScrollArea()
        self.scrollArea.setWidgetResizable(True)

        # CTA组件的日志监控
        self.ctaLogMonitor = QtGui.QTextEdit()
        self.ctaLogMonitor.setReadOnly(True)
        self.ctaLogMonitor.setMaximumHeight(200)

        # 设置布局
        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(startAllButton)
        hbox2.addWidget(stopAllButton)
        # hbox2.addWidget(savePositionButton)
        hbox2.addStretch()

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox2)
        vbox.addWidget(self.scrollArea)
        vbox.addWidget(self.ctaLogMonitor)
        self.setLayout(vbox)
コード例 #15
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'CTA策略')

        # 按钮
        loadButton = QtGui.QPushButton(u'加载策略')
        startAllButton = QtGui.QPushButton(u'全部启动')
        stopAllButton = QtGui.QPushButton(u'全部停止')

        loadButton.clicked.connect(self.load)
        startAllButton.clicked.connect(self.startAll)
        stopAllButton.clicked.connect(self.stopAll)

        # 滚动区域,放置所有的CtaStrategyManager
        self.scrollArea = QtGui.QScrollArea()

        # CTA组件的日志监控
        self.ctaLogMonitor = QtGui.QTextEdit()
        self.ctaLogMonitor.setReadOnly(True)

        # 设置布局
        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(loadButton)
        hbox2.addWidget(startAllButton)
        hbox2.addWidget(stopAllButton)
        hbox2.addStretch()

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox2)
        vbox.addWidget(self.scrollArea)
        vbox.addWidget(self.ctaLogMonitor)
        self.setLayout(vbox)
コード例 #16
0
    def initUi(self, startDate=None):
        """初始化界面"""
        self.setWindowTitle(u'Price')

        self.vbl_1 = QtGui.QVBoxLayout()
        self.initplotTick()  # plotTick初始化

        self.vbl_2 = QtGui.QVBoxLayout()
        self.initplotKline()  # plotKline初始化
        self.initplotTendency()  # plot分时图的初始化

        # 整体布局
        self.hbl = QtGui.QHBoxLayout()
        self.hbl.addLayout(self.vbl_1)
        self.hbl.addLayout(self.vbl_2)
        self.setLayout(self.hbl)

        self.initHistoricalData()  # 下载历史数据
コード例 #17
0
ファイル: uiCtaWidget.py プロジェクト: hong142101/CTPTrader
    def initUi(self):
        """初始化界面"""
        self.setTitle(self.name)

        self.paramMonitor = CtaValueMonitor(self)
        self.varMonitor = CtaValueMonitor(self)

        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(self.paramMonitor)

        hbox3 = QtGui.QHBoxLayout()
        hbox3.addWidget(self.varMonitor)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox2)
        vbox.addLayout(hbox3)

        self.setLayout(vbox)
コード例 #18
0
        def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='w'))  # 0.4 means w*2, width=0.4
            w = 0.2  # w*2是 阴线阳线宽度

            # 用来记录上一个k线值 和打印更新的k线状态值
            global pre
            if len(self.data) == 0:
                pass
            elif len(self.data) < 2:
                pre = self.data[0]
                cur = self.data[0]
            else:
                cur = self.data[-1]
                if pre == cur:
                    pass
                else:
                    print cur
                    pre = cur

            for (t, open_price, close_price, min_price,
                 max_price) in self.data:
                '''
                这里对画最高最低值的竖直线的一种意外情况的判断,
                如果max和min一样,则画出来的直线实际上成了一个方块
                '''
                if abs(min_price - max_price) < 0.00000001:
                    pass  # 如果最高价和最低价相同,则不绘制这直线
                else:
                    p.drawLine(QtCore.QPointF(t, min_price),
                               QtCore.QPointF(t, max_price))
                if open_price > close_price:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                # 绘制open和close的柱状图
                p.drawRect(
                    QtCore.QRectF(t - w, open_price, w * 2,
                                  close_price - open_price))
            p.end()
コード例 #19
0
ファイル: uiCtaWidget.py プロジェクト: zhengwsh/InplusTrader
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'CTA策略')

        # 按钮
        newButton = QtGui.QPushButton(u'新建策略')
        loadButton = QtGui.QPushButton(u'加载策略')
        initAllButton = QtGui.QPushButton(u'全部初始化')
        startAllButton = QtGui.QPushButton(u'全部启动')
        stopAllButton = QtGui.QPushButton(u'全部停止')
        savePositionButton = QtGui.QPushButton(u'保存持仓')

        newButton.clicked.connect(self.new)
        loadButton.clicked.connect(self.load)
        initAllButton.clicked.connect(self.initAll)
        startAllButton.clicked.connect(self.startAll)
        stopAllButton.clicked.connect(self.stopAll)
        savePositionButton.clicked.connect(self.ctaEngine.savePosition)

        # 滚动区域,放置所有的CtaStrategyManager
        self.scrollArea = QtGui.QScrollArea()
        self.scrollArea.setWidgetResizable(True)

        # CTA组件的日志监控
        self.ctaLogMonitor = QtGui.QTextEdit()
        self.ctaLogMonitor.setReadOnly(True)
        self.ctaLogMonitor.setMaximumHeight(200)

        # 设置布局
        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(newButton)
        hbox2.addWidget(loadButton)
        hbox2.addWidget(initAllButton)
        hbox2.addWidget(startAllButton)
        hbox2.addWidget(stopAllButton)
        hbox2.addWidget(savePositionButton)
        hbox2.addStretch()

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox2)
        vbox.addWidget(self.scrollArea)
        vbox.addWidget(self.ctaLogMonitor)
        self.setLayout(vbox)
コード例 #20
0
ファイル: uiCtaWidget.py プロジェクト: lijielife/vnTrader
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'CTA策略')

        # 按钮
        loadButton = QtGui.QPushButton(u'加载策略')
        initAllButton = QtGui.QPushButton(u'全部初始化')
        startAllButton = QtGui.QPushButton(u'全部启动')
        stopAllButton = QtGui.QPushButton(u'全部停止')
        addStrategy = QtGui.QPushButton(u'添加策略')
        thumbnail = QtGui.QPushButton(u'策略持仓')

        loadButton.clicked.connect(self.load)
        initAllButton.clicked.connect(self.initAll)
        startAllButton.clicked.connect(self.startAll)
        stopAllButton.clicked.connect(self.stopAll)
        addStrategy.clicked.connect(self.addStrategy)
        thumbnail.clicked.connect(self.thumbnail)
        # 滚动区域,放置所有的CtaStrategyManager
        self.scrollArea = QtGui.QScrollArea()
        self.scrollArea.setWidgetResizable(True)

        # CTA组件的日志监控
        self.ctaLogMonitor = QtGui.QTextEdit()
        self.ctaLogMonitor.setReadOnly(True)
        self.ctaLogMonitor.setMaximumHeight(200)

        # 设置布局
        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(loadButton)
        hbox2.addWidget(initAllButton)
        hbox2.addWidget(startAllButton)
        hbox2.addWidget(stopAllButton)
        hbox2.addWidget(addStrategy)
        hbox2.addWidget(thumbnail)
        hbox2.addStretch()

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox2)
        vbox.addWidget(self.scrollArea)
        vbox.addWidget(self.ctaLogMonitor)
        self.setLayout(vbox)
コード例 #21
0
    def initUi(self):
        """初始化界面"""
        self.setTitle(self.name)

        self.paramMonitor = CtaValueMonitor(self)
        self.varMonitor = CtaValueMonitor(self)

        maxHeight = 60
        self.paramMonitor.setMaximumHeight(maxHeight)
        self.varMonitor.setMaximumHeight(maxHeight)

        buttonInit = QtGui.QPushButton(u'初始化')
        buttonStart = QtGui.QPushButton(u'启动')
        buttonStop = QtGui.QPushButton(u'停止')
        buttonParam = QtGui.QPushButton(u'参数')
        buttonDelete = QtGui.QPushButton(u'删除')
        buttonDelete.clicked.connect(self.delete)
        #updateInfo = QtGui.QPushButton(u'更新缓存')
        #buttonPosition = QtGui.QPushButton(u'重置今持仓')
        buttonInit.clicked.connect(self.init)
        buttonStart.clicked.connect(self.start)
        buttonStop.clicked.connect(self.stop)
        buttonParam.clicked.connect(self.param)
        #updateInfo.clicked.connect(self.update)
        #buttonPosition.clicked.connect(self.position)
        hbox1 = QtGui.QHBoxLayout()
        hbox1.addWidget(buttonInit)
        hbox1.addWidget(buttonStart)
        hbox1.addWidget(buttonStop)
        hbox1.addWidget(buttonParam)
        hbox1.addWidget(buttonDelete)
        #hbox1.addWidget(updateInfo)
        #hbox1.addWidget(buttonPosition)
        hbox1.addStretch()

        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(self.paramMonitor)

        hbox3 = QtGui.QHBoxLayout()
        hbox3.addWidget(self.varMonitor)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        vbox.addLayout(hbox3)

        self.setLayout(vbox)
コード例 #22
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'任务管理')
        
        buttonStopAll = QtGui.QPushButton(u'全部停止')
        buttonStopAll.setObjectName(_fromUtf8('redButton'))
        buttonStopAll.clicked.connect(self.taskTab.stopAll)
        buttonClearAll = QtGui.QPushButton(u'清空所有')
        buttonClearAll.setObjectName(_fromUtf8('blueButton'))
        buttonClearAll.clicked.connect(self.taskTab.clearAll)
        hbox11 = QtGui.QHBoxLayout()     
        hbox11.addWidget(buttonStopAll)
        hbox11.addWidget(buttonClearAll)
        hbox11.addStretch()
        
        grid = QtGui.QVBoxLayout()
        grid.addLayout(hbox11)
        grid.addWidget(self.taskTab)

        self.setLayout(grid)
コード例 #23
0
    def edit(self):
        self.textBrowser = QtGui.QTextBrowser()
        self.textBrowser.setGeometry(QtCore.QRect(0, 0, 1000, 1000))
        self.textBrowser.setReadOnly(False)
        self.textBrowser.setObjectName(QtCore.QString.fromUtf8("textBrowser"))

        f = open(self.setting['base']['strategy_file'])
        my_data = f.read()
        f.close()
        self.textBrowser.append(my_data.decode('utf-8'))
        self.textBrowser.showMaximized()
コード例 #24
0
 def __init__(self,
              ParamWindow,
              ParamWindow2,
              ParamWindow3,
              CtaEngineManager=None):
     super(strategyWindow, self).__init__()
     self.setWindowTitle(u"策略类型")
     self.pw = ParamWindow
     self.gt = ParamWindow2
     self.cai = ParamWindow3
     self.ce = CtaEngineManager
     self.tradeTestButton = QtGui.QPushButton(u"配置双合约套利策略", self)
     self.tradeTestButton.clicked.connect(self.createTradeTest)
     self.girdTradingButton = QtGui.QPushButton(u"配置单合约网格策略", self)
     self.girdTradingButton.clicked.connect(self.createGirdTrading)
     self.CtpAndIB = QtGui.QPushButton(u"配置CTP IB套利策略", self)
     self.CtpAndIB.clicked.connect(self.createCtpAndIB)
     self.moreStrategyCoding = QtGui.QPushButton(u"更多策略开发中", self)
     self.moreStrategyCoding.clicked.connect(self.coding)
     self.initUI()
コード例 #25
0
    def initStrategyManager(self):
        """初始化策略管理组件界面"""
        w = QtGui.QWidget()
        vbox = QtGui.QVBoxLayout()
        self.runID = 9999

        for name in self.stockBacktestEngine.strategyDict.keys():
            strategyManager = StockStrategyManager(self.stockBacktestEngine,
                                                   self.eventEngine, name,
                                                   self.runID)
            vbox.addWidget(strategyManager)
            self.runID -= 1

            self.signal2.connect(self.updateBktResult)
            self.eventEngine.register(EVENT_BKT_STRATEGY + name,
                                      self.signal2.emit)

        vbox.addStretch()

        w.setLayout(vbox)
        self.scrollArea.setWidget(w)
コード例 #26
0
ファイル: uiCtaWidget.py プロジェクト: lijielife/vnTrader
    def initUI(self):

        vbox1 = QtGui.QVBoxLayout()
        for x in self.l:
            fileName = "parameter_" + x['name'] + '.json'
            d = {}
            with open(fileName, 'r') as f:
                d = json.load(f)
                f.close()
            symbols = d['postoday'].keys()
            label = [u'策略名\持仓'] + symbols
            newTable = QtGui.QTableWidget(1, 3)
            newTable.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
            newTable.setMaximumHeight(60)
            newTable.setHorizontalHeaderLabels(label)
            vbox1.addWidget(newTable)
            newItem = QtGui.QTableWidgetItem(x['name'])
            newTable.setItem(0, 0, newItem)
            newItem = QtGui.QTableWidgetItem(str(d['postoday'][symbols[0]]))
            newTable.setItem(0, 1, newItem)
            newItem = QtGui.QTableWidgetItem(' ')
            newTable.setItem(0, 2, newItem)
            if len(symbols) == 2:
                newItem = QtGui.QTableWidgetItem(str(
                    d['postoday'][symbols[1]]))
                newTable.setItem(0, 2, newItem)

        self.vbox = vbox1
        self.setLayout(self.vbox)
コード例 #27
0
    def initUi(self):
        """初始化界面"""
        self.setTitle(self.name)

        paramLabel = QtGui.QLabel(u'参数')
        varLabel = QtGui.QLabel(u'变量')

        self.paramMonitor = ValueMonitor(self)
        self.varMonitor = ValueMonitor(self)

        buttonStart = QtGui.QPushButton(u'启动')
        buttonStop = QtGui.QPushButton(u'停止')
        buttonStart.clicked.connect(self.start)
        buttonStop.clicked.connect(self.stop)

        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(buttonStart)
        hbox.addWidget(buttonStop)
        hbox.addStretch()

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(paramLabel)
        vbox.addWidget(self.paramMonitor)
        vbox.addWidget(varLabel)
        vbox.addWidget(self.varMonitor)
        self.setLayout(vbox)
コード例 #28
0
ファイル: uiCtaWidget.py プロジェクト: zhengwsh/InplusTrader
    def updateData(self, data):
        """更新数据"""
        if not self.inited:
            self.setColumnCount(len(data))
            self.setHorizontalHeaderLabels(data.keys())
            self.resizeColumnsToContents()

            col = 0
            for k, v in data.items():
                if k == 'vtSymbols':
                    cell = QtGui.QTableWidgetItem('; '.join(v))
                elif k == 'pos':
                    poses = ""
                    for sym in v:
                        poses += sym + ":long:" + str(
                            v[sym]["long"]) + ",short:" + str(
                                v[sym]["short"]) + "; "
                    cell = QtGui.QTableWidgetItem(poses)
                else:
                    cell = QtGui.QTableWidgetItem(unicode(v))

                self.keyCellDict[k] = cell
                self.setItem(0, col, cell)
                col += 1

            self.inited = True
        else:
            for k, v in data.items():
                cell = self.keyCellDict[k]
                if k == 'vtSymbols':
                    cell.setText('; '.join(v))
                elif k == 'pos':
                    poses = ""
                    for sym in v:
                        poses += sym + ":long:" + str(
                            v[sym]["long"]) + ",short:" + str(
                                v[sym]["short"]) + "; "
                    cell.setText(poses)
                else:
                    cell.setText(unicode(v))
コード例 #29
0
    def updateData(self, data):
        """更新数据"""
        if not self.inited:
            self.setColumnCount(len(data))
            self.setHorizontalHeaderLabels(data.keys())

            col = 0
            for k, v in data.items():
                cell = QtGui.QTableWidgetItem(unicode(v))
                self.keyCellDict[k] = cell
                self.setItem(0, col, cell)
                col += 1

            self.inited = True
        else:
            for k, v in data.items():
                cell = self.keyCellDict[k]
                cell.setText(unicode(v))
コード例 #30
0
    def initUi(self):
        """初始化界面"""
        self.setTitle(self.name)

        self.paramMonitor = CtaValueMonitor(self)
        self.varMonitor = CtaValueMonitor(self)
        self.dynamicMonitor = CtaValueMonitor(self)

        maxHeight = 60
        self.paramMonitor.setMaximumHeight(maxHeight)
        self.varMonitor.setMaximumHeight(maxHeight)

        buttonInit = QtGui.QPushButton(u'初始化')
        buttonStart = QtGui.QPushButton(u'启动')
        buttonStop = QtGui.QPushButton(u'停止')
        buttonInit.clicked.connect(self.init)
        buttonStart.clicked.connect(self.start)
        buttonStop.clicked.connect(self.stop)

        hbox1 = QtGui.QHBoxLayout()
        hbox1.addWidget(buttonInit)
        hbox1.addWidget(buttonStart)
        hbox1.addWidget(buttonStop)
        hbox1.addStretch()

        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(self.paramMonitor)

        hbox3 = QtGui.QHBoxLayout()
        hbox3.addWidget(self.varMonitor)

        hbox4 = QtGui.QHBoxLayout()
        hbox4.addWidget(self.dynamicMonitor)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        vbox.addLayout(hbox3)
        vbox.addLayout(hbox4)

        self.setLayout(vbox)