openseries 1.7.7__py3-none-any.whl → 1.7.8__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/portfoliotools.py +1 -1
- openseries/series.py +16 -20
- openseries/types.py +0 -10
- {openseries-1.7.7.dist-info → openseries-1.7.8.dist-info}/METADATA +1 -1
- {openseries-1.7.7.dist-info → openseries-1.7.8.dist-info}/RECORD +7 -7
- {openseries-1.7.7.dist-info → openseries-1.7.8.dist-info}/LICENSE.md +0 -0
- {openseries-1.7.7.dist-info → openseries-1.7.8.dist-info}/WHEEL +0 -0
openseries/portfoliotools.py
CHANGED
@@ -189,7 +189,7 @@ def efficient_frontier( # noqa: C901
|
|
189
189
|
frontier_max = cleaned_arithmetic_means.max()
|
190
190
|
|
191
191
|
def _check_sum(weights: NDArray[float64]) -> float64:
|
192
|
-
return
|
192
|
+
return npsum(weights) - 1
|
193
193
|
|
194
194
|
def _get_ret_vol_sr(
|
195
195
|
lg_ret: DataFrame,
|
openseries/series.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
5
|
import datetime as dt
|
6
|
+
from collections.abc import Iterable
|
6
7
|
from copy import deepcopy
|
7
8
|
from logging import warning
|
8
9
|
from typing import Any, TypeVar, cast
|
@@ -35,7 +36,6 @@ from .types import (
|
|
35
36
|
CountriesType,
|
36
37
|
Currency,
|
37
38
|
CurrencyStringType,
|
38
|
-
DatabaseIdStringType,
|
39
39
|
DateListType,
|
40
40
|
DaysInYearType,
|
41
41
|
LiteralBizDayFreq,
|
@@ -60,9 +60,9 @@ class OpenTimeSeries(_CommonModel):
|
|
60
60
|
|
61
61
|
Parameters
|
62
62
|
----------
|
63
|
-
timeseries_id :
|
63
|
+
timeseries_id : str
|
64
64
|
Database identifier of the timeseries
|
65
|
-
instrument_id:
|
65
|
+
instrument_id: str
|
66
66
|
Database identifier of the instrument associated with the timeseries
|
67
67
|
name : str
|
68
68
|
string identifier of the timeseries and/or instrument
|
@@ -91,8 +91,8 @@ class OpenTimeSeries(_CommonModel):
|
|
91
91
|
|
92
92
|
"""
|
93
93
|
|
94
|
-
timeseries_id:
|
95
|
-
instrument_id:
|
94
|
+
timeseries_id: str
|
95
|
+
instrument_id: str
|
96
96
|
name: str
|
97
97
|
valuetype: ValueType
|
98
98
|
dates: DateListType
|
@@ -147,8 +147,8 @@ class OpenTimeSeries(_CommonModel):
|
|
147
147
|
dates: DateListType,
|
148
148
|
values: ValueListType,
|
149
149
|
valuetype: ValueType = ValueType.PRICE,
|
150
|
-
timeseries_id:
|
151
|
-
instrument_id:
|
150
|
+
timeseries_id: str = "",
|
151
|
+
instrument_id: str = "",
|
152
152
|
isin: str | None = None,
|
153
153
|
baseccy: CurrencyStringType = "SEK",
|
154
154
|
*,
|
@@ -166,9 +166,9 @@ class OpenTimeSeries(_CommonModel):
|
|
166
166
|
Array of float values
|
167
167
|
valuetype : ValueType, default: ValueType.PRICE
|
168
168
|
Identifies if the series is a series of values or returns
|
169
|
-
timeseries_id :
|
169
|
+
timeseries_id : str, optional
|
170
170
|
Database identifier of the timeseries
|
171
|
-
instrument_id:
|
171
|
+
instrument_id: str, optional
|
172
172
|
Database identifier of the instrument associated with the timeseries
|
173
173
|
isin : str, optional
|
174
174
|
ISO 6166 identifier code of the associated instrument
|
@@ -234,12 +234,13 @@ class OpenTimeSeries(_CommonModel):
|
|
234
234
|
|
235
235
|
"""
|
236
236
|
msg = "Argument dframe must be pandas Series or DataFrame."
|
237
|
+
values: list[float]
|
237
238
|
if isinstance(dframe, Series):
|
238
239
|
if isinstance(dframe.name, tuple):
|
239
240
|
label, _ = dframe.name
|
240
241
|
else:
|
241
242
|
label = dframe.name
|
242
|
-
values = dframe.to_numpy().tolist()
|
243
|
+
values = cast(list[float], dframe.to_numpy().tolist())
|
243
244
|
elif isinstance(dframe, DataFrame):
|
244
245
|
values = dframe.iloc[:, column_nmbr].to_list()
|
245
246
|
if isinstance(dframe.columns, MultiIndex):
|
@@ -331,24 +332,19 @@ class OpenTimeSeries(_CommonModel):
|
|
331
332
|
An OpenTimeSeries object
|
332
333
|
|
333
334
|
"""
|
334
|
-
if not isinstance(d_range,
|
335
|
+
if not isinstance(d_range, Iterable) and all([days, end_dt]):
|
335
336
|
d_range = DatetimeIndex(
|
336
337
|
[d.date() for d in date_range(periods=days, end=end_dt, freq="D")],
|
337
338
|
)
|
338
|
-
elif not isinstance(d_range,
|
339
|
+
elif not isinstance(d_range, Iterable) and not all([days, end_dt]):
|
339
340
|
msg = "If d_range is not provided both days and end_dt must be."
|
340
341
|
raise ValueError(msg)
|
341
342
|
|
342
343
|
deltas = array(
|
343
|
-
[
|
344
|
-
i.days
|
345
|
-
for i in cast(DatetimeIndex, d_range)[1:]
|
346
|
-
- cast(DatetimeIndex, d_range)[:-1]
|
347
|
-
],
|
344
|
+
[i.days for i in DatetimeIndex(d_range)[1:] - DatetimeIndex(d_range)[:-1]], # type: ignore[arg-type]
|
348
345
|
)
|
349
|
-
|
350
|
-
|
351
|
-
dates = [d.strftime("%Y-%m-%d") for d in cast(DatetimeIndex, d_range)]
|
346
|
+
arr: list[float] = list(cumprod(insert(1 + deltas * rate / 365, 0, 1.0)))
|
347
|
+
dates = [d.strftime("%Y-%m-%d") for d in DatetimeIndex(d_range)] # type: ignore[arg-type]
|
352
348
|
|
353
349
|
return cls(
|
354
350
|
timeseries_id="",
|
openseries/types.py
CHANGED
@@ -77,16 +77,6 @@ DateListType = Annotated[
|
|
77
77
|
|
78
78
|
ValueListType = Annotated[list[float], conlist(float, min_length=1)]
|
79
79
|
|
80
|
-
DatabaseIdStringType = Annotated[
|
81
|
-
str,
|
82
|
-
StringConstraints(
|
83
|
-
pattern=r"^([0-9a-f]{24})?$",
|
84
|
-
strict=True,
|
85
|
-
strip_whitespace=True,
|
86
|
-
max_length=24,
|
87
|
-
),
|
88
|
-
]
|
89
|
-
|
90
80
|
DaysInYearType = Annotated[int, Field(strict=True, ge=1, le=366)]
|
91
81
|
|
92
82
|
DateType = str | dt.date | dt.datetime | datetime64 | Timestamp
|
@@ -6,11 +6,11 @@ openseries/frame.py,sha256=nGqqLlENLuSj0YuR1AXtgLg-w8kPCfUQf6xkjGiOTEI,55378
|
|
6
6
|
openseries/load_plotly.py,sha256=vL4nZuX20d3F5q-NbaHldIsKInUc9tXOu6S-rDGHuDw,1956
|
7
7
|
openseries/plotly_captor_logo.json,sha256=F5nhMzEyxKywtjvQqMTKgKRCJQYMDIiBgDSxdte8Clo,178
|
8
8
|
openseries/plotly_layouts.json,sha256=ahx8-dL4_RPzvHtBOX0SiL0AH7xQJzNRSDhGrSmU-Og,1429
|
9
|
-
openseries/portfoliotools.py,sha256=
|
10
|
-
openseries/series.py,sha256=
|
9
|
+
openseries/portfoliotools.py,sha256=B4oJkT_j44h3IsRsFAQcepGonvXda8uriAWGXEHyWmE,19087
|
10
|
+
openseries/series.py,sha256=vvwpTH-My5ju-m2LOQOYzXV0VCU4DJCxOo6v-DXpWHI,27514
|
11
11
|
openseries/simulation.py,sha256=Gc5h3KD3K5AySWqXzm1lbsn2_mwOEWjHr6EVNHb1R-w,13878
|
12
|
-
openseries/types.py,sha256=
|
13
|
-
openseries-1.7.
|
14
|
-
openseries-1.7.
|
15
|
-
openseries-1.7.
|
16
|
-
openseries-1.7.
|
12
|
+
openseries/types.py,sha256=J102TI1x1X6BQxsF65RN3U1heBUfzrCFVRwXAJj_R7k,7302
|
13
|
+
openseries-1.7.8.dist-info/LICENSE.md,sha256=IQ8_IMXgHxyv4M48G14fJsjcrkiSASdalASTXWCOsj4,1515
|
14
|
+
openseries-1.7.8.dist-info/METADATA,sha256=8030LLO_xBVZTcuFhmR4_YJieAG17NepGvoi7M_hgZ8,43744
|
15
|
+
openseries-1.7.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
16
|
+
openseries-1.7.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|