Module 8Data & TestingLesson 5 of 720 min
Testing Quant Code
Approx equality, put-call parity checks, regression fixtures mindset.
Unit tests (local)
rust
#[cfg(test)]
mod tests {
#[test]
fn parity() { ... }
}Floats
Never == on computed floats. Use abs epsilon.
Properties
C-P = S-K at expiry for undiscounted vanilla payoffs.
Challenge
Property: call_payoff always >= 0 for sampled spots.
Tips
- cargo test offline
- epsilon compares
- Snapshot known BS values
Try it live
Testing Quant CodeRust 2021
Loading editor…
Output
Press Run to compile and execute.