openseries 2.0.3__tar.gz → 2.1.1__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.
- {openseries-2.0.3 → openseries-2.1.1}/PKG-INFO +3 -6
- {openseries-2.0.3 → openseries-2.1.1}/README.md +0 -2
- {openseries-2.0.3 → openseries-2.1.1}/openseries/__init__.py +2 -3
- {openseries-2.0.3 → openseries-2.1.1}/openseries/_common_model.py +47 -27
- {openseries-2.0.3 → openseries-2.1.1}/openseries/_risk.py +4 -3
- {openseries-2.0.3 → openseries-2.1.1}/openseries/frame.py +630 -415
- {openseries-2.0.3 → openseries-2.1.1}/openseries/owntypes.py +10 -8
- {openseries-2.0.3 → openseries-2.1.1}/openseries/portfoliotools.py +478 -174
- openseries-2.1.1/openseries/report.py +1232 -0
- {openseries-2.0.3 → openseries-2.1.1}/openseries/series.py +34 -25
- {openseries-2.0.3 → openseries-2.1.1}/openseries/simulation.py +1 -2
- {openseries-2.0.3 → openseries-2.1.1}/pyproject.toml +18 -29
- openseries-2.0.3/openseries/report.py +0 -465
- {openseries-2.0.3 → openseries-2.1.1}/LICENSE.md +0 -0
- {openseries-2.0.3 → openseries-2.1.1}/openseries/datefixer.py +0 -0
- {openseries-2.0.3 → openseries-2.1.1}/openseries/load_plotly.py +0 -0
- {openseries-2.0.3 → openseries-2.1.1}/openseries/plotly_captor_logo.json +0 -0
- {openseries-2.0.3 → openseries-2.1.1}/openseries/plotly_layouts.json +0 -0
- {openseries-2.0.3 → openseries-2.1.1}/openseries/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openseries
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: Tools for analyzing financial timeseries.
|
|
5
5
|
License-Expression: BSD-3-Clause
|
|
6
6
|
License-File: LICENSE.md
|
|
@@ -9,8 +9,7 @@ Author: Martin Karrin
|
|
|
9
9
|
Author-email: martin.karrin@captor.se
|
|
10
10
|
Maintainer: Martin Karrin
|
|
11
11
|
Maintainer-email: martin.karrin@captor.se
|
|
12
|
-
Requires-Python: >=3.
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Requires-Python: >=3.11,<3.15
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -33,7 +32,7 @@ Requires-Dist: requests (>=2.20.0)
|
|
|
33
32
|
Requires-Dist: scikit-learn (>=1.4.0)
|
|
34
33
|
Requires-Dist: scipy (>=1.14.1)
|
|
35
34
|
Project-URL: Documentation, https://openseries.readthedocs.io/
|
|
36
|
-
Project-URL: Homepage, https://github.
|
|
35
|
+
Project-URL: Homepage, https://captorab.github.io/openseries/
|
|
37
36
|
Project-URL: Issue Tracker, https://github.com/CaptorAB/openseries/issues
|
|
38
37
|
Project-URL: Release Notes, https://github.com/CaptorAB/openseries/releases
|
|
39
38
|
Project-URL: Source, https://github.com/CaptorAB/openseries
|
|
@@ -59,8 +58,6 @@ Description-Content-Type: text/markdown
|
|
|
59
58
|
|
|
60
59
|
Tools for analyzing financial timeseries of a single asset or a group of assets. Designed for daily or less frequent data.
|
|
61
60
|
|
|
62
|
-
> **⚠️ Python Version Notice**: Python 3.10 support is deprecated and will be removed, no earlier than 2025-12-01. Please upgrade to Python ≥3.11. See [#340](https://github.com/CaptorAB/openseries/issues/340) (pinned) for details.
|
|
63
|
-
|
|
64
61
|
## Documentation
|
|
65
62
|
|
|
66
63
|
Complete documentation is available at: [https://openseries.readthedocs.io](https://openseries.readthedocs.io/)
|
|
@@ -18,8 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
Tools for analyzing financial timeseries of a single asset or a group of assets. Designed for daily or less frequent data.
|
|
20
20
|
|
|
21
|
-
> **⚠️ Python Version Notice**: Python 3.10 support is deprecated and will be removed, no earlier than 2025-12-01. Please upgrade to Python ≥3.11. See [#340](https://github.com/CaptorAB/openseries/issues/340) (pinned) for details.
|
|
22
|
-
|
|
23
21
|
## Documentation
|
|
24
22
|
|
|
25
23
|
Complete documentation is available at: [https://openseries.readthedocs.io](https://openseries.readthedocs.io/)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""openseries package initialization."""
|
|
2
2
|
|
|
3
|
-
__version__ = "2.0
|
|
3
|
+
__version__ = "2.1.0"
|
|
4
4
|
|
|
5
5
|
from .datefixer import (
|
|
6
6
|
date_fix,
|
|
@@ -12,7 +12,7 @@ from .datefixer import (
|
|
|
12
12
|
)
|
|
13
13
|
from .frame import OpenFrame
|
|
14
14
|
from .load_plotly import load_plotly_dict
|
|
15
|
-
from .owntypes import
|
|
15
|
+
from .owntypes import ValueType
|
|
16
16
|
from .portfoliotools import (
|
|
17
17
|
constrain_optimized_portfolios,
|
|
18
18
|
efficient_frontier,
|
|
@@ -28,7 +28,6 @@ __all__ = [
|
|
|
28
28
|
"OpenFrame",
|
|
29
29
|
"OpenTimeSeries",
|
|
30
30
|
"ReturnSimulation",
|
|
31
|
-
"Self",
|
|
32
31
|
"ValueType",
|
|
33
32
|
"constrain_optimized_portfolios",
|
|
34
33
|
"date_fix",
|
|
@@ -12,7 +12,7 @@ from math import ceil
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
from secrets import choice
|
|
14
14
|
from string import ascii_letters
|
|
15
|
-
from typing import TYPE_CHECKING, Any, Generic, Literal, cast
|
|
15
|
+
from typing import TYPE_CHECKING, Any, Generic, Literal, Self, cast
|
|
16
16
|
|
|
17
17
|
from numpy import asarray, float64, inf, isnan, log, maximum, sqrt
|
|
18
18
|
|
|
@@ -23,7 +23,6 @@ from .owntypes import (
|
|
|
23
23
|
NumberOfItemsAndLabelsNotSameError,
|
|
24
24
|
PlotlyConfigType,
|
|
25
25
|
ResampleDataLossError,
|
|
26
|
-
Self,
|
|
27
26
|
SeriesOrFloat_co,
|
|
28
27
|
ValueType,
|
|
29
28
|
)
|
|
@@ -206,15 +205,13 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
206
205
|
if self.tsdf.shape[1] == 1:
|
|
207
206
|
arr = float(asarray(a=result, dtype=float64).squeeze())
|
|
208
207
|
return cast("SeriesOrFloat_co", arr) # type: ignore[redundant-cast]
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
name=name,
|
|
215
|
-
dtype="float64",
|
|
216
|
-
),
|
|
208
|
+
series_result: SeriesOrFloat_co = Series( # type: ignore[assignment]
|
|
209
|
+
data=result,
|
|
210
|
+
index=self.tsdf.columns,
|
|
211
|
+
name=name,
|
|
212
|
+
dtype="float64",
|
|
217
213
|
)
|
|
214
|
+
return series_result
|
|
218
215
|
|
|
219
216
|
@property
|
|
220
217
|
def length(self: Self) -> int:
|
|
@@ -272,7 +269,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
272
269
|
|
|
273
270
|
@property
|
|
274
271
|
def max_drawdown_cal_year(self: Self) -> SeriesOrFloat_co:
|
|
275
|
-
"""
|
|
272
|
+
"""Maximum drawdown in a single calendar year.
|
|
273
|
+
|
|
274
|
+
Reference: https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
|
|
276
275
|
|
|
277
276
|
Returns:
|
|
278
277
|
--------
|
|
@@ -294,7 +293,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
294
293
|
|
|
295
294
|
@property
|
|
296
295
|
def geo_ret(self: Self) -> SeriesOrFloat_co:
|
|
297
|
-
"""
|
|
296
|
+
"""Compounded Annual Growth Rate (CAGR).
|
|
297
|
+
|
|
298
|
+
Reference: https://www.investopedia.com/terms/c/cagr.asp.
|
|
298
299
|
|
|
299
300
|
Returns:
|
|
300
301
|
--------
|
|
@@ -308,7 +309,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
308
309
|
|
|
309
310
|
@property
|
|
310
311
|
def arithmetic_ret(self: Self) -> SeriesOrFloat_co:
|
|
311
|
-
"""
|
|
312
|
+
"""Annualized arithmetic mean of returns.
|
|
313
|
+
|
|
314
|
+
Reference: https://www.investopedia.com/terms/a/arithmeticmean.asp.
|
|
312
315
|
|
|
313
316
|
Returns:
|
|
314
317
|
--------
|
|
@@ -339,7 +342,8 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
339
342
|
"""Annualized volatility.
|
|
340
343
|
|
|
341
344
|
Based on Pandas .std() which is the equivalent of stdev.s([...]) in MS Excel.
|
|
342
|
-
|
|
345
|
+
|
|
346
|
+
Reference: https://www.investopedia.com/terms/v/volatility.asp.
|
|
343
347
|
|
|
344
348
|
Returns:
|
|
345
349
|
--------
|
|
@@ -357,7 +361,8 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
357
361
|
|
|
358
362
|
Standard deviation of returns that are below a Minimum Accepted Return
|
|
359
363
|
of zero. It is used to calculate the Sortino Ratio.
|
|
360
|
-
|
|
364
|
+
|
|
365
|
+
Reference: https://www.investopedia.com/terms/d/downside-deviation.asp.
|
|
361
366
|
|
|
362
367
|
Returns:
|
|
363
368
|
--------
|
|
@@ -391,7 +396,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
391
396
|
|
|
392
397
|
@property
|
|
393
398
|
def sortino_ratio(self: Self) -> SeriesOrFloat_co:
|
|
394
|
-
"""
|
|
399
|
+
"""Sortino ratio.
|
|
400
|
+
|
|
401
|
+
Reference: https://www.investopedia.com/terms/s/sortinoratio.asp.
|
|
395
402
|
|
|
396
403
|
Returns:
|
|
397
404
|
--------
|
|
@@ -438,7 +445,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
438
445
|
|
|
439
446
|
@property
|
|
440
447
|
def omega_ratio(self: Self) -> SeriesOrFloat_co:
|
|
441
|
-
"""
|
|
448
|
+
"""Omega ratio.
|
|
449
|
+
|
|
450
|
+
Reference: https://en.wikipedia.org/wiki/Omega_ratio.
|
|
442
451
|
|
|
443
452
|
Returns:
|
|
444
453
|
--------
|
|
@@ -453,7 +462,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
453
462
|
|
|
454
463
|
@property
|
|
455
464
|
def z_score(self: Self) -> SeriesOrFloat_co:
|
|
456
|
-
"""
|
|
465
|
+
"""Z-score.
|
|
466
|
+
|
|
467
|
+
Reference: https://www.investopedia.com/terms/z/zscore.asp.
|
|
457
468
|
|
|
458
469
|
Returns:
|
|
459
470
|
--------
|
|
@@ -467,7 +478,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
467
478
|
|
|
468
479
|
@property
|
|
469
480
|
def max_drawdown(self: Self) -> SeriesOrFloat_co:
|
|
470
|
-
"""
|
|
481
|
+
"""Maximum drawdown without any limit on date range.
|
|
482
|
+
|
|
483
|
+
Reference: https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
|
|
471
484
|
|
|
472
485
|
Returns:
|
|
473
486
|
--------
|
|
@@ -483,7 +496,7 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
483
496
|
def max_drawdown_date(self: Self) -> dt.date | Series[dt.date]:
|
|
484
497
|
"""Date when the maximum drawdown occurred.
|
|
485
498
|
|
|
486
|
-
https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
|
|
499
|
+
Reference: https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp.
|
|
487
500
|
|
|
488
501
|
Returns:
|
|
489
502
|
--------
|
|
@@ -493,16 +506,17 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
493
506
|
"""
|
|
494
507
|
mdddf = self.tsdf.copy()
|
|
495
508
|
mdddf.index = DatetimeIndex(mdddf.index)
|
|
496
|
-
result = (mdddf / mdddf.expanding(min_periods=1).max()).idxmin().dt.date
|
|
509
|
+
result = (mdddf / mdddf.expanding(min_periods=1).max()).idxmin().dt.date # type: ignore[attr-defined,arg-type]
|
|
497
510
|
|
|
498
511
|
if self.tsdf.shape[1] == 1:
|
|
499
|
-
return result.iloc[0]
|
|
500
|
-
|
|
512
|
+
return cast("dt.date", result.iloc[0])
|
|
513
|
+
date_series = Series(
|
|
501
514
|
data=result,
|
|
502
515
|
index=self.tsdf.columns,
|
|
503
516
|
name="Max drawdown date",
|
|
504
517
|
dtype="datetime64[ns]",
|
|
505
|
-
).dt.date
|
|
518
|
+
).dt.date # type: ignore[attr-defined]
|
|
519
|
+
return cast("Series[dt.date]", date_series)
|
|
506
520
|
|
|
507
521
|
@property
|
|
508
522
|
def worst(self: Self) -> SeriesOrFloat_co:
|
|
@@ -581,7 +595,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
581
595
|
|
|
582
596
|
@property
|
|
583
597
|
def skew(self: Self) -> SeriesOrFloat_co:
|
|
584
|
-
"""
|
|
598
|
+
"""Skew of the return distribution.
|
|
599
|
+
|
|
600
|
+
Reference: https://www.investopedia.com/terms/s/skewness.asp.
|
|
585
601
|
|
|
586
602
|
Returns:
|
|
587
603
|
--------
|
|
@@ -595,7 +611,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
595
611
|
|
|
596
612
|
@property
|
|
597
613
|
def kurtosis(self: Self) -> SeriesOrFloat_co:
|
|
598
|
-
"""
|
|
614
|
+
"""Kurtosis of the return distribution.
|
|
615
|
+
|
|
616
|
+
Reference: https://www.investopedia.com/terms/k/kurtosis.asp.
|
|
599
617
|
|
|
600
618
|
Returns:
|
|
601
619
|
--------
|
|
@@ -609,7 +627,9 @@ class _CommonModel(BaseModel, Generic[SeriesOrFloat_co]):
|
|
|
609
627
|
|
|
610
628
|
@property
|
|
611
629
|
def cvar_down(self: Self) -> SeriesOrFloat_co:
|
|
612
|
-
"""
|
|
630
|
+
"""Downside 95% Conditional Value At Risk "CVaR".
|
|
631
|
+
|
|
632
|
+
Reference: https://www.investopedia.com/terms/c/conditional_value_at_risk.asp.
|
|
613
633
|
|
|
614
634
|
Returns:
|
|
615
635
|
--------
|
|
@@ -23,7 +23,7 @@ def _cvar_down_calc(
|
|
|
23
23
|
) -> float:
|
|
24
24
|
"""Calculate downside Conditional Value at Risk (CVaR).
|
|
25
25
|
|
|
26
|
-
https://www.investopedia.com/terms/c/conditional_value_at_risk.asp.
|
|
26
|
+
Reference: https://www.investopedia.com/terms/c/conditional_value_at_risk.asp.
|
|
27
27
|
|
|
28
28
|
Args:
|
|
29
29
|
data: The data to perform the calculation over.
|
|
@@ -48,8 +48,9 @@ def _var_down_calc(
|
|
|
48
48
|
) -> float:
|
|
49
49
|
"""Calculate downside Value At Risk (VaR).
|
|
50
50
|
|
|
51
|
-
The equivalent of percentile.inc([...], 1-level) over returns in MS Excel
|
|
52
|
-
|
|
51
|
+
The equivalent of percentile.inc([...], 1-level) over returns in MS Excel.
|
|
52
|
+
|
|
53
|
+
Reference: https://www.investopedia.com/terms/v/var.asp.
|
|
53
54
|
|
|
54
55
|
Args:
|
|
55
56
|
data: The data to perform the calculation over.
|