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: DateEffective (start) date of both legs.
maturity: DateMaturity date of both legs.
rate: f64Quoted (par) fixed rate, decimal (e.g. 0.04 for 4%).
fixed_freq: FrequencyFixed-leg payment frequency.
fixed_daycount: DaycountFixed-leg day-count convention (drives the tau_i^fixed accruals).
float_freq: FrequencyFloat-leg payment frequency.
float_daycount: DaycountFloat-leg day-count convention (carried for symmetry / multi-curve pricing; not used in the single-curve identity).
fixed_schedule: SwapScheduleFixed-leg payment schedule.
float_schedule: SwapScheduleFloat-leg payment schedule.
Implementations§
Source§impl SwapFixedFloat
impl SwapFixedFloat
Sourcepub fn new(
start: Date,
maturity: Date,
rate: f64,
fixed_freq: Frequency,
fixed_daycount: Daycount,
float_freq: Frequency,
float_daycount: Daycount,
) -> Result<Self, BootstrapError>
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:
ratemust 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
BootstrapError::InvalidInstrumentifrateis not finite, ifstart >= maturity, or if either schedule cannot be built regularly at the requested frequency.
§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 { .. },
));Sourcepub 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>
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:
ratemust be finite.start < maturity.- Both schedules must align:
fixed_schedule.start() == start,fixed_schedule.maturity() == maturity, and likewise forfloat_schedule.
§Errors
BootstrapError::InvalidInstrumentif any validation step fails.
§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
impl Clone for SwapFixedFloat
Source§fn clone(&self) -> SwapFixedFloat
fn clone(&self) -> SwapFixedFloat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more