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- 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)#
- 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
envenvironent 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 withgrid_market_defan attribute of typeGridMarketDefinition.pool_config (
PoolConfig, defaultPoolConfig.off().) – The pool configuration to use for loading the market data. Default isPoolConfig.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, defaultContext.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#
- __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
dtis not None, then this function expects theexpiriesto 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
dtis None, then this function does not compute price returns.