The article “Pricing of FX Forward in R and Excel” was originally posted on SHLee AI Financial Model.
This post explains how to price an FX forward. We assume that 1) USD is the foreign currency and KRW the domestic one, 2) USD IRS zero curve and KRW FX implied zero curve are given. Before making a R code, we use Excel spreadsheet for the clear understanding of the calculation process.
In this post, we consider two solutions using Excel and R. In particular, Excel solution uses the same linear interpolation as that of the following post.
FX Forward Pricing
FX forward is a contractual agreement between two parties to exchange a pair of currencies at a specific time in the future. Given discount factors for domestic and foreign currencies, FX forward price is easily calculated. For example, let’s take an example of the USD KRW FX forward contract as follows.

The difference between present values of two nominal amount is the price of FX forward. Of course, it can be represented by either domestic or foreign currencies.
Example Trade
As of 2021/06/30, let’s investigate the calculation process of FX forward contract of the detailed example above.

Understanding using Excel
We need the each currency’s discount factor of maturity date, which is needed to be interpolated. We use the LINEST Excel function for this purpose. This interpolation procedure is simple and useful in that we only generate regression coefficients for the corresponding maturity ranges. From Excel spreadsheet calculation, we can learn how to price a FX forward. The important thing is to calculate present values of each nominal amounts using each discount factor and get their difference under the same currency.

Here, notations used in the above Excel spreadsheet are defined in the following way.
- Zero(T) : zero rate at maturity
- DF(T) : discount factor at maturity
- FA : notional amount of foreign currency
- DA : notional amount of domestic currency
- PV(FA) in F : present value of FA denominated in Foreign currency
- PV(DA) in D : present value of DA denominated in Domestic currency
- PV(FA) in D : present value of FA denominated in Domestic currency
- PV(DA) in F : present value of DA denominated in Foreign currency
- Price in D : KRW (domestic currency) price of FX forward
- Price in F : USD (foreign currency) price of FX forward
R code
We can use R code to get the same results from Excel calculation.
#=========================================================================# # Financial Econometrics & Derivatives, ML/DL using R, Python, Tensorflow # by Sang-Heon Lee # # https://shleeai.blogspot.com #-------------------------------------------------------------------------# # FX Forward Pricing #=========================================================================# graphics.off() # clear all graphs rm(list = ls()) # remove all files from your workspace #-------------------------------------------------------------------------- # 1. Market Information #-------------------------------------------------------------------------- #-------------------------------- # Zero curves as of 2021-06-30 #-------------------------------- lt.mt <- list( spot_date = 44377, # spot date KRWUSD.FX.Spot = 1129.945, # FX Spot Rate KRW_CRS.zero = data.frame( # Excel numeric date date = c(44378, 44379, 44386, 44410, 44441, 44474, 44564, 44747), rate = c(0.00629994563073550, 0.00629994563073550, 0.00463177425055339, 0.00329405202619836, 0.00292249195639071, 0.00273429173667466, 0.00331796879551685, 0.00397939937284654) ), USD_IRS.zero = data.frame( # Excel numeric date date = c(44378, 44386, 44410, 44441, 44473, 44564, 44655, 44747), rate = c(0.000842844860217754, 0.000908701294845472, 0.001006361388394810, 0.001238311778397180, 0.001455778457003310, 0.001533135923937390, 0.001716219715472820, 0.001848263900368730) ) ) #-------------------------------- # Interpolation of zero curve #-------------------------------- # USD IRS v.date <- lt.mt$USD_IRS.zero$date v.zero <- lt.mt$USD_IRS.zero$rate func_linear_USD_IRS.zero <- approxfun(v.date, v.zero, method="linear") # KRW CRS v.date <- lt.mt$KRW_CRS.zero$date v.zero <- lt.mt$KRW_CRS.zero$rate func_linear_KRW_CRS.zero <- approxfun(v.date, v.zero, method="linear") #-------------------------------------------------------------------------- # 2. FX Forward Trade Information #-------------------------------------------------------------------------- fAmt <- 10000 # Foreign notional amount dAmt <- 10948600 # Domestic notional amount fPosition <- 1 # 1 if Foreign is a buy position, -1 if sell mat_date <- 44561 # maturity date of FX Forward contract #-------------------------------------------------------------------------- # 3. FX Forward Pricing #-------------------------------------------------------------------------- #-------------------------------- # 1) Foreign #-------------------------------- # zero rate for discounting fzero <- func_linear_USD_IRS.zero(mat_date) # discount factor fDF <- exp(-fzero*(mat_date-lt.mt$spot_date)/365) # discounted foreign amount denominated in foreign currency pv_fAmt_in_f <- fAmt*fDF # discounted foreign amount denominated in domestic currency pv_fAmt_in_d <- pv_fAmt_in_f*lt.mt$KRWUSD.FX.Spot #-------------------------------- # 2) Domestic #-------------------------------- # zero rate for discounting dzero <- func_linear_KRW_CRS.zero(mat_date) # discount factor dDF <- exp(-dzero*(mat_date-lt.mt$spot_date)/365) # discounted domestic amount denominated in foreign currency pv_dAmt_in_d <- dAmt*dDF # discounted domestic amount denominated in domestic currency pv_dAmt_in_f <- pv_dAmt_in_d/lt.mt$KRWUSD.FX.Spot # 3) Price #-------------------------------- price_in_f <- fPosition*(pv_fAmt_in_f - pv_dAmt_in_f) price_in_d <- fPosition*(pv_fAmt_in_d - pv_dAmt_in_d) print(paste0("FX Forward Price ($) = ", round(price_in_f,2))) print(paste0("FX Forward Price (w) = ", round(price_in_d,2)))
Results
The following results show FX forward prices which are denominated in both USD dollar and KRW won respectively. The price of this example is $318.89 or ₩360,325.24. These result is the same as those obtained by using Excel.
> print(paste0("FX Forward Price ($) = ", round(price_in_f,2))) [1] "FX Forward Price ($) = 318.89" > print(paste0("FX Forward Price (w) = ", round(price_in_d,2))) [1] "FX Forward Price (w) = 360325.24"
From this post, we can calculate the price of FX forward using Excel and R. For simplicity, FX implied zero curve is assumed away in this work, we will discuss it later.
Disclosure: Interactive Brokers Third Party
Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.
This material is from SHLee AI Financial Model and is being posted with its permission. The views expressed in this material are solely those of the author and/or SHLee AI Financial Model and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.
Disclosure: Forex
There is a substantial risk of loss in foreign exchange trading. The settlement date of foreign exchange trades can vary due to time zone differences and bank holidays. When trading across foreign exchange markets, this may necessitate borrowing funds to settle foreign exchange trades. The interest rate on borrowed funds must be considered when computing the cost of trades across multiple markets.
Join The Conversation
For specific platform feedback and suggestions, please submit it directly to our team using these instructions.
If you have an account-specific question or concern, please reach out to Client Services.
We encourage you to look through our FAQs before posting. Your question may already be covered!