Ejemplo n.º 1
0
    def loadSymbol(self, symbol):
        if Avidus.ds.hasSymbol(symbol):
            import DateTime
            date = DateTime.now() - DateTime.RelativeDate(years=+5)
            self.mData.setData(Avidus.ds.getData(symbol, date), symbol)
        else:
            message = 'Invalid symbol'
            self.emit(PYSIGNAL("statusMessage"), (message, ))
            QMessageBox.information(self, 't a c t', """Invalid Symbol""")
            return

        self.xsize = self.mX.UpdateData(self.mData, self.width())

        if self.splitter.width() != self.xsize:
            self.mChart.UpdateData(DataSet())
            for i in range(len(self.mIndCharts)):
                self.mIndCharts[i].UpdateData(DataSet())
            self.resizeContents(self.xsize, self.visibleHeight())
            self.splitter.resize(self.xsize, self.visibleHeight())

            # move to the far right
            self.center(4000, 0, 0, 0)

        #print 'got a size of: ', self.width(), self.height()
        #print 'got a size of: ', self.mChart.width(), self.mChart.height()
        #print 'got a size of: ', self.splitter.width(), self.splitter.height()

        self.mChart.UpdateData(self.mData)
        for i in range(len(self.mIndCharts)):
            self.mIndCharts[i].UpdateData(self.mData)

        # move to the far right
        self.center(4000, 0, 0, 0)

        message = symbol + ' loaded.'
        self.emit(PYSIGNAL("statusMessage"), (message, ))

        self.ticker.insertItem(symbol, 0)
Ejemplo n.º 2
0
    def __init__(self, parent=None, name='Chart Window'):
        """ Constructor """

        QScrollView.__init__(self, parent, name)

        #fixme: for some reason, the following statement throws
        #error output, but still seems to work....
        self.setMinimumSize(800, 600)

        self.xsize = self.width()
        self.mYAxisSize = 60

        self.chartStyle = ['OHLC', 'Candle', 'Line']
        self.timeScale = [('3 Months',80), \
                          ('1 Year',260), \
                          ('2 Years',520), \
                          ('3 Years',780)]
        #self.numberOfBars = 80

        self.mData = DataSet()
        self.mProps = ChartProperties(self)
        self.connect(self.mProps, \
                     PYSIGNAL('propertiesChanged'), self.redraw)

        self.mIndCharts = []
        self.mNumIndCharts = 0
        self.mMaxNumIndCharts = 5

        self.setHScrollBarMode(QScrollView.AlwaysOn)
        self.setVScrollBarMode(QScrollView.AlwaysOff)
        self.splitter = QSplitter(Qt.Vertical, self.viewport())
        self.addChild(self.splitter, 0, 0)

        #X Axis
        self.mX = XAxis(self.mData, self.mYAxisSize, self.mProps, \
                        self.splitter, 'XAxis')
        self.splitter.setResizeMode(self.mX, \
                                    QSplitter.Stretch)

        # Price Chart
        self.mChart = PriceChart(self.mX, self.mData, \
                                 self.mYAxisSize, self.mProps,  \
                                 self.splitter, 'Main Chart')
        #self.splitter.setResizeMode(self.mChart, \
        #                            QSplitter.FollowSizeHint)

        self.splitter.moveToLast(self.mX)

        #self.mChart.AddThisIndicator('SMA')

        #for i in range(self.mMaxNumIndCharts):
        #    indchart = IndicatorChart(self.mX, self.mData, \
        #                              self.mYAxisSize, \
        #                              self.mProps, \
        #                              self.splitter, 'Indicator Chart')
        #self.splitter.setResizeMode(indchart, \
        #                            QSplitter.Stretch)
        #    indchart.hide()
        #    self.mIndCharts.append(indchart)

        self.newIndicatorChart('Volume')

        self.symbols = Avidus.ds.listSymbols()
        self.symbol_index = -1