First successΒΆ

This example is the release-gating public workflow. It creates two observation times, three expiries, five strikes, calls and puts, and an aligned spot series. Prices and Greeks are generated deterministically with Black-Scholes-Merton; there is no random state, network access, credential, or local-data dependency.

From the repository root, run:

python examples/first_success.py

The executable source is included directly below.

 1"""Construct and query a deterministic option panel without data or credentials.
 2
 3This release-gating example reconstructs the first observation, reports its
 4front-expiry ATM volatility, and selects a weekly roll maturity::
 5
 6    python examples/first_success.py
 7"""
 8
 9from enum import Enum
10
11from option_chain_analytics import (
12    NearestStrikeOnGrid,
13    create_chain_at_time,
14    generate_simulated_options_data,
15)
16from option_chain_analytics.utils.roll_maturities import (
17    RollMaturitySelection,
18    get_roll_maturity_slices_at_value_time,
19)
20
21
22class LocalTests(Enum):
23    """Runnable cases for the deterministic first-success example."""
24
25    FIRST_SUCCESS = 1
26
27
28def _run_first_success() -> None:
29    """Construct the deterministic panel and print its core evidence."""
30    options_data = generate_simulated_options_data()
31    value_time = options_data.get_timeindex()[0]
32    chain = create_chain_at_time(options_data=options_data, value_time=value_time)
33    if chain is None:
34        raise RuntimeError('the deterministic panel did not produce a chain')
35
36    first_expiry_id = next(iter(chain.expiry_slices))
37    first_expiry = chain.get_expiry_slice(first_expiry_id)
38    roll_expiries = get_roll_maturity_slices_at_value_time(
39        options_data_dfs=options_data,
40        value_time=value_time,
41        maturity_selection=RollMaturitySelection.WEEKLY_FRIDAY,
42        is_apply_open_interest_filter=False,
43        hour_offset=8,
44    )
45
46    print(f'ticker={options_data.ticker}')
47    print(f'observation_times={len(options_data.get_timeindex())}')
48    print(f'contracts_at_first_time={len(chain.options_df)}')
49    print(f'expiries={list(chain.expiry_slices)}')
50    print(
51        'first_expiry_atm='
52        f'{first_expiry.get_atm_option_strike(NearestStrikeOnGrid.NEAREST):.2f}, '
53        f'vol={first_expiry.get_atm_vol(NearestStrikeOnGrid.NEAREST):.4f}'
54    )
55    print(f'weekly_roll_expiries={roll_expiries}')
56
57
58def run_local_test(local_test: LocalTests) -> None:
59    """Run one selected local example case."""
60    if local_test == LocalTests.FIRST_SUCCESS:
61        _run_first_success()
62    else:
63        raise NotImplementedError(f'unsupported local test: {local_test}')
64
65
66if __name__ == '__main__':
67
68    run_local_test(local_test=LocalTests.FIRST_SUCCESS)

The output must end with a finite ATM strike/volatility and weekly_roll_expiries=['12Jan2024']. Tests also verify deterministic equality, declining time to maturity for the same contracts, quote ordering, and put-call parity.

The synthetic surface is a fixture, not calibrated market data. It is intended for tutorials, visualisations, and integration tests; empirical conclusions require a documented empirical feed.