Stochastic Differential Modeling Module

class experimentalis.extension.sde.DriftNet(*args, **kwargs)

Bases: Model

This is a drift network form for automatically learning the stochastic drift \(\mu\) from the data rather than manually guessing, as a means to curb the local-minima issue resulting from the naive model.

Parameters:

hidden_units (int) – The number of hidden units (weight + bias) to use in the model, effectively a measure of the model’s complexity.

call(t)
class experimentalis.extension.sde.GBM(initial_value, drift, volatility, drift_bounds=(-1.0, 1.0), volatility_bounds=(1e-06, 2.0))

Bases: IntegratedItoSDEModel

This is a very generic stochastic differential equation (SDE) model in 1D using Geometric Brownian Motion. (GBM) in integrated form.

Example:

# some time-series dataset with inherent randomness
dataset = Dataset(...)

...

model = GBM(
    initial_value = prices[0],
    drift = 1.01e-3,             # very small drift, i.e., predictibility
    drift_bounds = (0,0.1),      # depending on data, drift is usually small
    volatility = 2e-2,           # higher volatility
    volatility_bounds = (0,1)    # volatility can be higher, but this makes sense for the data
)

result = autofit(dataset, model, graphing_options=g_opts)
...    
class experimentalis.extension.sde.IntegratedItoSDEModel(integrated_function, initial_value, param_names, param_values, param_bounds=None)

Bases: Model

This is a base class for implementing various superclass models in the family of stochastic PDEs, as solved via Ito’s lemma, following the equation

\[dS_t = \mu(S_t, t) dt + \sigma(S_t, t) dB_t\]
evaluate(t, *params)

Evaluates the SDE integrated solution with the given parameters.

Parameters:
  • t (NDArray) – Array of times to evaluate on

  • params (float or NDArray) – Parameter values

class experimentalis.extension.sde.LearnedDriftGBM(initial_value, volatility, hidden_units=8, volatility_bounds=(1e-06, 2.0), weight_init_scale=0.1, use_cpu=False)

Bases: Model

This is another implementation of the integrated Geometric Brownian Motion model for a stochastic differential dataset, but in this case, the drift parameter \(\mu\) is learned from the data using machine learning, and only the volatility \(\sigma\) is set manually.

evaluate(t, volatility)

Simultaneously trains the model and evaluates it on the present data.

Parameters:
  • t (float or NDArray) – The time data to evaluate at.

  • volatility (float) – The volatility of the data.

  • weights (NDArray or float) – The current weights of the data.

experimentalis.extension.sde.gbm_function(t, initial_value, drift, volatility)

Implementation of the GBM equation

\[S_t = S_0 \exp\left\{\sigma B_t + \left( \mu - \frac{\sigma^2}{2} \right) t\right\}\]
Parameters:
  • t (NDArray) – The time values to evaluate on

  • initial_value (float) – \(S_0\) The initial value

  • drift\(\mu\) The percentage drift (predictability).

  • volatility (float) – \(\sigma\) The percentage volatility of the dataset.

  • drift_bounds (tuple[float, float] or None) – Optional bounds on the geometric drift.

  • volatility_bounds (tuple[float, float] or None) – Optional bounds on the volatility.