quantdata.dysanos.grid.torch_model#

SANOS (Torch)#

Fitting the DLVs of SANOS.

class quantdata.dysanos.grid.torch_model.SanosModelConfig(label='', group='', user_version='0.1', decoder_config=SanosDecoderConfig(smoothness=None, num_state=20, num_nms=20, learn_nms=False, nms_range=(-2, 1), nms_eps=None, min_dlv=0.009, max_dlv=3.0, min_fvol=0.01, max_fvol=2.0, nn_config=FeedForwardConfig(activation='Softplus', num_depth=0, num_width=16, use_bias=True), _xnms_scale=2.0), encoder_config=FeedForwardConfig(activation='Softplus', num_depth=0, num_width=16, use_bias=True), min_vega_sqrt=0.0001, scale_by_weights='sample', seed=213123123)[source]#

Bases: object

label: str = ''#
group: str = ''#
user_version: str = '0.1'#
decoder_config: SanosDecoderConfig = SanosDecoderConfig(smoothness=None, num_state=20, num_nms=20, learn_nms=False, nms_range=(-2, 1), nms_eps=None, min_dlv=0.009, max_dlv=3.0, min_fvol=0.01, max_fvol=2.0, nn_config=FeedForwardConfig(activation='Softplus', num_depth=0, num_width=16, use_bias=True), _xnms_scale=2.0)#
encoder_config: FeedForwardConfig = FeedForwardConfig(activation='Softplus', num_depth=0, num_width=16, use_bias=True)#
min_vega_sqrt: float = 0.0001#
scale_by_weights: str = 'sample'#
seed: int = 213123123#
property smoothness: float | None#
property num_state: int#
property qualified_label: str#
property label_str: str#
property obj_str: str#
create(env, *, num_expiries, num_market_strikes)[source]#

Create Model

torch_data(env, market, *, pool_config=<cdxcore.jcpool.JCPoolConfig object>, message_context=None, verbose=<cdxcore.verbose.Context object>)[source]#

Preprocessing training data set.

This function returns a full formed training data set to be passed to the model, all on torch. The env environent defines the device, debugging, and the floating point precision.

Parameters:
  • env (BaseEnvironment) – The torch environment to use for the model.

  • market (PrettyObject) – The market definition or market data to use for the model. Contains with grid_market_def an attribute of type GridMarketDefinition.

  • pool_config (PoolConfig, default PoolConfig.off().) – The pool configuration to use for loading the market data. Default is PoolConfig.off().

  • message_context (str|callable[[], str]|None, default None) – The message context to use for error messages. If None, no additional message context will be used.

  • verbose (Context, default Context.all) – The verbosity context to use for logging.

class quantdata.dysanos.grid.torch_model.SanosModel(env, num_expiries, num_market_strikes, *, config)[source]#

Bases: BaseModel

NUM_FEATURES = 7#
property label: str#
property qualified_label: str#
property smoothness: float | None#
property num_state: int#
build_default_features(data, *, training=False)[source]#

Compute feature block

__call__(data, *, state=None, training=False)[source]#

Run Training or valuation In valuation mode, this function returns a dictionary with the following keys: - loss: the loss value - raw_errors: the raw errors (S, T, N) - errors: the errors (S, T, N) - fits: the fitted prices (S, T, N) - fit_vols: the fitted volatilities (S, T, N) - state: the state (S, num_state) - dlvsqs: the dlvsqs (S, T, N) - sqrtVars: the sqrtVars (S, T) - calls: the calls (S, T, N) - xstrikes: the xstrikes (S, T, N+2) - xnms: the xnms (S, N+2) - xdensities: the xdensities (S, T, N+2) - xdensity0: the xdensity0 (S, N+2) - expiries: the expiries (S, T)

create_paths(spots, expiries, price_dt, state, *, with_vols=False, verbose=<cdxcore.verbose.Context object>)[source]#

Create a universe of calls and vols from a ‘state’. If dt is not None, then this function expects the expiries to be the expiries at time t, and will differences with call prices at t+dt. In this case ‘dt’ cannot cross an expiry or be more than the first expiry (because the function then needs a past spot to value an option).

If dt is None, then this function does not compute price returns.