openseries 1.9.7__py3-none-any.whl → 2.0.0__py3-none-any.whl

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.
openseries/__init__.py CHANGED
@@ -1,11 +1,4 @@
1
- """openseries.openseries.__init__.py.
2
-
3
- Copyright (c) Captor Fund Management AB. This file is part of the openseries project.
4
-
5
- Licensed under the BSD 3-Clause License. You may obtain a copy of the License at:
6
- https://github.com/CaptorAB/openseries/blob/master/LICENSE.md
7
- SPDX-License-Identifier: BSD-3-Clause
8
- """
1
+ """openseries.openseries.__init__.py."""
9
2
 
10
3
  from .datefixer import (
11
4
  date_fix,
@@ -1,10 +1,6 @@
1
- """Defining the _CommonModel class.
1
+ """The _CommonModel class.
2
2
 
3
- Copyright (c) Captor Fund Management AB. This file is part of the openseries project.
4
-
5
- Licensed under the BSD 3-Clause License. You may obtain a copy of the License at:
6
- https://github.com/CaptorAB/openseries/blob/master/LICENSE.md
7
- SPDX-License-Identifier: BSD-3-Clause
3
+ _CommonModel class which is the base class for OpenFrame and OpenTimeSeries.
8
4
  """
9
5
 
10
6
  from __future__ import annotations
@@ -110,7 +106,7 @@ def _get_date_range_and_factor(
110
106
  comparisons
111
107
 
112
108
  Returns:
113
- -------
109
+ --------
114
110
  tuple[dt.date, dt.date, float, DataFrame]
115
111
  earlier, later, time_factor, data
116
112
  """
@@ -153,7 +149,7 @@ def _get_base_column_data(
153
149
  End date
154
150
 
155
151
  Returns:
156
- -------
152
+ --------
157
153
  tuple[Series[float], tuple[str, ValueType], str]
158
154
  data, item, label
159
155
  """
@@ -196,7 +192,7 @@ def _calculate_time_factor(
196
192
  Fixed periods in year
197
193
 
198
194
  Returns:
199
- -------
195
+ --------
200
196
  float
201
197
  Time factor
202
198
  """
@@ -239,7 +235,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
239
235
  """Number of observations.
240
236
 
241
237
  Returns:
242
- -------
238
+ --------
243
239
  int
244
240
  Number of observations
245
241
 
@@ -251,7 +247,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
251
247
  """The first date in the timeseries.
252
248
 
253
249
  Returns:
254
- -------
250
+ --------
255
251
  datetime.date
256
252
  The first date in the timeseries
257
253
 
@@ -263,7 +259,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
263
259
  """The last date in the timeseries.
264
260
 
265
261
  Returns:
266
- -------
262
+ --------
267
263
  datetime.date
268
264
  The last date in the timeseries
269
265
 
@@ -275,7 +271,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
275
271
  """Number of days from the first date to the last.
276
272
 
277
273
  Returns:
278
- -------
274
+ --------
279
275
  int
280
276
  Number of days from the first date to the last
281
277
 
@@ -287,7 +283,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
287
283
  """Length of series expressed in years assuming all years have 365.25 days.
288
284
 
289
285
  Returns:
290
- -------
286
+ --------
291
287
  float
292
288
  Length of the timeseries expressed in years assuming all years
293
289
  have 365.25 days
@@ -300,7 +296,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
300
296
  """The average number of observations per year.
301
297
 
302
298
  Returns:
303
- -------
299
+ --------
304
300
  float
305
301
  The average number of observations per year
306
302
 
@@ -312,7 +308,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
312
308
  """https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
313
309
 
314
310
  Returns:
315
- -------
311
+ --------
316
312
  SeriesOrFloat_co
317
313
  Maximum drawdown in a single calendar year.
318
314
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -334,7 +330,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
334
330
  """https://www.investopedia.com/terms/c/cagr.asp.
335
331
 
336
332
  Returns:
337
- -------
333
+ --------
338
334
  SeriesOrFloat_co
339
335
  Compounded Annual Growth Rate (CAGR).
340
336
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -348,7 +344,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
348
344
  """https://www.investopedia.com/terms/a/arithmeticmean.asp.
349
345
 
350
346
  Returns:
351
- -------
347
+ --------
352
348
  SeriesOrFloat_co
353
349
  Annualized arithmetic mean of returns.
354
350
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -362,7 +358,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
362
358
  """Simple return.
363
359
 
364
360
  Returns:
365
- -------
361
+ --------
366
362
  SeriesOrFloat_co
367
363
  Simple return.
368
364
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -379,7 +375,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
379
375
  https://www.investopedia.com/terms/v/volatility.asp.
380
376
 
381
377
  Returns:
382
- -------
378
+ --------
383
379
  SeriesOrFloat_co
384
380
  Annualized volatility.
385
381
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -397,7 +393,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
397
393
  https://www.investopedia.com/terms/d/downside-deviation.asp.
398
394
 
399
395
  Returns:
400
- -------
396
+ --------
401
397
  SeriesOrFloat_co
402
398
  Downside deviation.
403
399
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -416,10 +412,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
416
412
  """Ratio of annualized arithmetic mean of returns and annualized volatility.
417
413
 
418
414
  Returns:
419
- -------
415
+ --------
420
416
  SeriesOrFloat_co
421
- Ratio of the annualized arithmetic mean of returns and annualized.
422
- Returns float for OpenTimeSeries, Series[float] for OpenFrame.
417
+ Ratio of the annualized arithmetic mean of returns and annualized
423
418
  volatility.
424
419
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
425
420
 
@@ -432,10 +427,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
432
427
  """https://www.investopedia.com/terms/s/sortinoratio.asp.
433
428
 
434
429
  Returns:
435
- -------
430
+ --------
436
431
  SeriesOrFloat_co
437
- Sortino ratio calculated as the annualized arithmetic mean of returns.
438
- Returns float for OpenTimeSeries, Series[float] for OpenFrame
432
+ Sortino ratio calculated as the annualized arithmetic mean of returns
439
433
  / downside deviation. The ratio implies that the riskfree asset has zero
440
434
  volatility, and a minimum acceptable return of zero.
441
435
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -459,10 +453,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
459
453
  the Sortino ratio (which uses order 2).
460
454
 
461
455
  Returns:
462
- -------
456
+ --------
463
457
  SeriesOrFloat_co
464
458
  Kappa-3 ratio calculation with the riskfree rate and.
465
- Returns float for OpenTimeSeries, Series[float] for OpenFrame
466
459
  Minimum Acceptable Return (MAR) both set to zero.
467
460
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
468
461
 
@@ -481,7 +474,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
481
474
  """https://en.wikipedia.org/wiki/Omega_ratio.
482
475
 
483
476
  Returns:
484
- -------
477
+ --------
485
478
  SeriesOrFloat_co
486
479
  Omega ratio calculation.
487
480
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -496,7 +489,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
496
489
  """https://www.investopedia.com/terms/z/zscore.asp.
497
490
 
498
491
  Returns:
499
- -------
492
+ --------
500
493
  SeriesOrFloat_co
501
494
  Z-score as (last return - mean return) / standard deviation of returns.
502
495
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -510,7 +503,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
510
503
  """https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
511
504
 
512
505
  Returns:
513
- -------
506
+ --------
514
507
  SeriesOrFloat_co
515
508
  Maximum drawdown without any limit on date range.
516
509
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -526,7 +519,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
526
519
  https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
527
520
 
528
521
  Returns:
529
- -------
522
+ --------
530
523
  datetime.date | pandas.Series[dt.date]
531
524
  Date when the maximum drawdown occurred
532
525
 
@@ -549,7 +542,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
549
542
  """Most negative percentage change.
550
543
 
551
544
  Returns:
552
- -------
545
+ --------
553
546
  SeriesOrFloat_co
554
547
  Most negative percentage change.
555
548
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -564,7 +557,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
564
557
  """Most negative month.
565
558
 
566
559
  Returns:
567
- -------
560
+ --------
568
561
  SeriesOrFloat_co
569
562
  Most negative month.
570
563
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -610,7 +603,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
610
603
  """The share of percentage changes that are greater than zero.
611
604
 
612
605
  Returns:
613
- -------
606
+ --------
614
607
  SeriesOrFloat_co
615
608
  The share of percentage changes that are greater than zero.
616
609
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -624,7 +617,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
624
617
  """https://www.investopedia.com/terms/s/skewness.asp.
625
618
 
626
619
  Returns:
627
- -------
620
+ --------
628
621
  SeriesOrFloat_co
629
622
  Skew of the return distribution.
630
623
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -638,7 +631,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
638
631
  """https://www.investopedia.com/terms/k/kurtosis.asp.
639
632
 
640
633
  Returns:
641
- -------
634
+ --------
642
635
  SeriesOrFloat_co
643
636
  Kurtosis of the return distribution.
644
637
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -652,7 +645,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
652
645
  """https://www.investopedia.com/terms/c/conditional_value_at_risk.asp.
653
646
 
654
647
  Returns:
655
- -------
648
+ --------
656
649
  SeriesOrFloat_co
657
650
  Downside 95% Conditional Value At Risk "CVaR".
658
651
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -670,7 +663,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
670
663
  https://www.investopedia.com/terms/v/var.asp.
671
664
 
672
665
  Returns:
673
- -------
666
+ --------
674
667
  SeriesOrFloat_co
675
668
  Downside 95% Value At Risk (VaR).
676
669
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -688,10 +681,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
688
681
  Assumes that returns are normally distributed.
689
682
 
690
683
  Returns:
691
- -------
684
+ --------
692
685
  SeriesOrFloat_co
693
- Implied annualized volatility from the Downside 95% VaR using the.
694
- Returns float for OpenTimeSeries, Series[float] for OpenFrame.
686
+ Implied annualized volatility from the Downside 95% VaR using the
695
687
  assumption that returns are normally distributed.
696
688
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
697
689
 
@@ -719,7 +711,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
719
711
  Specific from date
720
712
 
721
713
  Returns:
722
- -------
714
+ --------
723
715
  tuple[datetime.date, datetime.date]
724
716
  Start and end date of the chosen date range
725
717
 
@@ -776,8 +768,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
776
768
  Argument where missing holidays can be added
777
769
  method: LiteralPandasReindexMethod, default: "nearest"
778
770
 
771
+
779
772
  Returns:
780
- -------
773
+ --------
781
774
  OpenFrame
782
775
  An OpenFrame object
783
776
 
@@ -837,7 +830,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
837
830
  Equivalent to LN(value[t] / value[t=0]) in Excel.
838
831
 
839
832
  Returns:
840
- -------
833
+ --------
841
834
  self
842
835
  An object of the same class
843
836
 
@@ -858,7 +851,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
858
851
  Method used to handle NaN. Either fill with last known or drop
859
852
 
860
853
  Returns:
861
- -------
854
+ --------
862
855
  self
863
856
  An object of the same class
864
857
 
@@ -878,7 +871,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
878
871
  Method used to handle NaN. Either fill with zero or drop
879
872
 
880
873
  Returns:
881
- -------
874
+ --------
882
875
  self
883
876
  An object of the same class
884
877
 
@@ -893,7 +886,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
893
886
  """Convert timeseries into a drawdown series.
894
887
 
895
888
  Returns:
896
- -------
889
+ --------
897
890
  self
898
891
  An object of the same class
899
892
 
@@ -923,7 +916,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
923
916
  File folder location
924
917
 
925
918
  Returns:
926
- -------
919
+ --------
927
920
  list[dict[str, str | bool | ValueType | list[str] | list[float]]]
928
921
  A list of dictionaries with the data of the series
929
922
 
@@ -990,7 +983,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
990
983
  Flag whether to overwrite an existing file
991
984
 
992
985
  Returns:
993
- -------
986
+ --------
994
987
  str
995
988
  The Excel file path
996
989
 
@@ -1161,7 +1154,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1161
1154
  If True a Captor logo is added to the plot
1162
1155
 
1163
1156
  Returns:
1164
- -------
1157
+ --------
1165
1158
  tuple[plotly.go.Figure, str]
1166
1159
  Plotly Figure and a div section or a html filename with location
1167
1160
 
@@ -1258,7 +1251,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1258
1251
  If True the last self.tsdf point is highlighted as red dot with a label
1259
1252
 
1260
1253
  Returns:
1261
- -------
1254
+ --------
1262
1255
  tuple[plotly.go.Figure, str]
1263
1256
  Plotly Figure and a div section or a html filename with location
1264
1257
 
@@ -1395,7 +1388,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1395
1388
  If True a Captor logo is added to the plot
1396
1389
 
1397
1390
  Returns:
1398
- -------
1391
+ --------
1399
1392
  tuple[plotly.go.Figure, str]
1400
1393
  Plotly Figure and a div section or a html filename with location
1401
1394
 
@@ -1493,7 +1486,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1493
1486
  comparisons
1494
1487
 
1495
1488
  Returns:
1496
- -------
1489
+ --------
1497
1490
  SeriesOrFloat_co
1498
1491
  Annualized arithmetic mean of returns.
1499
1492
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -1537,7 +1530,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1537
1530
  Allows locking the periods-in-a-year to simplify test cases and comparisons
1538
1531
 
1539
1532
  Returns:
1540
- -------
1533
+ --------
1541
1534
  SeriesOrFloat_co
1542
1535
  Annualized volatility.
1543
1536
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -1591,11 +1584,11 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1591
1584
  An adjustment to remove the bias implied by the average return
1592
1585
 
1593
1586
  Returns:
1594
- -------
1587
+ --------
1595
1588
  SeriesOrFloat_co
1596
- Implied annualized volatility from the Downside VaR using the.
1597
- Returns float for OpenTimeSeries, Series[float] for OpenFrame.
1589
+ Implied annualized volatility from the Downside VaR using the
1598
1590
  assumption that returns are normally distributed.
1591
+ Returns float for OpenTimeSeries, Series[float] for OpenFrame.
1599
1592
 
1600
1593
  """
1601
1594
  return self._var_implied_vol_and_target_func(
@@ -1653,11 +1646,11 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1653
1646
  An adjustment to remove the bias implied by the average return
1654
1647
 
1655
1648
  Returns:
1656
- -------
1649
+ --------
1657
1650
  SeriesOrFloat_co
1658
- A position weight multiplier from the ratio between a VaR implied.
1651
+ A position weight multiplier from the ratio between a VaR implied
1652
+ volatility and a given target volatility. Multiplier = 1.0 -> target met.
1659
1653
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
1660
- volatility and a given target volatility. Multiplier = 1.0 -> target met
1661
1654
 
1662
1655
  """
1663
1656
  return self._var_implied_vol_and_target_func(
@@ -1720,11 +1713,11 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1720
1713
  An adjustment to remove the bias implied by the average return
1721
1714
 
1722
1715
  Returns:
1723
- -------
1716
+ --------
1724
1717
  SeriesOrFloat_co
1725
- Target volatility if target_vol is provided otherwise the VaR.
1726
- Returns float for OpenTimeSeries, Series[float] for OpenFrame.
1718
+ Target volatility if target_vol is provided otherwise the VaR
1727
1719
  implied volatility.
1720
+ Returns float for OpenTimeSeries, Series[float] for OpenFrame.
1728
1721
 
1729
1722
  """
1730
1723
  earlier, later = self.calc_range(
@@ -1808,7 +1801,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1808
1801
  Specific to date
1809
1802
 
1810
1803
  Returns:
1811
- -------
1804
+ --------
1812
1805
  SeriesOrFloat_co
1813
1806
  Downside Conditional Value At Risk "CVaR".
1814
1807
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -1868,7 +1861,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1868
1861
  comparisons
1869
1862
 
1870
1863
  Returns:
1871
- -------
1864
+ --------
1872
1865
  SeriesOrFloat_co
1873
1866
  Downside deviation if order set to 2.
1874
1867
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -1942,7 +1935,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1942
1935
  Specific to date
1943
1936
 
1944
1937
  Returns:
1945
- -------
1938
+ --------
1946
1939
  SeriesOrFloat_co
1947
1940
  Compounded Annual Growth Rate (CAGR).
1948
1941
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -1992,7 +1985,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
1992
1985
  Specific to date
1993
1986
 
1994
1987
  Returns:
1995
- -------
1988
+ --------
1996
1989
  SeriesOrFloat_co
1997
1990
  Skew of the return distribution.
1998
1991
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2036,7 +2029,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2036
2029
  Specific to date
2037
2030
 
2038
2031
  Returns:
2039
- -------
2032
+ --------
2040
2033
  SeriesOrFloat_co
2041
2034
  Kurtosis of the return distribution.
2042
2035
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2087,7 +2080,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2087
2080
  Smallest number of observations to use to find the maximum drawdown
2088
2081
 
2089
2082
  Returns:
2090
- -------
2083
+ --------
2091
2084
  SeriesOrFloat_co
2092
2085
  Maximum drawdown without any limit on date range.
2093
2086
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2126,7 +2119,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2126
2119
  Specific to date
2127
2120
 
2128
2121
  Returns:
2129
- -------
2122
+ --------
2130
2123
  SeriesOrFloat_co
2131
2124
  Calculate share of percentage changes that are greater than zero.
2132
2125
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2191,11 +2184,11 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2191
2184
  comparisons
2192
2185
 
2193
2186
  Returns:
2194
- -------
2187
+ --------
2195
2188
  SeriesOrFloat_co
2196
- Ratio of the annualized arithmetic mean of returns and annualized.
2189
+ Ratio of the annualized arithmetic mean of returns and annualized
2190
+ volatility or, if risk-free return provided, Sharpe ratio.
2197
2191
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
2198
- volatility or, if risk-free return provided, Sharpe ratio
2199
2192
 
2200
2193
  """
2201
2194
  result = Series(
@@ -2256,11 +2249,11 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2256
2249
  comparisons
2257
2250
 
2258
2251
  Returns:
2259
- -------
2252
+ --------
2260
2253
  SeriesOrFloat_co
2261
- Sortino ratio calculated as ( return - riskfree return ) /.
2254
+ Sortino ratio calculated as ( return - riskfree return ) /
2255
+ downside deviation (std dev of returns below MAR).
2262
2256
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
2263
- downside deviation (std dev of returns below MAR)
2264
2257
 
2265
2258
  """
2266
2259
  result = Series(
@@ -2312,7 +2305,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2312
2305
  Specific to date
2313
2306
 
2314
2307
  Returns:
2315
- -------
2308
+ --------
2316
2309
  SeriesOrFloat_co
2317
2310
  Omega ratio calculation.
2318
2311
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2353,7 +2346,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2353
2346
  Specific to date
2354
2347
 
2355
2348
  Returns:
2356
- -------
2349
+ --------
2357
2350
  SeriesOrFloat_co
2358
2351
  Calculate simple return.
2359
2352
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2394,7 +2387,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2394
2387
  Calendar month of the period to calculate.
2395
2388
 
2396
2389
  Returns:
2397
- -------
2390
+ --------
2398
2391
  SeriesOrFloat_co
2399
2392
  Calculate simple return for a specific calendar period.
2400
2393
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2440,7 +2433,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2440
2433
  Type of interpolation in Pandas.DataFrame.quantile() function.
2441
2434
 
2442
2435
  Returns:
2443
- -------
2436
+ --------
2444
2437
  SeriesOrFloat_co
2445
2438
  Downside Value At Risk.
2446
2439
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2482,11 +2475,11 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2482
2475
  Specific to date
2483
2476
 
2484
2477
  Returns:
2485
- -------
2478
+ --------
2486
2479
  SeriesOrFloat_co
2487
- Most negative percentage change over a rolling number of observations.
2480
+ Most negative percentage change over a rolling number of observations
2481
+ within a chosen date range.
2488
2482
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
2489
- within a chosen date range
2490
2483
 
2491
2484
  """
2492
2485
  earlier, later = self.calc_range(
@@ -2526,7 +2519,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2526
2519
  Specific to date
2527
2520
 
2528
2521
  Returns:
2529
- -------
2522
+ --------
2530
2523
  SeriesOrFloat_co
2531
2524
  Z-score as (last return - mean return) / standard deviation of returns.
2532
2525
  Returns float for OpenTimeSeries, Series[float] for OpenFrame.
@@ -2564,7 +2557,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2564
2557
  Number of observations in the overlapping window.
2565
2558
 
2566
2559
  Returns:
2567
- -------
2560
+ --------
2568
2561
  Pandas.DataFrame
2569
2562
  Calculate rolling annualized downside CVaR
2570
2563
 
@@ -2595,7 +2588,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2595
2588
  Number of observations in the overlapping window.
2596
2589
 
2597
2590
  Returns:
2598
- -------
2591
+ --------
2599
2592
  Pandas.DataFrame
2600
2593
  Calculate rolling returns
2601
2594
 
@@ -2634,7 +2627,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2634
2627
  Type of interpolation in Pandas.DataFrame.quantile() function.
2635
2628
 
2636
2629
  Returns:
2637
- -------
2630
+ --------
2638
2631
  Pandas.DataFrame
2639
2632
  Calculate rolling annualized downside Value At Risk "VaR"
2640
2633
 
@@ -2674,7 +2667,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
2674
2667
  Variance bias factor taking the value 0 or 1.
2675
2668
 
2676
2669
  Returns:
2677
- -------
2670
+ --------
2678
2671
  Pandas.DataFrame
2679
2672
  Calculate rolling annualised volatilities
2680
2673
 
openseries/_risk.py CHANGED
@@ -1,11 +1,4 @@
1
- """Various risk related functions.
2
-
3
- Copyright (c) Captor Fund Management AB. This file is part of the openseries project.
4
-
5
- Licensed under the BSD 3-Clause License. You may obtain a copy of the License at:
6
- https://github.com/CaptorAB/openseries/blob/master/LICENSE.md
7
- SPDX-License-Identifier: BSD-3-Clause
8
- """
1
+ """Functions caclculating risk measures."""
9
2
 
10
3
  from __future__ import annotations
11
4
 
@@ -40,7 +33,7 @@ def _cvar_down_calc(
40
33
  The sought CVaR level
41
34
 
42
35
  Returns:
43
- -------
36
+ --------
44
37
  float
45
38
  Downside Conditional Value At Risk "CVaR"
46
39
 
@@ -74,7 +67,7 @@ def _var_down_calc(
74
67
  type of interpolation in Pandas.DataFrame.quantile() function.
75
68
 
76
69
  Returns:
77
- -------
70
+ --------
78
71
  float
79
72
  Downside Value At Risk
80
73