Pricing of FX Forward in R and Excel

This post explains how to price a 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.

Fx forward pricing diagram

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.

Pricing of FX Forward


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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#=========================================================================#
# 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(44378443794438644410
                     44441444744456444747), 
            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(44378443864441044441,
                     44473445644465544747), 
            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)))
 
cs


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.


1
2
3
4
5
6
 
>     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"
 
cs


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. \(\blacksquare\)


2 comments:

  1. Replies
    1. Hi, Thank you for visiting my blog.
      Unfortunately, I didn't save it after R code is completed since this content is simple.
      I think that you can make it easily based on the content of this post and R code I implemented for you.

      Delete