An entity annual purchase 500 barrels of Light Sweet Crude Oil. These purchases are made in a regular pattern over the year. To ensure the price risk the entity enters into a commodity swap-contract with a contract volume of 500 barrels and a duration of one year. The purchase price for 500 barrels Light Sweet Crude Oil is fixed at USD 88.37.
At settlement date of the commodity swap-contract, the average exchange spot price of Light Sweet Crude Oil on the Chicago Mercantile Exchange was USD 91.21.
As a result, the entity receives USD 1,420 or 500 barrels x (91.21 – 88.37) or USD 2.84/barrel.
Because the purchases are made in a regular pattern over the year the average purchase price over that period will be close to USD 91.21/barrel. As a result, the entity has paid (on average) USD 91.21 for its 500 barrels. Which is more than anticipated! However with the gain on the commodity swap, the average purchase price is 91.21 – 2.84 = 88.37, exactly the price swapped.
You can perform a calculation with different average prices, however, the end result will be that a loss on the actual average price of purchased barrels of Light Sweet Crude Oil is compensated by a gain on the swap and vice versa.