Example #1
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)