Skip to content

Conversation

@joaquinbejar
Copy link
Owner

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 >= 0
  • test_put_price_non_negative: Put prices >= 0
  • test_call_price_increases_with_spot: Positive delta behavior
  • test_put_price_decreases_with_spot: Negative delta behavior

Greeks 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 >= 0
  • test_vega_non_negative: Vega >= 0 for long options
  • test_call_put_same_gamma: Call/put gamma equality
  • test_call_put_same_vega: Call/put vega equality
  • test_delta_gamma_relationship: Delta changes with gamma

Changes

  • Add proptest = "1.5" to dev-dependencies
  • Create tests/property/ directory with test modules
  • Add property_tests target to Cargo.toml

Run Tests

cargo test --test property_tests

Verification

  • cargo build - Compiles successfully
  • make lint-fix - No warnings
  • make pre-push - All tests pass

Closes #222

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 >= 0
- test_put_price_non_negative: Put prices >= 0
- test_call_price_increases_with_spot: Positive delta
- test_put_price_decreases_with_spot: Negative delta

### Greeks 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 >= 0
- test_vega_non_negative: Vega >= 0 for long options
- test_call_put_same_gamma: Call/put gamma equality
- test_call_put_same_vega: Call/put vega equality
- test_delta_gamma_relationship: Delta changes with gamma

## Changes
- Add proptest 1.5 to dev-dependencies
- Create tests/property/ directory with test modules
- Add property_tests target to Cargo.toml

Closes #217
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joaquinbejar joaquinbejar merged commit ba221c3 into main Jan 12, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Add property-based testing for mathematical invariants

2 participants