Redesing `evaluate` interface for dispatch, modularity and extensibility
Motivation
The current package supports a variety of financial models (e.g., Black-Scholes, Heston, Vasicek) and instruments (e.g., European Options, American Options, FX Options), but tightly couples them via a shared evaluate function. This design limits flexibility and maintainability, making it difficult to:
- Add new pricing models without changing existing instrument code
- Add new financial instruments without altering model implementations
- Handle diverse market data inputs in a consistent way
- Introduce model calibration or validation workflows
- Test components independently
Proposal: Abstract Interfaces
To decouple components and improve extensibility, we propose defining a set of abstract interfaces:
abstract type FinancialInstrument end
abstract type PricingModel end
abstract type PricingEngine end
abstract type MarketData end
Required Methods
All models and instruments should implement:
required_parameters(::Type{T}) where T <: Union{FinancialInstrument, PricingModel}
validate_parameters(x::Union{FinancialInstrument, PricingModel})
price(engine::PricingEngine, instrument::FinancialInstrument, model::PricingModel, market_data::MarketData)
Type Hierarchy
Instruments
- Options:
EuropeanOption,AmericanOption,BarrierOption,BinaryOption,FXOption, etc. - Forwards/Futures:
EquityForward,FXForward,InterestRateFuture, etc. - Swaps:
InterestRateSwap,CrossCurrencySwap,EquitySwap - Bonds:
FixedRateBond,FloatingRateBond,ZeroCouponBond - Credit Derivatives:
CreditDefaultSwap,CreditSpreadOption
Market Data
EquityMarketDataInterestRateMarketDataFXMarketData
Pricing Engines
BlackScholesEngineHestonEngineBinomialEngineMonteCarloEngineFiniteDifferenceEngine
Models
BlackScholesModelHestonModelBinomialModelCoxRossRubinsteinModelJarrowRuddModelLeisenReimerModel
Benefits
-
Modularity: Models and instruments are decoupled, enabling easier maintenance and extension.
-
Testability: Components can be tested independently.
-
Consistency: Unified interface for handling market data and validation.
-
Extensibility: New capabilities can be added easily, such as:
- Model calibration
- Sensitivity and risk analysis
- Integration with external market data feeds
- Support for custom pricing engines