You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add allow_non_overlapping parameter for bivariate statistics (#547)
* Add allow_non_overlapping parameter for bivariate statistics cov, corr and ema_cov
Signed-off-by: Adam Glustein <adamglustein@gmail.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
* Remove unused zip dependency
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
---------
Signed-off-by: Adam Glustein <adamglustein@gmail.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
y, interval, min_window, trigger, sampler, reset, weights, False, recalc
292
306
)
293
307
294
-
in_seq=None
295
-
ifxisnoty:
296
-
in_seq=_in_sequence_check(x, y)
297
-
298
308
return (
299
309
series,
300
310
interval,
@@ -308,7 +318,6 @@ def _bivariate_setup(
308
318
weights,
309
319
recalc,
310
320
clear_stat,
311
-
in_seq,
312
321
)
313
322
314
323
@@ -2181,25 +2190,27 @@ def cov(
2181
2190
reset: ts[object] =None,
2182
2191
recalc: ts[object] =None,
2183
2192
min_data_points: int=0,
2193
+
allow_non_overlapping: bool=False,
2184
2194
) ->ts[Union[float, np.ndarray]]:
2185
2195
"""
2186
2196
2187
2197
Returns the covariance between two in-sequence time-series within the given window. If the time-series are of type np.ndarray, the covariance is calculated elementwise.
2188
2198
2189
2199
Inputs
2190
-
x: time series data, of type float or np.ndarray
2191
-
y: time series data, of type float or np.ndarray, which ticks at the same time as x
2192
-
interval: the window interval (either time or tick specified)
2193
-
min_window: the minimum window (either time or tick specified) before statistics are returned. Must be the same type as interval
2194
-
ddof: delta degrees of freedom
2195
-
ignore_na: if True, will treat NaN values as missing data. If False, a NaN present in the window will make the computed statistic NaN as well
2196
-
trigger: another time-series which specifies when you want to recalculate the statistic
2197
-
weights: another time-series which specifies the weights to use on each x value, if a weighted covariance is desired
2198
-
sampler: another time-series which specifies when x should tick. If x ticks when sampler does not, the data is ignored. If sampler ticks when x does not,
2199
-
the data point is treated as NaN
2200
-
reset: another time-series which will clear the data in the window when it ticks
2201
-
recalc: another time-series which triggers a clean recalculation of the window statistic, and in doing so clears any accumulated floating-point error
2202
-
min_data_points: minimum number of current ticks in the interval needed for a valid computation. If there are fewer ticks, NaN is returned.
2200
+
x: time series data, of type float or np.ndarray
2201
+
y: time series data, of type float or np.ndarray, which ticks at the same time as x
2202
+
interval: the window interval (either time or tick specified)
2203
+
min_window: the minimum window (either time or tick specified) before statistics are returned. Must be the same type as interval
2204
+
ddof: delta degrees of freedom
2205
+
ignore_na: if True, will treat NaN values as missing data. If False, a NaN present in the window will make the computed statistic NaN as well
2206
+
trigger: another time-series which specifies when you want to recalculate the statistic
2207
+
weights: another time-series which specifies the weights to use on each x value, if a weighted covariance is desired
2208
+
sampler: another time-series which specifies when x should tick. If x ticks when sampler does not, the data is ignored. If sampler ticks when x does not,
2209
+
the data point is treated as NaN
2210
+
reset: another time-series which will clear the data in the window when it ticks
2211
+
recalc: another time-series which triggers a clean recalculation of the window statistic, and in doing so clears any accumulated floating-point error
2212
+
min_data_points: minimum number of current ticks in the interval needed for a valid computation. If there are fewer ticks, NaN is returned.
2213
+
allow_non_overlapping: if True, discard any ticks of x and y that occur out-of-sync with one another. If False, raise an exception on any out-of-sync ticks.
Returns the correlation between x and y within the given window. If the time-series are of type np.ndarray, the correlation is calculated elementwise.
2550
2561
2551
2562
Inputs
2552
-
x: time series data, of type float or np.ndarray
2553
-
y: time series data, of type float or np.ndarray, which ticks at the same time x ticks
2554
-
interval: the window interval (either time or tick specified)
2555
-
min_window: the minimum window (either time or tick specified) before statistics are returned. Must be the same type as interval
2556
-
ignore_na: if True, will treat NaN values as missing data. If False, a NaN present in the window will make the computed statistic NaN as well
2557
-
trigger: another time-series which specifies when you want to recalculate the statistic
2558
-
weights: another time-series which specifies the weights to use on each x value, if a weighted correlation is desired
2559
-
sampler: another time-series which specifies when x should tick. If x ticks when sampler does not, the data is ignored. If sampler ticks when x does not,
2560
-
the data point is treated as NaN
2561
-
reset: another time-series which will clear the data in the window when it ticks
2562
-
recalc: another time-series which triggers a clean recalculation of the window statistic, and in doing so clears any accumulated floating-point error
2563
-
min_data_points: minimum number of current ticks in the interval needed for a valid computation. If there are fewer ticks, NaN is returned.
2563
+
x: time series data, of type float or np.ndarray
2564
+
y: time series data, of type float or np.ndarray, which ticks at the same time x ticks
2565
+
interval: the window interval (either time or tick specified)
2566
+
min_window: the minimum window (either time or tick specified) before statistics are returned. Must be the same type as interval
2567
+
ignore_na: if True, will treat NaN values as missing data. If False, a NaN present in the window will make the computed statistic NaN as well
2568
+
trigger: another time-series which specifies when you want to recalculate the statistic
2569
+
weights: another time-series which specifies the weights to use on each x value, if a weighted correlation is desired
2570
+
sampler: another time-series which specifies when x should tick. If x ticks when sampler does not, the data is ignored. If sampler ticks when x does not,
2571
+
the data point is treated as NaN
2572
+
reset: another time-series which will clear the data in the window when it ticks
2573
+
recalc: another time-series which triggers a clean recalculation of the window statistic, and in doing so clears any accumulated floating-point error
2574
+
min_data_points: minimum number of current ticks in the interval needed for a valid computation. If there are fewer ticks, NaN is returned.
2575
+
allow_non_overlapping: if True, discard any ticks of x and y that occur out-of-sync with one another. If False, raise an exception on any out-of-sync ticks.
Returns the exponential moving covariance between two time series.
2972
2984
2973
2985
Inputs
2974
-
x: time series data, of type float or np.ndarray
2975
-
y: time series data, of type float or np.ndarray, which ticks at the same time as x
2976
-
min_periods: the minimum number of data points before statistics are returned
2977
-
alpha: specify the decay parameter in terms of alpha
2978
-
span: specify the decay parameter in terms of span
2979
-
com: specify the decay parameter in terms of com
2980
-
halflife: specify the decay parameter in terms of halflife
2981
-
adjust: if True, an adjusted EMA will be computed. If False, a standard (unadjusted) EMA will be computed
2982
-
horizon: if specified, values that are older than the horizon will be removed entirely from the computation (essentially making EMA a window computation)
2983
-
bias: if True, a biased EMA covariance is computed. If False, the covariance estimate is unbiased
2984
-
ignore_na: if True, NaNs will be ignored and have no effect on the computation. If False, a NaN will shift the observation window once new non-NaN data comes in
2985
-
trigger: another time-series which specifies when you want to recalculate the statistic
2986
-
sampler: another time-series which specifies when x should tick. If x ticks when sampler does not, the data is ignored. If sampler ticks when x does not,
2987
-
the data point is treated as NaN
2988
-
reset: another time-series which will clear the data in the window when it ticks
2989
-
recalc: only valid when a finite-horizon EMA is used. Another time-series which triggers a clean recalculation of the window statistic, and in doing so clears any accumulated floating-point error
2990
-
min_data_points: minimum number of current ticks in the interval needed for a valid computation. If there are fewer ticks, NaN is returned.
2986
+
x: time series data, of type float or np.ndarray
2987
+
y: time series data, of type float or np.ndarray, which ticks at the same time as x
2988
+
min_periods: the minimum number of data points before statistics are returned
2989
+
alpha: specify the decay parameter in terms of alpha
2990
+
span: specify the decay parameter in terms of span
2991
+
com: specify the decay parameter in terms of com
2992
+
halflife: specify the decay parameter in terms of halflife
2993
+
adjust: if True, an adjusted EMA will be computed. If False, a standard (unadjusted) EMA will be computed
2994
+
horizon: if specified, values that are older than the horizon will be removed entirely from the computation (essentially making EMA a window computation)
2995
+
bias: if True, a biased EMA covariance is computed. If False, the covariance estimate is unbiased
2996
+
ignore_na: if True, NaNs will be ignored and have no effect on the computation. If False, a NaN will shift the observation window once new non-NaN data comes in
2997
+
trigger: another time-series which specifies when you want to recalculate the statistic
2998
+
sampler: another time-series which specifies when x should tick. If x ticks when sampler does not, the data is ignored. If sampler ticks when x does not,
2999
+
the data point is treated as NaN
3000
+
reset: another time-series which will clear the data in the window when it ticks
3001
+
recalc: only valid when a finite-horizon EMA is used. Another time-series which triggers a clean recalculation of the window statistic, and in doing so clears any accumulated floating-point error
3002
+
min_data_points: minimum number of current ticks in the interval needed for a valid computation. If there are fewer ticks, NaN is returned.
3003
+
allow_non_overlapping: if True, discard any ticks of x and y that occur out-of-sync with one another. If False, raise an exception on any out-of-sync ticks.
0 commit comments