nsa2000Luna price states
    Updated 2022-10-07
    with luna_price as (
    select
    date_trunc('week',block_timestamp) as date,
    avg(price_usd) as avg_price,
    min(price_usd) as min_price,
    max(price_usd) as max_price
    from terra.oracle_prices
    where symbol = 'LUNA'
    and block_timestamp >= '2022-05-15' -- Inception date
    group by date
    ),
    open_strike_price as (
    select * from (
    select
    date_trunc('week',block_timestamp) as date,
    price_usd as open_price,
    1.15 * price_usd as strike_price,
    rank() over (partition by date order by block_timestamp asc) as rank
    from terra.oracle_prices
    where symbol = 'LUNA'
    and block_timestamp >= '2022-05-15' -- Inception date
    ) where rank = 1
    ),
    close_price as (
    select * from (
    select
    date_trunc('week',block_timestamp) as date,
    price_usd as close_price,
    rank() over (partition by date order by block_timestamp desc) as rank
    from terra.oracle_prices
    where symbol = 'LUNA'
    and block_timestamp >= '2022-05-15' -- Inception date
    ) where rank = 1
    )

    select
    Run a query to Download Data