multi_resolutionΒΆ
Defined in fynance.features.engineering
- multi_resolution(func, X, windows, **kwargs)[source]
Stack a window-based feature computed at several resolutions.
Applies
func(X, w, **kwargs)for every windowwinwindowsand column-stacks the results, letting a model learn the relevant horizon instead of fixing one.- Parameters:
- funccallable
A feature function taking
(X, w, **kwargs)(e.g.sma,realized_volatility).- Xnp.ndarray
One-dimensional input series.
- windowsiterable of int
Window sizes / resolutions.
- **kwargs
Extra keyword arguments forwarded to
func.
- Returns:
- np.ndarray
Array of shape
(len(X), len(windows)), one column per resolution.
Examples
>>> import numpy as np >>> from fynance.features.momentums import sma >>> X = np.arange(1., 6.) >>> multi_resolution(sma, X, [2, 3]).shape (5, 2)