Fix stale date - #89
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #89 +/- ##
==========================================
+ Coverage 88.75% 88.88% +0.12%
==========================================
Files 84 85 +1
Lines 5142 5381 +239
==========================================
+ Hits 4564 4783 +219
- Misses 578 598 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses stale “as of” dates when building volatility surfaces from Yahoo option chains by deriving the reference date from Yahoo’s regularMarketTime when available. It also expands/clarifies put-call parity documentation and standardizes how doc tooling scripts are invoked (via uv run python ...), adding a new utility to record trimmed live-market fixtures.
Changes:
- Use Yahoo’s
regularMarketTimeas the defaultref_datewhen not explicitly provided, reducing stale curve calibration. - Expand and cross-link put-call parity, forward, and discount-factor explanations across API docstrings and tutorials/glossary.
- Replace older executable-script invocations with Python entrypoints under
dev/tools/, and add amake fixturestarget plus debug config.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| quantflow/options/surface.py | Docstring update for spot calibration from short-dated put-call parity. |
| quantflow/options/parity.py | Docstring improvements and LaTeX equation formatting for discount fitting. |
| quantflow/data/yahoo.py | Derive default yield-curve reference date from regularMarketTime. |
| Makefile | Use dev/tools/* Python scripts for docs tasks; add fixtures target. |
| docs/tutorials/volatility_surface.md | Adds clearer narrative for implied forwards and discount calibration from parity. |
| docs/glossary.md | Improves cross-references (e.g., time-to-maturity links) and parity exposition. |
| dev/tools/record_fixtures.py | New CLI tool to record trimmed live-market fixtures (e.g., Yahoo SPX chain). |
| dev/tools/build_examples.py | New helper entrypoint to run example scripts and fail CI on errors. |
| dev/tools/bib2md.py | Update usage/docs path handling for the relocated script. |
| dev/quantflow.dockerfile | Update docs build instructions to the new build-examples command. |
| .vscode/launch.json | Add a debug configuration for recording fixtures. |
| .github/workflows/examples.yml | Update CI to run the new build-examples entrypoint. |
| .github/copilot-instructions.md | Update contributor instructions for rebuilding doc examples. |
| For short-dated options where discount factors are approximately 1, | ||
| put-call parity simplifies to C - P = S - K, so S = C - P + K. | ||
| put-call parity simplifies to `C - P = S - K`, so `S = C - P + K`. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 14 changed files in this pull request and generated no new comments.
Suppressed comments (3)
quantflow/options/surface.py:1447
- The docstring uses Markdown inline code for equations, which won't render as math in the docs. If you want the parity formula to appear as an equation, switch the docstring to a raw string and use a LaTeX equation block (this also avoids Python interpreting sequences like
\bin\begin).
"""Calibrate the spot price from short-dated put-call parity.
For short-dated options where discount factors are approximately 1,
put-call parity simplifies to `C - P = S - K`, so `S = C - P + K`.
This method computes the median implied spot across all put-call pairs
with time to maturity at or below `max_ttm` and updates the spot price.
quantflow/data/yahoo.py:145
loader_from_chain()now supports derivingref_datefromquote.regularMarketTime, butsave_fixture()currently stripsregularMarketTimefrom the saved payload. Fixtures produced viasave_fixture()will therefore still load with a "now" ref date, which undermines the stale-date fix. Consider includingregularMarketTimeinquote_keysand updating the corresponding round-trip test expectation.
symbol = chain.get("underlyingSymbol", "")
quote = chain.get("quote") or {}
if ref_date is None and (market_time := quote.get("regularMarketTime")):
ref_date = datetime.fromtimestamp(market_time, tz=timezone.utc)
ref = ref_date or utcnow()
loader = VolSurfaceLoader(
quantflow/data/yahoo.py:144
- The new behavior of using
quote.regularMarketTimeas the yield-curve reference date whenref_dateis omitted is not covered by the existing Yahoo loader tests. Please add a test that constructs a minimal chain withregularMarketTimeand asserts the resulting loader/surfaceref_datematches that timestamp (UTC).
quote = chain.get("quote") or {}
if ref_date is None and (market_time := quote.get("regularMarketTime")):
ref_date = datetime.fromtimestamp(market_time, tz=timezone.utc)
ref = ref_date or utcnow()
No description provided.