Module 13Pricing EngineLesson 3 of 720 min
Pricer Trait Pattern
Abstract BS vs MC behind one interface.
Pattern
rust
trait Pricer { fn price(&self, opt: &OptionSpec) -> f64; }Why
Swap models, unit test with stubs, hang Greeks later.
Challenge
Add price method returning a dummy 1.0 for both.
Tips
- dyn Trait for heterogeneous
- Generics when monomorphize
- Real systems use this
Try it live
Pricer Trait PatternRust 2021
Loading editor…
Output
Press Run to compile and execute.