Query editor
with avalanche as (select a.evt_block_time, b.account, a.averagePrice/1e30 as avgPrice, a.realisedPnl/1e30 as pnl, a.size/1e30 as size , case when cast(a.realisedPnl/1e30 as INTEGER) > 0 then 1 else 0 end as win , case when true then 'avax' else '0' end as blockchain , t.symbol as clateral , e.symbol as indexfrom gmx_avalanche_c.Vault_evt_ClosePosition a -- Close Positionleft join gmx_avalanche_c.Vault_evt_DecreasePosition b on a.evt_tx_hash = b.evt_tx_hash -- Decrease Position, we use "Vault_evt_DecreasePosition" to get account, because it's not on Vault_evt_ClosePositionleft join tokens.erc20 t on t.contract_address = b.collateralTokenleft join tokens.erc20 e on e.contract_address = b.indexTokenwhere a.evt_block_time > cast('{{Start_Date}}'as TIMESTAMP) and a.evt_block_time < cast('{{End_Date}}' as TIMESTAMP) ),arbitrum as (select a.evt_block_time, b.account, a.averagePrice/1e30 as avgPrice, a.realisedPnl/1e30 as pnl, a.size/1e30 as size , case when cast(a.realisedPnl/1e30 as INTEGER) > 0 then 1 else 0 end as win , case when true then 'arb' else '0' end as blockchain, t.symbol as clateral , e.symbol as indexfrom gmx_arbitrum.Vault_evt_ClosePosition a -- Close Positionleft join gmx_arbitrum.Vault_evt_DecreasePosition b on a.evt_tx_hash = b.evt_tx_hash -- Decrease Position, we use "Vault_evt_DecreasePosition" to get account, because it's not on Vault_evt_ClosePositionleft join tokens.erc20 t on t.contract_address = b.collateralTokenleft join tokens.erc20 e on e.contract_address = b.indexTokenwhere a.evt_block_time > cast('{{Start_Date}}' as TIMESTAMP) and a.evt_block_time < cast('{{End_Date}}' as TIMESTAMP) ),data as ( select * from avalancheUNIONselect * from arbitrum )select account , sum(pnl) as sumpnl , avg(win) as winrate , count(*) as numberoftradefrom datagroup by 1