openseries 1.5.4__tar.gz → 1.5.5__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.5}/PKG-INFO +1 -1
- {openseries-1.5.4 → openseries-1.5.5}/openseries/_common_model.py +21 -8
- {openseries-1.5.4 → openseries-1.5.5}/openseries/types.py +1 -0
- {openseries-1.5.4 → openseries-1.5.5}/pyproject.toml +7 -7
- {openseries-1.5.4 → openseries-1.5.5}/LICENSE.md +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/README.md +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/__init__.py +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/_risk.py +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/datefixer.py +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/frame.py +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/load_plotly.py +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/plotly_captor_logo.json +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/plotly_layouts.json +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/series.py +0 -0
- {openseries-1.5.4 → openseries-1.5.5}/openseries/simulation.py +0 -0
@@ -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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "openseries"
|
3
|
-
version = "1.5.
|
3
|
+
version = "1.5.5"
|
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"
|
@@ -50,16 +50,16 @@ statsmodels = ">=0.14.0,<1.0.0"
|
|
50
50
|
coverage = "^7.5.1"
|
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.
|
53
|
+
pandas-stubs = "^2.2.2.240514"
|
54
|
+
pre-commit = "^3.7.1"
|
55
|
+
pytest = "^8.2.1"
|
56
|
+
ruff = "^0.4.5"
|
57
57
|
types-openpyxl = "^3.1.0.20240428"
|
58
58
|
types-python-dateutil = "^2.9.0.20240316"
|
59
|
-
types-requests = "^2.
|
59
|
+
types-requests = "^2.32.0.20240523"
|
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
65
|
[tool.pytest.ini_options]
|
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
|
File without changes
|
File without changes
|