def __ui_to_config(self): sas = StockAnalysisSystem() config = sas.get_config() config.set('TS_TOKEN', self.__line_ts_token.text()) config.set('NOSQL_DB_HOST', self.__line_nosql_db_host.text()) config.set('NOSQL_DB_PORT', self.__line_nosql_db_port.text()) config.set('NOSQL_DB_USER', self.__line_nosql_db_user.text()) config.set('NOSQL_DB_PASS', self.__line_nosql_db_pass.text()) config.set('PROXY_PROTOCOL', self.__combo_web_proxy_protocol.currentText()) config.set('PROXY_HOST', self.__line_web_proxy_host.text()) config.save_config()
def __config_to_ui(self): sas = StockAnalysisSystem() config = sas.get_config() if config.load_config(): text = config.get('TS_TOKEN') self.__line_ts_token.setText(text) text = config.get('NOSQL_DB_HOST') self.__line_nosql_db_host.setText(text) self.__line_nosql_db_port.setText(config.get('NOSQL_DB_PORT')) self.__line_nosql_db_user.setText(config.get('NOSQL_DB_USER')) self.__line_nosql_db_pass.setText(config.get('NOSQL_DB_PASS')) self.__combo_web_proxy_protocol.setEditText(config.get('PROXY_PROTOCOL')) self.__combo_web_proxy_protocol.setCurrentIndex(0) self.__line_web_proxy_host.setText(config.get('PROXY_HOST'))
def __config_control(self): self.setWindowTitle('System Config') self.__button_ok.clicked.connect(self.on_button_ok) self.__button_exit.clicked.connect(self.on_button_exit) self.__button_browse.clicked.connect(self.on_button_browse) self.__button_import.clicked.connect(self.on_button_import) self.__button_export.clicked.connect(self.on_button_export) # self.__text_information.setEnabled(False) self.__text_information.setStyleSheet("QLabel{border:2px solid rgb(0, 0, 0);}") self.__text_information.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard) self.__combo_web_proxy_protocol.setEditable(True) self.__combo_web_proxy_protocol.addItem('HTTP_PROXY') self.__combo_web_proxy_protocol.addItem('HTTPS_PROXY') sas = StockAnalysisSystem() logs = sas.get_log_errors() self.__config_to_ui() self.__text_information.setText('\n'.join(logs))
def execute_update_task(self): options = AnalysisTask.OPTION_CALC if not self.__check_force_calc.isChecked(): options |= AnalysisTask.OPTION_FROM_CACHE if self.__check_auto_cache.isChecked(): options |= AnalysisTask.OPTION_UPDATE_CACHE if self.__check_from_json.isChecked(): options |= AnalysisTask.OPTION_FROM_JSON if self.__check_dump_json.isChecked(): options |= AnalysisTask.OPTION_DUMP_JSON time_serial = (to_py_datetime(self.__datetime_time_since.dateTime()), to_py_datetime(self.__datetime_time_until.dateTime())) task = AnalysisTask(self, self.__strategy_entry, self.__data_hub_entry, self.__selector_list, self.__analyzer_list, time_serial, options, self.__result_output, self.__progress_rate) StockAnalysisSystem().get_task_queue().append_task(task)
def update_special(): sas = StockAnalysisSystem() data_hub = sas.get_data_hub_entry() data_center = data_hub.get_data_center() data_utility = data_hub.get_data_utility() df1 = data_center.query_from_plugin('Finance.Audit', '000021.SZSE', force=True) df2 = data_center.query_from_plugin('Finance.BalanceSheet', '000021.SZSE', force=True) df3 = data_center.query_from_plugin('Finance.IncomeStatement', '000021.SZSE', force=True) df4 = data_center.query_from_plugin('Finance.CashFlowStatement', '000021.SZSE', force=True) print(df1) print(df2) print(df3) print(df4)
def main(): app = QApplication(sys.argv) data_hub_entry = StockAnalysisSystem().get_data_hub_entry() strategy_entry = StockAnalysisSystem().get_strategy_entry() dlg = WrapperQDialog(AnalyzerUi(data_hub_entry, strategy_entry)) dlg.exec()
def __init__(self, data_hub_entry: DataHubEntry, strategy_entry: StrategyEntry): super(AnalyzerUi, self).__init__() self.__data_hub_entry = data_hub_entry self.__strategy_entry = strategy_entry self.__analyzer_info = self.__strategy_entry.analyzer_info() # Thread and task related self.__selector_list = [] self.__analyzer_list = [] self.__result_output = StockAnalysisSystem().get_project_path() self.__timing_clock = Clock() self.__progress_rate = ProgressRate() self.task_finish_signal.connect(self.__on_task_done) # Timer for update status self.__timer = QTimer() self.__timer.setInterval(1000) self.__timer.timeout.connect(self.on_timer) self.__timer.start() # UI related group, layout = create_v_group_box('Selector') self.__group_selector = group self.__layout_selector = layout group, layout = create_v_group_box('Analyzer') self.__group_analyzer = group self.__layout_analyzer = layout group, layout = create_v_group_box('Option') self.__group_option = group self.__layout_option = layout group, layout = create_h_group_box('Result') self.__group_result = group self.__layout_result = layout self.__table_selector = TableViewEx() self.__table_analyzer = TableViewEx() # self.__radio_group_selector = QButtonGroup(self) # self.__radio_all = QRadioButton('All') # self.__radio_tags = QRadioButton('Tags') # self.__radio_manual = QRadioButton('Manual') # self.__table_preview = QTableWidget() self.__check_force_calc = QCheckBox('Force Calc') self.__check_auto_cache = QCheckBox('Cache Result') self.__check_load_json = QCheckBox('Load Json') self.__check_dump_json = QCheckBox('Dump Json') self.__check_load_dump_all = QCheckBox('Load/Dump All') self.__datetime_time_since = QDateTimeEdit(years_ago(5)) self.__datetime_time_until = QDateTimeEdit(now()) self.__edit_path = QLineEdit('analysis_report.xlsx') self.__button_browse = QPushButton('Browse') self.__button_selector = QPushButton('Selector') self.__button_analyzer = QPushButton('Analyzer') self.__button_result = QPushButton('Result') self.__button_run_strategy = QPushButton('Run Strategy') self.__check_attach_basic_index = QCheckBox('Attach Basic Index') self.init_ui() self.update_selector() self.update_analyzer()
def sas() -> StockAnalysisSystem: return StockAnalysisSystem()
def update_local(update_list: [str], force: bool = False): sas = StockAnalysisSystem() sas.check_initialize() data_hub = sas.get_data_hub_entry() data_center = data_hub.get_data_center() data_utility = data_hub.get_data_utility() if 'Market.SecuritiesInfo' in update_list: print('Updating SecuritiesInfo...') data_center.update_local_data('Market.SecuritiesInfo', force=force) if 'Market.NamingHistory' in update_list: print('Updating Naming History...') data_center.update_local_data('Market.NamingHistory', force=force) if 'Market.TradeCalender' in update_list: print('Updating TradeCalender...') data_center.update_local_data('Market.TradeCalender', exchange='SSE', force=force) stock_list = data_utility.get_stock_list() start_total = time.time() print('Updating Finance Data for All A-SHARE Stock.') counter = 0 for stock_identity, name in stock_list: start_single = time.time() print('Updating Finance Data for ' + stock_identity + ' [' + name + ']') if 'Finance.Audit' in update_list: data_center.update_local_data('Finance.Audit', stock_identity, force=force) if 'Finance.BalanceSheet' in update_list: data_center.update_local_data('Finance.BalanceSheet', stock_identity, force=force) if 'Finance.IncomeStatement' in update_list: data_center.update_local_data('Finance.IncomeStatement', stock_identity, force=force) if 'Finance.CashFlowStatement' in update_list: data_center.update_local_data('Finance.CashFlowStatement', stock_identity, force=force) if 'TradeData.Stock.Daily' in update_list: data_center.update_local_data('TradeData.Stock.Daily', stock_identity, force=force) if 'Stockholder.PledgeStatus' in update_list: data_center.update_local_data('Stockholder.PledgeStatus', stock_identity, force=force) if 'Stockholder.PledgeHistory' in update_list: data_center.update_local_data('Stockholder.PledgeHistory', stock_identity, force=force) if 'Stockholder.Statistics' in update_list: data_center.update_local_data('Stockholder.Statistics', stock_identity, force=force) counter += 1 print('Done (%s / %s). Time Spending: %s s' % (counter, len(stock_list), time.time() - start_single)) if 'Market.IndexInfo' in update_list: print('Updating IndexInfo...') data_center.update_local_data('Market.IndexInfo', force=force, dump_flag=True) index_dict = data_utility.get_support_index_identities() index_list = list(index_dict.keys()) print('Updating Index Data for All Support Market.') counter = 0 for index_identity, name in index_list: start_single = time.time() if 'TradeData.Index.Daily' in update_list: data_center.update_local_data('TradeData.Index.Daily', index_identity, force=force) counter += 1 print('Done (%s / %s). Time Spending: %s s' % (counter, len(index_list), time.time() - start_single)) print('Update Finance Data for All A-SHARE Stock Done. Time Spending: ' + str(time.time() - start_total) + 's')
def update_table(self): self.__table_main.Clear() self.__table_main.SetColumn(DataUpdateUi.TABLE_HEADER) self.__table_main.AppendRow(['', '刷新中...', '', '', '', '', '', '', '']) task = RefreshTask(self) StockAnalysisSystem().get_task_queue().append_task(task)
def main(): app = QApplication(sys.argv) data_hub = StockAnalysisSystem().get_data_hub_entry() update_table = StockAnalysisSystem().get_database_entry().get_update_table() dlg = WrapperQDialog(DataUpdateUi(data_hub, update_table)) dlg.exec()
def __json_path(analyzer: str) -> str: return os.path.join(StockAnalysisSystem().get_project_path(), 'TestData', analyzer + '.json')