def load_config(): global WECHAT_TOKEN config = Config() config.load_config() WECHAT_TOKEN = config.get('wechat_token') if WECHAT_TOKEN == '': print('Warning: Wechat token is empty.')
def init(self, config: Config): self.__result_url = config.get( 'analysis_result_url', 'http://sleepysoft.xyz/analysis?security=%s') self.__result_path = config.get('analysis_result_path', 'analysis_result.json') self.__name_dict_path = config.get('analysis_name_dict_path', 'analyzer_names.json') self.create_load_offline_data_task()
def load_config(config: Config): wechat_token = config.get('wechat_token', '') wechat_app_id = config.get('wechat_app_id', '') wechat_app_secret = config.get('wechat_app_secret', '') print('Load config - WeChat Token: %s' % wechat_token) print('Load config - WeChat App ID: %s' % wechat_app_id) print('Load config - WeChat App Secret: %s' % wechat_app_id) global wechat wechat.set_token(wechat_token) wechat.set_app_id(wechat_app_id) wechat.set_app_secret(wechat_app_secret)
def main(): config = Config() provider = ServiceProvider({ 'stock_analysis_system': True, # 'offline_analysis_result': True, }) init(provider, config) port = config.get('service_port', '80') debug = config.get('service_debug', 'true') print('Start service: port = %s, debug = %s.' % (port, debug)) # https://stackoverflow.com/a/9476701/12929244 app.run(host='0.0.0.0', port=str(port), debug=(debug == 'true'), use_reloader=False)
def init(config: Config): global ANALYZER_NAME_DICT global ANALYSIS_RESULT_HTML global ANALYSIS_RESULT_TABLE result_path = config.get('analysis_result_path', 'analysis_result.json') name_dict_path = config.get('analysis_name_dict_path', 'analyzer_names.json') try: print('Loading analyzer name table...') with open(name_dict_path, 'rt') as f: ANALYZER_NAME_DICT = json.load(f) print('Load analyzer name table done.') except Exception as e: print('Load analyzer name table fail.') print(e) print(traceback.format_exc()) finally: pass try: with open(result_path, 'rt') as f: print('Loading analysis result...') analysis_result = analyzer_util.analysis_results_from_json(f) print('Convert analysis result...') analysis_result_table = analyzer_util.analysis_result_list_to_security_analyzer_table( analysis_result) ANALYSIS_RESULT_TABLE = { k.split('.')[0]: v for k, v in analysis_result_table.items() } print('Load analysis result done.') except Exception as e: print('Load analysis result fail.') print(e) print(traceback.format_exc()) finally: pass
def init(self, config) -> bool: final_ret = True from StockAnalysisSystem.core.config import Config self.__config = config if config is not None else Config() if self.__service_table.get('stock_analysis_system'): ret = self.__init_sas() final_ret = ret and final_ret if self.__service_table.get('offline_analysis_result'): ret = self.__init_offline_analysis_result() final_ret = ret and final_ret return final_ret
def init(self, config: Config): result_path = config.get('analysis_result_path', 'analysis_result.json') name_dict_path = config.get('analysis_name_dict_path', 'analyzer_names.json') try: self.log('Loading analyzer name table...') with open(name_dict_path, 'rt') as f: self.__analyzer_name_dict = json.load(f) self.log('Load analyzer name table done.') except Exception as e: self.log('Load analyzer name table fail.') self.log(str(e)) self.log(str(traceback.format_exc())) finally: pass try: with open(result_path, 'rt') as f: self.log('Loading analysis result...') analysis_result = analyzer_util.analysis_results_from_json(f) self.log('Convert analysis result...') self.__analysis_result_table = analyzer_util.analysis_result_list_to_security_analyzer_table( analysis_result) self.__analysis_result_table = { k.split('.')[0]: v for k, v in self.__analysis_result_table.items() } self.log('Load analysis result done.') except Exception as e: self.log('Load analysis result fail.') self.log(str(e)) self.log(str(traceback.format_exc())) finally: pass
def init(provider: ServiceProvider, config: Config): config.load_config() provider.init(config) restIF.init(provider, config) wechatIF.init(provider, config) webapiIF.init(provider, config)
import os import pandas as pd import tushare as ts from StockAnalysisSystem.core.config import Config from StockAnalysisSystem.core.Utility.CollectorUtility import * root_path = os.path.dirname(os.path.dirname(__file__)) config = Config() config.load_config(os.path.join(root_path, 'config.json')) token = config.get('TS_TOKEN') pro = ts.pro_api(token) # result = pro.daily_basic(ts_code='', trade_date='20200805') # print(result) # result = pro.daily_basic(ts_code='600000.SH', start_date='19900101', end_date='20210720') # print(len(result)) # 4500, Reach end_date, not fits start_date # print('%s - %s' % (min(result['trade_date']), max(result['trade_date']))) # print(result) # result = pro.index_daily(ts_code='000001.SH', start_date='19000101', end_date='20150101') # print(len(result)) # 4500, Reach end_date, not fits start_date # print('%s - %s' % (min(result['trade_date']), max(result['trade_date']))) # print(result) # # Not support # result = pro.index_daily(ts_code='', trade_date='20200805') # print(result) # result = pro.trade_cal(exchange='', start_date='19900101', end_date='20210726')