@ -1,6 +1,6 @@
import sys
import sys
running_which_env = ' pr d'
running_which_env = ' dev '
from os . path import dirname , abspath , join
from os . path import dirname , abspath , join
@ -69,31 +69,43 @@ def run_add_1day_code_init_minKline(date,code_list):
# del ddb2
# del ddb2
def check_if_date_codelist_exists ( date, code_list ) :
def check_if_date_codelist_exists ( typ, date, code_list ) :
code_list_filtered = code_list
code_list_filtered = code_list
ddb1 = DDBfm ( running_which_env )
ddb1 = DDBfm ( running_which_env )
code_list_filtered = ddb1 . get_missing_code_date_in_tb ( ddb1 . ddf_hft_mink_tbname , date , code_list )
if typ == ' tick ' :
tbName = ddb1 . ddf_hft_tick_tbname
elif typ == ' mink ' :
tbName = ddb1 . ddf_hft_mink_tbname
code_list_filtered = ddb1 . get_missing_code_date_in_tb ( tbName , date , code_list )
if code_list_filtered :
if code_list_filtered :
logger . info ( f " getting { ' + ' . join ( code_list_filtered ) } on { date } " )
logger . info ( f " Need to download { ' + ' . join ( code_list_filtered ) } on { dat e} in { tbNam e} " )
else :
else :
logger . info ( f " all checked in database " )
logger . info ( f " all c odes c hecked in database { tbName } on { date } " )
ddb1 . close_sess ( )
ddb1 . close_sess ( )
del ddb1
del ddb1
return code_list_filtered
return code_list_filtered
def run_pool_add_by day_code_init_tick( date_list , code_list , if_check = 1 ) :
def run_pool_add_by _datelist_codeinit( typ , date_list , code_list , if_check = 1 ) :
df_list = [ ]
df_list = [ ]
for date in date_list :
for date in date_list :
if if_check :
if if_check :
code_list_filtered = check_if_date_codelist_exists ( date, code_list )
code_list_filtered = check_if_date_codelist_exists ( typ, date, code_list )
else :
else :
code_list_filtered = code_list
code_list_filtered = code_list
with TSLfm ( ) as tsl :
with TSLfm ( ) as tsl :
if typ == ' tick ' :
df = tsl . process_result_data_type ( tsl . get_trade_tick ( date , date , code_list_filtered ) )
df = tsl . process_result_data_type ( tsl . get_trade_tick ( date , date , code_list_filtered ) )
elif typ == ' mink ' :
df = tsl . process_result_data_type ( tsl . get_mkt_min_k ( date , date , code_list_filtered ) )
if not df . empty :
if not df . empty :
df_list . append ( df )
df_list . append ( df )
if not df_list :
return 0
df_all = pd . concat ( df_list )
df_all = pd . concat ( df_list )
ddb2 = DDBfm ( running_which_env , pool = True )
ddb2 = DDBfm ( running_which_env , pool = True )
@ -186,27 +198,28 @@ def run_pool_dates_by_code_init_n_group(typ='mink',gp_amt=10,start_date='2022010
code_list = all_code_dict_by_init [ code_init ]
code_list = all_code_dict_by_init [ code_init ]
if typ == ' mink ' :
if typ == ' mink ' :
# logger.info('Running mink')
# logger.info('Running mink')
logger. error ( ' mink by day to be fixed ' )
run_pool_add_by_datelist_codeinit( ' mink ' , date_list , code_list , if_check )
# run_pool_add_byday_code_init_minKline(date_list,code_list)
# run_pool_add_byday_code_init_minKline(date_list,code_list)
elif typ == ' tick ' :
elif typ == ' tick ' :
logger . info ( ' Running tick ' )
logger . info ( ' Running tick ' )
run_pool_add_by day_code_init_tick( date_list , code_list , if_check )
run_pool_add_by _datelist_codeinit( ' tick ' , date_list , code_list , if_check )
if __name__ == ' __main__ ' :
if __name__ == ' __main__ ' :
import time
import time
# run()
run_create_hft_db ( ) # including two tables
# run_create_hft_db() # including two tables
tic = time . perf_counter ( )
tic = time . perf_counter ( )
typ = ' tick '
typ = ' mink '
st_d = ' 20220601 '
st_d = ' 20221101 '
en_d = ' 20221031 '
en_d = ' 20221102 '
if_check = 0
if_check = 1
logger . info ( f " Going to run { typ } from { st_d } to { en_d } with if_check dupliactes= { if_check } " )
logger . info ( f " Going to run { typ } from { st_d } to { en_d } with if_check dupliactes= { if_check } in { running_which_env } , plz check if this info is correct. \n \n \n \n " )
run_pool_dates_by_code_init_n_group ( typ = typ , gp_amt = 3 , start_date = st_d , end_date = en_d , if_check = if_check )
run_pool_dates_by_code_init_n_group ( typ = typ , gp_amt = 3 , start_date = st_d , end_date = en_d , if_check = if_check )
# run_pool_dates_by_code_init_n_group(typ='mink',group_amount=5)
# run_pool_dates_by_code_init_n_group(typ='mink',group_amount=5)