Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/examples_exotics/src/bin/cliquet_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ fn main() {
spread_second_asset_volatility: None,
spread_second_asset_dividend: None,
spread_correlation: None,
quanto_fx_volatility: None,
quanto_fx_correlation: None,
quanto_foreign_rate: None,
}),
);

Expand Down
17 changes: 16 additions & 1 deletion src/model/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ impl fmt::Display for ExoticParams {
fields.push(format!("Spread Correlation: {corr:.4}"));
}

if let Some(ref vol) = self.quanto_fx_volatility {
fields.push(format!("Quanto FX Volatility: {vol}"));
}

if let Some(corr) = self.quanto_fx_correlation {
fields.push(format!("Quanto FX Correlation: {corr:.4}"));
}

if let Some(rate) = self.quanto_foreign_rate {
fields.push(format!("Quanto Foreign Rate: {rate:.4}"));
}

write!(f, "{}", fields.join(", "))
}
}
Expand Down Expand Up @@ -462,6 +474,9 @@ mod tests_options {
spread_second_asset_volatility: None,
spread_second_asset_dividend: None,
spread_correlation: None,
quanto_fx_volatility: None,
quanto_fx_correlation: None,
quanto_foreign_rate: None,
};
let naive_date = NaiveDate::from_ymd_opt(2024, 8, 8)
.expect("Invalid date")
Expand Down Expand Up @@ -497,7 +512,7 @@ mod tests_options {
Quantity: 5\n\
Risk-free Rate: 1.50%\n\
Dividend Yield: 1%\n\
Exotic Parameters: ExoticParams { spot_prices: None, spot_min: None, spot_max: None, cliquet_local_cap: None, cliquet_local_floor: None, cliquet_global_cap: None, cliquet_global_floor: None, rainbow_second_asset_price: None, rainbow_second_asset_volatility: None, rainbow_second_asset_dividend: None, rainbow_correlation: None, spread_second_asset_volatility: None, spread_second_asset_dividend: None, spread_correlation: None }";
Exotic Parameters: ExoticParams { spot_prices: None, spot_min: None, spot_max: None, cliquet_local_cap: None, cliquet_local_floor: None, cliquet_global_cap: None, cliquet_global_floor: None, rainbow_second_asset_price: None, rainbow_second_asset_volatility: None, rainbow_second_asset_dividend: None, rainbow_correlation: None, spread_second_asset_volatility: None, spread_second_asset_dividend: None, spread_correlation: None, quanto_fx_volatility: None, quanto_fx_correlation: None, quanto_foreign_rate: None }";

assert_eq!(display_output, expected_output);
}
Expand Down
10 changes: 10 additions & 0 deletions src/model/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ pub struct ExoticParams {
/// Correlation between the two underlying assets for Spread options.
/// Must be between -1.0 and 1.0.
pub spread_correlation: Option<Decimal>, // Spread

/// Volatility of the exchange rate for Quanto options.
pub quanto_fx_volatility: Option<Positive>, // Quanto

/// Correlation between the underlying asset and the exchange rate for Quanto options.
/// Must be between -1.0 and 1.0.
pub quanto_fx_correlation: Option<Decimal>, // Quanto

/// Foreign risk-free interest rate for Quanto options.
pub quanto_foreign_rate: Option<Decimal>, // Quanto
}

/// Represents a financial option contract with its essential parameters and characteristics.
Expand Down
5 changes: 1 addition & 4 deletions src/pricing/black_scholes_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ pub fn black_scholes(option: &Options) -> Result<Decimal, PricingError> {
OptionType::Cliquet { .. } => crate::pricing::cliquet::cliquet_black_scholes(option),
OptionType::Rainbow { .. } => crate::pricing::rainbow::rainbow_black_scholes(option),
OptionType::Spread { .. } => crate::pricing::spread::spread_black_scholes(option),
OptionType::Quanto { .. } => Err(PricingError::unsupported_option_type(
"Quanto",
"Black-Scholes",
)),
OptionType::Quanto { .. } => crate::pricing::quanto::quanto_black_scholes(option),
OptionType::Exchange { .. } => Err(PricingError::unsupported_option_type(
"Exchange",
"Black-Scholes",
Expand Down
3 changes: 3 additions & 0 deletions src/pricing/cliquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ mod tests {
spread_second_asset_volatility: None,
spread_second_asset_dividend: None,
spread_correlation: None,
quanto_fx_volatility: None,
quanto_fx_correlation: None,
quanto_foreign_rate: None,
}),
)
}
Expand Down
4 changes: 4 additions & 0 deletions src/pricing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ pub mod rainbow;
/// Spread option pricing (price differential options).
pub mod spread;

/// Quanto option pricing (currency-protected options).
pub mod quanto;

/// Black-Scholes model for option pricing and analysis.
///
/// This module implements the Black-Scholes-Merton model for European option pricing
Expand Down Expand Up @@ -289,6 +292,7 @@ pub use compound::compound_black_scholes;
pub use lookback::lookback_black_scholes;
pub use monte_carlo::monte_carlo_option_pricing;
pub use payoff::{Payoff, PayoffInfo, Profit};
pub use quanto::quanto_black_scholes;
pub use rainbow::rainbow_black_scholes;
pub use spread::spread_black_scholes;
pub use telegraph::{TelegraphProcess, telegraph};
Expand Down
Loading
Loading