# How to calculate average price?

Upstox uses the First In, First Out (FIFO) method to calculate the average price for overnight (Delivery) positions. To better understand this, here's an example based on Nifty Futures.

As part of this example, consider that the two orders below were placed on 1st July.

 Date Side Qty Price Value 1st July Bought 225 Rs. 10,000.00 Rs. 22,50,000.00 1st July Bought 75 Rs. 10,200.00 Rs. 7,65,000.00 Average Price 300 Rs. 10,050.00 Rs. 30,15,000.00

From the above table, we understand the following about the two placed orders.

1st order: Quantity = 225 | Price: Rs. 10,000.00

2nd order: Quantity = 75 | Price: Rs. 10,200.00

To calculate the average price, first calculate the value (Quantity x Price).

Total quantity = 300| Total value: Rs. 30,15,000.00

Now, divide the total value by the total quantity:

Rs. 30,15,000.00 ÷ 300 = Rs.10,050.00

Therefore, Rs.10,050.00 is the average price.

Now, consider that the following orders have been placed on 5th July.

 Date Side Qty Price Value 1st July Bought 225 Rs. 10,000.00 Rs. 22,50,000.00 1st July Bought 75 Rs. 10,200.00 Rs. 7,65,000.00 Average price 300 Rs. 10,050.00 Rs. 30,15,000.00 5th July Sold 150 Rs. 9,950.00 Rs. 14,92,500.00 Average price 150 Rs. 10,100.00 Rs. 15,15,000.00

Here’s what happens when you add a sell order to this:

Sell order placed on 5th July: 150 (out of 300)

Price: Rs. 9,950.00

Here’s how the FIFO method will be applied here. The method will be applicable the first trade (on the buy side). In this case, the first trade’s quantity is 225. 150 will be deducted from 225. The balance left is shown below.

(Please Note: In case the sell quantity exceeded 225, the remaining quantity would be deducted from the next trade)

 Date Side Qty Price Value 1st July Bought 75 Rs. 10,000.00 Rs. 7,50,000.00 1st July Bought 75 Rs. 10,200.00 Rs. 7,65,000.00 Average price 150 Rs. 10,100.00 Rs. 15,15,000.00

After applying the FIFO method, here is the balance:

225 - 150 = 75

Average price: Total Price ÷ Total Quantity

Average price: Rs. 15,15,000.00 ÷ 150 = Rs. 10,100.00

This is how the FIFO method is used for calculating the average price. The calculation remains the same even if you are carrying it on a short sold position instead of a buy position.

Take a look at the calculation of average price for Intraday trading:

 Date Side Qty Price Value 1st July Bought 75 10,100 7,57,500 5th July Sold 75 10,150 7,61,250 5th July Bought 75 10,200 7,65,000 Average Price 75 10,100 7,57,500

On 1st July:

Order Placed - 1
Order: Quantity = 75 | Price: Rs. 10,000.00
Total value = 75*10,100 = Rs. 7,57,500.00 | Average Price: Rs. 10,000.00

On 5th July:
Orders Placed - 2

1st Order : Quantity = 75 , Sell Order | Price: Rs. 10,150.00
2nd Order : Quantity = 75 , Purchase Order | Price: Rs. 10,200.00

Now consider that the same quantity was sold at Rs. 10,150 on 5th July and bought again on the same day at Rs. 10,200. Hence, this trade that was placed on 5th July will be considered as an Intraday trade and will be visible in Positions.

Since Intraday trades are not considered in the calculation of average price, the average price remains as it was on 1st July (Rs. 10,100).

Here is what the final Holdings will look like -

 Date Side Qty Average Price Value 1st July Bought 75 10,100 75,7500