


# https://dexscreener.com/?rankBy=volume&order=desc&chainIds=solana&maxAge=24&min24HTxns=500&min24HSells=200&min24HChg=100

# 将油猴脚本获取的top trader
from base_class import BaseVariableFunction
from base_class import *
baseclass = BaseVariableFunction(__file__)

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---------------")

def makescreenurl( urlname,urlparam):
    _url = urlname + urlparam
    return '=HYPERLINK("{}","{}")'.format(_url, _url)


buytoken_df_file_list = [f for f in os.listdir(
    baseclass.dalao_merge_path) if f.startswith("buytoken_df_") ]
arr_token_address = [tokenadd.split("_")[-1].replace(".xlsx","") for tokenadd in buytoken_df_file_list   ]
arr_token_address=list(set(arr_token_address))
print(arr_token_address)
df = None
for tokenadd in arr_token_address:
    cur_buytoken_df = pd.read_excel(baseclass.dalao_merge_path /
                    f"buytoken_df_{tokenadd}.xlsx", dtype=object)
    cur_buytoken_df["TokenAddress"] = tokenadd
    df = pd.concat([df,cur_buytoken_df])


 


df["DexScreenURL"] = df.apply(lambda ser: makescreenurl(
    "https://dexscreener.com/solana/" , f"{ser['TokenAddress'] }?maker={ser['Maker']}" ), axis=1)
 
 
df = df.astype({
    "MinBuyPrice":float,
    "Amountper":float,
    "Earnper":float,
    "Buycount":int,

})


df = df[df["Buycount"]<=3]
# df = df[df["Amountper"]<=1]
df = df [df["Buymoney"] >= 0.3]
df = df[df["Amountper"]<=1]

df = df[ 
 ~(  ( df["Earnper"]<=0.3 )
    & (df["Amountper"]>=0.7) 
     & (df["Amountper"] <=1) 
     
    )
   
    ]


 
df = df.reset_index(drop=True)
 
df=df.sort_values(by=["Maker"],ascending=[True])
cur_datetime = int(time.time())
df.to_excel(baseclass.dalao_merge_path /f"{cur_datetime}_onetoken_profit_dalao.xlsx",index=False)


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