openseries 1.2.2__py3-none-any.whl → 1.2.4__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/types.py CHANGED
@@ -1,20 +1,31 @@
1
- """
2
- Declaring types used throughout the project
3
- """
1
+ """Declaring types used throughout the project."""
4
2
  from __future__ import annotations
3
+
4
+ import datetime as dt
5
5
  from enum import Enum
6
- from typing import Annotated, Literal, Union
7
- from pydantic import confloat, conint, conlist, constr, StringConstraints
6
+ from typing import Annotated, ClassVar, Literal, TypeVar, Union
7
+
8
+ from numpy import datetime64
9
+ from pandas import Timestamp
10
+ from pydantic import StringConstraints, confloat, conint, conlist, constr
8
11
 
9
12
  CountryStringType = Annotated[
10
13
  str,
11
14
  StringConstraints(
12
- pattern=r"^[A-Z]{2}$", to_upper=True, min_length=2, max_length=2, strict=True
15
+ pattern=r"^[A-Z]{2}$",
16
+ to_upper=True,
17
+ min_length=2,
18
+ max_length=2,
19
+ strict=True,
13
20
  ),
14
21
  ]
15
22
  CountryListType = conlist(
16
23
  constr(
17
- pattern=r"^[A-Z]{2}$", to_upper=True, min_length=2, max_length=2, strict=True
24
+ pattern=r"^[A-Z]{2}$",
25
+ to_upper=True,
26
+ min_length=2,
27
+ max_length=2,
28
+ strict=True,
18
29
  ),
19
30
  min_length=1,
20
31
  )
@@ -23,14 +34,19 @@ CountriesType = Union[CountryListType, CountryStringType] # type: ignore[valid-
23
34
  CurrencyStringType = Annotated[
24
35
  str,
25
36
  StringConstraints(
26
- pattern=r"^[A-Z]{3}$", to_upper=True, min_length=3, max_length=3, strict=True
37
+ pattern=r"^[A-Z]{3}$",
38
+ to_upper=True,
39
+ min_length=3,
40
+ max_length=3,
41
+ strict=True,
27
42
  ),
28
43
  ]
29
44
 
30
45
  DateListType = Annotated[
31
46
  list[str],
32
47
  conlist(
33
- constr(pattern=r"^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$"), min_length=2
48
+ constr(pattern=r"^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$"),
49
+ min_length=2,
34
50
  ),
35
51
  ]
36
52
 
@@ -46,6 +62,33 @@ SimCountType = Annotated[int, conint(strict=True, ge=1)]
46
62
 
47
63
  VolatilityType = Annotated[float, confloat(strict=True, gt=0.0)]
48
64
 
65
+ DateType = Union[str, dt.date, dt.datetime, datetime64, Timestamp]
66
+
67
+ HolidayType = Union[
68
+ dict[Union[dt.date, dt.datetime, str, float, int], str],
69
+ list[Union[dt.date, dt.datetime, str, float, int]],
70
+ dt.date,
71
+ dt.datetime,
72
+ str,
73
+ float,
74
+ int,
75
+ ]
76
+
77
+ PlotlyLayoutType = tuple[
78
+ dict[
79
+ str,
80
+ Union[
81
+ str,
82
+ int,
83
+ float,
84
+ bool,
85
+ list[str],
86
+ dict[str, Union[str, int, float, bool, list[str]]],
87
+ ],
88
+ ],
89
+ dict[str, Union[str, float]],
90
+ ]
91
+
49
92
  LiteralLinePlotMode = Literal[
50
93
  "lines",
51
94
  "markers",
@@ -59,7 +102,12 @@ LiteralQuantileInterp = Literal["linear", "lower", "higher", "midpoint", "neares
59
102
  LiteralBizDayFreq = Literal["BM", "BQ", "BA"]
60
103
  LiteralPandasResampleConvention = Literal["start", "s", "end", "e"]
61
104
  LiteralPandasReindexMethod = Literal[
62
- None, "pad", "ffill", "backfill", "bfill", "nearest"
105
+ None,
106
+ "pad",
107
+ "ffill",
108
+ "backfill",
109
+ "bfill",
110
+ "nearest",
63
111
  ]
64
112
  LiteralNanMethod = Literal["fill", "drop"]
65
113
  LiteralCaptureRatio = Literal["up", "down", "both"]
@@ -135,11 +183,17 @@ LiteralFrameProps = Literal[
135
183
  "span_of_days_all",
136
184
  ]
137
185
 
186
+ TypeOpenTimeSeriesPropertiesList = TypeVar(
187
+ "TypeOpenTimeSeriesPropertiesList",
188
+ bound="OpenTimeSeriesPropertiesList",
189
+ )
190
+
138
191
 
139
192
  class OpenTimeSeriesPropertiesList(list[str]):
140
- """Allowed property arguments for the OpenTimeSeries class"""
141
193
 
142
- allowed_strings = {
194
+ """Allowed property arguments for the OpenTimeSeries class."""
195
+
196
+ allowed_strings: ClassVar[set[str]] = {
143
197
  "value_ret",
144
198
  "geo_ret",
145
199
  "arithmetic_ret",
@@ -167,26 +221,37 @@ class OpenTimeSeriesPropertiesList(list[str]):
167
221
  "periods_in_a_year",
168
222
  }
169
223
 
170
- def __init__(self, *args: LiteralSeriesProps) -> None:
224
+ def __init__(
225
+ self: TypeOpenTimeSeriesPropertiesList,
226
+ *args: LiteralSeriesProps,
227
+ ) -> None:
228
+ """Property arguments for the OpenTimeSeries class."""
171
229
  super().__init__(args)
172
230
  self._validate()
173
231
 
174
- def _validate(self) -> None:
232
+ def _validate(self: TypeOpenTimeSeriesPropertiesList) -> None:
175
233
  seen = set()
176
234
  for item in self:
177
235
  if item not in self.allowed_strings:
178
236
  raise ValueError(
179
- f"Invalid string: {item}. Allowed strings: {self.allowed_strings}"
237
+ f"Invalid string: {item}. Allowed strings: {self.allowed_strings}",
180
238
  )
181
239
  if item in seen:
182
240
  raise ValueError(f"Duplicate string: {item}")
183
241
  seen.add(item)
184
242
 
185
243
 
244
+ TypeOpenFramePropertiesList = TypeVar(
245
+ "TypeOpenFramePropertiesList",
246
+ bound="OpenFramePropertiesList",
247
+ )
248
+
249
+
186
250
  class OpenFramePropertiesList(list[str]):
187
- """Allowed property arguments for the OpenFrame class"""
188
251
 
189
- allowed_strings = {
252
+ """Allowed property arguments for the OpenFrame class."""
253
+
254
+ allowed_strings: ClassVar[set[str]] = {
190
255
  "value_ret",
191
256
  "geo_ret",
192
257
  "arithmetic_ret",
@@ -212,16 +277,17 @@ class OpenFramePropertiesList(list[str]):
212
277
  "span_of_days_all",
213
278
  }
214
279
 
215
- def __init__(self, *args: LiteralFrameProps) -> None:
280
+ def __init__(self: TypeOpenFramePropertiesList, *args: LiteralFrameProps) -> None:
281
+ """Property arguments for the OpenFrame class."""
216
282
  super().__init__(args)
217
283
  self._validate()
218
284
 
219
- def _validate(self) -> None:
285
+ def _validate(self: TypeOpenFramePropertiesList) -> None:
220
286
  seen = set()
221
287
  for item in self:
222
288
  if item not in self.allowed_strings:
223
289
  raise ValueError(
224
- f"Invalid string: {item}. Allowed strings: {self.allowed_strings}"
290
+ f"Invalid string: {item}. Allowed strings: {self.allowed_strings}",
225
291
  )
226
292
  if item in seen:
227
293
  raise ValueError(f"Duplicate string: {item}")
@@ -229,7 +295,8 @@ class OpenFramePropertiesList(list[str]):
229
295
 
230
296
 
231
297
  class ValueType(str, Enum):
232
- """Class defining the different timeseries types within the project"""
298
+
299
+ """Class defining the different timeseries types within the project."""
233
300
 
234
301
  EWMA = "EWMA"
235
302
  PRICE = "Price(Close)"
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openseries
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: Package for simple financial time series analysis.
5
5
  Home-page: https://github.com/CaptorAB/OpenSeries
6
6
  License: BSD-3-Clause
7
- Keywords: python,python3,plotly,pandas,finance,fintech,data-science,timeseries,timeseries-data,timeseries-analysis,investment,investment-analysis,investing
7
+ Keywords: python,finance,fintech,data-science,timeseries,timeseries-data,timeseries-analysis,investment,investment-analysis,investing
8
8
  Author: Martin Karrin
9
9
  Author-email: martin.karrin@captor.se
10
10
  Requires-Python: >=3.9,<3.12
@@ -20,15 +20,15 @@ Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Topic :: Office/Business :: Financial :: Investment
22
22
  Requires-Dist: ffn (>=0.3.7,<0.4.0)
23
- Requires-Dist: holidays (>=0.30,<0.31)
23
+ Requires-Dist: holidays (>=0.31,<0.32)
24
24
  Requires-Dist: numpy (>=1.25.2,<2.0.0)
25
25
  Requires-Dist: openpyxl (>=3.1.2,<4.0.0)
26
26
  Requires-Dist: pandas (>=2.0.3,<3.0.0)
27
- Requires-Dist: plotly (>=5.16.0,<6.0.0)
28
- Requires-Dist: pydantic (>=2.2.0,<3.0.0)
27
+ Requires-Dist: plotly (>=5.16.1,<6.0.0)
28
+ Requires-Dist: pydantic (>=2.3.0,<3.0.0)
29
29
  Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
30
- Requires-Dist: python-stdnum (>=1.18,<2.0)
31
- Requires-Dist: scipy (>=1.11.1,<2.0.0)
30
+ Requires-Dist: python-stdnum (>=1.19,<2.0)
31
+ Requires-Dist: scipy (>=1.11.2,<2.0.0)
32
32
  Requires-Dist: statsmodels (>=0.14.0,<0.15.0)
33
33
  Project-URL: Repository, https://github.com/CaptorAB/OpenSeries
34
34
  Description-Content-Type: text/markdown
@@ -46,7 +46,7 @@ width="81" height="100" align="left" float="right"/><br/>
46
46
  ![GitHub Action Test Suite](https://github.com/CaptorAB/OpenSeries/actions/workflows/test.yml/badge.svg)
47
47
  ![Coverage](https://cdn.jsdelivr.net/gh/CaptorAB/OpenSeries@master/coverage.svg)
48
48
  [![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://black.readthedocs.io/en/stable/index.html)
49
- ![pylint](https://github.com/CaptorAB/OpenSeries/actions/workflows/pylint.yml/badge.svg)
49
+ ![ruff](https://github.com/CaptorAB/OpenSeries/actions/workflows/ruff.yml/badge.svg)
50
50
  [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
51
51
 
52
52
  **OpenSeries** is a project with tools to analyse financial timeseries of a single
@@ -153,10 +153,10 @@ make install
153
153
 
154
154
  ## Testing and Linting / Type-checking
155
155
 
156
- Flake8, Black and Pylint checking is embedded in the pre-commit hook but not mypy. All
157
- packages are used in the project's GitHub workflows and are run when the `lint`
156
+ Ruff, Black and Mypy checking is embedded in the pre-commit hook. All
157
+ are also used in the project's GitHub workflows and are run when the `lint`
158
158
  alternative is chosen in the below commands.
159
- The silenced error codes can be found in the
159
+ Any silenced error codes can be found in the
160
160
  [pyproject.toml](https://github.com/CaptorAB/OpenSeries/blob/master/pyproject.toml)
161
161
  file or in in-line comments.
162
162
 
@@ -200,7 +200,6 @@ make lint
200
200
  | [series.py](https://github.com/CaptorAB/OpenSeries/blob/master/openseries/series.py) | Defines the class _OpenTimeSeries_ for managing and analyzing a single timeseries. The module also defines a function `timeseries_chain` that can be used to chain two timeseries objects together. |
201
201
  | [frame.py](https://github.com/CaptorAB/OpenSeries/blob/master/openseries/frame.py) | Defines the class _OpenFrame_ for managing a group of timeseries, and e.g. calculate a portfolio timeseries from a rebalancing strategy between timeseries. |
202
202
  | [common_model.py](https://github.com/CaptorAB/OpenSeries/blob/master/openseries/common_model.py) | Defines the class _CommonModel_ which is a base class for both the above classes. |
203
- | [common_tools.py](https://github.com/CaptorAB/OpenSeries/blob/master/openseries/common_tools.py) | Contains a few functions used elsewhere in the project. |
204
203
  | [datefixer.py](https://github.com/CaptorAB/OpenSeries/blob/master/openseries/datefixer.py) | Date utilities. Please read the docstring of each function for its description. |
205
204
  | [load_plotly.py](https://github.com/CaptorAB/OpenSeries/blob/master/openseries/load_plotly.py) | Functions to load [Plotly](https://plotly.com/python/) default layout and configuration from local json file. |
206
205
  | [plotly_layouts.json](https://github.com/CaptorAB/OpenSeries/blob/master/openseries/plotly_layouts.json) | [Plotly](https://plotly.com/python/) defaults used in the `plot_bars` and `plot_series` methods. |
@@ -0,0 +1,15 @@
1
+ openseries/__init__.py,sha256=hA7I5IFk88EnX6eyBbI1KLT_FGcmPIKF49xa5g3T8Yg,41
2
+ openseries/common_model.py,sha256=wS-e5Kvgy3kGXOBvvOLfPcmaYYf6UhJlWb0-o_-Fk1M,62340
3
+ openseries/datefixer.py,sha256=o6vePHinMhJeC_z82ekGdKGePriP8d_0pCravckYoCI,15651
4
+ openseries/frame.py,sha256=1if8q37ZaUzFJXfeV8P7tGCZ0S6PtMjlO6_EgYer_QI,56963
5
+ openseries/load_plotly.py,sha256=U5UQ3R2VktEA_QneCfFObiOV1yfzZBuVmRmyXiLSwc8,1001
6
+ openseries/plotly_captor_logo.json,sha256=pGMuPVu4cEO3ZsCH1wU03hxqbIQkHFNoJUs1k1WK89Y,178
7
+ openseries/plotly_layouts.json,sha256=xhrMOqW8LXb4QMtPiNBGdkPX518OHThiIJ68jpQk524,1429
8
+ openseries/risk.py,sha256=3l73XY78R1IuyafSKYF1Ly8GTnPBWmKXGK57HVek0e0,5504
9
+ openseries/series.py,sha256=RmZUSyvYJk1AuWeHYFbnHQ4RQFdqXmzWL_dkn5FNomk,31909
10
+ openseries/simulation.py,sha256=-QfiiVqzKh-Ar_i33WECHuMq1IQcpFJUBBGxhDHDWEM,35504
11
+ openseries/types.py,sha256=7BJKEjnUPyIEAUBo6NjDa6MggJwVT3C0W42e57IXCXw,7589
12
+ openseries-1.2.4.dist-info/LICENSE.md,sha256=NJjeq3wyB7EnnHLmsdK1EK6zT00T1eB3FgAmHAPT_vM,1521
13
+ openseries-1.2.4.dist-info/METADATA,sha256=7WPSH4miwPHTQK-pEGpQaOLtu7Hs7WvazHQt2U_tGpU,47916
14
+ openseries-1.2.4.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
15
+ openseries-1.2.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.6.1
2
+ Generator: poetry-core 1.7.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,15 +0,0 @@
1
- openseries/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- openseries/common_model.py,sha256=d2gnWYdBc84OafOYzxx-KkmFZb0dH31r8rd6kDPJSXg,60281
3
- openseries/datefixer.py,sha256=si-sFJgS5RPf42bZHHHZ3JQLJLBNST11cpI2X37cQ30,17466
4
- openseries/frame.py,sha256=7gu6H3XVhHQlcF7wnP0y3louqLpqtZXM7PwENgV82L8,54862
5
- openseries/load_plotly.py,sha256=zBLlO8gjPrguWmf3u3nfyUd-EhI_ZmCk9AQDZ9QSx3E,1161
6
- openseries/plotly_captor_logo.json,sha256=pGMuPVu4cEO3ZsCH1wU03hxqbIQkHFNoJUs1k1WK89Y,178
7
- openseries/plotly_layouts.json,sha256=xhrMOqW8LXb4QMtPiNBGdkPX518OHThiIJ68jpQk524,1429
8
- openseries/risk.py,sha256=9JzGSXPjcOOpuZmlaTca7OeEwSihipNWoh6zJyDT090,5139
9
- openseries/series.py,sha256=qTYeaLMSUb7vojY9Y1yuAK1Zv4GtnC1kklIH70Emy1I,31426
10
- openseries/simulation.py,sha256=Cs8cjiVsiwvSQxEXb3J6EMxXsZqaqZuBVRto5EkNVFk,34667
11
- openseries/types.py,sha256=_UohZyqbJqsP_rtGM3tAHXuOOyOZmraMvtIHZHyjonM,6253
12
- openseries-1.2.2.dist-info/LICENSE.md,sha256=NJjeq3wyB7EnnHLmsdK1EK6zT00T1eB3FgAmHAPT_vM,1521
13
- openseries-1.2.2.dist-info/METADATA,sha256=iN1jB5D3fTT9bdWrqwP8gz8cklGVFLt0tPwPThz8K6Q,48278
14
- openseries-1.2.2.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
15
- openseries-1.2.2.dist-info/RECORD,,