Skip to main content

SwapFixedFloat

Struct SwapFixedFloat 

Source
pub struct SwapFixedFloat {
    pub start: Date,
    pub maturity: Date,
    pub rate: f64,
    pub fixed_freq: Frequency,
    pub fixed_daycount: Daycount,
    pub float_freq: Frequency,
    pub float_daycount: Daycount,
    pub fixed_schedule: SwapSchedule,
    pub float_schedule: SwapSchedule,
}
Expand description

A vanilla fixed-floating interest-rate swap with separate fixed- and floating-leg schedules.

Both legs span the same [start, maturity] interval but may use different payment frequencies and day-count conventions (e.g. semi- annual 30/360 fixed against quarterly Act/360 float — the standard USD LIBOR vanilla convention).

Constructed via SwapFixedFloat::new (which builds regular schedules internally) or SwapFixedFloat::with_schedules (which accepts pre-built schedules — useful for stub first/last periods).

§Examples

use regit_curves::instruments::SwapFixedFloat;
use regit_curves::types::{Date, Daycount, Frequency};

let start    = Date::from_ymd(2024, 1, 2).unwrap();
let maturity = Date::from_ymd(2026, 1, 2).unwrap();
let swap = SwapFixedFloat::new(
    start,
    maturity,
    0.04,
    Frequency::SemiAnnual,
    Daycount::Act360,
    Frequency::Quarterly,
    Daycount::Act360,
)
.unwrap();
assert_eq!(swap.fixed_schedule.len(), 4);
assert_eq!(swap.float_schedule.len(), 8);

Fields§

§start: Date

Effective (start) date of both legs.

§maturity: Date

Maturity date of both legs.

§rate: f64

Quoted (par) fixed rate, decimal (e.g. 0.04 for 4%).

§fixed_freq: Frequency

Fixed-leg payment frequency.

§fixed_daycount: Daycount

Fixed-leg day-count convention (drives the tau_i^fixed accruals).

§float_freq: Frequency

Float-leg payment frequency.

§float_daycount: Daycount

Float-leg day-count convention (carried for symmetry / multi-curve pricing; not used in the single-curve identity).

§fixed_schedule: SwapSchedule

Fixed-leg payment schedule.

§float_schedule: SwapSchedule

Float-leg payment schedule.

Implementations§

Source§

impl SwapFixedFloat

Source

pub fn new( start: Date, maturity: Date, rate: f64, fixed_freq: Frequency, fixed_daycount: Daycount, float_freq: Frequency, float_daycount: Daycount, ) -> Result<Self, BootstrapError>

Constructs a swap with regularly generated fixed- and float-leg schedules.

Validation:

  • rate must be finite.
  • start < maturity.
  • Both (start, maturity, freq) triples must yield a regular schedule (i.e. the term must be an integer multiple of each leg’s period).
§Errors
§Examples
use regit_curves::instruments::SwapFixedFloat;
use regit_curves::types::{Date, Daycount, Frequency};
use regit_curves::BootstrapError;

let s = Date::from_ymd(2024, 1, 2).unwrap();
let m = Date::from_ymd(2026, 1, 2).unwrap();
assert!(
    SwapFixedFloat::new(
        s,
        m,
        0.04,
        Frequency::SemiAnnual,
        Daycount::Act360,
        Frequency::Quarterly,
        Daycount::Act360,
    )
    .is_ok()
);
// Inverted dates rejected:
assert!(matches!(
    SwapFixedFloat::new(
        m,
        s,
        0.04,
        Frequency::SemiAnnual,
        Daycount::Act360,
        Frequency::Quarterly,
        Daycount::Act360,
    )
    .unwrap_err(),
    BootstrapError::InvalidInstrument { .. },
));
Source

pub fn with_schedules( start: Date, maturity: Date, rate: f64, fixed_freq: Frequency, fixed_daycount: Daycount, float_freq: Frequency, float_daycount: Daycount, fixed_schedule: SwapSchedule, float_schedule: SwapSchedule, ) -> Result<Self, BootstrapError>

Constructs a swap from pre-built schedules — the irregular-stub counterpart to SwapFixedFloat::new.

Validation:

  • rate must be finite.
  • start < maturity.
  • Both schedules must align: fixed_schedule.start() == start, fixed_schedule.maturity() == maturity, and likewise for float_schedule.
§Errors
§Examples
use regit_curves::instruments::{SwapFixedFloat, SwapSchedule};
use regit_curves::types::{Date, Daycount, Frequency};

let s = Date::from_ymd(2024, 1, 2).unwrap();
let m = Date::from_ymd(2026, 1, 2).unwrap();
let fixed = SwapSchedule::from_regular(s, m, Frequency::SemiAnnual).unwrap();
let float = SwapSchedule::from_regular(s, m, Frequency::Quarterly).unwrap();
let swap = SwapFixedFloat::with_schedules(
    s,
    m,
    0.04,
    Frequency::SemiAnnual,
    Daycount::Act360,
    Frequency::Quarterly,
    Daycount::Act360,
    fixed,
    float,
)
.unwrap();
assert_eq!(swap.fixed_schedule.len(), 4);

Trait Implementations§

Source§

impl Clone for SwapFixedFloat

Source§

fn clone(&self) -> SwapFixedFloat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SwapFixedFloat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SwapFixedFloat

Source§

fn eq(&self, other: &SwapFixedFloat) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SwapFixedFloat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.