From 5fca851d728f5b2e8ac7d74574da295696592673 Mon Sep 17 00:00:00 2001 From: Alex Kan <29241719+akan72@users.noreply.github.com> Date: Tue, 20 Aug 2024 19:25:47 -0400 Subject: [PATCH] Add polymarket trump and kamala metrics --- .../polymarket/core/ez_polymarket_metrics.sql | 18 ++++++++++++++++++ .../polymarket/__polymarket__sources.yml | 7 +++++++ .../fact_polymarket_prediction_markets.sql | 10 ++++++++++ 3 files changed, 35 insertions(+) create mode 100644 models/projects/polymarket/core/ez_polymarket_metrics.sql create mode 100644 models/staging/polymarket/__polymarket__sources.yml create mode 100644 models/staging/polymarket/fact_polymarket_prediction_markets.sql diff --git a/models/projects/polymarket/core/ez_polymarket_metrics.sql b/models/projects/polymarket/core/ez_polymarket_metrics.sql new file mode 100644 index 00000000..8d9c4ddd --- /dev/null +++ b/models/projects/polymarket/core/ez_polymarket_metrics.sql @@ -0,0 +1,18 @@ +{{ + config( + materialized="table", + snowflake_warehouse="POLYMARKET", + database="polymarket", + schema="core", + alias="ez_metrics", + ) +}} + +SELECT + date, + 'polymarket' AS app, + 'DeFi' AS category, + "'21742633143463906290569050155826241533067272736897614950488156847949938836455'" AS trump_prediction_market_100k_buy_order_price, + "'21271000291843361249209065706097167029083067325856089903026951915683588703117'" AS kamala_prediction_market_100k_buy_order_price +FROM {{ ref("fact_polymarket_prediction_markets") }} +PIVOT(SUM(PREDICTION_MARKET_100K_BUY_ORDER_PRICE) FOR market IN (ANY ORDER BY market)) diff --git a/models/staging/polymarket/__polymarket__sources.yml b/models/staging/polymarket/__polymarket__sources.yml new file mode 100644 index 00000000..94b8c339 --- /dev/null +++ b/models/staging/polymarket/__polymarket__sources.yml @@ -0,0 +1,7 @@ +sources: + - name: PROD_LANDING + schema: PROD_LANDING + database: LANDING_DATABASE + tables: + - name: raw_polymarket_fill_price_by_market + \ No newline at end of file diff --git a/models/staging/polymarket/fact_polymarket_prediction_markets.sql b/models/staging/polymarket/fact_polymarket_prediction_markets.sql new file mode 100644 index 00000000..4048f968 --- /dev/null +++ b/models/staging/polymarket/fact_polymarket_prediction_markets.sql @@ -0,0 +1,10 @@ +{{ config(materialized="table") }} + +SELECT + DATEADD('DAY', -1, DATE_TRUNC('DAY', extraction_date)::date) AS date, + value:market::varchar as market, + AVG(value:average_fill_price) as prediction_market_100k_buy_order_price +FROM {{ source("PROD_LANDING", "raw_polymarket_fill_price_by_market") }}, +lateral flatten(input => parse_json(source_json)) +GROUP BY + 1, 2