-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CoW AMM] 10k growth for HODL strategy
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
cowamm/profitability/10k_growth/daily_rebalancing_4055484.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- Computes the balances and current value of a counterfactual portfolio that invests 10k evenly into two tokens and holds them | ||
-- Parameters | ||
-- {{token_a}} - either token | ||
-- {{token_b}} - other token | ||
-- {{start}} - date as of which the analysis should run | ||
|
||
-- limit the relevant date range | ||
with date_series as ( | ||
select t.day | ||
from | ||
unnest(sequence( | ||
date(timestamp '{{start}}'), | ||
date(now()) | ||
)) t (day) --noqa: AL01 | ||
), | ||
|
||
starting_balance as ( | ||
select | ||
5000 / p1.price_close as token_a_start, | ||
5000 / p2.price_close as token_b_start | ||
from prices.usd_daily as p1 | ||
inner join prices.usd_daily as p2 | ||
on | ||
p1.day = p2.day | ||
and p1.day = date(timestamp '{{start}}') | ||
and p1.contract_address = {{token_a}} | ||
and p2.contract_address = {{token_b}} | ||
) | ||
|
||
select | ||
ds.day, | ||
token_a_start * p1.price_close + token_b_start * p2.price_close as current_value_of_investment | ||
from starting_balance, date_series as ds | ||
inner join prices.usd_daily as p1 | ||
on | ||
ds.day = p1.day | ||
and p1.contract_address = {{token_a}} | ||
inner join prices.usd_daily as p2 | ||
on | ||
ds.day = p2.day | ||
and p2.contract_address = {{token_b}} | ||
order by 1 desc |