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:
Paths as pandas DataFrame with datetime index
Cross section of paths at time t
Dates of paths as a pandas DatetimeIndex
Estimate the Hurst exponent from all paths
Integrate paths
Paths cross-section mean
Generate normal draws
Path i
mean for each path
standard deviation for each path
variance for each path
Probability density function of paths
Plot paths
Paths cross-section standard deviation
Paths cross-section variance
Attributes:
Paths of the stochastic process
Paths as pandas DataFrame
Time step
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Number of samples
Time horizon - the unit of time is not specified
Time as numpy array
Number of time steps
Time as list of list (for visualization tools)
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
- 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)