Compare commits

...

3 Commits

2 changed files with 4 additions and 8 deletions

View File

@ -145,7 +145,7 @@ class TimeSeries(TimeSeriesCore):
res_string: str = "First date: {}\nLast date: {}\nNumber of rows: {}"
return res_string.format(self.start_date, self.end_date, total_dates)
def ffill(self, inplace: bool = False, limit: int = None, skip_weekends: bool = False) -> TimeSeries | None:
def ffill(self, inplace: bool = False, limit: int = 1000, skip_weekends: bool = False) -> TimeSeries | None:
"""Forward fill missing dates in the time series
Parameters
@ -188,7 +188,7 @@ class TimeSeries(TimeSeriesCore):
return self.__class__(new_ts, frequency=self.frequency.symbol)
def bfill(self, inplace: bool = False, limit: int = None, skip_weekends: bool = False) -> TimeSeries | None:
def bfill(self, inplace: bool = False, limit: int = 1000, skip_weekends: bool = False) -> TimeSeries | None:
"""Backward fill missing dates in the time series
Parameters
@ -449,7 +449,7 @@ class TimeSeries(TimeSeriesCore):
prior_match: str = "closest",
closest: Literal["previous", "next", "exact"] = "previous",
if_not_found: Literal["fail", "nan"] = "fail",
annual_compounded_returns: bool = None,
annual_compounded_returns: bool = False,
date_format: str = None,
) -> float:
"""Calculates the volatility of the time series.add()
@ -504,9 +504,6 @@ class TimeSeries(TimeSeriesCore):
if to_date is None:
to_date = self.end_date
if annual_compounded_returns is None:
annual_compounded_returns = False if frequency.days <= 366 else True
rolling_returns = self.calculate_rolling_returns(
from_date=from_date,
to_date=to_date,

View File

@ -30,7 +30,6 @@ def sharpe_ratio(
"from_date": from_date,
"to_date": to_date,
"frequency": frequency,
"annual_compounded_returns": True,
"return_period_unit": return_period_unit,
"return_period_value": return_period_value,
"as_on_match": as_on_match,
@ -38,7 +37,7 @@ def sharpe_ratio(
"closest": closest,
"date_format": date_format,
}
returns_ts = time_series_data.calculate_rolling_returns(**common_params)
returns_ts = time_series_data.calculate_rolling_returns(**common_params, annual_compounded_returns=True)
if risk_free_data is not None:
risk_free_data = returns_ts.sync(risk_free_data)