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' ]
|
'profit_usd' ]
|
||||||
"""
|
"""
|
||||||
tokens = profit[CG_ID_RECEIVED_KEY].unique()
|
tokens = profit[CG_ID_RECEIVED_KEY].unique()
|
||||||
|
addresses = profit[TOKEN_RECEIVED_KEY].unique()
|
||||||
mapping = get_address_to_coingecko_ids_mapping(chain)
|
mapping = get_address_to_coingecko_ids_mapping(chain)
|
||||||
profit_with_price_tokens = pd.DataFrame()
|
profit_with_price_tokens = pd.DataFrame()
|
||||||
failures = {}
|
failures = {}
|
||||||
for token in tokens:
|
for i in range(len(tokens)):
|
||||||
print("Processing", token)
|
token = tokens[i]
|
||||||
|
token_address = addresses[i]
|
||||||
|
print(f"Processing {token} ({token_address})")
|
||||||
try:
|
try:
|
||||||
|
|
||||||
profit_by_received_token = pd.DataFrame(
|
profit_by_received_token = pd.DataFrame(
|
||||||
@ -196,9 +199,9 @@ def get_usd_profit(profit, chain, save_to_csv=False):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# @TODO: save into list to add later
|
# @TODO: save into list to add later
|
||||||
print(" Failed for token=", token)
|
print(" Failed for token=", token_address)
|
||||||
print(e)
|
print(e)
|
||||||
failures[token] = e
|
failures[token_address] = e
|
||||||
print("Finished processing all tokens")
|
print("Finished processing all tokens")
|
||||||
profit_with_price_tokens[PRICE_DEBT_KEY] = profit_with_price_tokens[
|
profit_with_price_tokens[PRICE_DEBT_KEY] = profit_with_price_tokens[
|
||||||
PRICE_DEBT_KEY
|
PRICE_DEBT_KEY
|
||||||
|
@ -45,6 +45,12 @@ def add_cg_ids(profit_by_block, chain):
|
|||||||
profit_by_block = profit_by_block.merge(
|
profit_by_block = profit_by_block.merge(
|
||||||
token_cg_ids[[TOKEN_RECEIVED_KEY, CG_ID_RECEIVED_KEY]], how="left"
|
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[
|
return profit_by_block[
|
||||||
[
|
[
|
||||||
"block_number",
|
"block_number",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user