Esempio n. 1
0
    def __init__(self, parentWidget=None):
        super().__init__(parentWidget)
        self.ui = UiTargetClass()
        self.ui.setupUi(self)

        self.recentOutput = None

        toDate = datetime.date.today() - datetime.timedelta(days=1)
        self.ui.fromDE.setDate(toDate)
        self.ui.toDE.setDate(toDate)

        #         toDate   = datetime.date.today() - datetime.timedelta( days=1 )
        #         fromDate = toDate - datetime.timedelta( days=7 )
        #
        #         self.ui.fromDE.setDate( fromDate )
        #         self.ui.toDE.setDate( toDate )

        self.ui.openPB.setEnabled(False)

        analysis = StockAnalysis()
        self.ui.sourceLabel.setTextInteractionFlags(Qt.TextBrowserInteraction)
        self.ui.sourceLabel.setOpenExternalLinks(True)
        set_label_url(self.ui.sourceLabel, analysis.sourceLink())

        self.ui.calculatePB.clicked.connect(self.calculate)
        self.ui.openPB.clicked.connect(self.openResults)

        self.ui.limitResultsCB.currentIndexChanged.connect(
            self.ui.dataTable.limitResults)

        self.ui.todayDataRB.click()
        self.ui.currentRefRB.click()
Esempio n. 2
0
    def _updateView(self):
        rangeText = self.ui.rangeCB.currentText()
        _LOGGER.debug("updating chart, range[%s]", rangeText)

        self.clearData()

        sourceLink = self.getDataSourceLink()
        if sourceLink is not None:
            self.ui.sourceTextLabel.show()
            self.ui.sourceLabel.show()
            set_label_url(self.ui.sourceLabel, sourceLink)
        else:
            self.ui.sourceTextLabel.hide()
            self.ui.sourceLabel.hide()

        self.ui.refreshPB.setEnabled(True)
        dataFrame = self._getDataFrame()
        if dataFrame is None:
            _LOGGER.warning("no data received")
            return

        timeColumn = dataFrame["t"]
        priceColumn = dataFrame["c"]

        timeData = list(timeColumn)
        if len(timeData) < 1:
            _LOGGER.warning("no data received")
            return

        self.ui.dataChart.addPriceLine(timeData, priceColumn)

        set_ref_format_coord(self.ui.dataChart.pricePlot)
        _LOGGER.debug("updating chart data done, range[%s]", rangeText)
Esempio n. 3
0
    def connectData(self, dataObject: DataObject):
        self.dataObject = dataObject
        self.dataAccess = self.dataObject.gpwIndicatorsData

        set_label_url( self.sourceLabel, self.dataAccess.sourceLink() )

        colorDecorator = IndicatorsColorDelegate( self )
        self.dataTable.setColorDelegate( colorDecorator )

        self.dataTable.connectData( self.dataObject )
Esempio n. 4
0
    def connectData(self, dataObject):
        self.dataObject = dataObject
        self.dataAccess = self.dataObject.gpwPubReportsData

        set_label_url(self.sourceLabel, self.dataAccess.sourceLink())

        colorDecorator = ReportsColorDelegate(self.dataAccess, self.dataObject)
        self.dataTable.setColorDelegate(colorDecorator)

        self.dataTable.connectData(self.dataObject)
Esempio n. 5
0
    def _updateView(self):
        self.ui.refreshPB.setEnabled(True)

        rangeText = self.ui.rangeCB.currentText()
        _LOGGER.debug("updating chart data, range[%s]", rangeText)

        intraSource = self.getIntradayDataSource()
        dataFrame = intraSource.getWorksheetData()

        self.clearData()
        if dataFrame is None:
            return

        currentSource: GpwCurrentIndexesData = self.getCurrentDataSource()
        currentSource.getWorksheetData()

        #         print( "got intraday data:", dataFrame )
        timeColumn = dataFrame["t"]
        priceColumn = dataFrame["c"]

        value = currentSource.getRecentValueByIsin(self.isin)
        change = currentSource.getRecentChangeByIsin(self.isin)
        timestamp = timeColumn.iloc[-1]

        timeData = list(timeColumn)
        self.ui.dataChart.addPriceLine(timeData, priceColumn)

        #         refPrice = priceColumn[ 0 ]
        refPrice = self.getReferenceValue()
        self.ui.dataChart.addPriceSecondaryY(refPrice)

        refX = [timeData[0], timeData[-1]]
        refY = [refPrice, refPrice]
        self.ui.dataChart.addPriceLine(refX, refY, style="--")

        currTime = datetime.datetime.now() - datetime.timedelta(minutes=15)
        if timeData[0] < currTime < timeData[-1]:
            self.ui.dataChart.pricePlot.axvline(x=currTime,
                                                color="black",
                                                linestyle="--")

        set_ref_format_coord(self.ui.dataChart.pricePlot, refPrice)

        self.ui.valueLabel.setText(str(value))
        self.ui.changeLabel.setText(str(change) + "%")
        self.ui.timeLabel.setText(str(timestamp))

        set_label_url(self.ui.sourceLabel, intraSource.sourceLink())
Esempio n. 6
0
    def connectData(self, dataObject: DataObject):
        self.dataObject = dataObject
        self.currentData = self.dataObject.gpwCurrentShortSellingsData
        self.historyData = self.dataObject.gpwHistoryShortSellingsData

        colorDecorator = ShortSellingsColorDelegate(self.currentData,
                                                    self.dataObject)
        self.currentShortsTable.setColorDelegate(colorDecorator)
        self.currentShortsTable.connectData(self.dataObject)

        colorDecorator = ShortSellingsColorDelegate(self.historyData,
                                                    self.dataObject)
        self.historyShortsTable.setColorDelegate(colorDecorator)
        self.historyShortsTable.connectData(self.dataObject)

        set_label_url(self.sourceLabel, self.currentData.sourceLink())
Esempio n. 7
0
    def __init__(self, parentWidget=None):
        super().__init__(parentWidget)
        self.ui = UiTargetClass()
        self.ui.setupUi(self)

        self.recentOutput = None

        self.ui.openPB.setEnabled(False)

        for value in DaysDataType:
            self.ui.fieldCB.addItem(value.name, value)

        analysis = StockAnalysis()
        self.ui.sourceLabel.setTextInteractionFlags(Qt.TextBrowserInteraction)
        self.ui.sourceLabel.setOpenExternalLinks(True)
        set_label_url(self.ui.sourceLabel, analysis.sourceLink())

        self.ui.calculatePB.clicked.connect(self.calculate)
        self.ui.openPB.clicked.connect(self.openResults)

        self.ui.limitResultsCB.currentIndexChanged.connect(
            self.ui.dataTable.limitResults)
Esempio n. 8
0
    def __init__(self):
        super().__init__()
        self.ui = UiTargetClass()
        self.ui.setupUi(self)

        self.data = DataObject(self)
        self.appSettings = AppSettings()

        self.ui.actionRefresh_All.triggered.connect(self.refreshStockDataForce)

        self.ui.walletValueLabel.setStyleSheet("font-weight: bold")
        self.ui.walletProfitLabel.setStyleSheet("font-weight: bold")
        self.ui.changeToRefLabel.setStyleSheet("font-weight: bold")
        self.ui.gainLabel.setStyleSheet("font-weight: bold")
        self.ui.overallProfitLabel.setStyleSheet("font-weight: bold")

        self.tickTimer = QtCore.QTimer(self)
        ## if function takes longer than timer timeout, then next timeout is emmited immediately
        self.tickTimer.timeout.connect(self.updateTrayIndicator)
        #         self.tickTimer.start( 60 * 1000 )                           ## every minute

        ## =============================================================

        undoStack = self.data.undoStack

        undoAction = undoStack.createUndoAction(self, "&Undo")
        undoAction.setShortcuts(QtGui.QKeySequence.Undo)
        redoAction = undoStack.createRedoAction(self, "&Redo")
        redoAction.setShortcuts(QtGui.QKeySequence.Redo)

        self.ui.menuEdit.insertAction(self.ui.actionUndo, undoAction)
        self.ui.menuEdit.removeAction(self.ui.actionUndo)
        self.ui.menuEdit.insertAction(self.ui.actionRedo, redoAction)
        self.ui.menuEdit.removeAction(self.ui.actionRedo)

        self.ui.actionOverall_profit_chart.triggered.connect(
            self.ui.walletwidget.openWalletProfitChart)
        self.ui.actionGain_chart.triggered.connect(
            self.ui.walletwidget.openWalletGainChart)
        self.ui.actionImport_mb_transactions.triggered.connect(
            self.ui.walletwidget.importMBTransactions)

        self.ui.actionMatch_oldest.triggered.connect(
            self.data.matchTransactionsOldest)
        self.ui.actionMatch_best.triggered.connect(
            self.data.matchTransactionsBest)
        self.ui.actionMatch_recent.triggered.connect(
            self.data.matchTransactionsRecent)

        matchTransactionGroup = QtWidgets.QActionGroup(self)
        matchTransactionGroup.addAction(self.ui.actionMatch_oldest)
        matchTransactionGroup.addAction(self.ui.actionMatch_best)
        matchTransactionGroup.addAction(self.ui.actionMatch_recent)
        self.ui.actionMatch_best.setChecked(True)

        self.ui.actionSave_data.triggered.connect(self.saveData)
        self.ui.actionLogs.triggered.connect(self.openLogsWindow)
        self.ui.actionOptions.triggered.connect(self.openSettingsDialog)

        ## =============================================================

        self.trayIcon = trayicon.TrayIcon(self)
        self._setIconTheme(trayicon.TrayIconTheme.WHITE)

        self.ui.activitywidget.connectData(self.data)
        self.ui.volumenwidget.connectData(self.data)
        self.ui.daywidget.connectData(self.data)

        self.ui.espiList.connectData(self.data)

        self.ui.gpwIndexesTable.connectData(self.data)

        self.ui.stockFullTable.connectData(self.data)
        self.ui.walletwidget.connectData(self.data)
        self.ui.transactionswidget.connectData(self.data)
        self.ui.favsWidget.connectData(self.data)
        self.ui.markersWidget.connectData(self.data)

        self.ui.indicatorswidget.connectData(self.data)
        self.ui.reportswidget.connectData(self.data)
        self.ui.recentrepswidget.connectData(self.data)
        self.ui.dividendswidget.connectData(self.data)
        self.ui.shortswidget.connectData(self.data)

        self.ui.gpwIndexesSourceLabel.setOpenExternalLinks(True)
        indexesDataAccess = self.data.gpwIndexesData
        set_label_url(self.ui.gpwIndexesSourceLabel,
                      indexesDataAccess.sourceLink())

        self.ui.globalIndexesSourceLabel.setOpenExternalLinks(True)
        indexesDataAccess = self.data.globalIndexesData
        set_label_url(self.ui.globalIndexesSourceLabel,
                      indexesDataAccess.sourceLink())

        self.ui.espiSourceLabel.setOpenExternalLinks(True)
        set_label_url(self.ui.espiSourceLabel,
                      self.data.gpwESPIData.sourceLink())

        self.ui.stockSourceLabel.setOpenExternalLinks(True)
        set_label_url(self.ui.stockSourceLabel,
                      self.data.gpwCurrentSource.stockData.sourceLink())

        ## ================== connecting signals ==================

        self.data.favsChanged.connect(self.triggerSaveTimer)
        self.data.markersChanged.connect(self.triggerSaveTimer)
        self.data.stockDataChanged.connect(self._updateStockViews)
        self.data.stockDataChanged.connect(self._updateWalletSummary)
        self.data.walletDataChanged.connect(self._updateWalletSummary)
        self.data.stockHeadersChanged.connect(self._handleStockHeadersChange)

        self.ui.favsWidget.addFavGrp.connect(self.data.addFavGroup)
        self.ui.favsWidget.renameFavGrp.connect(self.data.renameFavGroup)
        self.ui.favsWidget.removeFavGrp.connect(self.data.deleteFavGroup)

        self.ui.refreshStockPB.clicked.connect(self.refreshStockDataForce)
        self.ui.refreshAllPB.clicked.connect(self.refreshAllDataForce)

        self.ui.notesWidget.dataChanged.connect(self.triggerSaveTimer)

        #qApp.saveStateRequest.connect( self.saveSession )
        #qApp.aboutToQuit.connect( self.saveOnQuit )

        #         self.applySettings()
        self.trayIcon.show()

        self.setWindowTitle()

        self.setStatusMessage("Ready", timeout=10000)
Esempio n. 9
0
    def _updateView(self):
        self.ui.refreshPB.setEnabled(True)

        rangeText = self.ui.rangeCB.currentText()
        isin = self.dataObject.getStockIsinFromTicker(self.ticker)
        _LOGGER.debug("updating chart data, range[%s] isin[%s]", rangeText,
                      isin)

        intraSource = self.getIntradayDataSource()
        dataFrame = intraSource.getWorksheetData()

        self.clearData()
        if dataFrame is None:
            return

        currentSource: GpwCurrentStockData = self.getCurrentDataSource()
        currentSource.getWorksheetData()

        timeColumn = dataFrame["t"]
        priceColumn = dataFrame["c"]
        volumeColumn = dataFrame["v"]
        #         print( "got intraday data:", priceColumn )

        price = currentSource.getRecentValueByTicker(self.ticker)
        change = currentSource.getRecentChangeByTicker(self.ticker)
        volumen = volumeColumn.iloc[-1]
        refPrice = currentSource.getReferenceValueByTicker(self.ticker)
        timestamp = timeColumn.iloc[-1]

        timeData = list(timeColumn)
        self.ui.dataChart.addPriceLine(timeData, priceColumn)

        self.ui.dataChart.addPriceSecondaryY(refPrice)

        refX = [timeData[0], timeData[-1]]
        refY = [refPrice, refPrice]
        self.ui.dataChart.addPriceLine(refX, refY, style="--")

        transMode = self.dataObject.transactionsMatchMode()

        walletStock: TransHistory = self.dataObject.wallet[self.ticker]
        if walletStock is not None:
            if self.ui.showWalletCB.isChecked():
                amount, buy_unit_price = walletStock.currentTransactionsAvg(
                    transMode)
                if amount > 0:
                    refY = [buy_unit_price, buy_unit_price]
                    self.ui.dataChart.addPriceLine(refX,
                                                   refY,
                                                   color='black',
                                                   style="--")

            if self.ui.showTransactionsLevelsCB.isChecked():
                currTransactions = walletStock.currentTransactions(transMode)
                for item in currTransactions:
                    buy_unit_price = item[1]
                    refY = [buy_unit_price, buy_unit_price]
                    self.ui.dataChart.addPriceLine(refX,
                                                   refY,
                                                   color='blue',
                                                   style="--")

            if self.ui.showTransactionsPointsCB.isChecked():
                allTransactions = walletStock.allTransactions()
                for item in allTransactions:
                    trans_time = item[2]
                    if trans_time < timeData[0]:
                        continue
                    amount = item[0]
                    buy_unit_price = item[1]
                    if amount > 0:
                        self.ui.dataChart.addPricePoint(trans_time,
                                                        buy_unit_price,
                                                        color='blue',
                                                        annotation="+")
                    else:
                        self.ui.dataChart.addPricePoint(trans_time,
                                                        buy_unit_price,
                                                        color='blue',
                                                        annotation="-")

        self.ui.dataChart.addVolumeLine(timeData, volumeColumn)

        recentPrice = priceColumn.iloc[-1]
        self.ui.dataChart.addVolumeSecondaryY(recentPrice)

        set_ref_format_coord(self.ui.dataChart.pricePlot, refPrice)
        set_int_format_coord(self.ui.dataChart.volumePlot)

        self.ui.valueLabel.setText(str(price))
        self.ui.changeLabel.setText(str(change) + "%")
        self.ui.volumeLabel.setText(str(volumen))
        self.ui.timeLabel.setText(str(timestamp))

        set_label_url(self.ui.sourceLabel, intraSource.sourceLink())