# 对 total_anaing_dalao 进行筛选  获取递增的


from base_class import BaseVariableFunction
from base_class import *
baseclass = BaseVariableFunction(__file__)


baseclass.makedirpath(baseclass.new_dalao_ana_fm_path)

baseclass.open_base_library()
decimal.getcontext().prec = 100
old_print = print


def timestamped_print(*args, **kwargs):
    old_print(datetime.datetime.utcnow().replace(
        microsecond=0), *args, **kwargs)


print = timestamped_print
print('\n'*5)
print(f"{'{:<6}'.format('ENTER')} {baseclass.scriptfilename} ----------------NOTE-----------NOTE---------------")

totalana_anaing_dalao_df = pd.read_excel(
    baseclass.dalao_total_ana_fm_path/f"totalana_anaing_dalao.xlsx", dtype=object )

 
 
totalana_anaing_dalao_df = totalana_anaing_dalao_df.astype({
 
    '03d_mine_fir_earn_sum':float,
    '07d_mine_fir_earn_sum':float,
    '11d_mine_fir_earn_sum':float,
    '15d_mine_fir_earn_sum':float,

    '03d_mine_fir_earn_sum_dropmax':float,
    '07d_mine_fir_earn_sum_dropmax':float,
    '11d_mine_fir_earn_sum_dropmax':float,
    '15d_mine_fir_earn_sum_dropmax':float,

   '03d_mine_fir_earn_sum_dropfirsttimetx':float,
    '07d_mine_fir_earn_sum_dropfirsttimetx':float,
    '11d_mine_fir_earn_sum_dropfirsttimetx':float,
    '15d_mine_fir_earn_sum_dropfirsttimetx':float,
})

mine_fir_earn_sum_filter_mask = (
    (totalana_anaing_dalao_df["15d_mine_fir_earn_sum"] >=
        0.8*totalana_anaing_dalao_df["11d_mine_fir_earn_sum"])
    & (totalana_anaing_dalao_df["11d_mine_fir_earn_sum"] >= 0.8*totalana_anaing_dalao_df["07d_mine_fir_earn_sum"])
 & (totalana_anaing_dalao_df["07d_mine_fir_earn_sum"] >= 0.8*totalana_anaing_dalao_df["03d_mine_fir_earn_sum"])
)

mine_fir_earn_sum_dropmax_filter_mask = (
    (totalana_anaing_dalao_df["15d_mine_fir_earn_sum_dropmax"] >=
        0.8*totalana_anaing_dalao_df["11d_mine_fir_earn_sum_dropmax"])
    & (totalana_anaing_dalao_df["11d_mine_fir_earn_sum_dropmax"] >= 0.8*totalana_anaing_dalao_df["07d_mine_fir_earn_sum_dropmax"])
 & (totalana_anaing_dalao_df["07d_mine_fir_earn_sum_dropmax"] >= 0.8*totalana_anaing_dalao_df["03d_mine_fir_earn_sum_dropmax"])
)
mine_fir_earn_sum_dropfirsttimetx_filter_mask = (
    (totalana_anaing_dalao_df["15d_mine_fir_earn_sum_dropfirsttimetx"] >=
        0.8*totalana_anaing_dalao_df["11d_mine_fir_earn_sum_dropfirsttimetx"])
    & (totalana_anaing_dalao_df["11d_mine_fir_earn_sum_dropfirsttimetx"] >= 0.8*totalana_anaing_dalao_df["07d_mine_fir_earn_sum_dropfirsttimetx"])
 & (totalana_anaing_dalao_df["07d_mine_fir_earn_sum_dropfirsttimetx"] >= 0.8*totalana_anaing_dalao_df["03d_mine_fir_earn_sum_dropfirsttimetx"])
)
filter_mask = (
    mine_fir_earn_sum_filter_mask
    | mine_fir_earn_sum_dropmax_filter_mask
    | mine_fir_earn_sum_dropfirsttimetx_filter_mask
)
increase_totalana_anaing_dalao_df = totalana_anaing_dalao_df[   filter_mask ].reset_index(
    drop=True)
increase_totalana_anaing_dalao_df.to_excel(
    baseclass.dalao_total_ana_fm_path/f"increase_totalana_anaing_dalao.xlsx", index=False)


print(f"{'{:<6}'.format('END')} {baseclass.scriptfilename} ----------------NOTE-----------NOTE---------------")
