openseries 1.8.1__tar.gz → 1.8.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openseries
3
- Version: 1.8.1
3
+ Version: 1.8.2
4
4
  Summary: Tools for analyzing financial timeseries.
5
5
  License: # BSD 3-Clause License
6
6
 
@@ -71,14 +71,14 @@ Description-Content-Type: text/markdown
71
71
 
72
72
  [![PyPI version](https://img.shields.io/pypi/v/openseries.svg)](https://pypi.org/project/openseries/)
73
73
  [![Conda Version](https://img.shields.io/conda/vn/conda-forge/openseries.svg)](https://anaconda.org/conda-forge/openseries)
74
- [![Conda platforms](https://img.shields.io/conda/pn/conda-forge/openseries.svg)](https://anaconda.org/conda-forge/openseries)
75
- [![Code Sample](https://img.shields.io/badge/-Code%20Sample-blue)](https://nbviewer.org/github/karrmagadgeteer2/NoteBook/blob/master/openseriesnotebook.ipynb)
74
+ ![Platform](https://img.shields.io/badge/platforms-Windows%20%7C%20macOS%20%7C%20Linux-blue)
76
75
  [![Python version](https://img.shields.io/pypi/pyversions/openseries.svg)](https://www.python.org/)
77
76
  [![GitHub Action Test Suite](https://github.com/CaptorAB/openseries/actions/workflows/test.yml/badge.svg)](https://github.com/CaptorAB/openseries/actions/workflows/test.yml)
78
77
  [![Coverage](https://cdn.jsdelivr.net/gh/CaptorAB/openseries@master/coverage.svg)](https://github.com/CaptorAB/openseries/actions/workflows/test.yml)
79
78
  [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
80
79
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://beta.ruff.rs/docs/)
81
- [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
80
+ [![GitHub License](https://img.shields.io/github/license/CaptorAB/openseries)](https://github.com/CaptorAB/openseries/blob/master/LICENSE.md)
81
+ [![Code Sample](https://img.shields.io/badge/-Code%20Sample-blue)](https://nbviewer.org/github/karrmagadgeteer2/NoteBook/blob/master/openseriesnotebook.ipynb)
82
82
 
83
83
  This is a project with tools to analyze financial timeseries of a single
84
84
  asset or a group of assets. It is solely made for daily or less frequent data.
@@ -6,14 +6,14 @@
6
6
 
7
7
  [![PyPI version](https://img.shields.io/pypi/v/openseries.svg)](https://pypi.org/project/openseries/)
8
8
  [![Conda Version](https://img.shields.io/conda/vn/conda-forge/openseries.svg)](https://anaconda.org/conda-forge/openseries)
9
- [![Conda platforms](https://img.shields.io/conda/pn/conda-forge/openseries.svg)](https://anaconda.org/conda-forge/openseries)
10
- [![Code Sample](https://img.shields.io/badge/-Code%20Sample-blue)](https://nbviewer.org/github/karrmagadgeteer2/NoteBook/blob/master/openseriesnotebook.ipynb)
9
+ ![Platform](https://img.shields.io/badge/platforms-Windows%20%7C%20macOS%20%7C%20Linux-blue)
11
10
  [![Python version](https://img.shields.io/pypi/pyversions/openseries.svg)](https://www.python.org/)
12
11
  [![GitHub Action Test Suite](https://github.com/CaptorAB/openseries/actions/workflows/test.yml/badge.svg)](https://github.com/CaptorAB/openseries/actions/workflows/test.yml)
13
12
  [![Coverage](https://cdn.jsdelivr.net/gh/CaptorAB/openseries@master/coverage.svg)](https://github.com/CaptorAB/openseries/actions/workflows/test.yml)
14
13
  [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
15
14
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://beta.ruff.rs/docs/)
16
- [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
15
+ [![GitHub License](https://img.shields.io/github/license/CaptorAB/openseries)](https://github.com/CaptorAB/openseries/blob/master/LICENSE.md)
16
+ [![Code Sample](https://img.shields.io/badge/-Code%20Sample-blue)](https://nbviewer.org/github/karrmagadgeteer2/NoteBook/blob/master/openseriesnotebook.ipynb)
17
17
 
18
18
  This is a project with tools to analyze financial timeseries of a single
19
19
  asset or a group of assets. It is solely made for daily or less frequent data.
@@ -50,11 +50,11 @@ from pandas import (
50
50
  to_datetime,
51
51
  )
52
52
  from pandas.tseries.offsets import CustomBusinessDay
53
- from plotly.graph_objs import Figure # type: ignore[import-untyped,unused-ignore]
54
- from plotly.io import to_html # type: ignore[import-untyped,unused-ignore]
55
- from plotly.offline import plot # type: ignore[import-untyped,unused-ignore]
53
+ from plotly.graph_objs import Figure # type: ignore[import-untyped]
54
+ from plotly.io import to_html # type: ignore[import-untyped]
55
+ from plotly.offline import plot # type: ignore[import-untyped]
56
56
  from pydantic import BaseModel, ConfigDict, DirectoryPath
57
- from scipy.stats import ( # type: ignore[import-untyped,unused-ignore]
57
+ from scipy.stats import ( # type: ignore[import-untyped]
58
58
  kurtosis,
59
59
  norm,
60
60
  skew,
@@ -73,7 +73,7 @@ from .load_plotly import load_plotly_dict
73
73
 
74
74
 
75
75
  # noinspection PyTypeChecker
76
- class _CommonModel(BaseModel):
76
+ class _CommonModel(BaseModel): # type: ignore[misc]
77
77
  """Declare _CommonModel."""
78
78
 
79
79
  tsdf: DataFrame = DataFrame(dtype="float64")
@@ -88,7 +88,7 @@ class _CommonModel(BaseModel):
88
88
  def length(self: Self) -> int:
89
89
  """Number of observations.
90
90
 
91
- Returns
91
+ Returns:
92
92
  -------
93
93
  int
94
94
  Number of observations
@@ -100,7 +100,7 @@ class _CommonModel(BaseModel):
100
100
  def first_idx(self: Self) -> dt.date:
101
101
  """The first date in the timeseries.
102
102
 
103
- Returns
103
+ Returns:
104
104
  -------
105
105
  datetime.date
106
106
  The first date in the timeseries
@@ -112,7 +112,7 @@ class _CommonModel(BaseModel):
112
112
  def last_idx(self: Self) -> dt.date:
113
113
  """The last date in the timeseries.
114
114
 
115
- Returns
115
+ Returns:
116
116
  -------
117
117
  datetime.date
118
118
  The last date in the timeseries
@@ -124,7 +124,7 @@ class _CommonModel(BaseModel):
124
124
  def span_of_days(self: Self) -> int:
125
125
  """Number of days from the first date to the last.
126
126
 
127
- Returns
127
+ Returns:
128
128
  -------
129
129
  int
130
130
  Number of days from the first date to the last
@@ -136,7 +136,7 @@ class _CommonModel(BaseModel):
136
136
  def yearfrac(self: Self) -> float:
137
137
  """Length of series expressed in years assuming all years have 365.25 days.
138
138
 
139
- Returns
139
+ Returns:
140
140
  -------
141
141
  float
142
142
  Length of the timeseries expressed in years assuming all years
@@ -149,7 +149,7 @@ class _CommonModel(BaseModel):
149
149
  def periods_in_a_year(self: Self) -> float:
150
150
  """The average number of observations per year.
151
151
 
152
- Returns
152
+ Returns:
153
153
  -------
154
154
  float
155
155
  The average number of observations per year
@@ -161,7 +161,7 @@ class _CommonModel(BaseModel):
161
161
  def max_drawdown_cal_year(self: Self) -> float | Series[float]:
162
162
  """https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
163
163
 
164
- Returns
164
+ Returns:
165
165
  -------
166
166
  float | Pandas.Series[float]
167
167
  Maximum drawdown in a single calendar year.
@@ -189,7 +189,7 @@ class _CommonModel(BaseModel):
189
189
  def geo_ret(self: Self) -> float | Series[float]:
190
190
  """https://www.investopedia.com/terms/c/cagr.asp.
191
191
 
192
- Returns
192
+ Returns:
193
193
  -------
194
194
  float | Pandas.Series[float]
195
195
  Compounded Annual Growth Rate (CAGR)
@@ -201,7 +201,7 @@ class _CommonModel(BaseModel):
201
201
  def arithmetic_ret(self: Self) -> float | Series[float]:
202
202
  """https://www.investopedia.com/terms/a/arithmeticmean.asp.
203
203
 
204
- Returns
204
+ Returns:
205
205
  -------
206
206
  float | Pandas.Series[float]
207
207
  Annualized arithmetic mean of returns
@@ -213,7 +213,7 @@ class _CommonModel(BaseModel):
213
213
  def value_ret(self: Self) -> float | Series[float]:
214
214
  """Simple return.
215
215
 
216
- Returns
216
+ Returns:
217
217
  -------
218
218
  float | Pandas.Series[float]
219
219
  Simple return
@@ -228,7 +228,7 @@ class _CommonModel(BaseModel):
228
228
  Based on Pandas .std() which is the equivalent of stdev.s([...]) in MS Excel.
229
229
  https://www.investopedia.com/terms/v/volatility.asp.
230
230
 
231
- Returns
231
+ Returns:
232
232
  -------
233
233
  float | Pandas.Series[float]
234
234
  Annualized volatility
@@ -244,7 +244,7 @@ class _CommonModel(BaseModel):
244
244
  of zero. It is used to calculate the Sortino Ratio.
245
245
  https://www.investopedia.com/terms/d/downside-deviation.asp.
246
246
 
247
- Returns
247
+ Returns:
248
248
  -------
249
249
  float | Pandas.Series[float]
250
250
  Downside deviation
@@ -257,7 +257,7 @@ class _CommonModel(BaseModel):
257
257
  def ret_vol_ratio(self: Self) -> float | Series[float]:
258
258
  """Ratio of annualized arithmetic mean of returns and annualized volatility.
259
259
 
260
- Returns
260
+ Returns:
261
261
  -------
262
262
  float | Pandas.Series[float]
263
263
  Ratio of the annualized arithmetic mean of returns and annualized
@@ -271,7 +271,7 @@ class _CommonModel(BaseModel):
271
271
  def sortino_ratio(self: Self) -> float | Series[float]:
272
272
  """https://www.investopedia.com/terms/s/sortinoratio.asp.
273
273
 
274
- Returns
274
+ Returns:
275
275
  -------
276
276
  float | Pandas.Series[float]
277
277
  Sortino ratio calculated as the annualized arithmetic mean of returns
@@ -290,7 +290,7 @@ class _CommonModel(BaseModel):
290
290
  def omega_ratio(self: Self) -> float | Series[float]:
291
291
  """https://en.wikipedia.org/wiki/Omega_ratio.
292
292
 
293
- Returns
293
+ Returns:
294
294
  -------
295
295
  float | Pandas.Series[float]
296
296
  Omega ratio calculation
@@ -303,7 +303,7 @@ class _CommonModel(BaseModel):
303
303
  def z_score(self: Self) -> float | Series[float]:
304
304
  """https://www.investopedia.com/terms/z/zscore.asp.
305
305
 
306
- Returns
306
+ Returns:
307
307
  -------
308
308
  float | Pandas.Series[float]
309
309
  Z-score as (last return - mean return) / standard deviation of returns.
@@ -315,7 +315,7 @@ class _CommonModel(BaseModel):
315
315
  def max_drawdown(self: Self) -> float | Series[float]:
316
316
  """https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
317
317
 
318
- Returns
318
+ Returns:
319
319
  -------
320
320
  float | Pandas.Series[float]
321
321
  Maximum drawdown without any limit on date range
@@ -329,7 +329,7 @@ class _CommonModel(BaseModel):
329
329
 
330
330
  https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
331
331
 
332
- Returns
332
+ Returns:
333
333
  -------
334
334
  datetime.date | pandas.Series[dt.date]
335
335
  Date when the maximum drawdown occurred
@@ -352,7 +352,7 @@ class _CommonModel(BaseModel):
352
352
  def worst(self: Self) -> float | Series[float]:
353
353
  """Most negative percentage change.
354
354
 
355
- Returns
355
+ Returns:
356
356
  -------
357
357
  float | Pandas.Series[float]
358
358
  Most negative percentage change
@@ -365,7 +365,7 @@ class _CommonModel(BaseModel):
365
365
  def worst_month(self: Self) -> float | Series[float]:
366
366
  """Most negative month.
367
367
 
368
- Returns
368
+ Returns:
369
369
  -------
370
370
  Pandas.Series[float]
371
371
  Most negative month
@@ -396,7 +396,7 @@ class _CommonModel(BaseModel):
396
396
  def positive_share(self: Self) -> float | Series[float]:
397
397
  """The share of percentage changes that are greater than zero.
398
398
 
399
- Returns
399
+ Returns:
400
400
  -------
401
401
  float | Pandas.Series[float]
402
402
  The share of percentage changes that are greater than zero
@@ -408,7 +408,7 @@ class _CommonModel(BaseModel):
408
408
  def skew(self: Self) -> float | Series[float]:
409
409
  """https://www.investopedia.com/terms/s/skewness.asp.
410
410
 
411
- Returns
411
+ Returns:
412
412
  -------
413
413
  float | Pandas.Series[float]
414
414
  Skew of the return distribution
@@ -420,7 +420,7 @@ class _CommonModel(BaseModel):
420
420
  def kurtosis(self: Self) -> float | Series[float]:
421
421
  """https://www.investopedia.com/terms/k/kurtosis.asp.
422
422
 
423
- Returns
423
+ Returns:
424
424
  -------
425
425
  float | Pandas.Series[float]
426
426
  Kurtosis of the return distribution
@@ -432,7 +432,7 @@ class _CommonModel(BaseModel):
432
432
  def cvar_down(self: Self) -> float | Series[float]:
433
433
  """https://www.investopedia.com/terms/c/conditional_value_at_risk.asp.
434
434
 
435
- Returns
435
+ Returns:
436
436
  -------
437
437
  float | Pandas.Series[float]
438
438
  Downside 95% Conditional Value At Risk "CVaR"
@@ -448,7 +448,7 @@ class _CommonModel(BaseModel):
448
448
  The equivalent of percentile.inc([...], 1-level) over returns in MS Excel.
449
449
  https://www.investopedia.com/terms/v/var.asp.
450
450
 
451
- Returns
451
+ Returns:
452
452
  -------
453
453
  float | Pandas.Series[float]
454
454
  Downside 95% Value At Risk (VaR)
@@ -464,7 +464,7 @@ class _CommonModel(BaseModel):
464
464
 
465
465
  Assumes that returns are normally distributed.
466
466
 
467
- Returns
467
+ Returns:
468
468
  -------
469
469
  float | Pandas.Series[float]
470
470
  Implied annualized volatility from the Downside 95% VaR using the
@@ -493,7 +493,7 @@ class _CommonModel(BaseModel):
493
493
  to_dt: datetime.date, optional
494
494
  Specific from date
495
495
 
496
- Returns
496
+ Returns:
497
497
  -------
498
498
  tuple[datetime.date, datetime.date]
499
499
  Start and end date of the chosen date range
@@ -543,14 +543,14 @@ class _CommonModel(BaseModel):
543
543
  countries: CountriesType, default: "SE"
544
544
  (List of) country code(s) according to ISO 3166-1 alpha-2
545
545
 
546
- Returns
546
+ Returns:
547
547
  -------
548
548
  OpenFrame
549
549
  An OpenFrame object
550
550
 
551
551
  """
552
- startyear = to_datetime(self.tsdf.index[0]).year
553
- endyear = to_datetime(self.tsdf.index[-1]).year
552
+ startyear = cast("int", to_datetime(self.tsdf.index[0]).year)
553
+ endyear = cast("int", to_datetime(self.tsdf.index[-1]).year)
554
554
  calendar = holiday_calendar(
555
555
  startyear=startyear,
556
556
  endyear=endyear,
@@ -574,7 +574,7 @@ class _CommonModel(BaseModel):
574
574
 
575
575
  Equivalent to LN(value[t] / value[t=0]) in Excel.
576
576
 
577
- Returns
577
+ Returns:
578
578
  -------
579
579
  self
580
580
  An object of the same class
@@ -595,7 +595,7 @@ class _CommonModel(BaseModel):
595
595
  method: LiteralNanMethod, default: "fill"
596
596
  Method used to handle NaN. Either fill with last known or drop
597
597
 
598
- Returns
598
+ Returns:
599
599
  -------
600
600
  self
601
601
  An object of the same class
@@ -615,7 +615,7 @@ class _CommonModel(BaseModel):
615
615
  method: LiteralNanMethod, default: "fill"
616
616
  Method used to handle NaN. Either fill with zero or drop
617
617
 
618
- Returns
618
+ Returns:
619
619
  -------
620
620
  self
621
621
  An object of the same class
@@ -630,7 +630,7 @@ class _CommonModel(BaseModel):
630
630
  def to_drawdown_series(self: Self) -> Self:
631
631
  """Convert timeseries into a drawdown series.
632
632
 
633
- Returns
633
+ Returns:
634
634
  -------
635
635
  self
636
636
  An object of the same class
@@ -660,7 +660,7 @@ class _CommonModel(BaseModel):
660
660
  directory: DirectoryPath, optional
661
661
  File folder location
662
662
 
663
- Returns
663
+ Returns:
664
664
  -------
665
665
  list[dict[str, str | bool | ValueType | list[str] | list[float]]]
666
666
  A list of dictionaries with the data of the series
@@ -678,7 +678,7 @@ class _CommonModel(BaseModel):
678
678
  output = []
679
679
  if "label" in data:
680
680
  if what_output == "tsdf":
681
- values = self.tsdf.iloc[:, 0].tolist()
681
+ values = Series(self.tsdf.iloc[:, 0]).tolist()
682
682
  else:
683
683
  values = list(cast("list[float]", data.get("values")))
684
684
  for item in cleaner_list:
@@ -727,7 +727,7 @@ class _CommonModel(BaseModel):
727
727
  overwrite: bool, default: True
728
728
  Flag whether to overwrite an existing file
729
729
 
730
- Returns
730
+ Returns:
731
731
  -------
732
732
  str
733
733
  The Excel file path
@@ -802,7 +802,7 @@ class _CommonModel(BaseModel):
802
802
  add_logo: bool, default: True
803
803
  If True a Captor logo is added to the plot
804
804
 
805
- Returns
805
+ Returns:
806
806
  -------
807
807
  tuple[plotly.go.Figure, str]
808
808
  Plotly Figure and a div section or a html filename with location
@@ -917,7 +917,7 @@ class _CommonModel(BaseModel):
917
917
  show_last: bool, default: False
918
918
  If True the last self.tsdf point is highlighted as red dot with a label
919
919
 
920
- Returns
920
+ Returns:
921
921
  -------
922
922
  tuple[plotly.go.Figure, str]
923
923
  Plotly Figure and a div section or a html filename with location
@@ -966,7 +966,7 @@ class _CommonModel(BaseModel):
966
966
 
967
967
  for item in range(self.tsdf.shape[1]):
968
968
  figure.add_scatter(
969
- x=[self.tsdf.iloc[:, item].index[-1]],
969
+ x=[Series(self.tsdf.iloc[:, item]).index[-1]],
970
970
  y=[self.tsdf.iloc[-1, item]],
971
971
  mode="markers + text",
972
972
  marker={"color": "red", "size": 12},
@@ -1027,7 +1027,7 @@ class _CommonModel(BaseModel):
1027
1027
  Allows locking the periods-in-a-year to simplify test cases and
1028
1028
  comparisons
1029
1029
 
1030
- Returns
1030
+ Returns:
1031
1031
  -------
1032
1032
  float | Pandas.Series[float]
1033
1033
  Annualized arithmetic mean of returns
@@ -1046,7 +1046,7 @@ class _CommonModel(BaseModel):
1046
1046
  cast("int", earlier) : cast("int", later),
1047
1047
  self.tsdf.columns.to_numpy()[0],
1048
1048
  ].count()
1049
- time_factor = how_many / fraction
1049
+ time_factor = cast("int", how_many) / fraction
1050
1050
 
1051
1051
  result = (
1052
1052
  self.tsdf.loc[cast("int", earlier) : cast("int", later)]
@@ -1089,7 +1089,7 @@ class _CommonModel(BaseModel):
1089
1089
  periods_in_a_year_fixed : DaysInYearType, optional
1090
1090
  Allows locking the periods-in-a-year to simplify test cases and comparisons
1091
1091
 
1092
- Returns
1092
+ Returns:
1093
1093
  -------
1094
1094
  float | Pandas.Series[float]
1095
1095
  Annualized volatility
@@ -1158,7 +1158,7 @@ class _CommonModel(BaseModel):
1158
1158
  drift_adjust: bool, default: False
1159
1159
  An adjustment to remove the bias implied by the average return
1160
1160
 
1161
- Returns
1161
+ Returns:
1162
1162
  -------
1163
1163
  float | Pandas.Series[float]
1164
1164
  Implied annualized volatility from the Downside VaR using the
@@ -1219,7 +1219,7 @@ class _CommonModel(BaseModel):
1219
1219
  drift_adjust: bool, default: False
1220
1220
  An adjustment to remove the bias implied by the average return
1221
1221
 
1222
- Returns
1222
+ Returns:
1223
1223
  -------
1224
1224
  float | Pandas.Series[float]
1225
1225
  A position weight multiplier from the ratio between a VaR implied
@@ -1285,7 +1285,7 @@ class _CommonModel(BaseModel):
1285
1285
  drift_adjust: bool, default: False
1286
1286
  An adjustment to remove the bias implied by the average return
1287
1287
 
1288
- Returns
1288
+ Returns:
1289
1289
  -------
1290
1290
  float | Pandas.Series[float]
1291
1291
  Target volatility if target_vol is provided otherwise the VaR
@@ -1377,7 +1377,7 @@ class _CommonModel(BaseModel):
1377
1377
  to_date : datetime.date, optional
1378
1378
  Specific to date
1379
1379
 
1380
- Returns
1380
+ Returns:
1381
1381
  -------
1382
1382
  float | Pandas.Series[float]
1383
1383
  Downside Conditional Value At Risk "CVaR"
@@ -1392,14 +1392,14 @@ class _CommonModel(BaseModel):
1392
1392
  deep=True
1393
1393
  )
1394
1394
  result = [
1395
- cvar_df.loc[:, x] # type: ignore[call-overload,index,unused-ignore]
1395
+ cvar_df.loc[:, x] # type: ignore[call-overload,index]
1396
1396
  .ffill()
1397
1397
  .pct_change()
1398
1398
  .sort_values()
1399
1399
  .iloc[
1400
1400
  : ceil(
1401
1401
  (1 - level)
1402
- * cvar_df.loc[:, x] # type: ignore[index,unused-ignore]
1402
+ * cvar_df.loc[:, x] # type: ignore[index]
1403
1403
  .ffill()
1404
1404
  .pct_change()
1405
1405
  .count(),
@@ -1446,7 +1446,7 @@ class _CommonModel(BaseModel):
1446
1446
  Allows locking the periods-in-a-year to simplify test cases and
1447
1447
  comparisons
1448
1448
 
1449
- Returns
1449
+ Returns:
1450
1450
  -------
1451
1451
  float | Pandas.Series[float]
1452
1452
  Downside deviation
@@ -1514,7 +1514,7 @@ class _CommonModel(BaseModel):
1514
1514
  to_date : datetime.date, optional
1515
1515
  Specific to date
1516
1516
 
1517
- Returns
1517
+ Returns:
1518
1518
  -------
1519
1519
  float | Pandas.Series[float]
1520
1520
  Compounded Annual Growth Rate (CAGR)
@@ -1529,7 +1529,7 @@ class _CommonModel(BaseModel):
1529
1529
  fraction = (later - earlier).days / 365.25
1530
1530
 
1531
1531
  any_below_zero = any(
1532
- self.tsdf.loc[[earlier, later]] # type: ignore[index,unused-ignore]
1532
+ self.tsdf.loc[[earlier, later]] # type: ignore[index]
1533
1533
  .lt(0.0)
1534
1534
  .any()
1535
1535
  .to_numpy()
@@ -1572,7 +1572,7 @@ class _CommonModel(BaseModel):
1572
1572
  to_date : datetime.date, optional
1573
1573
  Specific to date
1574
1574
 
1575
- Returns
1575
+ Returns:
1576
1576
  -------
1577
1577
  float | Pandas.Series[float]
1578
1578
  Skew of the return distribution
@@ -1621,7 +1621,7 @@ class _CommonModel(BaseModel):
1621
1621
  to_date : datetime.date, optional
1622
1622
  Specific to date
1623
1623
 
1624
- Returns
1624
+ Returns:
1625
1625
  -------
1626
1626
  float | Pandas.Series[float]
1627
1627
  Kurtosis of the return distribution
@@ -1675,7 +1675,7 @@ class _CommonModel(BaseModel):
1675
1675
  min_periods: int, default: 1
1676
1676
  Smallest number of observations to use to find the maximum drawdown
1677
1677
 
1678
- Returns
1678
+ Returns:
1679
1679
  -------
1680
1680
  float | Pandas.Series[float]
1681
1681
  Maximum drawdown without any limit on date range
@@ -1719,7 +1719,7 @@ class _CommonModel(BaseModel):
1719
1719
  to_date : datetime.date, optional
1720
1720
  Specific to date
1721
1721
 
1722
- Returns
1722
+ Returns:
1723
1723
  -------
1724
1724
  float | Pandas.Series[float]
1725
1725
  Calculate share of percentage changes that are greater than zero
@@ -1789,7 +1789,7 @@ class _CommonModel(BaseModel):
1789
1789
  Allows locking the periods-in-a-year to simplify test cases and
1790
1790
  comparisons
1791
1791
 
1792
- Returns
1792
+ Returns:
1793
1793
  -------
1794
1794
  float | Pandas.Series[float]
1795
1795
  Ratio of the annualized arithmetic mean of returns and annualized
@@ -1854,7 +1854,7 @@ class _CommonModel(BaseModel):
1854
1854
  Allows locking the periods-in-a-year to simplify test cases and
1855
1855
  comparisons
1856
1856
 
1857
- Returns
1857
+ Returns:
1858
1858
  -------
1859
1859
  float | Pandas.Series[float]
1860
1860
  Sortino ratio calculated as ( return - riskfree return ) /
@@ -1912,7 +1912,7 @@ class _CommonModel(BaseModel):
1912
1912
  to_date : datetime.date, optional
1913
1913
  Specific to date
1914
1914
 
1915
- Returns
1915
+ Returns:
1916
1916
  -------
1917
1917
  float | Pandas.Series[float]
1918
1918
  Omega ratio calculation
@@ -1959,7 +1959,7 @@ class _CommonModel(BaseModel):
1959
1959
  to_date : datetime.date, optional
1960
1960
  Specific to date
1961
1961
 
1962
- Returns
1962
+ Returns:
1963
1963
  -------
1964
1964
  float | Pandas.Series[float]
1965
1965
  Calculate simple return
@@ -2003,7 +2003,7 @@ class _CommonModel(BaseModel):
2003
2003
  month : int, optional
2004
2004
  Calendar month of the period to calculate.
2005
2005
 
2006
- Returns
2006
+ Returns:
2007
2007
  -------
2008
2008
  float | Pandas.Series[float]
2009
2009
  Calculate simple return for a specific calendar period
@@ -2054,7 +2054,7 @@ class _CommonModel(BaseModel):
2054
2054
  interpolation: LiteralQuantileInterp, default: "lower"
2055
2055
  Type of interpolation in Pandas.DataFrame.quantile() function.
2056
2056
 
2057
- Returns
2057
+ Returns:
2058
2058
  -------
2059
2059
  float | Pandas.Series[float]
2060
2060
  Downside Value At Risk
@@ -2102,7 +2102,7 @@ class _CommonModel(BaseModel):
2102
2102
  to_date : datetime.date, optional
2103
2103
  Specific to date
2104
2104
 
2105
- Returns
2105
+ Returns:
2106
2106
  -------
2107
2107
  float | Pandas.Series[float]
2108
2108
  Most negative percentage change over a rolling number of observations
@@ -2152,7 +2152,7 @@ class _CommonModel(BaseModel):
2152
2152
  to_date : datetime.date, optional
2153
2153
  Specific to date
2154
2154
 
2155
- Returns
2155
+ Returns:
2156
2156
  -------
2157
2157
  float | Pandas.Series[float]
2158
2158
  Z-score as (last return - mean return) / standard deviation of returns
@@ -2196,7 +2196,7 @@ class _CommonModel(BaseModel):
2196
2196
  observations: int, default: 252
2197
2197
  Number of observations in the overlapping window.
2198
2198
 
2199
- Returns
2199
+ Returns:
2200
2200
  -------
2201
2201
  Pandas.DataFrame
2202
2202
  Calculate rolling annualized downside CVaR
@@ -2204,7 +2204,7 @@ class _CommonModel(BaseModel):
2204
2204
  """
2205
2205
  cvar_label = cast("tuple[str]", self.tsdf.iloc[:, column].name)[0]
2206
2206
  cvarseries = (
2207
- self.tsdf.iloc[:, column]
2207
+ Series(self.tsdf.iloc[:, column])
2208
2208
  .rolling(observations, min_periods=observations)
2209
2209
  .apply(lambda x: _cvar_down_calc(x, level=level))
2210
2210
  )
@@ -2227,7 +2227,7 @@ class _CommonModel(BaseModel):
2227
2227
  observations: int, default: 21
2228
2228
  Number of observations in the overlapping window.
2229
2229
 
2230
- Returns
2230
+ Returns:
2231
2231
  -------
2232
2232
  Pandas.DataFrame
2233
2233
  Calculate rolling returns
@@ -2235,7 +2235,7 @@ class _CommonModel(BaseModel):
2235
2235
  """
2236
2236
  ret_label = cast("tuple[str]", self.tsdf.iloc[:, column].name)[0]
2237
2237
  retseries = (
2238
- self.tsdf.iloc[:, column]
2238
+ Series(self.tsdf.iloc[:, column])
2239
2239
  .ffill()
2240
2240
  .pct_change()
2241
2241
  .rolling(observations, min_periods=observations)
@@ -2266,7 +2266,7 @@ class _CommonModel(BaseModel):
2266
2266
  interpolation: LiteralQuantileInterp, default: "lower"
2267
2267
  Type of interpolation in Pandas.DataFrame.quantile() function.
2268
2268
 
2269
- Returns
2269
+ Returns:
2270
2270
  -------
2271
2271
  Pandas.DataFrame
2272
2272
  Calculate rolling annualized downside Value At Risk "VaR"
@@ -2274,7 +2274,7 @@ class _CommonModel(BaseModel):
2274
2274
  """
2275
2275
  var_label = cast("tuple[str]", self.tsdf.iloc[:, column].name)[0]
2276
2276
  varseries = (
2277
- self.tsdf.iloc[:, column]
2277
+ Series(self.tsdf.iloc[:, column])
2278
2278
  .rolling(observations, min_periods=observations)
2279
2279
  .apply(
2280
2280
  lambda x: _var_down_calc(x, level=level, interpolation=interpolation),
@@ -2303,7 +2303,7 @@ class _CommonModel(BaseModel):
2303
2303
  Allows locking the periods-in-a-year to simplify test cases and
2304
2304
  comparisons
2305
2305
 
2306
- Returns
2306
+ Returns:
2307
2307
  -------
2308
2308
  Pandas.DataFrame
2309
2309
  Calculate rolling annualised volatilities
@@ -2314,7 +2314,7 @@ class _CommonModel(BaseModel):
2314
2314
  else:
2315
2315
  time_factor = self.periods_in_a_year
2316
2316
  vol_label = cast("tuple[str, ValueType]", self.tsdf.iloc[:, column].name)[0]
2317
- dframe = self.tsdf.iloc[:, column].ffill().pct_change()
2317
+ dframe = Series(self.tsdf.iloc[:, column]).ffill().pct_change()
2318
2318
  volseries = dframe.rolling(
2319
2319
  observations,
2320
2320
  min_periods=observations,