There are a lot of variables to consider when we are talking about pricing a forward/future. For now, we'll simplify the problem and focus on the few key variables: the risk-free interest rate, the time until delivery date, and the underlying price.
Since in a forward/future contract, we are agreeing to pay the amount of money on the day of delivery, we need to take into account how much the money is worth when the trade actually happens. For instance, you have $1,000 right now but the future contract says the actual exchange of cash and goods will happen exactly 250 days from today. How much is that money worth to you at the time the exchange?
To answer this question, let's look at r -- the risk-free interest rate per year. If you deposited some money into a bank account, you might notice the bank will pay out some sort of interest rate on your cash (nowadays, the interest rate is extremely low but that's a whole other discussion). This observation also presents a small problem since when the bank pays the interest is important to how much money you will be making off the interest. Let me show you in some concrete numbers.
Assuming the risk-free rate of interest per year, r, is 3.25%, what is $7,000 today worth in 5 years?
First, let's assume the bank pays the interest once a year. So after the first year, the bank pays 3.25% interest on $7,000 (which is $7,000 * 0.0325 = $227.50), making your total amount $7,227.50. After one more year, the bank pays 3.25% interest on what you currently have in your bank ($7,227.50) which makes the total $7,462.39 [ = $7,227.50 + ($7,227.50 * 0.0325) = $7,227.50 * (1 + 0.0325)]. We can simply the equation into the following:
But what if the bank -- instead of paying every year -- pays every 6 months? Or every month? Or every day?
We can drill this down into smaller and smaller increments (think every minute, every second, every half a second, etc.). If we take continue down this road, we assume that the interest is paid continuously. Then (maybe you remember from high school algebra) we will approach e (Euler's Number). That is:
So, to summarize, we can say that
where r is the risk-free interest rate per year and t is the time in terms of year. So, to answer the previous question (you have $1,000 right now but the future contract says the actual exchange of cash and goods will happen exactly 250 days from today. How much is that money worth to you at the time the exchange?), we have the following:
So, how does this math translate into calculating the price of a future contract? Well, under the simple assumptions we put in place, your future contract will be worth what the underlying asset is worth times the interest that your money will accrue until the time of the exchange.
For example, in Andy and Steve enter into a forward contract. Andy promises to pay Steve to pay some amount of money in exactly 500 days and Steve agrees to give Andy 5,000 bushels of corn in 500 days. The 5,000 bushels of corn is currently worth $20,000. If the risk-free interest rate is 4.25%, what is the fair price Andy should promise to pay Steve?
Note that just because you entered into a forward/future contract, you are not immune to the moving prices. In fact, under the assumptions (and generally true) you are just as open to price movement risk as much as the guy who is currently holding onto the underlying asset. If the price of corn were to move up, you would profit from it (since in essence you bought it at a determined price in the future), whereas if the price went down you would lose.
The equation becomes more complicated when you start to consider the cost of carry (e.g. if you promised to sell me 50 barrels of oil in 5 months, where are you going to store it until then? Surely, you can't be doing that for free), any future income stream, or (if we're talking about stocks) any future dividends.
For the most part, in my job, we did not price futures, which is one of the reasons I'm sort of skimming this part. Instead, we focused mainly on pricing options that were based off of futures. To price the futures, we simply used the bids and offers that were available in the market. There are, however, traders that trade the spread between price of the underlying asset and the price of the future.