openseries 1.5.4__tar.gz → 1.5.6__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-1.5.4 → openseries-1.5.6}/PKG-INFO +3 -3
- {openseries-1.5.4 → openseries-1.5.6}/README.md +1 -1
- {openseries-1.5.4 → openseries-1.5.6}/openseries/_common_model.py +21 -8
- {openseries-1.5.4 → openseries-1.5.6}/openseries/datefixer.py +3 -1
- {openseries-1.5.4 → openseries-1.5.6}/openseries/types.py +1 -0
- {openseries-1.5.4 → openseries-1.5.6}/pyproject.toml +10 -15
- {openseries-1.5.4 → openseries-1.5.6}/LICENSE.md +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/__init__.py +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/_risk.py +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/frame.py +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/load_plotly.py +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/plotly_captor_logo.json +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/plotly_layouts.json +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/series.py +0 -0
- {openseries-1.5.4 → openseries-1.5.6}/openseries/simulation.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: openseries
|
3
|
-
Version: 1.5.
|
3
|
+
Version: 1.5.6
|
4
4
|
Summary: Tools for analyzing financial timeseries.
|
5
5
|
Home-page: https://github.com/CaptorAB/openseries
|
6
6
|
License: BSD-3-Clause
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
21
21
|
Classifier: Programming Language :: Python :: 3.12
|
22
22
|
Classifier: Topic :: Office/Business :: Financial :: Investment
|
23
|
-
Requires-Dist: holidays (>=0.30,<
|
23
|
+
Requires-Dist: holidays (>=0.30,<0.50)
|
24
24
|
Requires-Dist: numpy (>=1.23.2,<=2.0.0)
|
25
25
|
Requires-Dist: openpyxl (>=3.1.2,<4.0.0)
|
26
26
|
Requires-Dist: pandas (>=2.1.2,<3.0.0)
|
@@ -302,7 +302,7 @@ make lint
|
|
302
302
|
| `value_nan_handle` | `OpenTimeSeries`, `OpenFrame` | Fills `Nan` in a value series with the preceding non-Nan value. |
|
303
303
|
| `return_nan_handle` | `OpenTimeSeries`, `OpenFrame` | Replaces `Nan` in a return series with a 0.0 `float`. |
|
304
304
|
| `to_cumret` | `OpenTimeSeries`, `OpenFrame` | Converts a return series into a value series and/or resets a value series to be rebased from 1.0. |
|
305
|
-
| `to_json` | `OpenTimeSeries`, `OpenFrame` | Method to export
|
305
|
+
| `to_json` | `OpenTimeSeries`, `OpenFrame` | Method to export object data to a json file. |
|
306
306
|
| `to_xlsx` | `OpenTimeSeries`, `OpenFrame` | Method to save the data in the .tsdf DataFrame to an Excel file. |
|
307
307
|
| `value_to_ret` | `OpenTimeSeries`, `OpenFrame` | Converts a value series into a percentage return series. |
|
308
308
|
| `value_to_diff` | `OpenTimeSeries`, `OpenFrame` | Converts a value series into a series of differences. |
|
@@ -266,7 +266,7 @@ make lint
|
|
266
266
|
| `value_nan_handle` | `OpenTimeSeries`, `OpenFrame` | Fills `Nan` in a value series with the preceding non-Nan value. |
|
267
267
|
| `return_nan_handle` | `OpenTimeSeries`, `OpenFrame` | Replaces `Nan` in a return series with a 0.0 `float`. |
|
268
268
|
| `to_cumret` | `OpenTimeSeries`, `OpenFrame` | Converts a return series into a value series and/or resets a value series to be rebased from 1.0. |
|
269
|
-
| `to_json` | `OpenTimeSeries`, `OpenFrame` | Method to export
|
269
|
+
| `to_json` | `OpenTimeSeries`, `OpenFrame` | Method to export object data to a json file. |
|
270
270
|
| `to_xlsx` | `OpenTimeSeries`, `OpenFrame` | Method to save the data in the .tsdf DataFrame to an Excel file. |
|
271
271
|
| `value_to_ret` | `OpenTimeSeries`, `OpenFrame` | Converts a value series into a percentage return series. |
|
272
272
|
| `value_to_diff` | `OpenTimeSeries`, `OpenFrame` | Converts a value series into a series of differences. |
|
@@ -38,6 +38,7 @@ from openseries.types import (
|
|
38
38
|
CountriesType,
|
39
39
|
DaysInYearType,
|
40
40
|
LiteralBarPlotMode,
|
41
|
+
LiteralJsonOutput,
|
41
42
|
LiteralLinePlotMode,
|
42
43
|
LiteralNanMethod,
|
43
44
|
LiteralPlotlyJSlib,
|
@@ -651,16 +652,18 @@ class _CommonModel(BaseModel):
|
|
651
652
|
|
652
653
|
def to_json(
|
653
654
|
self: Self,
|
655
|
+
what_output: LiteralJsonOutput,
|
654
656
|
filename: str,
|
655
657
|
directory: Optional[DirectoryPath] = None,
|
656
658
|
) -> list[dict[str, Union[str, bool, ValueType, list[str], list[float]]]]:
|
657
659
|
"""
|
658
660
|
Dump timeseries data into a json file.
|
659
661
|
|
660
|
-
The label and tsdf parameters are deleted before the json file is saved
|
661
|
-
|
662
662
|
Parameters
|
663
663
|
----------
|
664
|
+
what_output: LiteralJsonOutput
|
665
|
+
Choice on whether the raw values or the tsdf Dataframe values are
|
666
|
+
returned as json and exported as json file.
|
664
667
|
filename: str
|
665
668
|
Filename including filetype
|
666
669
|
directory: DirectoryPath, optional
|
@@ -669,7 +672,7 @@ class _CommonModel(BaseModel):
|
|
669
672
|
Returns
|
670
673
|
-------
|
671
674
|
list[Dict[str, Union[str, bool, ValueType, list[str], list[float]]]]
|
672
|
-
A list of dictionaries with the
|
675
|
+
A list of dictionaries with the data of the series
|
673
676
|
|
674
677
|
"""
|
675
678
|
if directory:
|
@@ -683,21 +686,31 @@ class _CommonModel(BaseModel):
|
|
683
686
|
data = dict(self.__dict__)
|
684
687
|
output = []
|
685
688
|
if "label" in data:
|
689
|
+
if what_output == "tsdf":
|
690
|
+
values = self.tsdf.iloc[:, 0].tolist()
|
691
|
+
else:
|
692
|
+
values = list(cast(list[float], data.get("values")))
|
686
693
|
for item in cleaner_list:
|
687
694
|
data.pop(item)
|
695
|
+
valuetype = cast(ValueType, data.get("valuetype")).value
|
696
|
+
data.update({"valuetype": valuetype})
|
697
|
+
data.update({"values": values})
|
688
698
|
output.append(dict(data))
|
689
699
|
else:
|
690
700
|
for serie in cast(list[Any], data.get("constituents")):
|
701
|
+
if what_output == "tsdf":
|
702
|
+
values = serie.tsdf.iloc[:, 0].tolist()
|
703
|
+
else:
|
704
|
+
values = list(serie.values)
|
691
705
|
itemdata = dict(serie.__dict__)
|
692
706
|
for item in cleaner_list:
|
693
707
|
itemdata.pop(item)
|
708
|
+
valuetype = cast(ValueType, itemdata["valuetype"]).value
|
709
|
+
itemdata.update({"valuetype": valuetype})
|
710
|
+
itemdata.update({"values": values})
|
694
711
|
output.append(dict(itemdata))
|
695
712
|
|
696
|
-
with
|
697
|
-
dirpath.joinpath(filename),
|
698
|
-
"w",
|
699
|
-
encoding="utf-8",
|
700
|
-
) as jsonfile:
|
713
|
+
with dirpath.joinpath(filename).open(mode="w", encoding="utf-8") as jsonfile:
|
701
714
|
dump(output, jsonfile, indent=2, sort_keys=False)
|
702
715
|
|
703
716
|
return output
|
@@ -62,7 +62,7 @@ def holiday_calendar(
|
|
62
62
|
endyear += 1
|
63
63
|
if startyear == endyear:
|
64
64
|
endyear += 1
|
65
|
-
years = list(range(startyear, endyear))
|
65
|
+
years = list(range(int(startyear), int(endyear)))
|
66
66
|
|
67
67
|
if isinstance(countries, str) and countries in list_supported_countries():
|
68
68
|
staging = country_holidays(country=countries, years=years)
|
@@ -412,9 +412,11 @@ def do_resample_to_business_period_ends(
|
|
412
412
|
data.index = Index(d.date() for d in DatetimeIndex(data.index))
|
413
413
|
|
414
414
|
if newhead.index[0] not in data.index:
|
415
|
+
# noinspection PyUnreachableCode
|
415
416
|
data = concat([data, newhead])
|
416
417
|
|
417
418
|
if newtail.index[0] not in data.index:
|
419
|
+
# noinspection PyUnreachableCode
|
418
420
|
data = concat([data, newtail])
|
419
421
|
|
420
422
|
data = data.sort_index()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "openseries"
|
3
|
-
version = "1.5.
|
3
|
+
version = "1.5.6"
|
4
4
|
description = "Tools for analyzing financial timeseries."
|
5
5
|
authors = ["Martin Karrin <martin.karrin@captor.se>"]
|
6
6
|
repository = "https://github.com/CaptorAB/openseries"
|
@@ -34,7 +34,7 @@ keywords = [
|
|
34
34
|
|
35
35
|
[tool.poetry.dependencies]
|
36
36
|
python = ">=3.9,<3.13"
|
37
|
-
holidays = ">=0.30,<
|
37
|
+
holidays = ">=0.30,<0.50"
|
38
38
|
numpy = ">=1.23.2,<=2.0.0"
|
39
39
|
openpyxl = ">=3.1.2,<4.0.0"
|
40
40
|
pandas = ">=2.1.2,<3.0.0"
|
@@ -47,26 +47,21 @@ scipy = ">=1.11.4,<2.0.0"
|
|
47
47
|
statsmodels = ">=0.14.0,<1.0.0"
|
48
48
|
|
49
49
|
[tool.poetry.group.dev.dependencies]
|
50
|
-
coverage = "^7.5.
|
50
|
+
coverage = "^7.5.3"
|
51
51
|
coverage-badge = "^1.1.1"
|
52
52
|
mypy = "^1.10.0"
|
53
|
-
pandas-stubs = "^2.2.
|
54
|
-
pre-commit = "^3.7.
|
55
|
-
pytest = "^8.2.
|
56
|
-
ruff = "^0.4.
|
57
|
-
types-openpyxl = "^3.1.
|
53
|
+
pandas-stubs = "^2.2.2.240603"
|
54
|
+
pre-commit = "^3.7.1"
|
55
|
+
pytest = "^8.2.1"
|
56
|
+
ruff = "^0.4.7"
|
57
|
+
types-openpyxl = "^3.1.2.20240601"
|
58
58
|
types-python-dateutil = "^2.9.0.20240316"
|
59
|
-
types-requests = "^2.
|
59
|
+
types-requests = "^2.32.0.20240602"
|
60
60
|
|
61
61
|
[build-system]
|
62
|
-
requires = ["poetry-core>=1.8.
|
62
|
+
requires = ["poetry-core>=1.8.3"]
|
63
63
|
build-backend = "poetry.core.masonry.api"
|
64
64
|
|
65
|
-
[tool.pytest.ini_options]
|
66
|
-
filterwarnings = [
|
67
|
-
"ignore::DeprecationWarning:openpyxl.*:"
|
68
|
-
]
|
69
|
-
|
70
65
|
[tool.coverage.run]
|
71
66
|
omit = ["venv/*"]
|
72
67
|
include = ["openseries/*"]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|