コード例 #1
0
    def initDialogSummary(self, result, KData=None):
        # 1) creates layouts
        dialog = QtGui.QDialog()
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)
        dialog.setWindowTitle(('Strategy Results'))

        import os, sys
        xpower = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
                         os.pardir, 'midProjects', 'histdataUI'))
        sys.path.append(xpower)

        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        from pyqtgraph.dockarea import DockArea, Dock
        area = DockArea()
        rightLayout.addWidget(area)

        # 2) creates widgets
        #  2.1)candle
        pgCandleView = pgCandleWidgetCross(dataForCandle=KData)
        dCandle = Dock("candles", closable=True,
                       size=(200,
                             300))  ## give this dock the minimum possible size
        area.addDock(dCandle, 'bottom')
        dCandle.addWidget(pgCandleView)
        # 2) creates widgets
        # 2.3)position_cost
        if (True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.availableCashPlot(PyqtGraphPositionCost)
            dAvailableCash = Dock("available_cash",
                                  closable=True,
                                  size=(200, 100))
            area.addDock(dAvailableCash, 'bottom')
            dAvailableCash.addWidget(PyqtGraphPositionCost)
            PyqtGraphPositionCost.setXLink(pgCandleView)
        # 2.3)position_cost
        if (True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.portfolioPlot(PyqtGraphPositionCost)
            dPortfolioValue = Dock("portfolio_value",
                                   closable=True,
                                   size=(200, 100))
            area.addDock(dPortfolioValue, 'bottom')
            dPortfolioValue.addWidget(PyqtGraphPositionCost)
            PyqtGraphPositionCost.setXLink(pgCandleView)
        return dialog
コード例 #2
0
 def initLayoutLocalDataVisualizer(self):
     bottomLeft02 = QtGui.QVBoxLayout(self)  
 
     # 05)bottomLeft02---------------------
     label7=QtGui.QLabel(self.tr("Current symbol graphview:"))
     
     dataForCandle = self.dataCenter.retriveCandleData(datasource = 'tushare',storageType = 'mongodb',symbol = '600028')     
     candle = pgCandleWidgetCross(dataForCandle=dataForCandle)          
     
     
     
     bottomLeft02.addWidget(label7)
     bottomLeft02.addWidget(candle)  
     
     return bottomLeft02
コード例 #3
0
    def createDataVisualizerLayout(self):
        bottomLeft02 = QtGui.QHBoxLayout(self.parent)
        bottomLeft02.addLayout(self.createTableLayout())

        # 05)bottomLeft02---------------------
        params = self.getDataSourceParams()
        if (params is not None):
            dataForCandle = self.dataCenter.retriveCandleData(params=params)

            self.candleWidget = pgCandleWidgetCross(
                dataForCandle=dataForCandle)

        bottomLeft02.addWidget(self.candleWidget)

        bottomLeft02.setStretch(0, 1)
        bottomLeft02.setStretch(1, 3.5)
        return bottomLeft02
コード例 #4
0
 def createDataVisualizerLayout(self):
     bottomLeft02 = QtGui.QHBoxLayout(self.parent)  
     bottomLeft02.addLayout(self.createTableLayout())        
 
     # 05)bottomLeft02---------------------        
     params = self.getDataSourceParams()
     if(params is not None):   
         dataForCandle = self.dataCenter.retriveCandleData(params = params)
     
         self.candleWidget = pgCandleWidgetCross(dataForCandle=dataForCandle)          
 
     
     bottomLeft02.addWidget(self.candleWidget)  
     
     bottomLeft02.setStretch(0,1)
     bottomLeft02.setStretch(1,3.5)
     return bottomLeft02    
コード例 #5
0
 def __showCandle__(self,dataForCandle):
     dialog = QtGui.QDialog()
     self.pgCandleView = dialog
     layout = QtGui.QHBoxLayout()
     layoutLeft = QtGui.QVBoxLayout()
     layout.addLayout(layoutLeft)
     dialog.setLayout(layout)        
     dialog.setWindowTitle(('ComboView'))
     # 2) creates widgets 
     editor = QtGui.QTextEdit()
     editor.setText("<span style='font-size: 15pt' style='color: red'>x = %0.1f,y = %0.1f</span>"% (2.0,2.0))
 
     candle = pgCandleWidgetCross(dataForCandle=dataForCandle)  
     #candle = pgCrossAddition()
     # 3)arrange widgets
     #layout.addWidget(editor)
     layout.addWidget(candle)
     dialog.showMaximized()           
コード例 #6
0
    def initDialogSummary(self,result,KData=None):
        # 1) creates layouts
        dialog = QtGui.QDialog()   
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)        
        dialog.setWindowTitle(('Strategy Results'))

        import os,sys        
        xpower = os.path.abspath(os.path.join(os.path.dirname(__file__),os.pardir,os.pardir,os.pardir,'midProjects','histdataUI'))
        sys.path.append(xpower)

        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        from pyqtgraph.dockarea import DockArea,Dock 
        area = DockArea()   
        rightLayout.addWidget(area)


        # 2) creates widgets 
        #  2.1)candle        
        pgCandleView = pgCandleWidgetCross(dataForCandle=KData)        
        dCandle = Dock("candles",closable=True, size=(200,300))     ## give this dock the minimum possible size
        area.addDock(dCandle, 'bottom') 
        dCandle.addWidget(pgCandleView)       
        # 2) creates widgets 
        # 2.3)position_cost 
        if(True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.availableCashPlot(PyqtGraphPositionCost)
            dAvailableCash = Dock("available_cash",closable=True, size=(200,100))
            area.addDock(dAvailableCash, 'bottom')        
            dAvailableCash.addWidget(PyqtGraphPositionCost)             
            PyqtGraphPositionCost.setXLink(pgCandleView)         
        # 2.3)position_cost 
        if(True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.portfolioPlot(PyqtGraphPositionCost)
            dPortfolioValue = Dock("portfolio_value",closable=True, size=(200,100))
            area.addDock(dPortfolioValue, 'bottom')        
            dPortfolioValue.addWidget(PyqtGraphPositionCost)             
            PyqtGraphPositionCost.setXLink(pgCandleView) 
        return dialog        
コード例 #7
0
    def initDialog(self,results=None,KData=None,bDrawText=False):
        # 1) creates layouts
        dialog = QtGui.QDialog()   
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)        
        dialog.setWindowTitle(('Strategy Results'))
        # 2) creates widgets         
        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        from pyqtgraph.dockarea import DockArea,Dock     
        
    

        area = DockArea()
        ## Create docks, place them into the window one at a time.
        ## Note that size arguments are only a suggestion; docks will still have to
        ## fill the entire dock area and obey the limits of their internal widgets.
        d1 = Dock("price", size=(200,100))
        d2 = Dock("position", size=(200,100))


        area.addDock(d1, 'bottom')  
        area.addDock(d2, 'bottom')  

        rightLayout.addWidget(area)
       
       
       
        
        pgCandleView = pgCandleWidgetCross(dataForCandle=KData)            
        PyqtGraphindicators = pgCrossAddition()
        toShow = pgCandleView
        self.pricePlot(toShow) 
        d1.addWidget(toShow)   
        
        PyqtGraphPosition = pgCrossAddition()
        self.positionPlot(PyqtGraphPosition)        
        d2.addWidget(PyqtGraphPosition)
        PyqtGraphPosition.showGrid(x=True, y=True)
        
        PyqtGraphPosition.setXLink(toShow)        
        return dialog
コード例 #8
0
    def slotShowCandleView(self):
        """"""
        # 1) creates layouts
        dialog = QtGui.QDialog()
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)
        dialog.setWindowTitle(('Strategy Results'))
        # 2) creates widgets
        #  2.1)candle
        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        pgCandleView = pgCandleWidgetCross(dataForCandle=self.KData)
        self.pricePlot(pgCandleView)

        rightLayout.addWidget(pgCandleView)

        self.Globals.append(dialog)
        dialog.show()
コード例 #9
0
ファイル: Analyzer05.py プロジェクト: UpSea/ZipLineMid
    def slotShowCandleView(self):
        """"""
        # 1) creates layouts
        dialog = QtGui.QDialog()   
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)        
        dialog.setWindowTitle(('Strategy Results'))
        # 2) creates widgets 
        #  2.1)candle
        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        pgCandleView = pgCandleWidgetCross(dataForCandle=self.KData)        
        self.pricePlot(pgCandleView) 

        rightLayout.addWidget(pgCandleView)
 
        self.Globals.append(dialog)
        dialog.show()    
コード例 #10
0
ファイル: MinGraphView.py プロジェクト: chinobing/midProjects
 def __init__(self):
     super(MainWindow, self).__init__()
     dataForCandle = getCandleData('600028')
     cw = pgCandleWidgetCross(dataForCandle=dataForCandle)
     self.setCentralWidget(cw) 
コード例 #11
0
    def initDialogSymbol(self,results=None,KData=None,bDrawText=False,InKLine = False):
        # 1) creates layouts
        dialog = QtGui.QDialog()   
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)        
        dialog.setWindowTitle(('Strategy Results'))

        import os,sys        
        xpower = os.path.abspath(os.path.join(os.path.dirname(__file__),os.pardir,os.pardir,os.pardir,'midProjects','histdataUI'))
        sys.path.append(xpower)

        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        from pyqtgraph.dockarea import DockArea,Dock 
        area = DockArea()   
        rightLayout.addWidget(area)

        # 2) creates widgets 
        #  2.1)candle        
        pgCandleView = pgCandleWidgetCross(dataForCandle=KData)        
        self.pricePlot(pgCandleView) 
        if(InKLine):
            self.indicatorsPlot(pgCandleView) 
        #self.signalPlot(pgCandleView,yBuy = KData.take([1],axis=1),ySell = KData.take([1],axis=1))
        self.signalPlot(pgCandleView)
        dCandle = Dock("candles",closable=True, size=(200,300))     ## give this dock the minimum possible size
        area.addDock(dCandle, 'bottom') 
        dCandle.addWidget(pgCandleView)        

        #  2.2)long_pnl 当前position_pnl曲线
        if(True):
            PyqtGraphPnl = pgCrossAddition()
            self.longPnlPlot(PyqtGraphPnl,bDrawText=bDrawText)
            long_pnl = np.array(self.results.long_pnl)
            self.signalPlot(PyqtGraphPnl,yBuy = long_pnl,ySell = long_pnl)
            dPnl = Dock("long_pnl", closable=True, size=(200,100))
            area.addDock(dPnl, 'bottom')    
            dPnl.addWidget(PyqtGraphPnl)           
            PyqtGraphPnl.setXLink(pgCandleView)
        # 2.3)long_cost 
        if(True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.longCostPlot(PyqtGraphPositionCost)
            dPositionCost = Dock("long_cost",closable=True, size=(200,100))
            area.addDock(dPositionCost, 'bottom')        
            dPositionCost.addWidget(PyqtGraphPositionCost)             
            PyqtGraphPositionCost.setXLink(pgCandleView)         
        
        #  2.2)long_pnl 当前position_pnl曲线
        if(True):
            PyqtGraphPnl = pgCrossAddition()
            self.shortPnlPlot(PyqtGraphPnl,bDrawText=bDrawText)
            short_pnl = np.array(self.results.short_pnl)
            self.signalPlot(PyqtGraphPnl,yBuy = short_pnl,ySell = short_pnl)
            dPnl = Dock("short_pnl", closable=True, size=(200,100))
            area.addDock(dPnl, 'bottom')    
            dPnl.addWidget(PyqtGraphPnl)           
            PyqtGraphPnl.setXLink(pgCandleView)
        # 2.3)long_cost 
        if(True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.shortCostPlot(PyqtGraphPositionCost)
            dPositionCost = Dock("short_cost",closable=True, size=(200,100))
            area.addDock(dPositionCost, 'bottom')        
            dPositionCost.addWidget(PyqtGraphPositionCost)             
            PyqtGraphPositionCost.setXLink(pgCandleView)          
        
        #  2.3)position_volume
        if(False):
            PyqtGraphPosition = pgCrossAddition()
            self.positionVolumePlot(PyqtGraphPosition)
            dPosition = Dock("position_volume",closable=True, size=(200,100))
            area.addDock(dPosition, 'bottom')        
            dPosition.addWidget(PyqtGraphPosition)             
            PyqtGraphPosition.setXLink(pgCandleView)
        #  2.4)portfolio  总资产变动曲线 cash + equity
        if(True):
            PyqtGraphPortfolio = pgCrossAddition()
            self.positionValuePlot(PyqtGraphPortfolio)
            dPortfolio = Dock("portfolio", closable=True,size=(200,100))
            area.addDock(dPortfolio, 'bottom')     
            dPortfolio.addWidget(PyqtGraphPortfolio)        
            PyqtGraphPortfolio.setXLink(pgCandleView)
        #  2.5)indicator
        if(True):
            PyqtGraphindicators = pgCrossAddition()
            self.pricePlot(PyqtGraphindicators)    
            self.indicatorsPlot(PyqtGraphindicators)
            
            self.signalPlot(PyqtGraphindicators)
            
            dIndicator = Dock("indicator",closable=True, size=(200,100))
            dIndicator.addWidget(PyqtGraphindicators)
            area.addDock(dIndicator, 'bottom', dCandle)  
            PyqtGraphindicators.setXLink(pgCandleView)
        #  2.2)position_pnl 当前position_pnl曲线
        if(False):
            PyqtGraphPortfolioInstruments = pgCrossAddition()
            self.instrumentPnlPlot(PyqtGraphPortfolioInstruments,bDrawText=bDrawText)
            position_pnl = np.array(self.results.position_pnl)
            self.signalPlot(PyqtGraphPortfolioInstruments,yBuy = position_pnl,ySell = position_pnl)
            dPnl = Dock("instrumentsPNL", closable=True, size=(200,100))
            area.addDock(dPnl, 'bottom',dPositionCost)    
            dPnl.addWidget(PyqtGraphPortfolioInstruments)           
            PyqtGraphPortfolioInstruments.setXLink(pgCandleView)            
        return dialog
コード例 #12
0
    def initDialog(self,
                   results=None,
                   KData=None,
                   bDrawText=False,
                   InKLine=False):
        # 1) creates layouts
        dialog = QtGui.QDialog()
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)
        dialog.setWindowTitle(('Strategy Results'))

        import os, sys
        xpower = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
                         os.pardir, 'midProjects', 'histdataUI'))
        sys.path.append(xpower)

        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        from pyqtgraph.dockarea import DockArea, Dock
        area = DockArea()
        rightLayout.addWidget(area)

        # 2) creates widgets
        #  2.1)candle
        pgCandleView = pgCandleWidgetCross(dataForCandle=KData)
        self.pricePlot(pgCandleView)
        if (InKLine):
            self.indicatorsPlot(pgCandleView)
        self.signalPlot(pgCandleView,
                        yBuy=KData.take([1], axis=1),
                        ySell=KData.take([1], axis=1))
        dCandle = Dock("candles", closable=True,
                       size=(200,
                             300))  ## give this dock the minimum possible size
        area.addDock(dCandle, 'bottom')
        dCandle.addWidget(pgCandleView)

        #  2.2)position_pnl 当前position_pnl曲线
        if (True):
            PyqtGraphPnl = pgCrossAddition()
            self.positionPnlPlot(PyqtGraphPnl, bDrawText=bDrawText)
            position_pnl = np.array(self.results.position_pnl)
            self.signalPlot(PyqtGraphPnl,
                            yBuy=position_pnl,
                            ySell=position_pnl)
            dPnl = Dock("position_pnl", closable=True, size=(200, 100))
            area.addDock(dPnl, 'bottom')
            dPnl.addWidget(PyqtGraphPnl)
            PyqtGraphPnl.setXLink(pgCandleView)
        # 2.3)position_cost
        if (True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.positionCostPlot(PyqtGraphPositionCost)
            dPositionCost = Dock("position_cost",
                                 closable=True,
                                 size=(200, 100))
            area.addDock(dPositionCost, 'bottom')
            dPositionCost.addWidget(PyqtGraphPositionCost)
            PyqtGraphPositionCost.setXLink(pgCandleView)
        #  2.3)position_volume
        if (False):
            PyqtGraphPosition = pgCrossAddition()
            self.positionVolumePlot(PyqtGraphPosition)
            dPosition = Dock("position_volume", closable=True, size=(200, 100))
            area.addDock(dPosition, 'bottom')
            dPosition.addWidget(PyqtGraphPosition)
            PyqtGraphPosition.setXLink(pgCandleView)
        #  2.4)portfolio  总资产变动曲线 cash + equity
        if (True):
            PyqtGraphPortfolio = pgCrossAddition()
            self.portfolioPlot(PyqtGraphPortfolio)
            dPortfolio = Dock("portfolio", closable=True, size=(200, 100))
            area.addDock(dPortfolio, 'bottom')
            dPortfolio.addWidget(PyqtGraphPortfolio)
            PyqtGraphPortfolio.setXLink(pgCandleView)
        #  2.5)indicator
        if (True):
            PyqtGraphindicators = pgCrossAddition()
            self.pricePlot(PyqtGraphindicators)
            self.indicatorsPlot(PyqtGraphindicators)

            self.signalPlot(PyqtGraphindicators)

            dIndicator = Dock("indicator", closable=True, size=(200, 100))
            dIndicator.addWidget(PyqtGraphindicators)
            area.addDock(dIndicator, 'bottom', dCandle)
            PyqtGraphindicators.setXLink(pgCandleView)
        return dialog
コード例 #13
0
    def initDialog(self, results=None, KData=None, bDrawText=False):
        '''
        orders,记录当日00:00前一日开盘时间发送的交易命令
        trasactions,记录当日00:00前一日已执行的orders
        positions,记录当日00:00时,各个symbols的positions
        所以,这三个量都是数组,且大小不定,所以,不宜图形方式展示,适宜table方式展示
        其他单值参数都可以考虑图形化方式
        特别是pnl,cash,portfolio等
        perf的生成时点是00:00,其内容为00:00前一天的活动
        perf转化记录入result时,需要设置Index,
        此Index的值为生成记录时点后的一天的收盘时间。
        
        例如:
        有三个交易日:2015-12-01,12-02,12-03
        开收盘时间:Asia/Shanghai:09:30--15:00 (utc:01:30--07:00)
        使用instant_fill==True方式执行订单
        每日开盘时Buy(1)
        
        有如下Events列表会生成并被处理
        1)2015-12-01 00:00 utc
        生成perf
                perf内容:由于是第一交易日的开始时间(非开市时间),无内容可记
        记录入result:
                记录Index:result.index = 2015-12-01 07:00
        2)2015-12-01 01:30 utc
        生成order,生成transaction,生成position
        3)2015-12-02 00:00 utc
        生成perf
                perf内容:2015-12-01 00:00 utc 至 2015-12-02 00:00 utc期间发生的交易事项及内容
        记录入result:
                记录Index:result.index = 2015-12-02 07:00
        
        之后的4)5)6)同上
        
        不合逻辑的地方需特别注意:
	1)perf的生成时间和记录时间不一致,00:00生成(当日开始(非开市)),07:00记录(当日收市)
	2)perf记录的是00:00之前一日的交易,记录时点却是当日收盘(当日收盘时间的记录,给人直观的理解应是记录当日开盘到收盘期间发生的业务)
        '''
        self.results = results
        # 1) creates layouts
        dialog = QtGui.QDialog()
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)
        dialog.setWindowTitle(('Strategy Results'))

        import os, sys
        xpower = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
                         os.pardir, os.pardir, 'midProjects', 'histdataUI'))
        sys.path.append(xpower)

        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        from pyqtgraph.dockarea import DockArea, Dock
        area = DockArea()
        rightLayout.addWidget(area)

        # 2) creates widgets
        #  2.1)candle
        pgCandleView = pgCandleWidgetCross(dataForCandle=KData)
        self.pricePlot(pgCandleView)
        self.pricePlot(pgCandleView)
        self.indicatorsPlot(pgCandleView)
        self.signalPlot(pgCandleView)
        dCandle = Dock("candles", closable=True,
                       size=(200,
                             300))  ## give this dock the minimum possible size
        area.addDock(dCandle, 'bottom')
        dCandle.addWidget(pgCandleView)

        #  2.2)position_pnl 当前position_pnl曲线
        if (True):
            PyqtGraphPnl = pgCrossAddition()
            self.positionPnlPlot(PyqtGraphPnl, bDrawText=bDrawText)
            self.signalPlot(PyqtGraphPnl)
            dPnl = Dock("position_pnl", closable=True, size=(200, 100))
            area.addDock(dPnl, 'bottom')
            dPnl.addWidget(PyqtGraphPnl)
            PyqtGraphPnl.setXLink(pgCandleView)
        # 2.3)position_cost
        if (True):
            PyqtGraphPositionCost = pgCrossAddition()
            self.positionCostPlot(PyqtGraphPositionCost)
            dPositionCost = Dock("position_cost",
                                 closable=True,
                                 size=(200, 100))
            area.addDock(dPositionCost, 'bottom')
            dPositionCost.addWidget(PyqtGraphPositionCost)
            PyqtGraphPositionCost.setXLink(pgCandleView)
        #  2.3)position_volume
        if (False):
            PyqtGraphPosition = pgCrossAddition()
            self.positionVolumePlot(PyqtGraphPosition)
            dPosition = Dock("position_volume", closable=True, size=(200, 100))
            area.addDock(dPosition, 'bottom')
            dPosition.addWidget(PyqtGraphPosition)
            PyqtGraphPosition.setXLink(pgCandleView)
        #  2.4)portfolio  总资产变动曲线 cash + equity
        if (True):
            PyqtGraphPortfolio = pgCrossAddition()
            self.portfolioPlot(PyqtGraphPortfolio)
            dPortfolio = Dock("portfolio", closable=True, size=(200, 100))
            area.addDock(dPortfolio, 'bottom')
            dPortfolio.addWidget(PyqtGraphPortfolio)
            PyqtGraphPortfolio.setXLink(pgCandleView)
        #  2.5)indicator
        if (False):
            PyqtGraphindicators = pgCrossAddition()
            self.pricePlot(PyqtGraphindicators)
            self.indicatorsPlot(PyqtGraphindicators)
            dIndicator = Dock("indicator", closable=True, size=(200, 100))
            dIndicator.addWidget(PyqtGraphindicators)
            area.addDock(dIndicator, 'bottom', dCandle)
            PyqtGraphindicators.setXLink(pgCandleView)

        #  2.6)order
        #PyqtGraphOrder = pgCrossAddition()
        #self.orderPlot(PyqtGraphOrder)
        #self.pricePlot(PyqtGraphOrder)

        ## Create docks, place them into the window one at a time.
        ## Note that size arguments are only a suggestion; docks will still have to
        ## fill the entire dock area and obey the limits of their internal widgets.
        #d6 = Dock("order time,amount",size=(200,100))

        #area.addDock(d6, 'bottom', d1)

        #d6.addWidget(PyqtGraphOrder)

        #PyqtGraphOrder.setXLink(pgCandleView)
        return dialog
コード例 #14
0
ファイル: Analyzer05.py プロジェクト: UpSea/ZipLineMid
    def initDialog(self,results=None,KData=None,bDrawText=False):
        '''
        orders,记录当日00:00前一日开盘时间发送的交易命令
        trasactions,记录当日00:00前一日已执行的orders
        positions,记录当日00:00时,各个symbols的positions
        所以,这三个量都是数组,且大小不定,所以,不宜图形方式展示,适宜table方式展示
        其他单值参数都可以考虑图形化方式
        特别是pnl,cash,portfolio等
        perf的生成时点是00:00,其内容为00:00前一天的活动
        perf转化记录入result时,需要设置Index,
        此Index的值为生成记录时点后的一天的收盘时间。
        
        例如:
        有三个交易日:2015-12-01,12-02,12-03
        开收盘时间:Asia/Shanghai:09:30--15:00 (utc:01:30--07:00)
        使用instant_fill==True方式执行订单
        每日开盘时Buy(1)
        
        有如下Events列表会生成并被处理
        1)2015-12-01 00:00 utc
        生成perf
                perf内容:由于是第一交易日的开始时间(非开市时间),无内容可记
        记录入result:
                记录Index:result.index = 2015-12-01 07:00
        2)2015-12-01 01:30 utc
        生成order,生成transaction,生成position
        3)2015-12-02 00:00 utc
        生成perf
                perf内容:2015-12-01 00:00 utc 至 2015-12-02 00:00 utc期间发生的交易事项及内容
        记录入result:
                记录Index:result.index = 2015-12-02 07:00
        
        之后的4)5)6)同上
        
        不合逻辑的地方需特别注意:
	1)perf的生成时间和记录时间不一致,00:00生成(当日开始(非开市)),07:00记录(当日收市)
	2)perf记录的是00:00之前一日的交易,记录时点却是当日收盘(当日收盘时间的记录,给人直观的理解应是记录当日开盘到收盘期间发生的业务)
        '''
        # 1) creates layouts
        dialog = QtGui.QDialog()   
        mainLayout = QtGui.QHBoxLayout()
        rightLayout = QtGui.QVBoxLayout()
        mainLayout.addLayout(rightLayout)
        dialog.setLayout(mainLayout)        
        dialog.setWindowTitle(('Strategy Results'))
        # 2) creates widgets 
        #  2.1)candle
        import os,sys        
        xpower = os.path.abspath(os.path.join(os.path.dirname(__file__),os.pardir,os.pardir,os.pardir,'midProjects','histdataUI'))
        sys.path.append(xpower)
    
        from Widgets.pgCandleWidgetCross import pgCandleWidgetCross
        from Widgets.pgCrossAddition import pgCrossAddition
        pgCandleView = pgCandleWidgetCross(dataForCandle=KData)        
        self.pricePlot(pgCandleView) 
        #  2.2)Pnl
        PyqtGraphPnl = pgCrossAddition()
        self.pnlPlot(PyqtGraphPnl,bDrawText=bDrawText)
        #  2.3)Position
        #PyqtGraphPosition = pgCrossAddition()
        #self.positionPlot(PyqtGraphPosition)
        #  2.4)portfolio
        PyqtGraphPortfolio = pgCrossAddition()
        self.portfolioPlot(PyqtGraphPortfolio)
        #  2.5)price
        PyqtGraphindicators = pgCrossAddition()
        self.pricePlot(PyqtGraphindicators)    
        self.indicatorsPlot(PyqtGraphindicators)
        #  2.6)order
        #PyqtGraphOrder = pgCrossAddition()
        #self.orderPlot(PyqtGraphOrder)
        #self.pricePlot(PyqtGraphOrder)
        from pyqtgraph.dockarea import DockArea,Dock 
        area = DockArea()
        ## Create docks, place them into the window one at a time.
        ## Note that size arguments are only a suggestion; docks will still have to
        ## fill the entire dock area and obey the limits of their internal widgets.
        d1 = Dock("candles", size=(200,300))     ## give this dock the minimum possible size
        d2 = Dock("pnl", closable=True, size=(200,100))
        #d3 = Dock("position", size=(200,100))
        d4 = Dock("portfolio", size=(200,100))
        d5 = Dock("price", size=(200,100))
        #d6 = Dock("order time,amount",size=(200,100))

        area.addDock(d1, 'bottom') 
        area.addDock(d2, 'bottom')    
        #area.addDock(d3, 'bottom')
        area.addDock(d4, 'bottom')     
        area.addDock(d5, 'bottom', d1)  
        #area.addDock(d6, 'bottom', d1)
        rightLayout.addWidget(area)

        d1.addWidget(pgCandleView)        
        d2.addWidget(PyqtGraphPnl)     
        #d3.addWidget(PyqtGraphPosition)             
        d4.addWidget(PyqtGraphPortfolio)        
        d5.addWidget(PyqtGraphindicators)
        #d6.addWidget(PyqtGraphOrder)
        
        PyqtGraphPnl.setXLink(pgCandleView)
        #PyqtGraphPosition.setXLink(pgCandleView)
        PyqtGraphPortfolio.setXLink(pgCandleView)
        PyqtGraphindicators.setXLink(pgCandleView)
        #PyqtGraphOrder.setXLink(pgCandleView)
        return dialog