Пример #1
0
	def newSummary2(self):
		types = chart.getSummaryChartTypes(self.app.portfolio)
		revTypes = dict((v,k) for k, v in types.iteritems())
		typeName = self.chartTypesList[self.summary2.currentIndex()]
		type = revTypes[typeName]
		self.app.portfolio.setSummaryChart2(type)
Пример #2
0
 def newSummary2(self):
     types = chart.getSummaryChartTypes(self.app.portfolio)
     revTypes = dict((v, k) for k, v in types.iteritems())
     typeName = self.chartTypesList[self.summary2.currentIndex()]
     type = revTypes[typeName]
     self.app.portfolio.setSummaryChart2(type)
Пример #3
0
	def __init__(self, parent):
		QWidget.__init__(self, parent)
		self.app = appGlobal.getApp()

		portfolio = self.app.portfolio
		
		vbox = QVBoxLayout(self)
		vbox.setAlignment(Qt.AlignTop)

		frame = QFrame()
		frame.setFrameStyle(QFrame.Panel)
		frame.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
		frame.setStyleSheet("QFrame { background: white }")
		vbox.addWidget(frame)
		
		grid = QGridLayout(frame)
		
		grid.addWidget(QLabel("<b>Name</b>"), 0, 0)
		self.name = QLineEdit()
		self.name.setText(portfolio.name)
		grid.addWidget(self.name, 0, 1)
		self.connect(self.name, SIGNAL("textChanged(QString)"), self.newName)

		if portfolio.isBrokerage() or portfolio.isCombined():
			grid.addWidget(QLabel("<b>Benchmark</b>"), 1, 0)
			portfolios = self.app.prefs.getPortfolios()
			choices = []
			for name in portfolios:
				port = Portfolio(name)
				if port.isBenchmark():
					choices.append(port.name)
			self.benchmarkChoices = choices
			self.benchmark = QComboBox()
			self.benchmark.addItems(choices)
			if portfolio.getBenchmark() in choices:
				self.benchmark.setCurrentIndex(choices.index(portfolio.getBenchmark()))
			grid.addWidget(self.benchmark, 1, 1)
			self.connect(self.benchmark, SIGNAL("currentIndexChanged(int)"), self.newBenchmark)

		row = 2
		if portfolio.isBrokerage():
			brokerFrame = QFrame()
			brokerFrame.setFrameStyle(QFrame.StyledPanel)
			grid.addWidget(brokerFrame, row, 0, 1, 2)
			row += 1
			
			grid2 = QGridLayout(brokerFrame)
			grid2.addWidget(QLabel("<b>Brokerage</b>"), 0, 0)
			
			brokers = self.app.plugins.getBrokerages()
			choices = ["None"]
			text = False
			for b in brokers:
				choices.append(b.getName())
				if b.getName() == portfolio.brokerage:
					text = b.getNotes()
			self.brokerageChoices = choices
			
			self.brokerage = QComboBox()
			self.brokerage.addItems(choices)
			if portfolio.brokerage in choices:
				self.brokerage.setCurrentIndex(choices.index(portfolio.brokerage))
			grid2.addWidget(self.brokerage, 0, 1)
			self.connect(self.brokerage, SIGNAL("currentIndexChanged(int)"), self.newBrokerageInfo)
			
			grid2.addWidget(QLabel("<b>Notes</b>"), 1, 0)
			self.brokerageNotes = QLabel()
			grid2.addWidget(self.brokerageNotes, 1, 1)
				
			self.redoBrokerageNotes()
			
			grid2.addWidget(QLabel("<b>Username</b>"), 2, 0)
			self.username = QLineEdit()
			if portfolio.username:
				self.username.setText(portfolio.username)
			grid2.addWidget(self.username, 2, 1)
			self.connect(self.username, SIGNAL("textChanged(QString)"), self.newBrokerageInfo)

			grid2.addWidget(QLabel("<b>Account</b>"), 3, 0)
			self.account = QLineEdit()
			if portfolio.account:
				self.account.setText(portfolio.account)
			else:
				self.account.setText("(optional)")
			grid2.addWidget(self.account, 3, 1)
			self.connect(self.account, SIGNAL("textChanged(QString)"), self.newBrokerageInfo)
			
			buttonBox = QHBoxLayout()
			grid2.addLayout(buttonBox, 4, 0, 1, 2)
			
			testImport = QPushButton("Change Account")
			self.connect(testImport, SIGNAL("clicked()"), self.changeAccount)
			buttonBox.addWidget(testImport)

			testImport = QPushButton("Test Import")
			self.connect(testImport, SIGNAL("clicked()"), self.testImport)
			buttonBox.addWidget(testImport)
			
			buttonBox.addStretch(1)
		elif portfolio.isCombined():
			combinedFrame = QFrame()
			combinedFrame.setFrameStyle(QFrame.StyledPanel)
			grid.addWidget(combinedFrame, row, 0, 1, 2)
			row += 1

			grid2 = QGridLayout(combinedFrame)
			grid2.addWidget(QLabel("<b>Components</b>"), 0, 0)

			alreadyChecked = portfolio.portPrefs.getCombinedComponents()

			self.checks = {}
			compFrame = QFrame()
			compFrameLayout = QVBoxLayout(compFrame)
			for portName in self.app.prefs.getPortfolios():
				p = Portfolio(portName)
				if p.isBrokerage():
					check = QCheckBox(portName)
					compFrameLayout.addWidget(check)

					# See if already checked
					if portName in alreadyChecked:
						check.setChecked(True)

					self.checks[portName] = check
					self.connect(check, SIGNAL("stateChanged(int)"), self.toggleCombined)
			grid2.addWidget(compFrame, 0, 1)
		
		self.advancedOptions = QCheckBox("Show advanced options")
		self.connect(self.advancedOptions, SIGNAL("clicked()"), self.twiddleAdvanced)
		grid.addWidget(self.advancedOptions, row, 0, 1, 2)
		row += 1

		self.summaryFrame = QFrame()
		self.summaryFrame.setFrameStyle(QFrame.StyledPanel)
		grid.addWidget(self.summaryFrame, row, 0, 1, 2)
		row += 1
		
		grid3 = QGridLayout(self.summaryFrame)

		grid3.addWidget(QLabel("<b>Summary Report</b>"), 0, 0)
		choices = ["Show current year only", "Show last year", "Show all years"]
		if portfolio.getSummaryYears() == "thisYear":
			value = 0
		elif portfolio.getSummaryYears() == "lastYear":
			value = 1
		else: # allYears
			value = 2
		self.reportChoices = choices
		self.report = QComboBox()
		self.report.addItems(choices)
		self.report.setCurrentIndex(value)
		grid3.addWidget(self.report, 0, 1)
		self.connect(self.report, SIGNAL("currentIndexChanged(int)"), self.newReport)

		grid3.addWidget(QLabel("<b>Summary Chart 1</b>"), 1, 0)
		self.summary1 = QComboBox()
		self.chartTypesList = [v for k,v in chart.getSummaryChartTypes(portfolio).items()]
		try:
			index = self.chartTypesList.index(chart.getSummaryChartTypes(portfolio)[portfolio.getSummaryChart1()])
		except:
			index = 0
		self.summary1.addItems(self.chartTypesList)
		self.summary1.setCurrentIndex(index)
		self.connect(self.summary1, SIGNAL("currentIndexChanged(int)"), self.newSummary1)
		grid3.addWidget(self.summary1, 1, 1)

		grid3.addWidget(QLabel("<b>Summary Chart 2</b>"), 2, 0)
		try:
			index = self.chartTypesList.index(chart.getSummaryChartTypes(portfolio)[portfolio.getSummaryChart2()])
		except:
			index = 0
		self.summary2 = QComboBox()
		self.summary2.addItems(self.chartTypesList)
		self.summary2.setCurrentIndex(index)
		self.connect(self.summary2, SIGNAL("currentIndexChanged(int)"), self.newSummary2)
		grid3.addWidget(self.summary2, 2, 1)

		if portfolio.name != "S&P 500":
			self.hasDelete = True
			self.deleteButton = QPushButton("Delete Portfolio")
			self.deleteButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
			self.connect(self.deleteButton, SIGNAL("clicked()"), self.delete)
			grid.addWidget(self.deleteButton, row, 0, 1, 2)
			row += 1
		else:
			self.hasDelete = False
		
		self.twiddleAdvanced()

		# Set timer for tutorial
		if portfolio.name != "Sample Portfolio" and portfolio.name != "S&P 500" and portfolio.name != "Aggressive":
			self.tutorialTimer = QTimer()
			self.tutorialTimer.setInterval(500)
			self.tutorialTimer.setSingleShot(True)
			self.connect(self.tutorialTimer, SIGNAL("timeout()"), self.checkTutorial)
			self.tutorialTimer.start()
Пример #4
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.app = appGlobal.getApp()

        portfolio = self.app.portfolio

        vbox = QVBoxLayout(self)
        vbox.setAlignment(Qt.AlignTop)

        frame = QFrame()
        frame.setFrameStyle(QFrame.Panel)
        frame.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        frame.setStyleSheet("QFrame { background: white }")
        vbox.addWidget(frame)

        grid = QGridLayout(frame)

        grid.addWidget(QLabel("<b>Name</b>"), 0, 0)
        self.name = QLineEdit()
        self.name.setText(portfolio.name)
        grid.addWidget(self.name, 0, 1)
        self.connect(self.name, SIGNAL("textChanged(QString)"), self.newName)

        if portfolio.isBrokerage() or portfolio.isCombined():
            grid.addWidget(QLabel("<b>Benchmark</b>"), 1, 0)
            portfolios = self.app.prefs.getPortfolios()
            choices = []
            for name in portfolios:
                port = Portfolio(name)
                if port.isBenchmark():
                    choices.append(port.name)
            self.benchmarkChoices = choices
            self.benchmark = QComboBox()
            self.benchmark.addItems(choices)
            if portfolio.getBenchmark() in choices:
                self.benchmark.setCurrentIndex(
                    choices.index(portfolio.getBenchmark()))
            grid.addWidget(self.benchmark, 1, 1)
            self.connect(self.benchmark, SIGNAL("currentIndexChanged(int)"),
                         self.newBenchmark)

        row = 2
        if portfolio.isBrokerage():
            brokerFrame = QFrame()
            brokerFrame.setFrameStyle(QFrame.StyledPanel)
            grid.addWidget(brokerFrame, row, 0, 1, 2)
            row += 1

            grid2 = QGridLayout(brokerFrame)
            grid2.addWidget(QLabel("<b>Brokerage</b>"), 0, 0)

            brokers = self.app.plugins.getBrokerages()
            choices = ["None"]
            text = False
            for b in brokers:
                choices.append(b.getName())
                if b.getName() == portfolio.brokerage:
                    text = b.getNotes()
            self.brokerageChoices = choices

            self.brokerage = QComboBox()
            self.brokerage.addItems(choices)
            if portfolio.brokerage in choices:
                self.brokerage.setCurrentIndex(
                    choices.index(portfolio.brokerage))
            grid2.addWidget(self.brokerage, 0, 1)
            self.connect(self.brokerage, SIGNAL("currentIndexChanged(int)"),
                         self.newBrokerageInfo)

            grid2.addWidget(QLabel("<b>Notes</b>"), 1, 0)
            self.brokerageNotes = QLabel()
            grid2.addWidget(self.brokerageNotes, 1, 1)

            self.redoBrokerageNotes()

            grid2.addWidget(QLabel("<b>Username</b>"), 2, 0)
            self.username = QLineEdit()
            if portfolio.username:
                self.username.setText(portfolio.username)
            grid2.addWidget(self.username, 2, 1)
            self.connect(self.username, SIGNAL("textChanged(QString)"),
                         self.newBrokerageInfo)

            grid2.addWidget(QLabel("<b>Account</b>"), 3, 0)
            self.account = QLineEdit()
            if portfolio.account:
                self.account.setText(portfolio.account)
            else:
                self.account.setText("(optional)")
            grid2.addWidget(self.account, 3, 1)
            self.connect(self.account, SIGNAL("textChanged(QString)"),
                         self.newBrokerageInfo)

            buttonBox = QHBoxLayout()
            grid2.addLayout(buttonBox, 4, 0, 1, 2)

            testImport = QPushButton("Change Account")
            self.connect(testImport, SIGNAL("clicked()"), self.changeAccount)
            buttonBox.addWidget(testImport)

            testImport = QPushButton("Test Import")
            self.connect(testImport, SIGNAL("clicked()"), self.testImport)
            buttonBox.addWidget(testImport)

            buttonBox.addStretch(1)
        elif portfolio.isCombined():
            combinedFrame = QFrame()
            combinedFrame.setFrameStyle(QFrame.StyledPanel)
            grid.addWidget(combinedFrame, row, 0, 1, 2)
            row += 1

            grid2 = QGridLayout(combinedFrame)
            grid2.addWidget(QLabel("<b>Components</b>"), 0, 0)

            alreadyChecked = portfolio.portPrefs.getCombinedComponents()

            self.checks = {}
            compFrame = QFrame()
            compFrameLayout = QVBoxLayout(compFrame)
            for portName in self.app.prefs.getPortfolios():
                p = Portfolio(portName)
                if p.isBrokerage():
                    check = QCheckBox(portName)
                    compFrameLayout.addWidget(check)

                    # See if already checked
                    if portName in alreadyChecked:
                        check.setChecked(True)

                    self.checks[portName] = check
                    self.connect(check, SIGNAL("stateChanged(int)"),
                                 self.toggleCombined)
            grid2.addWidget(compFrame, 0, 1)

        self.advancedOptions = QCheckBox("Show advanced options")
        self.connect(self.advancedOptions, SIGNAL("clicked()"),
                     self.twiddleAdvanced)
        grid.addWidget(self.advancedOptions, row, 0, 1, 2)
        row += 1

        self.summaryFrame = QFrame()
        self.summaryFrame.setFrameStyle(QFrame.StyledPanel)
        grid.addWidget(self.summaryFrame, row, 0, 1, 2)
        row += 1

        grid3 = QGridLayout(self.summaryFrame)

        grid3.addWidget(QLabel("<b>Summary Report</b>"), 0, 0)
        choices = [
            "Show current year only", "Show last year", "Show all years"
        ]
        if portfolio.getSummaryYears() == "thisYear":
            value = 0
        elif portfolio.getSummaryYears() == "lastYear":
            value = 1
        else:  # allYears
            value = 2
        self.reportChoices = choices
        self.report = QComboBox()
        self.report.addItems(choices)
        self.report.setCurrentIndex(value)
        grid3.addWidget(self.report, 0, 1)
        self.connect(self.report, SIGNAL("currentIndexChanged(int)"),
                     self.newReport)

        grid3.addWidget(QLabel("<b>Summary Chart 1</b>"), 1, 0)
        self.summary1 = QComboBox()
        self.chartTypesList = [
            v for k, v in chart.getSummaryChartTypes(portfolio).items()
        ]
        try:
            index = self.chartTypesList.index(
                chart.getSummaryChartTypes(portfolio)[
                    portfolio.getSummaryChart1()])
        except:
            index = 0
        self.summary1.addItems(self.chartTypesList)
        self.summary1.setCurrentIndex(index)
        self.connect(self.summary1, SIGNAL("currentIndexChanged(int)"),
                     self.newSummary1)
        grid3.addWidget(self.summary1, 1, 1)

        grid3.addWidget(QLabel("<b>Summary Chart 2</b>"), 2, 0)
        try:
            index = self.chartTypesList.index(
                chart.getSummaryChartTypes(portfolio)[
                    portfolio.getSummaryChart2()])
        except:
            index = 0
        self.summary2 = QComboBox()
        self.summary2.addItems(self.chartTypesList)
        self.summary2.setCurrentIndex(index)
        self.connect(self.summary2, SIGNAL("currentIndexChanged(int)"),
                     self.newSummary2)
        grid3.addWidget(self.summary2, 2, 1)

        if portfolio.name != "S&P 500":
            self.hasDelete = True
            self.deleteButton = QPushButton("Delete Portfolio")
            self.deleteButton.setSizePolicy(
                QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
            self.connect(self.deleteButton, SIGNAL("clicked()"), self.delete)
            grid.addWidget(self.deleteButton, row, 0, 1, 2)
            row += 1
        else:
            self.hasDelete = False

        self.twiddleAdvanced()

        # Set timer for tutorial
        if portfolio.name != "Sample Portfolio" and portfolio.name != "S&P 500" and portfolio.name != "Aggressive":
            self.tutorialTimer = QTimer()
            self.tutorialTimer.setInterval(500)
            self.tutorialTimer.setSingleShot(True)
            self.connect(self.tutorialTimer, SIGNAL("timeout()"),
                         self.checkTutorial)
            self.tutorialTimer.start()