MasiTotal Trading
    Updated 2024-11-15
    /**select TO_TIMESTAMP(value:time::string) as hour,
    'nearnvidia.near' as TOKEN_ADDRESS,
    (value:close+value:open)/2 as price
    from (
    select live.udf_api('https://api.coinmarketcap.com/kline/v3/k-line/candles/60/9488613?reverse-order=false&usd=true&type=1h&to=1816422400000&countBack=321') AS response
    ),
    LATERAL FLATTEN (input => response:data:data)
    union all
    **/

    with tb1 as ( select trunc(hour,'day') as day,
    'aurora' as token_address,
    avg(price) as avg_price
    from near.price.ez_prices_hourly
    where symbol = 'ETH'
    group by 1,2
    UNION
    select trunc(hour,'day') as day,
    '3.contract.portalbridge.near' as token_address,
    1 as avg_price
    from near.price.ez_prices_hourly
    where symbol = 'ETH'
    UNION
    Select trunc(TO_TIMESTAMP(value[0]::string),'day') as day,
    'usmeme.tg' as token_address,
    avg(value[1]) as avg_price
    from (
    SELECT livequery.live.udf_api(
    'https://api.coingecko.com/api/v3/coins/usmeme/market_chart?vs_currency=usd') as resp
    )
    ,LATERAL FLATTEN (input => resp:data:prices)
    group by all
    UNION
    Select trunc(TO_TIMESTAMP(value[0]::string),'day') as day,
    'token.jumbo_exchange.near' as token_address,
    avg(value[1]) as avg_price
    QueryRunArchived: QueryRun has been archived