def main(): args = getArgs() data = fetchData(args.type) dt = datetime.datetime.now().date().strftime('%Y%m%d') if not utils.is_bday(dt, 'hk'): print('hk holiday {}'.format(dt)) return df = parseData(data, args.type) data_file = data_path + '/{}/{}.txt'.format(args.type.lower(), dt) print(data_file) df.to_csv(data_file, index = False)
from functools import reduce root_path = os.path.dirname(os.path.realpath(__file__)) + '/../../' sys.path.append(root_path + 'scripts/') import utils import utils_choice from EmQuantAPI import * if len(sys.argv) < 2: print("usage: ./dump_ind_choice.py date country") quit() dt = sys.argv[1] country = sys.argv[2] data_path = root_path + 'data/industry_choice/{}/'.format(country) os.makedirs(data_path, 0o777, exist_ok = True) if not utils.is_bday(dt, country): print('{} is {} holiday'.format(dt, country)) c.stop() quit() if country == 'cn': import utils_jq stocks = utils_jq.get_universe(utils.date_str(dt)) stocks = [x.replace('XSHG', 'SH').replace('XSHE', 'SZ') for x in stocks] else: stocks = utils_choice.get_choice_universe(dt, country) res_gics = c.css(stocks, 'GICSCODE', 'ClassiFication=3,EndDate={},Ispandas=1'.format(dt)).reset_index().rename(columns = { 'GICSCODE': 'gics' }) res_list = [res_gics] if country == 'cn': res_citic1 = c.css(stocks,"CITICCODE2020", "ClassiFication=1,EndDate={},Ispandas=1".format(dt)).reset_index().rename(columns = { 'CITICCODE2020': 'citic_l1' }) res_citic2 = c.css(stocks, "CITICCODE2020", "ClassiFication=2,EndDate={},Ispandas=1".format(dt)).reset_index().rename(columns = { 'CITICCODE2020': 'citic_l2' }) res_citic3 = c.css(stocks, "CITICCODE2020", "ClassiFication=3,EndDate={},Ispandas=1".format(dt)).reset_index().rename(columns = { 'CITICCODE2020': 'citic_l3' })