From 0f002f347875a5e0309b374c4fafe6b7203713e2 Mon Sep 17 00:00:00 2001 From: Gourav Kumar Date: Fri, 29 Apr 2022 07:42:39 +0530 Subject: [PATCH] added mean() method --- fincal/fincal.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fincal/fincal.py b/fincal/fincal.py index f4d1bfa..0b34c43 100644 --- a/fincal/fincal.py +++ b/fincal/fincal.py @@ -476,7 +476,7 @@ class TimeSeries(TimeSeriesCore): Only used when annualizing volatility for a time series with daily frequency. If not provided, will use the value in FincalOptions.traded_days. - Remaining options are passed on to rolling_return function. + Remaining options are passed on to calculate_rolling_returns function. Returns: ------- @@ -715,6 +715,7 @@ class TimeSeries(TimeSeriesCore): This will ensure that both time series have the same frequency and same set of dates. The frequency will be set to the higher of the two objects. Dates will be taken from the class on which the method is called. + Values will be taken from the other class. Parameters: ----------- @@ -751,6 +752,11 @@ class TimeSeries(TimeSeriesCore): return self.__class__(new_other, frequency=other.frequency.symbol) + def mean(self) -> float: + """Calculates the mean value of the time series data""" + + return statistics.mean(self.values) + def _preprocess_csv(file_path: str | pathlib.Path, delimiter: str = ",", encoding: str = "utf-8") -> List[list]: """Preprocess csv data"""