Paths#

class quantflow.ta.paths.Paths(*, t: float, data: ndarray[tuple[int, ...], dtype[floating[Any]]])#

Paths of a stochastic process

This is the output from a simulation of a stochastic process.

Methods:

as_datetime_df

Paths as pandas DataFrame with datetime index

cross_section

Cross section of paths at time t

dates

Dates of paths as a pandas DatetimeIndex

hurst_exponent

Estimate the Hurst exponent from all paths

integrate

Integrate paths

mean

Paths cross-section mean

normal_draws

Generate normal draws

path

Path i

paths_mean

mean for each path

paths_std

standard deviation for each path

paths_var

variance for each path

pdf

Probability density function of paths

plot

Plot paths

std

Paths cross-section standard deviation

var

Paths cross-section variance

Attributes:

data

Paths of the stochastic process

df

Paths as pandas DataFrame

dt

Time step

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

samples

Number of samples

t

Time horizon - the unit of time is not specified

time

Time as numpy array

time_steps

Number of time steps

xs

Time as list of list (for visualization tools)

ys

Paths as list of list (for visualization tools)

as_datetime_df(*, start: datetime | None = None, unit: str = 'd') DataFrame#

Paths as pandas DataFrame with datetime index

cross_section(t: float | None = None) ndarray[tuple[int, ...], dtype[floating[Any]]]#

Cross section of paths at time t

dates(*, start: datetime | None = None, unit: str = 'd') DatetimeIndex#

Dates of paths as a pandas DatetimeIndex

hurst_exponent(steps: int | None = None) float#

Estimate the Hurst exponent from all paths

Parameters:

steps – number of lags to consider, if not provided it uses half of the time steps capped at 100

integrate() Paths#

Integrate paths

mean() ndarray[tuple[int, ...], dtype[floating[Any]]]#

Paths cross-section mean

classmethod normal_draws(paths: int, time_horizon: float = 1, time_steps: int = 1000, antithetic_variates: bool = True) Paths#

Generate normal draws

Parameters:
  • paths – number of paths

  • time_horizon – time horizon

  • time_steps – number of time steps to arrive at horizon

  • antithetic_variates – whether to use antithetic variates

path(i: int) ndarray[tuple[int, ...], dtype[floating[Any]]]#

Path i

paths_mean(*, scaled: bool = False) ndarray[tuple[int, ...], dtype[floating[Any]]]#

mean for each path

If scaled is True, the mean is scaled by the time step

paths_std(*, scaled: bool = False) ndarray[tuple[int, ...], dtype[floating[Any]]]#

standard deviation for each path

If scaled is True, the standard deviation is scaled by the square root of the time step

paths_var(*, scaled: bool = False) ndarray[tuple[int, ...], dtype[floating[Any]]]#

variance for each path

If scaled is True, the variance is scaled by the time step

pdf(t: float | None = None, num_bins: int | None = None, delta: float | None = None, symmetric: float | None = None) DataFrame#

Probability density function of paths

Calculate a DataFrame with the probability density function of the paths at a given cross section of time. By default it take the last section.

Parameters:
  • t – time at which to calculate the pdf

  • num_bins – number of bins

  • delta – optional size of bins (cannot be set with num_bins)

  • symmetric – optional center of bins

plot(**kwargs: Any) Any#

Plot paths

It requires plotly installed

std() ndarray[tuple[int, ...], dtype[floating[Any]]]#

Paths cross-section standard deviation

var() ndarray[tuple[int, ...], dtype[floating[Any]]]#

Paths cross-section variance

data: FloatArray#

Paths of the stochastic process

property df: DataFrame#

Paths as pandas DataFrame

property dt: float#

Time step

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property samples: int#

Number of samples

t: float#

Time horizon - the unit of time is not specified

property time: ndarray[tuple[int, ...], dtype[floating[Any]]]#

Time as numpy array

property time_steps: int#

Number of time steps

property xs: list[ndarray]#

Time as list of list (for visualization tools)

property ys: list[list[float]]#

Paths as list of list (for visualization tools)