openseries 1.2.3__py3-none-any.whl → 1.2.5__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/datefixer.py +6 -6
- openseries/load_plotly.py +2 -1
- openseries/series.py +22 -25
- openseries/types.py +1 -2
- {openseries-1.2.3.dist-info → openseries-1.2.5.dist-info}/METADATA +7 -6
- {openseries-1.2.3.dist-info → openseries-1.2.5.dist-info}/RECORD +8 -8
- {openseries-1.2.3.dist-info → openseries-1.2.5.dist-info}/LICENSE.md +0 -0
- {openseries-1.2.3.dist-info → openseries-1.2.5.dist-info}/WHEEL +0 -0
openseries/datefixer.py
CHANGED
@@ -24,7 +24,7 @@ def holiday_calendar(
|
|
24
24
|
startyear: int,
|
25
25
|
endyear: int,
|
26
26
|
countries: CountriesType = "SE",
|
27
|
-
custom_holidays: HolidayType = None,
|
27
|
+
custom_holidays: Optional[HolidayType] = None,
|
28
28
|
) -> busdaycalendar:
|
29
29
|
"""
|
30
30
|
Generate a business calendar.
|
@@ -121,14 +121,14 @@ def date_offset_foll(
|
|
121
121
|
adjust: bool = False,
|
122
122
|
following: bool = True,
|
123
123
|
countries: CountriesType = "SE",
|
124
|
-
custom_holidays: HolidayType = None,
|
124
|
+
custom_holidays: Optional[HolidayType] = None,
|
125
125
|
) -> dt.date:
|
126
126
|
"""
|
127
127
|
Offset dates according to a given calendar.
|
128
128
|
|
129
129
|
Parameters
|
130
130
|
----------
|
131
|
-
raw_date:
|
131
|
+
raw_date: DateType
|
132
132
|
The date to offset from
|
133
133
|
months_offset: int, default: 12
|
134
134
|
Number of months as integer
|
@@ -175,7 +175,7 @@ def date_offset_foll(
|
|
175
175
|
def get_previous_business_day_before_today(
|
176
176
|
today: Optional[dt.date] = None,
|
177
177
|
countries: CountriesType = "SE",
|
178
|
-
custom_holidays: HolidayType = None,
|
178
|
+
custom_holidays: Optional[HolidayType] = None,
|
179
179
|
) -> dt.date:
|
180
180
|
"""
|
181
181
|
Bump date backwards to find the previous business day.
|
@@ -212,7 +212,7 @@ def offset_business_days(
|
|
212
212
|
ddate: dt.date,
|
213
213
|
days: int,
|
214
214
|
countries: CountriesType = "SE",
|
215
|
-
custom_holidays: HolidayType = None,
|
215
|
+
custom_holidays: Optional[HolidayType] = None,
|
216
216
|
) -> dt.date:
|
217
217
|
"""
|
218
218
|
Bump date by business days.
|
@@ -481,7 +481,7 @@ def get_calc_range(
|
|
481
481
|
|
482
482
|
Returns
|
483
483
|
-------
|
484
|
-
|
484
|
+
tuple[datetime.date, datetime.date]
|
485
485
|
Start and end date of the chosen date range
|
486
486
|
"""
|
487
487
|
earlier, later = data.index[0], data.index[-1]
|
openseries/load_plotly.py
CHANGED
@@ -20,7 +20,8 @@ def load_plotly_dict(
|
|
20
20
|
|
21
21
|
Returns
|
22
22
|
-------
|
23
|
-
|
23
|
+
PlotlyLayoutType
|
24
|
+
A dictionary with the Plotly config and layout template
|
24
25
|
"""
|
25
26
|
project_root = dirname(dirname(abspath(__file__)))
|
26
27
|
layoutfile = join(abspath(project_root), "openseries", "plotly_layouts.json")
|
openseries/series.py
CHANGED
@@ -7,15 +7,14 @@ from re import compile as re_compile
|
|
7
7
|
from typing import Any, Optional, TypeVar, Union, cast
|
8
8
|
|
9
9
|
from numpy import (
|
10
|
+
append,
|
10
11
|
array,
|
11
12
|
cumprod,
|
12
|
-
float64,
|
13
13
|
insert,
|
14
14
|
isnan,
|
15
15
|
log,
|
16
16
|
sqrt,
|
17
17
|
)
|
18
|
-
from numpy.typing import NDArray
|
19
18
|
from pandas import (
|
20
19
|
DataFrame,
|
21
20
|
DatetimeIndex,
|
@@ -62,13 +61,13 @@ class OpenTimeSeries(BaseModel, CommonModel): # type: ignore[misc]
|
|
62
61
|
|
63
62
|
Parameters
|
64
63
|
----------
|
65
|
-
|
64
|
+
timeseries_id : DatabaseIdStringType
|
66
65
|
Database identifier of the timeseries
|
67
|
-
|
66
|
+
instrument_id: DatabaseIdStringType
|
68
67
|
Database identifier of the instrument associated with the timeseries
|
69
68
|
name : str
|
70
69
|
string identifier of the timeseries and/or instrument
|
71
|
-
valuetype :
|
70
|
+
valuetype : ValueType
|
72
71
|
Identifies if the series is a series of values or returns
|
73
72
|
dates : DateListType
|
74
73
|
Dates of the individual timeseries items
|
@@ -84,7 +83,7 @@ class OpenTimeSeries(BaseModel, CommonModel): # type: ignore[misc]
|
|
84
83
|
ISO 4217 currency code of the timeseries
|
85
84
|
domestic : CurrencyStringType, default: "SEK"
|
86
85
|
ISO 4217 currency code of the user's home currency
|
87
|
-
countries:
|
86
|
+
countries: CountriesType, default: "SE"
|
88
87
|
(List of) country code(s) according to ISO 3166-1 alpha-2
|
89
88
|
isin : str, optional
|
90
89
|
ISO 6166 identifier code of the associated instrument
|
@@ -92,8 +91,8 @@ class OpenTimeSeries(BaseModel, CommonModel): # type: ignore[misc]
|
|
92
91
|
Placeholder for a name of the timeseries
|
93
92
|
"""
|
94
93
|
|
95
|
-
|
96
|
-
|
94
|
+
timeseries_id: DatabaseIdStringType
|
95
|
+
instrument_id: DatabaseIdStringType
|
97
96
|
name: str
|
98
97
|
valuetype: ValueType
|
99
98
|
dates: DateListType
|
@@ -236,8 +235,8 @@ class OpenTimeSeries(BaseModel, CommonModel): # type: ignore[misc]
|
|
236
235
|
dates=dates,
|
237
236
|
values=values,
|
238
237
|
valuetype=valuetype,
|
239
|
-
|
240
|
-
|
238
|
+
timeseries_id=timeseries_id,
|
239
|
+
instrument_id=instrument_id,
|
241
240
|
isin=isin,
|
242
241
|
currency=baseccy,
|
243
242
|
local_ccy=local_ccy,
|
@@ -315,8 +314,8 @@ class OpenTimeSeries(BaseModel, CommonModel): # type: ignore[misc]
|
|
315
314
|
dates = [date_fix(d).strftime("%Y-%m-%d") for d in dframe.index]
|
316
315
|
|
317
316
|
return cls(
|
318
|
-
|
319
|
-
|
317
|
+
timeseries_id="",
|
318
|
+
instrument_id="",
|
320
319
|
currency=baseccy,
|
321
320
|
dates=dates,
|
322
321
|
name=label,
|
@@ -396,8 +395,8 @@ class OpenTimeSeries(BaseModel, CommonModel): # type: ignore[misc]
|
|
396
395
|
d_range = [d.strftime("%Y-%m-%d") for d in cast(DatetimeIndex, d_range)]
|
397
396
|
|
398
397
|
return cls(
|
399
|
-
|
400
|
-
|
398
|
+
timeseries_id="",
|
399
|
+
instrument_id="",
|
401
400
|
currency=baseccy,
|
402
401
|
dates=d_range,
|
403
402
|
name=label,
|
@@ -784,7 +783,7 @@ class OpenTimeSeries(BaseModel, CommonModel): # type: ignore[misc]
|
|
784
783
|
days_in_year: int = 365,
|
785
784
|
) -> TypeOpenTimeSeries:
|
786
785
|
"""
|
787
|
-
Add
|
786
|
+
Add or subtract a fee from the timeseries return.
|
788
787
|
|
789
788
|
Parameters
|
790
789
|
----------
|
@@ -913,21 +912,19 @@ def timeseries_chain(
|
|
913
912
|
raise ValueError("Failed to find a matching date between series")
|
914
913
|
|
915
914
|
dates: list[str] = [x.strftime("%Y-%m-%d") for x in olddf.index if x < first]
|
916
|
-
|
917
|
-
values =
|
918
|
-
|
919
|
-
|
920
|
-
)
|
915
|
+
|
916
|
+
values = old.tsdf.iloc[: len(dates), 0]
|
917
|
+
values = values.mul(new.tsdf.iloc[:, 0].loc[first] / olddf.iloc[:, 0].loc[first])
|
918
|
+
values = append(values, new.tsdf.iloc[:, 0])
|
921
919
|
|
922
920
|
dates.extend([x.strftime("%Y-%m-%d") for x in new.tsdf.index])
|
923
|
-
values += [x[0] for x in new.tsdf.to_numpy()]
|
924
921
|
|
925
922
|
if back.__class__.__subclasscheck__(
|
926
923
|
OpenTimeSeries,
|
927
924
|
):
|
928
925
|
return OpenTimeSeries(
|
929
|
-
|
930
|
-
|
926
|
+
timeseries_id=new.timeseries_id,
|
927
|
+
instrument_id=new.instrument_id,
|
931
928
|
currency=new.currency,
|
932
929
|
dates=dates,
|
933
930
|
name=new.name,
|
@@ -943,8 +940,8 @@ def timeseries_chain(
|
|
943
940
|
),
|
944
941
|
)
|
945
942
|
return back.__class__(
|
946
|
-
|
947
|
-
|
943
|
+
timeseries_id=new.timeseries_id,
|
944
|
+
instrument_id=new.instrument_id,
|
948
945
|
currency=new.currency,
|
949
946
|
dates=dates,
|
950
947
|
name=new.name,
|
openseries/types.py
CHANGED
@@ -72,7 +72,6 @@ HolidayType = Union[
|
|
72
72
|
str,
|
73
73
|
float,
|
74
74
|
int,
|
75
|
-
None,
|
76
75
|
]
|
77
76
|
|
78
77
|
PlotlyLayoutType = tuple[
|
@@ -297,7 +296,7 @@ class OpenFramePropertiesList(list[str]):
|
|
297
296
|
|
298
297
|
class ValueType(str, Enum):
|
299
298
|
|
300
|
-
"""
|
299
|
+
"""Enum types of OpenTimeSeries to identify the output."""
|
301
300
|
|
302
301
|
EWMA = "EWMA"
|
303
302
|
PRICE = "Price(Close)"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: openseries
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.5
|
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
|
@@ -24,8 +24,8 @@ 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.
|
28
|
-
Requires-Dist: pydantic (>=2.
|
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
30
|
Requires-Dist: python-stdnum (>=1.19,<2.0)
|
31
31
|
Requires-Dist: scipy (>=1.11.2,<2.0.0)
|
@@ -43,10 +43,11 @@ width="81" height="100" align="left" float="right"/><br/>
|
|
43
43
|
|
44
44
|
[](https://pypi.org/project/openseries/)
|
45
45
|
[](https://www.python.org/)
|
46
|
-

|
47
|
-

|
46
|
+
[](https://github.com/CaptorAB/OpenSeries/actions/workflows/test.yml)
|
47
|
+
[](https://github.com/CaptorAB/OpenSeries/actions/workflows/test.yml)
|
48
|
+
[](https://github.com/CaptorAB/OpenSeries/actions/workflows/checks.yml)
|
48
49
|
[](https://black.readthedocs.io/en/stable/index.html)
|
49
|
-
](https://beta.ruff.rs/docs/)
|
50
51
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
51
52
|
|
52
53
|
**OpenSeries** is a project with tools to analyse financial timeseries of a single
|
@@ -1,15 +1,15 @@
|
|
1
1
|
openseries/__init__.py,sha256=hA7I5IFk88EnX6eyBbI1KLT_FGcmPIKF49xa5g3T8Yg,41
|
2
2
|
openseries/common_model.py,sha256=wS-e5Kvgy3kGXOBvvOLfPcmaYYf6UhJlWb0-o_-Fk1M,62340
|
3
|
-
openseries/datefixer.py,sha256=
|
3
|
+
openseries/datefixer.py,sha256=sgPqd8UpHPysuEE_f4Q69kl8lrbZo4KdiCMXXkM18zA,15651
|
4
4
|
openseries/frame.py,sha256=1if8q37ZaUzFJXfeV8P7tGCZ0S6PtMjlO6_EgYer_QI,56963
|
5
|
-
openseries/load_plotly.py,sha256=
|
5
|
+
openseries/load_plotly.py,sha256=nPIit1-dAyVlNRuD8hOzTmidFqIhVVrgl9R0rhrSD7I,1026
|
6
6
|
openseries/plotly_captor_logo.json,sha256=pGMuPVu4cEO3ZsCH1wU03hxqbIQkHFNoJUs1k1WK89Y,178
|
7
7
|
openseries/plotly_layouts.json,sha256=xhrMOqW8LXb4QMtPiNBGdkPX518OHThiIJ68jpQk524,1429
|
8
8
|
openseries/risk.py,sha256=3l73XY78R1IuyafSKYF1Ly8GTnPBWmKXGK57HVek0e0,5504
|
9
|
-
openseries/series.py,sha256=
|
9
|
+
openseries/series.py,sha256=udatilM5KnmyR_gUGqxYPtg4q16sGXcUQsgVse2J7zg,31736
|
10
10
|
openseries/simulation.py,sha256=-QfiiVqzKh-Ar_i33WECHuMq1IQcpFJUBBGxhDHDWEM,35504
|
11
|
-
openseries/types.py,sha256=
|
12
|
-
openseries-1.2.
|
13
|
-
openseries-1.2.
|
14
|
-
openseries-1.2.
|
15
|
-
openseries-1.2.
|
11
|
+
openseries/types.py,sha256=sM-Bayvw8ubMyaRwEt-LSHLARPJ6y3k-P_edG3mqkl8,7576
|
12
|
+
openseries-1.2.5.dist-info/LICENSE.md,sha256=NJjeq3wyB7EnnHLmsdK1EK6zT00T1eB3FgAmHAPT_vM,1521
|
13
|
+
openseries-1.2.5.dist-info/METADATA,sha256=BHZJf5GBUb8o03828rXmhzpmuJASA2E9u1NhuNQcxzg,48303
|
14
|
+
openseries-1.2.5.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
15
|
+
openseries-1.2.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|