quantdata.dysanos.grid.gendysanos.expiry_arbitrage#

Expiry-separated conditional-arbitrage models and diagnostics.

Each expiry is an independent market containing its matched spot instrument and the 20 option strikes. No action or objective combines instruments from different expiries. Within one expiry the path P&L is

X_e = sum_t a_e(t, x_t)' R_e(t) - |a_e(t, x_t)|' c_e(t).

The helpers in this module implement three searches for the action a_e:

  • a generic lower bound over the complete piecewise-linear terminal-payoff cone;

  • maximum mean subject to a zero negative-part constraint; and

  • a power-exponential optimized certainty equivalent (OCE).

All searches use the same radial L1 map. An exterior quadratic penalty acts on the unconstrained output, so an output outside the unit ball retains a radial gradient back towards feasibility.

class quantdata.dysanos.grid.gendysanos.expiry_arbitrage.ExpiryActionNetwork(env, *, config, state_mean, state_scale)[source]#

Bases: BaseModel

One independent action network per expiry with a radial L1 budget.

zero_output_layers()[source]#

Start at no trade while retaining gradients in the final maps.

forward(state)[source]#

Forward method.

Parameters:
  • data (dict) – Input data dictionary containing tensors for the model. The expected keys and tensor shapes depend on the specific model implementation.

  • training (bool, default False) – Whether the model is in training mode.

  • return_what (BaseModel.ReturnWhat, default ReturnWhat.LOSS_WEIGHT) – Specifies what the model should return. Options are: - ReturnWhat.LOSS_WEIGHT: return float loss (with gradient) and float weight (without gradient) for training. - ReturnWhat.VALUATION: return loss, weight and a dictionary of additional float metrics. - ReturnWhat.PATHWISE: return pathwise metrics as dictionary.

class quantdata.dysanos.grid.gendysanos.expiry_arbitrage.ExpiryArbitrageConfig(*, label, state_features, trading_times=10, expiries=7, instruments_per_expiry=21, group='', user_version='0.1', method='negative-part', hedge='delta', cost_rate=0.0001, lmbda=1.0, raw_norm_penalty=1.0, network_config=FeedForwardConfig(activation='LeakyReLU', num_depth=2, num_width=128, use_bias=True))[source]#

Bases: object

Logical configuration of an expiry-separated conditional policy.

trading_times: int = 10#
expiries: int = 7#
instruments_per_expiry: int = 21#
group: str = ''#
user_version: str = '0.1'#
method: Literal['payoff-cone', 'negative-part', 'powerexp-oce'] = 'negative-part'#
hedge: Literal['raw', 'delta'] = 'delta'#
cost_rate: float = 0.0001#
lmbda: float = 1.0#
raw_norm_penalty: float = 1.0#
network_config: FeedForwardConfig = FeedForwardConfig(activation='LeakyReLU', num_depth=2, num_width=128, use_bias=True)#
property filename: str#
class quantdata.dysanos.grid.gendysanos.expiry_arbitrage.ExpiryArbitrageModel(env, *, config, state_mean, state_scale)[source]#

Bases: BaseModel

Expiry-separated action model with optional OCE cash offsets.

actions(state)[source]#

Return feasible actions, raw norms, and the exterior cap penalty.

forward(state)[source]#

Delegate module calls to actions() for torch.compile.

class quantdata.dysanos.grid.gendysanos.expiry_arbitrage.ExpiryArbitrageTrainConfig(*, batch_size=4096, valuation_batch_size=16384, epochs=30000, minimum_epochs=5000, value_update=500, checkpoint_update=2000, lr=0.0003, weight_decay=0.0, compile=True, augmented_rho=100.0, feasibility_tolerance=1e-10, convergence_points=8, convergence_relative_tolerance=0.0002, seed=82061)[source]#

Bases: object

Operational settings which may warm-start the same logical model.

batch_size: int = 4096#
valuation_batch_size: int = 16384#
epochs: int = 30000#
minimum_epochs: int = 5000#
value_update: int = 500#
checkpoint_update: int = 2000#
lr: float = 0.0003#
weight_decay: float = 0.0#
compile: bool = True#
augmented_rho: float = 100.0#
feasibility_tolerance: float = 1e-10#
convergence_points: int = 8#
convergence_relative_tolerance: float = 0.0002#
seed: int = 82061#
quantdata.dysanos.grid.gendysanos.expiry_arbitrage.exact_payoff_cone_lower_bound(action, *, spot, option_price, delta, cash_strike, costs, hedge)[source]#

Return time/path worst-case bounds and upper-tail slopes.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.expiry_portfolio_pnl(action, returns, costs)[source]#

Return trading-time and path P&L for expiry-separated actions.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.payoff_cone_values(action, *, spot, option_price, delta, cash_strike, costs, hedge)[source]#

Return payoff at every kink and the upper-tail portfolio slope.

Terminal spot is restricted to [0, infinity). The P&L is piecewise linear, so its finite minimum is attained at zero or at a cash strike, provided the upper-tail slope is nonnegative. The returned scenario axis contains exactly those points. The first instrument is the matched spot; the remaining instruments are calls ordered by strike.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.payoff_cone_numerical_band(action, *, spot, option_price, delta, cash_strike, costs, hedge, roundoff_multiplier=32.0)[source]#

Propagate float32 operand error through one payoff-cone action.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.powerexp_oce_by_expiry(model, path_pnl, path_weight)[source]#

Return weighted OCE values and both first-order residuals by expiry.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.propagated_expiry_band(action, returns, costs, instrument_band, *, roundoff_multiplier=32.0)[source]#

Propagate float32 instrument bands through time and each expiry.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.smooth_payoff_cone_lower_bound(action, *, spot, option_price, delta, cash_strike, costs, hedge, temperature)[source]#

Differentiable, zero-preserving soft minimum used only during fitting.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.solve_payoff_cone_lp(*, spot, option_price, delta, cash_strike, costs, hedge)[source]#

Solve one observable-state payoff-cone separation problem exactly.

The linear program maximizes the worst terminal P&L over all spot values in [0,infinity) subject to an L1 action budget. Long and short notionals are separate nonnegative variables. No realized future return is used.

quantdata.dysanos.grid.gendysanos.expiry_arbitrage.weighted_expiry_mean(value, path_weight)[source]#

Return N**-1 sum_r (p/q)_r value_r for every expiry.