How to user buy/ sell price to calculate proft and loss from jpg.store contract transaction using cardano-db sync query

How to fetch user buy/ sell asset price to calculate profit and loss from jpg.store contract transaction using cardano-db sync query. We have have cardano-db sync setup we get the data for all user holding with transaction out_sum But the transaction out_sum does not match with buy price of asset from jpg.store price. Help me draft a query to fetch all user hold and sold asset matching the jpg.store price.