def paintCompareChart(self):
        self.finObj = []
        print self.qModelIndex
        k = 0
        for x in self.listName:
            print self.qModelIndex[k]
            print x 
            if x == "index":
                index = int (self.qModelIndex[k].data(QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.INDEX_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(dataParser.INDEX_LIST[index][1],dataParser.INDEX_LIST[index][0],'index',dataParser.INDEX_LIST[index][3],self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(dataParser.INDEX_LIST[index][1],dataParser.INDEX_LIST[index][0],'index',dataParser.INDEX_LIST[index][3],self.settings["step"])
                self.finObj.append(finObj)
            if x == "stock":
                index = int (self.qModelIndex[k].data(QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.STOCK_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(dataParser.STOCK_LIST[index][1],dataParser.STOCK_LIST[index][0],'stock',dataParser.STOCK_LIST[index][3],self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(dataParser.STOCK_LIST[index][1],dataParser.STOCK_LIST[index][0],'stock',dataParser.STOCK_LIST[index][3],self.settings["step"])
                self.finObj.append(finObj)
            if x == "forex":
                index = int (self.qModelIndex[k].data(QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.FOREX_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(dataParser.FOREX_LIST[index][1],dataParser.FOREX_LIST[index][0],'forex',dataParser.FOREX_LIST[index][3],self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(dataParser.FOREX_LIST[index][1],dataParser.FOREX_LIST[index][0],'forex',dataParser.FOREX_LIST[index][3],self.settings["step"])
                self.finObj.append(finObj)
            if x == "bond":
                index = int (self.qModelIndex[k].data(QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.BOND_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(dataParser.BOND_LIST[index][1],dataParser.BOND_LIST[index][0],'bond',dataParser.BOND_LIST[index][3],self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(dataParser.BOND_LIST[index][1],dataParser.BOND_LIST[index][0],'bond',dataParser.BOND_LIST[index][3],self.settings["step"])
                self.finObj.append(finObj)
            if x == "resource":
                index = int (self.qModelIndex[k].data(QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.RESOURCE_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(dataParser.RESOURCE_LIST[index][1],dataParser.RESOURCE_LIST[index][0],'resource',dataParser.RESOURCE_LIST[index][3],self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(dataParser.RESOURCE_LIST[index][1],dataParser.RESOURCE_LIST[index][0],'resource',dataParser.RESOURCE_LIST[index][3],self.settings["step"])
                self.finObj.append(finObj)
                
            if x == "futures":
                index = int (self.qModelIndex[k].data(QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.FUTURES_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(dataParser.FUTURES_LIST[index][1],dataParser.FUTURES_LIST[index][0],'futures',dataParser.FUTURES_LIST[index][3],self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(dataParser.FUTURES_LIST[index][1],dataParser.FUTURES_LIST[index][0],'futures',dataParser.FUTURES_LIST[index][3],self.settings["step"])
                self.finObj.append(finObj)
            k=k+1
        
        self.chart = CompareChart(self)
        self.chart.setData(self.finObj,self.settings["start"],self.settings["end"],self.settings["step"])
        self.chartsLayout.addWidget(self.chart)

        #przywracamy opcje
        self.startDateEdit.setDate(QtCore.QDate(self.settings["start"].year,
                                   self.settings["start"].month,
                                   self.settings["start"].day))
        self.endDateEdit.setDate(QtCore.QDate(self.settings["end"].year,
                                 self.settings["end"].month,
                                 self.settings["end"].day))
        #step
        if self.settings["step"] == "daily":
            self.stepComboBox.setCurrentIndex(0)
        elif self.settings["step"] == "weekly":
            self.stepComboBox.setCurrentIndex(1)
        else:
            self.stepComboBox.setCurrentIndex(2)
        if self.settings["painting"]:
            self.paintCheckBox.setCheckState(2)
Beispiel #2
0
    def paintCompareChart(self):
        self.finObj = []
        print self.qModelIndex
        k = 0
        for x in self.listName:
            print self.qModelIndex[k]
            print x
            if x == "index":
                index = int(self.qModelIndex[k].data(
                    QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.INDEX_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(
                        dataParser.INDEX_LIST[index][1],
                        dataParser.INDEX_LIST[index][0], 'index',
                        dataParser.INDEX_LIST[index][3], self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(
                        dataParser.INDEX_LIST[index][1],
                        dataParser.INDEX_LIST[index][0], 'index',
                        dataParser.INDEX_LIST[index][3], self.settings["step"])
                self.finObj.append(finObj)
            if x == "stock":
                index = int(self.qModelIndex[k].data(
                    QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.STOCK_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(
                        dataParser.STOCK_LIST[index][1],
                        dataParser.STOCK_LIST[index][0], 'stock',
                        dataParser.STOCK_LIST[index][3], self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(
                        dataParser.STOCK_LIST[index][1],
                        dataParser.STOCK_LIST[index][0], 'stock',
                        dataParser.STOCK_LIST[index][3], self.settings["step"])
                self.finObj.append(finObj)
            if x == "forex":
                index = int(self.qModelIndex[k].data(
                    QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.FOREX_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(
                        dataParser.FOREX_LIST[index][1],
                        dataParser.FOREX_LIST[index][0], 'forex',
                        dataParser.FOREX_LIST[index][3], self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(
                        dataParser.FOREX_LIST[index][1],
                        dataParser.FOREX_LIST[index][0], 'forex',
                        dataParser.FOREX_LIST[index][3], self.settings["step"])
                self.finObj.append(finObj)
            if x == "bond":
                index = int(self.qModelIndex[k].data(
                    QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.BOND_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(
                        dataParser.BOND_LIST[index][1],
                        dataParser.BOND_LIST[index][0], 'bond',
                        dataParser.BOND_LIST[index][3], self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(
                        dataParser.BOND_LIST[index][1],
                        dataParser.BOND_LIST[index][0], 'bond',
                        dataParser.BOND_LIST[index][3], self.settings["step"])
                self.finObj.append(finObj)
            if x == "resource":
                index = int(self.qModelIndex[k].data(
                    QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.RESOURCE_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(
                        dataParser.RESOURCE_LIST[index][1],
                        dataParser.RESOURCE_LIST[index][0], 'resource',
                        dataParser.RESOURCE_LIST[index][3],
                        self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(
                        dataParser.RESOURCE_LIST[index][1],
                        dataParser.RESOURCE_LIST[index][0], 'resource',
                        dataParser.RESOURCE_LIST[index][3],
                        self.settings["step"])
                self.finObj.append(finObj)

            if x == "futures":
                index = int(self.qModelIndex[k].data(
                    QtCore.Qt.WhatsThisRole).toStringList()[-1])
                if dataParser.FUTURES_LIST[index][2] == 'Yahoo':
                    finObj = dataParser.createWithArchivesFromYahoo(
                        dataParser.FUTURES_LIST[index][1],
                        dataParser.FUTURES_LIST[index][0], 'futures',
                        dataParser.FUTURES_LIST[index][3],
                        self.settings["step"])
                else:
                    finObj = dataParser.createWithArchivesFromStooq(
                        dataParser.FUTURES_LIST[index][1],
                        dataParser.FUTURES_LIST[index][0], 'futures',
                        dataParser.FUTURES_LIST[index][3],
                        self.settings["step"])
                self.finObj.append(finObj)
            k = k + 1

        self.chart = CompareChart(self)
        self.chart.setData(self.finObj, self.settings["start"],
                           self.settings["end"], self.settings["step"])
        self.chartsLayout.addWidget(self.chart)

        #przywracamy opcje
        self.startDateEdit.setDate(
            QtCore.QDate(self.settings["start"].year,
                         self.settings["start"].month,
                         self.settings["start"].day))
        self.endDateEdit.setDate(
            QtCore.QDate(self.settings["end"].year, self.settings["end"].month,
                         self.settings["end"].day))
        #step
        if self.settings["step"] == "daily":
            self.stepComboBox.setCurrentIndex(0)
        elif self.settings["step"] == "weekly":
            self.stepComboBox.setCurrentIndex(1)
        else:
            self.stepComboBox.setCurrentIndex(2)
        if self.settings["painting"]:
            self.paintCheckBox.setCheckState(2)
    def paint2Chart(self):
        index = int (self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[-1])

        if self.listName == "index":
            if dataParser.INDEX_LIST[index][2] == 'Yahoo':     
                self.finObj = dataParser.createWithArchivesFromYahoo(dataParser.INDEX_LIST[index][1],dataParser.INDEX_LIST[index][0],'index',dataParser.INDEX_LIST[index][3],self.settings["step"])
	    else:
                self.finObj = dataParser.createWithArchivesFromStooq(dataParser.INDEX_LIST[index][1],dataParser.INDEX_LIST[index][0],'index',dataParser.INDEX_LIST[index][3],self.settings["step"])
            self.currentChart = self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[0]

        if self.listName == "stock":
            if dataParser.STOCK_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(dataParser.STOCK_LIST[index][1],dataParser.STOCK_LIST[index][0],'stock',dataParser.STOCK_LIST[index][3],self.settings["step"])
	    else:
		self.finObj = dataParser.createWithArchivesFromStooq(dataParser.STOCK_LIST[index][1],dataParser.STOCK_LIST[index][0],'stock',dataParser.STOCK_LIST[index][3],self.settings["step"])
            self.currentChart = self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[0]
        
        if self.listName == "forex":
            self.finObj = dataParser.createWithArchivesFromStooq(dataParser.FOREX_LIST[index][1],dataParser.FOREX_LIST[index][0],'forex',dataParser.FOREX_LIST[index][3],self.settings["step"])
            self.currentChart = self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[0]

        if self.listName == "bond":
            if dataParser.BOND_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(dataParser.BOND_LIST[index][1],dataParser.BOND_LIST[index][0],'bond',dataParser.BOND_LIST[index][3],self.settings["step"])
	    else:
		self.finObj = dataParser.createWithArchivesFromStooq(dataParser.BOND_LIST[index][1],dataParser.BOND_LIST[index][0],'bond',dataParser.BOND_LIST[index][3],self.settings["step"])
            self.currentChart = self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[0]
        if self.listName == "resource":
            if dataParser.RESOURCE_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(dataParser.RESOURCE_LIST[index][1],dataParser.RESOURCE_LIST[index][0],'resource',dataParser.RESOURCE_LIST[index][3],self.settings["step"])
	    else:
		self.finObj = dataParser.createWithArchivesFromStooq(dataParser.RESOURCE_LIST[index][1],dataParser.RESOURCE_LIST[index][0],'resource',dataParser.RESOURCE_LIST[index][3],self.settings["step"])
            self.currentChart = self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[0]
            
        if self.listName == "futures":
            if dataParser.FUTURES_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(dataParser.FUTURES_LIST[index][1],dataParser.FUTURES_LIST[index][0],'futures',dataParser.FUTURES_LIST[index][3],self.settings["step"])
	    else:
		self.finObj = dataParser.createWithArchivesFromStooq(dataParser.FUTURES_LIST[index][1],dataParser.FUTURES_LIST[index][0],'resource',dataParser.FUTURES_LIST[index][3],self.settings["step"])
            self.currentChart = self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[0]

        self.chart = Chart(self, self.finObj)        
        self.cid = self.chart.mpl_connect('button_press_event', self.showChartsWithAllIndicators)
        self.chartsLayout.addWidget(self.chart)
        self.hasChart = True
    
        self.chart.setOscPlot(self.settings["oscilator"])
        self.chart.setDrawingMode(self.settings["painting"])
        if self.settings["indicator"]:
            self.chart.setMainIndicator(self.settings["indicator"][-1])
        self.chart.setData(self.finObj,self.settings["start"],self.settings["end"],self.settings["step"])                

        self.chart.setScaleType(self.settings["scale"])
        self.chart.setMainType(self.settings["chartType"])
        
        if self.settings['drawTrend']:
            lineWidth = self.settings['lineWidth']
            self.chart.drawTrend()
        
        if self.settings["hideVolumen"]:
            self.chart.rmVolumeBars()
        self.setOptions()
Beispiel #4
0
    def paint2Chart(self):
        index = int(
            self.qModelIndex.data(QtCore.Qt.WhatsThisRole).toStringList()[-1])

        if self.listName == "index":
            if dataParser.INDEX_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(
                    dataParser.INDEX_LIST[index][1],
                    dataParser.INDEX_LIST[index][0], 'index',
                    dataParser.INDEX_LIST[index][3], self.settings["step"])
            else:
                self.finObj = dataParser.createWithArchivesFromStooq(
                    dataParser.INDEX_LIST[index][1],
                    dataParser.INDEX_LIST[index][0], 'index',
                    dataParser.INDEX_LIST[index][3], self.settings["step"])
            self.currentChart = self.qModelIndex.data(
                QtCore.Qt.WhatsThisRole).toStringList()[0]

        if self.listName == "stock":
            if dataParser.STOCK_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(
                    dataParser.STOCK_LIST[index][1],
                    dataParser.STOCK_LIST[index][0], 'stock',
                    dataParser.STOCK_LIST[index][3], self.settings["step"])
            else:
                self.finObj = dataParser.createWithArchivesFromStooq(
                    dataParser.STOCK_LIST[index][1],
                    dataParser.STOCK_LIST[index][0], 'stock',
                    dataParser.STOCK_LIST[index][3], self.settings["step"])
            self.currentChart = self.qModelIndex.data(
                QtCore.Qt.WhatsThisRole).toStringList()[0]

        if self.listName == "forex":
            self.finObj = dataParser.createWithArchivesFromStooq(
                dataParser.FOREX_LIST[index][1],
                dataParser.FOREX_LIST[index][0], 'forex',
                dataParser.FOREX_LIST[index][3], self.settings["step"])
            self.currentChart = self.qModelIndex.data(
                QtCore.Qt.WhatsThisRole).toStringList()[0]

        if self.listName == "bond":
            if dataParser.BOND_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(
                    dataParser.BOND_LIST[index][1],
                    dataParser.BOND_LIST[index][0], 'bond',
                    dataParser.BOND_LIST[index][3], self.settings["step"])
            else:
                self.finObj = dataParser.createWithArchivesFromStooq(
                    dataParser.BOND_LIST[index][1],
                    dataParser.BOND_LIST[index][0], 'bond',
                    dataParser.BOND_LIST[index][3], self.settings["step"])
            self.currentChart = self.qModelIndex.data(
                QtCore.Qt.WhatsThisRole).toStringList()[0]
        if self.listName == "resource":
            if dataParser.RESOURCE_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(
                    dataParser.RESOURCE_LIST[index][1],
                    dataParser.RESOURCE_LIST[index][0], 'resource',
                    dataParser.RESOURCE_LIST[index][3], self.settings["step"])
            else:
                self.finObj = dataParser.createWithArchivesFromStooq(
                    dataParser.RESOURCE_LIST[index][1],
                    dataParser.RESOURCE_LIST[index][0], 'resource',
                    dataParser.RESOURCE_LIST[index][3], self.settings["step"])
            self.currentChart = self.qModelIndex.data(
                QtCore.Qt.WhatsThisRole).toStringList()[0]

        if self.listName == "futures":
            if dataParser.FUTURES_LIST[index][2] == 'Yahoo':
                self.finObj = dataParser.createWithArchivesFromYahoo(
                    dataParser.FUTURES_LIST[index][1],
                    dataParser.FUTURES_LIST[index][0], 'futures',
                    dataParser.FUTURES_LIST[index][3], self.settings["step"])
            else:
                self.finObj = dataParser.createWithArchivesFromStooq(
                    dataParser.FUTURES_LIST[index][1],
                    dataParser.FUTURES_LIST[index][0], 'resource',
                    dataParser.FUTURES_LIST[index][3], self.settings["step"])
            self.currentChart = self.qModelIndex.data(
                QtCore.Qt.WhatsThisRole).toStringList()[0]

        self.chart = Chart(self, self.finObj)
        self.cid = self.chart.mpl_connect('button_press_event',
                                          self.showChartsWithAllIndicators)
        self.chartsLayout.addWidget(self.chart)
        self.hasChart = True

        self.chart.setOscPlot(self.settings["oscilator"])
        self.chart.setDrawingMode(self.settings["painting"])
        if self.settings["indicator"]:
            self.chart.setMainIndicator(self.settings["indicator"][-1])
        self.chart.setData(self.finObj, self.settings["start"],
                           self.settings["end"], self.settings["step"])

        self.chart.setScaleType(self.settings["scale"])
        self.chart.setMainType(self.settings["chartType"])

        if self.settings['drawTrend']:
            lineWidth = self.settings['lineWidth']
            self.chart.drawTrend()

        if self.settings["hideVolumen"]:
            self.chart.rmVolumeBars()
        self.setOptions()