-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alter Swap model to make Candlestick views with
timescaledb.continuous
- Loading branch information
1 parent
4e3b8cc
commit 2eb0b29
Showing
8 changed files
with
77 additions
and
134 deletions.
There are no files selected for viewing
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
32 changes: 0 additions & 32 deletions
32
src/demo_uniswap/sql/on_reindex/01_create_mv_token_price.sql
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/demo_uniswap/sql/on_reindex/10_create_mv_quotes_1m.sql
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/demo_uniswap/sql/on_reindex/11_create_mv_quotes_1d.sql
This file was deleted.
Oops, something went wrong.
50 changes: 25 additions & 25 deletions
50
src/demo_uniswap/sql/on_reindex/20_create_ca_quotes_1m.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
-- CREATE MATERIALIZED VIEW | ||
-- candlestick_1m | ||
-- WITH (timescaledb.continuous) AS | ||
-- | ||
-- SELECT | ||
-- time_bucket('1 minute'::INTERVAL, to_timestamp(timestamp)) AS bucket, | ||
-- token0_id as token_id, | ||
-- candlestick_agg( | ||
-- to_timestamp(timestamp), | ||
-- abs(amount_usd/amount0), | ||
-- amount_usd | ||
-- ) as candlestick | ||
-- FROM swap | ||
-- WHERE | ||
-- amount_usd!=0 | ||
-- AND | ||
-- amount0!=0 | ||
-- | ||
-- GROUP BY | ||
-- bucket, | ||
-- token0_id | ||
-- ORDER BY | ||
-- bucket, | ||
-- token0_id | ||
-- WITH NO DATA; | ||
CREATE MATERIALIZED VIEW | ||
candlestick_1m | ||
WITH (timescaledb.continuous) AS | ||
|
||
SELECT | ||
time_bucket('1 minute'::INTERVAL, timestamp) AS bucket, | ||
token0_id as token_id, | ||
candlestick_agg( | ||
timestamp, | ||
abs(amount_usd/amount0), | ||
amount_usd | ||
) as candlestick | ||
FROM swap | ||
WHERE | ||
amount_usd!=0 | ||
AND | ||
amount0!=0 | ||
|
||
GROUP BY | ||
bucket, | ||
token0_id | ||
ORDER BY | ||
bucket, | ||
token0_id | ||
WITH NO DATA; |
25 changes: 0 additions & 25 deletions
25
src/demo_uniswap/sql/on_reindex/21_create_ca_quotes_1d.sql
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
src/demo_uniswap/sql/on_reindex/21_create_ca_quotes_1h.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE MATERIALIZED VIEW | ||
candlestick_1h | ||
WITH (timescaledb.continuous) AS | ||
|
||
SELECT | ||
time_bucket('1 hour'::INTERVAL, timestamp) AS bucket, | ||
token0_id as token_id, | ||
candlestick_agg( | ||
timestamp, | ||
abs(amount_usd/amount0), | ||
amount_usd | ||
) as candlestick | ||
FROM swap | ||
WHERE | ||
amount_usd!=0 | ||
AND | ||
amount0!=0 | ||
|
||
GROUP BY | ||
bucket, | ||
token0_id | ||
ORDER BY | ||
bucket, | ||
token0_id | ||
WITH NO DATA; |
25 changes: 25 additions & 0 deletions
25
src/demo_uniswap/sql/on_reindex/22_create_ca_quotes_1d.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE MATERIALIZED VIEW | ||
candlestick_1d | ||
WITH (timescaledb.continuous) AS | ||
|
||
SELECT | ||
time_bucket('1 day'::INTERVAL, timestamp) AS bucket, | ||
token0_id as token_id, | ||
candlestick_agg( | ||
timestamp, | ||
abs(amount_usd/amount0), | ||
amount_usd | ||
) as candlestick | ||
FROM swap | ||
WHERE | ||
amount_usd!=0 | ||
AND | ||
amount0!=0 | ||
|
||
GROUP BY | ||
bucket, | ||
token0_id | ||
ORDER BY | ||
bucket, | ||
token0_id | ||
WITH NO DATA; |