quantdata.dysanos.grid.rndysanos.direct_arbitrage#
State-conditional direct-arbitrage policies and certification.
The policy sees only the current state z. A softmax chooses a long/short
direction while a separate sigmoid gate chooses gross exposure. Thus long
and short positions are represented separately and
sum(long + short) <= 1.
For realized return dH and effective one-way cost c, net return is
(long - short) @ dH - (long + short) @ c.
Population almost-sure nonnegativity cannot be proved from Monte Carlo data. The certification helpers therefore report every validation loss and use paths, rather than path-time observations, as independent clusters.
- class quantdata.dysanos.grid.rndysanos.direct_arbitrage.DirectArbitrageConfig(*, label, state_features, instruments, group='', user_version='0.1', epsilon=0.01, delta=0.01, numerical_tolerance=0.0001, smooth_temperature=0.0025, tail_fraction=0.01, downside_weight=10.0, tail_weight=100.0, overlap_weight=1.0, mean_reward_weight=0.1, discovery_fraction=0.05, constraint_ramp_fraction=0.45, initial_trade_fraction=0.01, mask_arbitrage_candidates=False, objective='simplex-soft-hit', cap_weight=1.0, seed=70771, network_config=FeedForwardConfig(activation='LeakyReLU', num_depth=2, num_width=100, use_bias=True))[source]#
Bases:
objectLogical policy, economic threshold, and constrained-loss configuration.
- network_config: FeedForwardConfig = FeedForwardConfig(activation='LeakyReLU', num_depth=2, num_width=100, use_bias=True)#
- class quantdata.dysanos.grid.rndysanos.direct_arbitrage.DirectArbitrageTrainConfig(*, batch_size=1024, valuation_batch_size=4096, lr=0.001, final_lr=1e-06, weight_decay=0.0001, compile=True, value_update=10000, checkpoint_update=10000, checkpoint_root='~/.cache/rndysanos/direct-arbitrage')[source]#
Bases:
objectOperational configuration for direct-policy optimization.
- class quantdata.dysanos.grid.rndysanos.direct_arbitrage.DirectArbitrageTrainingResult(policy, training, validation, tracker, checkpoint_path, restarted)[source]#
Bases:
objectTrained policy, complete valuations, and restart metadata.
- class quantdata.dysanos.grid.rndysanos.direct_arbitrage.LongShortSimplexPolicy(env, *, config, state_mean, state_scale)[source]#
Bases:
BaseModelState-only long/short direction and independent scalar exposure gate.
- forward(z, excluded_directions=None)[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, defaultReturnWhat.LOSS_WEIGHT) – Specifies what the model should return. Options are: -ReturnWhat.LOSS_WEIGHT: return floatloss(with gradient) and floatweight(without gradient) for training. -ReturnWhat.VALUATION: returnloss,weightand a dictionary of additional float metrics. -ReturnWhat.PATHWISE: return pathwise metrics as dictionary.
- class quantdata.dysanos.grid.rndysanos.direct_arbitrage.RadialL1Policy(env, *, config, state_mean, state_scale)[source]#
Bases:
BaseModelV2.0 policy with one unbounded signed output and radial L1 clipping.
- quantdata.dysanos.grid.rndysanos.direct_arbitrage.direct_arbitrage_loss(*, long, short, dH, cost, config, penalty_scale=1.0)[source]#
Reward threshold hits while heavily penalizing mean and tail downside.
- quantdata.dysanos.grid.rndysanos.direct_arbitrage.effective_cost(data, *, bar_c, cost_prop, conditional_variance_model, n_cost, batch_size)[source]#
Materialize
max(c_cond, bar_c, c_prop)without retaining gradients.
- quantdata.dysanos.grid.rndysanos.direct_arbitrage.net_return(*, long, short, dH, cost)[source]#
Return net P&L for separate long and short allocations.
- quantdata.dysanos.grid.rndysanos.direct_arbitrage.state_normalization(data, *, batch_size)[source]#
Return training-only state mean and population standard deviation.
- quantdata.dysanos.grid.rndysanos.direct_arbitrage.train_direct_policy(training, validation, *, config, train_config, epochs, env, restart=False)[source]#
Train a direct policy and atomically checkpoint resumable optimizer state.
- quantdata.dysanos.grid.rndysanos.direct_arbitrage.unconditional_cost(data, *, cost_uncond, batch_size)[source]#
Return the full-training population standard error per instrument.