🗃️Advanced Topics
Profit Loss Over Custom Time Periods
Currently, the dex_trader_stats_30d_by_hour_token
table into consideration all trades an address have made in its life time
There is another table, dex_trader_stats_30d_by_hour_token
, which only looks at balances opened in the last 30 days, on a rolling basis.
For custom time windows, please contact us for additional instructions.
How to Estimate Unrealized P&L
Each row has an end_valid_balance
field which is the remaining balance of that token after that trade (counting only tokens purchased on DEXs from the start of the table time range).
1) For each token, take the end_valid_balance
from the row with most recent block_hour
(the latest trade)
2) multiply that by the current token price
Note as mentioned in a previous section, because that table only tracks DEX sales and purchases, if those tokens are transferred out/ used to buy an nft/staked/used as collateral/... that is not reflected in end_valid_balance
. So you might have someone with high unrealized PnL when their wallet is actually empty.
An idea for a better estimate is to calculate their actual current token balance and pick the lowest between that and end_valid_balance
before multiplying by current price.
How to Calculate the P&L Manually?
You can use the following SQL to validate the correctness of the P&L calculation.
Last updated