Skip to content

Market #67

Closed
Closed

Description

@thejerwang

@claude for fx marker can we add or check how we treat ON SN and TN. Do you know this quote meaning from Bloomberg? image

Also you need to consider if it's one single forward or 2 legs swap so we know how to adjust per leg based on market quote. This will be used for pricing?

Can you also check what quantlib does so we are in line

Activity

  1. claude commented on May 12, 2026

    @claude

    Claude finished @thejerwang's task in 10m 2s —— View job • claude/issue-67-20260512-1241 • Create PR ➔


    Analysis & Implementation Complete

    • Gather context (read Bloomberg image and issue)
    • Read CLAUDE.md and explore existing FX market code
    • Research ON/TN/SN Bloomberg conventions and QuantLib treatment
    • Add TN (Tom-Next) to Period enum with correct settlement date logic
    • Add near_date() method to Period for 2-leg swap support
    • Update FXForwardHelper documentation for single forward vs swap distinction
    • Update sample/tests to cover ON and TN

    Bloomberg Quote Conventions: ON / TN / SN

    The Bloomberg screen shows EUR/USD (spot ~1.1744, spot date 05/14/26). The three short-end tenors are 2-leg FX swap quotes:

    Tenor Bloomberg name Near leg Far leg Bloomberg "Pts"
    ON Overnight T (today) T+1 swap pts for T→T+1 period
    TN Tom-Next T+1 (tom) T+2 (= spot for T+2 pairs) swap pts for T+1→T+2 period
    SN Spot-Next T+2 (spot) T+3 swap pts for T+2→T+3 period

    Bloomberg's "Pts" column = forward points for that individual overnight period (not cumulative).
    Bloomberg's "Fwds" column = outright forward rate at the far-leg date.

    From the image (EUR/USD, today 05/12/26):

    • ON far-leg date: 05/13/26, Fwds ≈ 1.1742 (below spot → negative forward pts, i.e. USD rates > EUR rates)
    • TN far-leg date: 05/14/26 = spot date → Fwds ≈ spot itself
    • SN far-leg date: 05/15/26, Fwds > spot

    Single Forward vs 2-Leg Swap

    Single outright forward: one cash exchange at the far-leg date.
    → Use FXForwardHelper::get_forward(settlement_date, cal) as before.

    2-leg FX swap (ON/TN/SN): simultaneous buy at near leg, sell at far leg (or vice versa).
    → Call get_forward for each leg separately, using:

    • Period::ON.near_date(val_date, cal) → near leg date (T)
    • Period::ON.settlement_date(val_date, cal) → far leg date (T+1)

    What Was Missing / Fixed

    TN was absent from the Period enum. ON and SN existed but not TN. Added in src/time/period.rs:

    pub enum Period {
        ON,   // Overnight: near=T, far=T+1
        TN,   // Tom-Next:  near=T+1, far=T+2 (spot for T+2 pairs)  ← NEW
        SPOT,
        SN,   // Spot-Next: near=spot, far=spot+1
        // ...
    }

    Settlement date logic for TN — base starts from T+1 (tom), then adds 1 day to land at the spot date (T+2):

    let target_date = match self {
        Period::ON => valuation_date,            // base = T
        Period::TN => valuation_date + ONE_DAY,  // base = T+1  ← NEW
        _          => valuation_date + TWO_DAYS, // base = T+2 (spot)
    };

    New near_date() API for pricing 2-leg swaps per-leg:

    // Example: pricing an ON FX swap
    let near = Period::ON.near_date(val_date, &cal)?;   // Some(T)
    let far  = Period::ON.settlement_date(val_date, &cal)?; // T+1
    let near_fwd = helper.get_forward(near.unwrap(), &cal)?;
    let far_fwd  = helper.get_forward(far, &cal)?;
    // swap P&L = far_leg_payoff - near_leg_payoff

    QuantLib Alignment

    QuantLib's FxSwapRateHelper explicitly models both legs of an FX swap, with separate near/far settlement dates. The new near_date() + settlement_date() pair mirrors that dual-date structure. QuantLib also does not have a named "TN" constant but constructs it from a 1-day offset off the tom date — equivalent to what Period::TN now does here.


    Files Changed

    File Change
    src/time/period.rs Added TN variant, near_date() method, updated all Add/Sub/Mul impls, 4 new tests
    src/markets/forex/quotes/forwardpoints.rs Extended FXForwardQuote doc with Bloomberg convention table + single-vs-swap explanation
    src/tests/common.rs Added Period::ON quote (negative pre-spot pts) to sample forward helper
  2. thejerwang commented on May 13, 2026

    @thejerwang
    CollaboratorAuthor

    @claude can you add test cases of the screenshot

  3. claude commented on May 13, 2026

    @claude

    Claude finished @thejerwang's task in 9m 33s —— View job • claude/issue-67-20260513-2106 • Create PR ➔


    Adding test cases from the Bloomberg screenshot

    • Read screenshot and gather context
    • Read existing codebase (period.rs, forwardpoints.rs, tests/common.rs)
    • Add TN (Tom-Next) period to enum — was missing from codebase
    • Add near_date() method for ON/TN/SN swap leg support
    • Add Bloomberg settlement date tests to period.rs
    • Add bloomberg_eurusd_fx_forward_helper() to tests/common.rs
    • Add Bloomberg forward curve tests to forwardpoints.rs
    • Commit and push

    What was added

    Period::TN (Tom-Next) — the variant was missing entirely from the enum. Added with correct settlement logic: base date = T+1 (tom), far-leg = T+2 = spot date.

    Period::near_date() — returns the near-leg settlement date for 2-leg FX swaps:

    • ON → near = T (today)
    • TN → near = T+1 (tom)
    • SN → near = spot (T+2)
    • SPOT and longer → None (single outright, no near leg)

    Bloomberg test data (EUR/USD, pricing date 2026-05-12, spot "Value 05/14/26"):

    Tenor Far-leg date (Bloomberg) Fwds Bid
    ON 2026-05-13 1.174188
    TN 2026-05-14 = spot 1.174244
    SN 2026-05-15 1.174354
    1W 2026-05-21 1.174682
    2W 2026-05-28 1.175068
    2M 2026-07-14 1.177487
    4M 2026-09-14 1.180255

    New tests (9 total across period.rs and forwardpoints.rs):

    • test_bloomberg_eurusd_settlement_dates_20260512 — all far-leg dates match Bloomberg screen
    • test_bloomberg_eurusd_near_dates_20260512 — near-leg dates for ON/TN/SN
    • test_bloomberg_eurusd_settlement_dates — same in forwardpoints.rs via helper
    • test_bloomberg_eurusd_get_forward_exact — exact rate match at each tenor's date
    • test_bloomberg_eurusd_get_forward_interpolation — linear interp between 1W and 2W
    • test_bloomberg_eurusd_on_below_tn — ON outright < TN outright (negative ON swap pts)

    • claude/issue-67-20260513-2106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions