Signed-off-by: Arthurim <arthurbdauphine@gmail.com> Signed-off-by: Arthurim <arthurbdauphine@gmail.com>
This commit is contained in:
parent
221b5aa6b4
commit
bb6d267460
@ -63,11 +63,14 @@ def get_usd_profit(profit, chain, save_to_csv=False):
|
||||
'profit_usd' ]
|
||||
"""
|
||||
tokens = profit[CG_ID_RECEIVED_KEY].unique()
|
||||
addresses = profit[TOKEN_RECEIVED_KEY].unique()
|
||||
mapping = get_address_to_coingecko_ids_mapping(chain)
|
||||
profit_with_price_tokens = pd.DataFrame()
|
||||
failures = {}
|
||||
for token in tokens:
|
||||
print("Processing", token)
|
||||
for i in range(len(tokens)):
|
||||
token = tokens[i]
|
||||
token_address = addresses[i]
|
||||
print(f"Processing {token} ({token_address})")
|
||||
try:
|
||||
|
||||
profit_by_received_token = pd.DataFrame(
|
||||
@ -196,9 +199,9 @@ def get_usd_profit(profit, chain, save_to_csv=False):
|
||||
)
|
||||
except Exception as e:
|
||||
# @TODO: save into list to add later
|
||||
print(" Failed for token=", token)
|
||||
print(" Failed for token=", token_address)
|
||||
print(e)
|
||||
failures[token] = e
|
||||
failures[token_address] = e
|
||||
print("Finished processing all tokens")
|
||||
profit_with_price_tokens[PRICE_DEBT_KEY] = profit_with_price_tokens[
|
||||
PRICE_DEBT_KEY
|
||||
|
@ -45,6 +45,12 @@ def add_cg_ids(profit_by_block, chain):
|
||||
profit_by_block = profit_by_block.merge(
|
||||
token_cg_ids[[TOKEN_RECEIVED_KEY, CG_ID_RECEIVED_KEY]], how="left"
|
||||
)
|
||||
addresses_with_nan_cg_ids = profit_by_block.loc[
|
||||
pd.isna(profit_by_block[CG_ID_RECEIVED_KEY]), TOKEN_RECEIVED_KEY
|
||||
]
|
||||
print(
|
||||
f"Tokens with missing coingecko ids in mapping:\n{addresses_with_nan_cg_ids.value_counts()}"
|
||||
)
|
||||
return profit_by_block[
|
||||
[
|
||||
"block_number",
|
||||
|
Loading…
x
Reference in New Issue
Block a user