Class FxSwap

java.lang.Object
com.quantfinlib.fx.FxSwap

public final class FxSwap extends Object
An FX swap: two offsetting FX exchanges — buy (sell) base currency on the near date, sell (buy) it back on the far date — the instrument behind funding, position rolls, and most of the daily FX forward volume.

An at-market swap has zero value at inception: both legs trade at the prevailing outrights, so only the points differential between the legs is economically exchanged. Value appears as the points move; this class marks each leg against a current SwapPointsCurve and (optionally) discounts the leg P&Ls with a quote-currency YieldCurve.

Sign convention: baseNotional > 0 means the near leg buys base currency (and the far leg sells it back). All results are in quote currency per the pair's quotation.

  • Method Details

    • of

      public static FxSwap of(CurrencyPair pair, double baseNotional, LocalDate nearDate, double nearRate, LocalDate farDate, double farRate)
      Explicit legs (off-market swaps, historical bookings).
    • atMarket

      public static FxSwap atMarket(SwapPointsCurve curve, String nearTenor, String farTenor, double baseNotional)
      At-market swap struck off a points curve: both legs at the curve's outrights, so inception value is zero by construction. "SPOT" is accepted as the near tenor for the classic spot-against-forward swap.
    • markToMarket

      public double markToMarket(SwapPointsCurve current)
      Undiscounted mark-to-market in quote currency against a current curve: each leg's (current forward − traded rate) × signed base notional. The near leg is long base when baseNotional > 0, the far leg short — so an at-market swap marks to ~zero on its own curve.

      Aged swaps: a leg whose settlement date lies before the marking curve's spot has already settled — its P&L is realized cash in the books, not mark-to-market — so it contributes zero here. Routine daily marking of a seasoned swap therefore values only the remaining live leg(s).

    • markToMarket

      public double markToMarket(SwapPointsCurve current, YieldCurve quoteDiscount)
      Discounted mark-to-market: live-leg P&Ls discounted off a quote-currency zero curve (ACT/365 from the valuation curve's spot date). Settled legs contribute zero, as in the undiscounted form.
    • swapPointsPips

      public double swapPointsPips()
      The swap's traded points differential (far − near) in pips — what the two counterparties actually negotiated.
    • rollCost

      public static double rollCost(CurrencyPair pair, double baseNotional, double tomNextPips)
      Cost in quote currency of rolling a base position one day at a quoted tom-next rate: what a position holder pays (or earns, when negative) to push settlement from tomorrow to the next day.
    • pair

      public CurrencyPair pair()
    • baseNotional

      public double baseNotional()
    • nearDate

      public LocalDate nearDate()
    • nearRate

      public double nearRate()
    • farDate

      public LocalDate farDate()
    • farRate

      public double farRate()
    • toString

      public String toString()
      Overrides:
      toString in class Object