Trading P&L =

base_asset_trade_delta * base_asset_usd_exchange_rate (at the end of query period) +

quote_asset_trade_delta *quote_asset_usd_exchange_rate (at the end of query period) -

sum (fee_amount * fee_asset_usd_exchange_rate (at time of transaction)) for each trade.

Total P&L =

trading_p&l + sum(liquidity_mining_rewards * (at the end of query period))