test: add property-based testing with proptest - Issue #222 #263
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add property-based tests using proptest to verify mathematical invariants across a wide range of inputs.
New Tests (12 total)
Put-Call Parity Tests (6 tests)
test_put_call_parity: Verify C - P = S - K*e^(-rT)test_call_price_non_negative: Call prices >= 0test_put_price_non_negative: Put prices >= 0test_call_price_increases_with_spot: Positive delta behaviortest_put_price_decreases_with_spot: Negative delta behaviorGreeks Bounds Tests (6 tests)
test_call_delta_bounds: Delta in [0, 1]test_put_delta_bounds: Delta in [-1, 0]test_gamma_non_negative: Gamma >= 0test_vega_non_negative: Vega >= 0 for long optionstest_call_put_same_gamma: Call/put gamma equalitytest_call_put_same_vega: Call/put vega equalitytest_delta_gamma_relationship: Delta changes with gammaChanges
proptest = "1.5"to dev-dependenciestests/property/directory with test modulesproperty_teststarget to Cargo.tomlRun Tests
cargo test --test property_testsVerification
cargo build- Compiles successfullymake lint-fix- No warningsmake pre-push- All tests passCloses #222