Skip to content

fix(tests,docs): chain fixtures + doc link (0.16.1)#384

Merged
joaquinbejar merged 1 commit into
mainfrom
hotfix/chain-tests-and-doc-warning
Apr 19, 2026
Merged

fix(tests,docs): chain fixtures + doc link (0.16.1)#384
joaquinbejar merged 1 commit into
mainfrom
hotfix/chain-tests-and-doc-warning

Conversation

@joaquinbejar
Copy link
Copy Markdown
Owner

Summary

  • Replace `get_tomorrow_formatted()` with `get_x_days_formatted(30)` in the three `create_test_option_chain` helpers in `src/chains/chain.rs`. `Actual365Fixed::day_count` in `expiration_date 0.2.0` truncates to integer days, so tomorrow's fixed 18:30 UTC expiry evaluated after that time of day collapsed to `t = 0` and broke every Black-Scholes-driven chain axis. 30 days puts every fixture well above the integer-truncation boundary regardless of execution time.
  • `constants.rs`: `MAX_NEWTON_ITER` no longer intra-doc-links the crate-private `MAX_ITERATIONS_IV`; prose mention only — `cargo doc --no-deps` now emits zero warnings.
  • Bump to `0.16.1`, update `CHANGELOG.md`.

Root cause

`cargo test --lib chains::chain::tests_basic_curves::test_curve_price_short_put` was failing depending on time of day:
```
[0] strike=90, iv=0.2, expiration=DateTime(2026-04-20T18:30:00Z), t2e=Ok(0)
[0] bs err: Pricing error using method 'unknown': Input validation error: Invalid time 0: Expiration date cannot be zero
```

Upstream `Actual365Fixed::day_count`:
```rust
Ok(duration.num_days() as f64) // integer truncation → 0 for sub-24h
```

Previous fixtures built a chain with tomorrow 18:30 UTC expiry, which is <24h away after 18:30 UTC today, yielding `t = 0` and breaking every BS-driven axis. Also fires up the 4 persistent failures on the coverage job.

Test plan

  • `cargo test --lib --all-features` — 3760 passed, 0 failed.
  • `cargo clippy --all-targets --all-features -- -D warnings` clean.
  • `cargo fmt --all --check`.
  • `cargo doc --no-deps --lib --all-features` — 0 warnings.

- Replace `get_tomorrow_formatted()` with `get_x_days_formatted(30)`
  in the three `create_test_option_chain` helpers in
  `src/chains/chain.rs`. `Actual365Fixed::day_count` in the
  `expiration_date` 0.2.0 crate truncates to integer days, so a
  chain whose expiration is tomorrow's fixed 18:30 UTC evaluated
  after that time of day collapsed to `t = 0` and broke every
  Black-Scholes-driven axis. Tests affected:
  `test_curve_multiple_axes`, `test_curve_price_short_put`,
  `test_surface_different_greeks`, `test_vanna_surface`. 30 days
  puts every fixture well above the integer-truncation boundary
  regardless of execution time.

- `constants.rs`: `MAX_NEWTON_ITER` no longer intra-doc-links to
  the crate-private `MAX_ITERATIONS_IV`; the doc just names the
  counterpart in prose, so `cargo doc --no-deps` emits zero
  warnings.

- Bump to `0.16.1` and document the hot-fix in `CHANGELOG.md`.
@joaquinbejar joaquinbejar merged commit 594164b into main Apr 19, 2026
13 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/chains/chain.rs 85.09% <ø> (-0.31%) ⬇️
src/constants.rs 95.23% <ø> (ø)

... and 3 files with indirect coverage changes

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

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.

1 participant