Example #1
0
    def __init__(self):
        self.wsetData = [
            "000001.SH", "399300.SZ", "000016.SH", "000905.SH", "000906.SH"
        ]  # 要获取数据的证券代码
        self.indexFieldName = [
            "open", "high", "low", "close", "volume", "amt", "chg", "pct_chg",
            "turn"
        ]  # 要获取的数据字段
        self.fundFieldName = ["nav", "NAV_acc", "sec_name"]
        self.monetaryFund = [
            "mmf_annualizedyield", "mmf_unityield", "sec_name"
        ]
        self.stockFieldName = [
            "open", "high", "low", "close", "volume", "amt", "turn",
            "mkt_cap_ard", "pe_ttm", "ps_ttm", "pb_lf"
        ]
        self.engine = MysqlCon().getMysqlCon(flag='engine')
        self.conn = MysqlCon().getMysqlCon(flag='connect')
        self.GetDataToMysqlDemo = GetDataToMysql()
        self.logger = mylog.set_log()
        # w.start()

        log_state = THS_iFinDLogin('zszq5072', '754628')
        if log_state == 0:
            self.logger.info("同花顺账号登录成功!")
        else:
            self.logger.error("同花顺账号登录异常,请检查!")
            return
Example #2
0
 def __init__(self, startDate='2015-09-01',file_path=''):
     self.startDate = startDate              #历史数据开始日期
     self.endDate = (datetime.today() - timedelta(days=0)).strftime('%Y-%m-%d')
     if not file_path:
         self.PathFolder = r'C:\\Users\\zouhao\\Desktop\\资产配置研究\\'
     else:
         self.PathFolder = r'C:\\Users\\zouhao\\Desktop\\资产配置研究\\' + file_path + '\\'
     self.logger = mylog.set_log()
Example #3
0
 def __init__(self, method, param_file_name=''):
     self.logger = mylog.set_log(method)
     # self.logger = logdemo.set_logger(method+'.log')
     self.method = method
     if not param_file_name:
         self.param_file_name = self.method
     else:
         self.param_file_name = param_file_name
     self.save_dic = {}
Example #4
0
 def __init__(self, data_resource='ifind'):
     self.logger = mylog.set_log()
     self.dic_init = {}
     self.dic_init['data_resource'] = data_resource
     self.dic_init['data_init_flag'] = self.log_init(data_resource)
     mysql_con_demo = MysqlCon()
     self.engine = mysql_con_demo.getMysqlCon(flag='engine')
     self.conn = mysql_con_demo.getMysqlCon(flag='connect')
     self.GetDataToMysqlDemo = GetDataToMysql()
 def __init__(self):
     calcDate = {}
     calcDate['OneMonth'] = (u'近一月', 21)
     calcDate['ThreeMonths'] = (u'近三月', 21 * 3)
     calcDate['SixMonths'] = (u'近六月', 21 * 6)
     calcDate['OneYear'] = (u'近一年', 21 * 12)
     calcDate['TwoYear'] = (u'近两年', 21 * 12 * 2)
     calcDate['TotalPeriod'] = (u'成立以来', np.inf)
     calcDate['ThisYear'] = (u'今年以来', np.inf)
     self.calcDate = calcDate
     self.logger = mylog.set_log()
Example #6
0
    def get_industry_recyle(self):
        '''
        行业轮动、主题轮动
        :return:
        '''

        # fund_type = 'OTC'
        fund_type = 'ETF'

        # style_flag = '主题'
        # style_flag = '行业'
        style_flag = '行业主题'
        # style_flag = '策略'

        method = 'industry_recyle'
        # method ="industry_recyle_equ"
        # method = 'industry_recyle_stock'
        # method = 'industry_recyle_mean_var_stock'
        # method = 'mean_var'

        IndustryRecyleDemo = IndustryRecyle()
        industry_index_name_dic, product_name_dic = IndustryRecyleDemo.get_fund_index(
            fund_type=fund_type, style_flag=style_flag)
        portfolio_str = '%s轮动组合99%s+%s' % (style_flag, fund_type, method
                                           )  # 1到14
        if method == 'industry_recyle':
            asset_index = {
                'stock': industry_index_name_dic,
                'bond': {
                    'H00140.SH': u'上证五年期国债指数'
                }
            }
            if 'H00140.SH' not in product_name_dic:
                if fund_type == 'ETF':
                    product_name_dic['H00140.SH'] = {'511010.SH': "国债ETF "}
                else:
                    product_name_dic['H00140.SH'] = {
                        '000088.OF': "嘉实中期国债ETF联接C "
                    }
        else:
            asset_index = {
                'stock': industry_index_name_dic,
            }

        FindBestParamDemo = FindBestParam(method,
                                          param_file_name=portfolio_str)
        target = 'maxreturn'
        # self.logger = mylogdemo.set_log(portfolio_str + '行业短周期有风控')
        self.logger = mylogdemo.set_log(portfolio_str + method)
        FindBestParamDemo.try_find_param(asset_index,
                                         control_method={},
                                         product_name_dic=product_name_dic,
                                         target=target)
Example #7
0
 def __init__(self):
     self.start_date = '2020-07-01'
     self.end_date = '2020-07-31'
     self.file_path = r"D:\\工作文件\\指数基金月报\\培训PPT\\0821\\"
     MysqlConDemo = MysqlCon()
     self.engine = MysqlConDemo.getMysqlCon('engine')
     self.name_dic = {
         'fund_code': '基金代码',
         'fund_type': '基金类型',
         'product_type': '产品类型',
         'fund_name': '基金名称',
         'establish_date': '基金成立日',
         'indx_sname': '跟踪指数',
         'class_classify': '跟踪指数类型',
         'index_code': '跟踪指数代码'
     }
     self.logger = mylog.set_log()
Example #8
0
 def __init__(self):
     self.target_path = "D:\\工作文件\\主题基金\\"
     self.mysql_name_dic = {
         "证券代码": 'fund_code',
         '证券名称': "fund_name",
         "基金简称": "fund_simple_name",
         "是否指数基金": "is_index_fund",
         "基金管理人": "fund_company",
         "管理费率百分": "manage_fee",
         "托管费率百分": "tg_fee",
         "跟踪指数同花顺代码": "ths_bench_code",
         '基金成立日': "establish_date",
         "上市日期": 'etf_pub_date',
         "基金经理(现任)": 'manager_name',
         "是否分级基金": "is_graded_fund",
         "主题名称": 'topic_name'
     }
     self.logger = mylog.set_log()
Example #9
0
    def get_pre_data(self, target='maxreturn'):
        total_df = pd.read_excel("组合明细.xlsx", index_col=0)
        portfolio_str = '组合34号'
        portfolio_total_str = portfolio_str  # 1到14
        self.logger = mylogdemo.set_log(portfolio_total_str + '长周期')
        asset_index = eval(total_df.loc[portfolio_str]['模型参数'])

        control_method = {}
        # control_method = total_df.loc[portfolio_str]['风控参数']
        # if np.isnan(control_method):
        #     control_method = {}
        # else:
        #     control_method = eval(total_df.loc[portfolio_str]['风控参数'])
        # control_method = eval(total_df.loc[portfolio_str]['风控参数'])
        method = total_df.loc[portfolio_str]['配置模型']
        # method='industry_recyle'
        FindBestParamDemo = FindBestParam(method,
                                          param_file_name=portfolio_total_str)
        FindBestParamDemo.try_find_param(asset_index,
                                         control_method,
                                         target=target)
Example #10
0
 def __init__(self):
     self.logger = mylog.set_log()
     self.GetDataToMysqlDemo = GetDataToMysql()
Example #11
0
 def __init__(self):
     self.logger = mylog.set_log()
     mysql_con_demo = MysqlCon()
     self.engine = mysql_con_demo.getMysqlCon(flag='engine')
     w.start()
Example #12
0
 def __init__(self):
     self.plotFlag = False  # 是否绘图
     self.logger = mylog.set_log()
Example #13
0
 def __init__(self):
     self.logger = mylog.set_log()
     self.GetIndexAndProductDemo = GetIndexAndProduct()
Example #14
0
 def __init__(self, assetIndex={}, ):
     self.assetIndex = assetIndex  # 大类资产指数
     self.logger = mylog.set_log()
Example #15
0
 def __init__(self):
     self.logger = mylog_demo.set_log('logfile')
     self.logger.info("calc_main init finish!")
     self.get_fund_data_demo = GetFundData(self.logger)
     self.fund_poc_optimize_demo = FundPocOptimize(self.logger)
Example #16
0
 def __init__(self):
     self.logger = mylog.set_log()
 def __init__(self):
     self.logger = mylog.set_log()
     self.AssetAllocationOptimizationDemo = AssetAllocationOptimization()
 def __init__(self):
     self.logger = mylog_demo.set_log('result_analy_logfile')
     self.get_fund_data_demo = GetFundData(self.logger)
 def __init__(self):
     self.logger = mylogdemo.set_log()
     self.last_date_str = datetime.today().strftime("%Y-%m-%d")
     self.target_code = '159995.SZ'
Example #20
0
 def __init__(self):
     self.conn = MysqlCon().getMysqlCon(flag='connect')
     self.logger = mylog.set_log()