# How do I calculate Profit&Loss for the User Account? HELP

**URL:** <https://forum.alpaca.markets/t/how-do-i-calculate-profit-loss-for-the-user-account-help/2064>\
**Category:** Alpaca Trading\
**Created:** [July 15, 2020, 2:44pm UTC](https://forum.alpaca.markets/t/how-do-i-calculate-profit-loss-for-the-user-account-help/2064 "2020-07-15T14:44:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milos](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@Milos](https://forum.alpaca.markets/u/Milos)\
**Post date:** [July 15, 2020, 2:44pm UTC](https://forum.alpaca.markets/t/how-do-i-calculate-profit-loss-for-the-user-account-help/2064/1 "2020-07-15T14:44:44Z")

</div>

Hi guys, I am trying to figure out the formula for calculating the Realized and Unrealized P&L, on the account level. Based on average price I guess…  
I am working on an investment app - e.g. user buys 3 AMZN at $3.000, than buys 2.8 AMZN at $2.900 and than sells 1.4 AMZN at $3.005, it is all calculated and written into the same ledger. No positions.

The approach I am investigating is by calculating the average price for buy and sell orders. Once the quantity of a certain asset increases by the buy order I can figure it out, but when it comes to the new order that is decreasing or flattening the quantity I get lost.

Can anyone assist?

---

<div class="post-metadata">

**Author:** ![sammp](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sammp](https://forum.alpaca.markets/u/sammp)\
**Post date:** [October 5, 2020, 4:24pm UTC](https://forum.alpaca.markets/t/how-do-i-calculate-profit-loss-for-the-user-account-help/2064/2 "2020-10-05T16:24:48Z")

</div>

Hi @Milos did you ever figure this out? I am looking for help with the getting the same metric.
