quantdata.dysanos.implied#

Direct log-implied-volatility PCA benchmark for DYSANOS.

class quantdata.dysanos.implied.ImpliedPCAExperiment(*, num_samples=100000, grid_strikes=100, num_traded_nms=20, num_surface_state=20, num_alpha=5, use_matrix_exp=True, bandwidth=1.0, trading_frequency='daily', return_horizon='expiry', num_trading_times=10, mode=None, option_return_horizon=None, num_steps=None, dt=0.003968253968253968, seed=700000, block_size=10000, importance_sampling=GaussianSpotImportanceConfig(spot_std_multiplier=8.0, base_probability=0.1, target_action_count=3), neighbors=1024, candidate_neighbors=8192, query_paths_per_split=1024, instrument_block_size=20, tail_ranks=(1, 2, 10, 20, 50), signal_thresholds=(2.0, 3.0), cost_proportion=0.0001, roundoff_multipliers=(0, 1, 8, 32, 128), static_mesh_points=201)[source]#

Bases: object

Logical inputs for one PCA-IV-AR(1) simulation and diagnostic run.

The published comparison uses 100,000 or 1,000,000 paths, 20 level components, and either five or all surface innovation factors. Smaller positive path counts remain valid for deterministic smoke tests.

num_samples: int = 100000#
grid_strikes: int = 100#
num_traded_nms: int = 20#
num_surface_state: int = 20#
num_alpha: int | None = 5#
use_matrix_exp: bool = True#
bandwidth: float = 1.0#
trading_frequency: str = 'daily'#
return_horizon: str = 'expiry'#
num_trading_times: int = 10#
mode: str | None = None#
option_return_horizon: str | None = None#
num_steps: int | None = None#
dt: float = 0.003968253968253968#
seed: int = 700000#
block_size: int = 10000#
importance_sampling: GaussianSpotImportanceConfig | None = GaussianSpotImportanceConfig(spot_std_multiplier=8.0, base_probability=0.1, target_action_count=3)#
neighbors: int = 1024#
candidate_neighbors: int = 8192#
query_paths_per_split: int = 1024#
instrument_block_size: int = 20#
tail_ranks: tuple[int, ...] = (1, 2, 10, 20, 50)#
signal_thresholds: tuple[float, ...] = (2.0, 3.0)#
cost_proportion: float = 0.0001#
roundoff_multipliers: tuple[int, ...] = (0, 1, 8, 32, 128)#
static_mesh_points: int = 201#
property fit_config: PCAFitConfig#

The result-affecting subset used by the fitted-PCA cache.

property trading_times: int#
property trading_step_stride: int#
property is_primary_path_count: bool#
property reference_paths: int#

Paths used to fit diagnostic estimators (80% of the universe).

property audit_paths: int#

Held-out paths used only to audit fitted diagnostics.

property filename: str#

Stable identity including every logical simulation input.

class quantdata.dysanos.implied.ImpliedPCASampler(*, pca, scores, time_y, spot_ref, num_alpha, seed, rescale_variance=False, verbose=<cdxcore.verbose.Context object>)[source]#

Bases: ARSampler

Adapt direct PCA scores to the shared DYSANOS AR/importance sampler.

The surface block is fitted first and is autonomous. Log-spot is appended only after that fit, with one orthogonal spot residual retained regardless of the number of surface innovation factors.

property num_xstate: int#
class quantdata.dysanos.implied.LogIVPCA(*, mean_log_iv, components, explained_variance, explained_variance_ratio, cumulative_explained_variance_ratio, expiries, nms)[source]#

Bases: object

Centered, unweighted PCA representation of log-IV surface levels.

property num_components: int#
property surface_shape: tuple[int, int]#
encode(implied_vols)[source]#

Encode positive IV surfaces whose trailing axes are (T,N).

decode_log_iv(scores)[source]#

Decode PCA scores to log-IV surfaces on the training grid.

decode(scores)[source]#

Decode PCA scores to strictly positive IV grid surfaces.

to_state_dict()[source]#

Return a cache-safe array tree.

classmethod from_state_dict(state)[source]#
class quantdata.dysanos.implied.PCAFitConfig(*, grid_strikes=100, num_surface_state=20, nms_eps=0.000496031746031746, interpolation='linear-total-variance-v1')[source]#

Bases: object

Logical inputs to the direct log-IV PCA representation.

grid_strikes: int = 100#
num_surface_state: int = 20#
nms_eps: float = 0.000496031746031746#
interpolation: str = 'linear-total-variance-v1'#
property filename: str#

Stable cache identity for a fitted PCA representation.

class quantdata.dysanos.implied.PCAFitDiagnostics(*, scores, reconstruction, errors_by_expiry, errors_by_nms_region, first_five_iv_eigensurfaces)[source]#

Bases: object

Reconstruction and eigensurface diagnostics for one PCA fit.

report(model)[source]#
class quantdata.dysanos.implied.PCATotalVarianceDecoder(pca, *, normalized_strikes=None)[source]#

Bases: object

Decode and interpolate a PCA state as a fixed-surface price map.

Total variance is linearly interpolated first in normalized moneyness and then in maturity after adding w(0,z)=0. The normalized-moneyness wings are flat. Maturities outside [0, max(training_expiry)] are rejected.

Relative strikes use NormalizedStrikes with the interpolated ATM volatility at the query maturity. The epsilon-volatility scale is the ATM volatility at the shortest decoded expiry, matching how the historical regular grid is constructed.

grid_implied_vols(scores)[source]#
total_variance(scores, maturities, normalized_moneyness)[source]#

Interpolate decoded total variance at arbitrary (T,z) queries.

relative_strikes_from_nms(scores, maturities, normalized_moneyness)[source]#

Convert NMS coordinates to relative strikes using decoded ATM IV.

nms_from_relative_strikes(scores, maturities, relative_strikes)[source]#

Convert relative strikes to NMS using the decoded ATM IV.

implied_volatility(scores, maturities, relative_strikes)[source]#

Evaluate positive implied volatility at arbitrary fixed strikes.

normalized_call_prices(scores, maturities, relative_strikes)[source]#

Price zero-rate normalized calls from the complete PCA surface.

cash_call_prices(scores, spots, maturities, cash_strikes)[source]#

Price fixed cash-strike contracts as S*c(T,k/S).

cash_deltas(scores, spots, maturities, cash_strikes, *, relative_step=1e-05)[source]#

Differentiate the complete fixed-surface cash price map centrally.

class quantdata.dysanos.implied.StaticArbitrageAccumulator(*, strikes, expiries, roundoff_multipliers=(0, 1, 8, 32, 128), reservoir_size=200000, seed=19731)[source]#

Bases: object

Update exact counts and bounded-memory violation quantiles by blocks.

update(prices, *, normalized_moneyness=None, log_path_weights=None)[source]#
report()[source]#
class quantdata.dysanos.implied.ValidatedPCAMarket(*, dates, time_y, mid_vols, nms, expiries, xstrikes, spot_ref, spot_ret)[source]#

Bases: object

Arrays required to fit and simulate the direct PCA benchmark.

property shape: tuple[int, int, int]#
class quantdata.dysanos.implied.WingHitDiagnostics(*, queries, left_hits, right_hits)[source]#

Bases: object

Counts of flat normalized-moneyness extrapolation.

property total_hits: int#
property hit_fraction: float#
quantdata.dysanos.implied.check_static_arbitrage(prices, *, strikes, expiries, normalized_moneyness=None, roundoff_multipliers=(0, 1, 8, 32, 128))[source]#

Run all static checks and return one exact small-sample report.

quantdata.dysanos.implied.check_sanos_static_control(prices, *, strikes, expiries, normalized_moneyness=None, require_primary_pass=True)[source]#

Evaluate SANOS calls with exactly the same numerical checker.

quantdata.dysanos.implied.fit_log_iv_pca(implied_vols, *, expiries, nms, num_components=20)[source]#

Fit ordinary centered, unweighted PCA to log-IV surface levels.

quantdata.dysanos.implied.validate_pca_market(market)[source]#

Validate the exact historical-grid inputs used by the PCA benchmark.

quantdata.dysanos.implied.write_aggregate_comparison(*, pca_reports, sanos_reports, output)[source]#

Write a configuration-verified side-by-side JSON/Markdown comparison.

Modules#