示例#1
0
    def DoAddButton(self):
        self.parent().ui.AddButton.setEnabled(False)
        Symbol = self.parent().ui.Stockline.text()
        NowGroup = self.parent().ui.StockGroupsComboBox.currentText()

        if Symbol in gv.StockGroups[NowGroup]:
            msg = AddStockAlreadySymbolMessage
            msg[Str_setText] = msg[Str_setText].format(NowGroup, Symbol)
            ShowInfoDialog(msg)
            self.parent().ui.AddButton.setEnabled(True)
            return False

        if DownloadStockDataFromAlphaVantage(Symbol,
                                             gv.StockDataPoolPath) is False:
            msg = AddStockDownloadFailMessage
            msg[Str_setText] = msg[Str_setText].format(Symbol)
            ShowInfoDialog(msg)
            self.parent().ui.AddButton.setEnabled(True)
            return False

        gv.AddStockInGroup(self.parent().ui.StockGroupsComboBox.currentText(),
                           Symbol)
        self.RefreshOverviewStock()
        self.parent().ui.AddButton.setEnabled(True)
        return True
示例#2
0
    def RefreshTechIndicatorsList(self):
        if self.parent().ui.ChartGroupsComboBox.count() == 0:
            return False

        if self.parent().ui.ChartGroupsComboBox.currentText() == 'New Group':
            response = QInputDialog().getText(None, "Create Group",
                                              "Please Input New Group Name:")

            self.parent().ui.ChartGroupsComboBox.setCurrentIndex(0)
            if response[1] == True and response[0] != '':
                gv.AddTechIndicatorGroup(response[0])
                self.SetChartGroupsComboBoxItem()
                self.parent().ui.ChartGroupsComboBox.setCurrentIndex(
                    self.parent().ui.ChartGroupsComboBox.count() - 2)
            return True

        self.parent().ui.TechIndicatorsListWidget.clear()
        SelectGroupName = self.parent().ui.ChartGroupsComboBox.currentText()
        TechIndicators = gv.TechIndicatorGroups[SelectGroupName]

        # print(TechIndicators)

        for TechIndicator in TechIndicators:
            IndicatorContent = self.FormatIndicatorParamString(
                TechIndicator.copy())
            item = QListWidgetItem(IndicatorContent)
            item.setIcon(QIcon(gv.ImgTsubasaPath))
            self.parent().ui.TechIndicatorsListWidget.addItem(item)
示例#3
0
def test_Common():
    gv.Init()
    assert_that(gv.StockDataPoolPath).is_not_empty()
    assert_that(
        DownloadStockDataListFromAlphaVantage('T',
                                              gv.StockDataPoolPath)).is_true()
    return True
示例#4
0
 def DelIndicatorInGroup(self):
     SelectGroupName = self.parent().ui.ChartGroupsComboBox.currentText()
     TechIndicators = gv.TechIndicatorGroups[SelectGroupName]
     current_ListWidget_index = self.parent().ui.TechIndicatorsListWidget.currentRow()
     if current_ListWidget_index >= 0:
         del TechIndicators[current_ListWidget_index]
         self.parent().ui.TechIndicatorsListWidget.takeItem(current_ListWidget_index)
         gv.ResetTechIndicatorInGroup(SelectGroupName, TechIndicators)
示例#5
0
    def RefreshOverviewStock(self):
        if self.parent().ui.StockGroupsComboBox.count() == 0:
            return False

        if self.parent().ui.StockGroupsComboBox.currentText() == 'New Group':
            response = QInputDialog().getText(
                None, "Create Group",
                "Please Input New OverviewStock Group Name:")

            self.parent().ui.StockGroupsComboBox.setCurrentIndex(0)
            if response[1] == True and response[0] != '':
                gv.AddStockGroup(response[0])
                self.SetStockGroupsComboBoxItem()
                self.parent().ui.StockGroupsComboBox.setCurrentIndex(
                    self.parent().ui.StockGroupsComboBox.count() - 2)

            return True

        ClearAllWidgetInLayout(self.OverviewStocklayout)
        SelectGroupName = self.parent().ui.StockGroupsComboBox.currentText()
        Stocks = gv.StockGroups[SelectGroupName]

        ChooseDateTime = self.parent().ui.DisplayDate.date()
        if self.parent().ui.DisplayDate.date() > QDate.currentDate():
            ChooseDateTime = QDate.currentDate()
        else:
            ChooseDateTime = self.parent().ui.DisplayDate.date()

        OverviewStocks = ReadOverviewStockData(Stocks,
                                               QDate.toPyDate(ChooseDateTime),
                                               gv.StockDataPoolPath)
        if OverviewStocks is False:
            return False

        FormatOverviewStockData(OverviewStocks)
        objectID = 1
        for stock in OverviewStocks:
            stockInfo = OverviewStockInfoWidget(self.parent().ui, stock,
                                                OverviewStocks[stock])
            stockInfo.setGeometry(
                QRect(0, 0, stockInfo.widget_width, stockInfo.widget_height))
            stockInfo.setMinimumSize(stockInfo.widget_width,
                                     stockInfo.widget_height)

            stockInfo.setObjectName(stock)

            self.OverviewStocklayout.addWidget(stockInfo)
            self.OverviewStocklayout.setSpacing(1)
            objectID += 1

        self.OverviewStocklayout.setSpacing(5)
        self.OverviewStocklayout.setContentsMargins(10, 10, 0, 10)
示例#6
0
    def DoDelButton(self):
        if self.parent().ui.StockGroupsComboBox.count() <= 1:
            return False

        NowGroup = self.parent().ui.StockGroupsComboBox.currentText()
        Stocks = gv.StockGroups[NowGroup]

        StockCheckBoxObjectNames = []
        for stock in Stocks:
            StockCheckBoxObjectNames.append(stock)

        for i in reversed(range(self.OverviewStocklayout.count())):
            widgetToRemove = self.OverviewStocklayout.itemAt(i).widget()
            if widgetToRemove.objectName() in StockCheckBoxObjectNames:
                if widgetToRemove.GetStockCheckBox().isChecked() is True:
                    Stocks.remove(widgetToRemove.objectName())
                    self.OverviewStocklayout.removeWidget(widgetToRemove)
                    widgetToRemove.setParent(None)

        if (len(Stocks) == len(StockCheckBoxObjectNames)):
            msg = DeleteGroupWarningMessage
            msg[Str_setText] = msg[Str_setText].format(NowGroup)
            msg[Str_setDetailedText] = msg[Str_setDetailedText].format(Stocks)
            if ShowWarningDialog(msg) == 'OK':
                select_index = self.parent(
                ).ui.StockGroupsComboBox.currentIndex()
                gv.DeleteStockGroup(
                    self.parent().ui.StockGroupsComboBox.currentText())
                self.parent().ui.StockGroupsComboBox.setCurrentIndex(0)
                self.parent().ui.StockGroupsComboBox.removeItem(select_index)

            self.RefreshOverviewStock()
            return True

        gv.ResetStockInGroup(
            self.parent().ui.StockGroupsComboBox.currentText(), Stocks)
        self.RefreshOverviewStock()
        return True
示例#7
0
    def DoDelButton(self):
        if self.parent().ui.ChartGroupsComboBox.count() <= 1:
            return False

        NowGroup = self.parent().ui.ChartGroupsComboBox.currentText()

        msg = DeleteGroupWarningMessage
        msg[Str_setText] = msg[Str_setText].format(NowGroup)
        msg[Str_setDetailedText] = 'None'
        if ShowWarningDialog(msg) == 'OK':
            select_index = self.parent().ui.ChartGroupsComboBox.currentIndex()
            gv.DeleteTechIndicatorGroup(NowGroup)
            self.parent().ui.ChartGroupsComboBox.setCurrentIndex(0)
            self.parent().ui.ChartGroupsComboBox.removeItem(select_index)

        self.RefreshTechIndicatorsList()
        return True
示例#8
0
    def setupUIEvent(self):
        gv.ReadStockGroups()

        self.OverviewStocklayout = QVBoxLayout()
        self.parent().ui.DisplayDate.setCalendarPopup(True)
        self.parent().ui.DisplayDate.setDate(QDate.currentDate())
        self.parent().ui.DisplayDate.dateChanged.connect(
            self.RefreshOverviewStock)
        self.parent().ui.UpdateButton.clicked.connect(self.DoUpdateButton)
        self.parent().ui.AddButton.clicked.connect(self.DoAddButton)
        self.parent().ui.StockGroupsComboBox.currentIndexChanged.connect(
            self.RefreshOverviewStock)
        self.parent().ui.DelButton.clicked.connect(self.DoDelButton)
        self.parent().ui.GraphSampleButton.setVisible(False)
        self.parent().ui.StockCheckBox.setVisible(False)
        self.parent().ui.scrollAreaWidgetContents.setLayout(
            self.OverviewStocklayout)
        self.SetGraphTypeComboBoxItem()

        self.SetStockGroupsComboBoxItem()
        self.RefreshOverviewStock()
示例#9
0
    def setupUIEvent(self):
        gv.ReadTechIndicatorGroups()

        self.TechIndicatorslayout = QVBoxLayout()

        self.parent().ui.ChartStartDate.setCalendarPopup(True)
        self.parent().ui.ChartStartDate.setDate(
            self.SetBackQDate(QDate.currentDate(), months=6))
        self.parent().ui.ChartEndDate.setCalendarPopup(True)
        self.parent().ui.ChartEndDate.setDate(QDate.currentDate())
        self.parent().ui.DelChartGroupButton.clicked.connect(self.DoDelButton)
        self.parent().ui.ShowButton.clicked.connect(self.DoShowButton)

        self.parent().ui.scrollAreaWidgetContents_2.setLayout(
            self.TechIndicatorslayout)
        TechIndicatorsWidget_width = self.parent(
        ).ui.scrollAreaWidgetContents_2.width() - 40
        for key, value in TechIndicatorWidgetParam.items():
            Indicator = TechIndicatorWidget(self, key, value,
                                            TechIndicatorsWidget_width)
            Indicator.setGeometry(
                QRect(0, 0, Indicator.widget_width, Indicator.widget_height))
            Indicator.setMinimumSize(Indicator.widget_width,
                                     Indicator.widget_height)
            Indicator.setObjectName(key)
            Indicator.TechIndicatorSignal.connect(self.AddIndicatorToGroup)

            self.TechIndicatorslayout.addWidget(Indicator)
            self.TechIndicatorslayout.setSpacing(1)

        self.TechIndicatorslayout.setSpacing(5)
        self.TechIndicatorslayout.setContentsMargins(10, 10, 0, 10)

        self.SetStockGroupsComboBoxItem()
        self.SetChartGroupsComboBoxItem()
        self.SetGraphTypeComboBoxItem()

        self.RefreshStockInGroup()
        self.RefreshTechIndicatorsList()
示例#10
0
# coding=UTF-8

import os
import sys

import Program.GlobalVar as gv
from AxisForm.AxisTradeCultForm import AxisTradeCultForm
from PyQt5.QtWidgets import QMainWindow, QApplication

from AxisPrediction.PredSoarCrash import *

if __name__ == "__main__":
    gv.Init()
    app = QApplication(sys.argv)
    window = AxisTradeCultForm()
    window.show()
    sys.exit(app.exec_())
示例#11
0
 def AddIndicatorToGroup(self, TechIndicatorParam):
     print(TechIndicatorParam)
     NowGroup = self.parent().ui.ChartGroupsComboBox.currentText()
     gv.AddTechIndicatorInGroup(NowGroup, TechIndicatorParam)
     self.RefreshTechIndicatorsList()