Query editor
-- daily PnLwith account_connection as (select distinct * from(select primaryAccount as account , subAccount from hmx_arbitrum.TradeService_evt_LogIncreasePosition)),pnl as (select ac.account as account, sum(coalesce(pnl.pnl,0))/1e30 as pnlfrom account_connection acjoin(select subAccount , sum(pnl) as pnl from((select subAccount, -sum(cast(usd as decimal)) as pnl from hmx_arbitrum.TradeHelper_evt_LogSettleUnRealizedPnlValuewhere evt_block_time >= timestamp '2024-08-19 00:00' and evt_block_time < timestamp '2024-08-31 00:00'group by 1)union all(select subAccount, sum(cast(usd as decimal)) as pnl from hmx_arbitrum.TradeHelper_evt_LogReceivedUnRealizedPnlValuewhere evt_block_time >= timestamp '2024-08-19 00:00' and evt_block_time < timestamp '2024-08-31 00:00'group by 1))group by subAccount) pnlon ac.subAccount = pnl.subAccountgroup by account)select * from pnlorder by pnl