Need an FX Fwds days-in-tenor function

Discussion in 'Options' started by Ricardo Reis, Apr 25, 2025 at 8:46 PM.

  1. I am looking for a function, almost any language is fine, to compute the number of days in an FX forward given the pair, the tenor, and the pricing date. FX forwards start on spot date, end on value date, and the calendar days difference between the two is the number I want the function to return. Spot and value dates are (mostly) trading dates and the calculation must account for holidays in the two countries, year-, quarter-, and month-end effects and deliverable vs ndf. For example the six month EURUSD forward for pricing date 2025-04-23 is 186 days.

    I have not been able to find such a function in any obviously relevant Python, R, or Matlab packages and I am wondering if anyone here has such a function. I post in this section because FX forward calcs are essential to FX option calcs and the posters in the Forex forum here all seem to be spam bots.

    I am willing to pay a reasonable amount for the function, either if you already have it or know where to find it, or if you want to write one from scratch. Assume I already have a decent holiday function of the form getHolidays(cc,dtStart,dtEnd)

    I have the information for most historical pricing dates, pairs, and tenors, but need the function for when the useful FX_MID_FORWARD_POINTS_PER_DAY (PX679) field or column is missing (NA) or zero (rates essentially equal). Days-in-tenor col is just PX_MID divided by PX679. I have a db table mostly filled in for 150+ pairs going back 25 years to calibrate or check function against. Below is a recent snippet for EURUSD6M, PX_MID is fwd points, PX679 is points per day, and DIT is days in tenor:

    Code:
      DATE  PX_MID PX679 DOW DIT
    1  2025-03-24 112.265  0.61  1 184
    2  2025-03-25 113.120  0.61  2 185
    3  2025-03-26 113.150  0.61  3 185
    4  2025-03-27 113.250  0.62  4 183
    5  2025-03-28 112.710  0.62  5 182
    8  2025-03-31 111.165  0.61  1 182
    9  2025-04-01 111.735  0.61  2 183
    10 2025-04-02 114.492  0.62  3 185
    11 2025-04-03 112.100  0.61  4 184
    12 2025-04-04 111.372  0.61  5 183
    15 2025-04-07 114.748  0.63  1 182
    16 2025-04-08 111.338  0.61  2 183
    17 2025-04-09 120.830  0.65  3 186
    18 2025-04-10 120.122  0.66  4 182
    19 2025-04-11 123.580  0.68  5 182
    22 2025-04-14 123.596  0.68  1 182
    23 2025-04-15 123.275  0.67  2 184
    24 2025-04-16 124.473  0.68  3 183
    25 2025-04-17 127.976  0.70  4 183
    26 2025-04-18 128.205  0.70  5 183
    29 2025-04-21 128.612  0.70  1 184
    30 2025-04-22 129.966  0.71  2 183
    31 2025-04-23 130.200  0.70  3 186
    32 2025-04-24 130.740  0.71  4 184
    
     
  2. 2rosy

    2rosy

    Python. Rust. Rateslib pkg