openseries 1.5.7__tar.gz → 1.6.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openseries
3
- Version: 1.5.7
3
+ Version: 1.6.0
4
4
  Summary: Tools for analyzing financial timeseries.
5
5
  Home-page: https://github.com/CaptorAB/openseries
6
6
  License: BSD-3-Clause
@@ -0,0 +1,44 @@
1
+ """openseries.openseries.__init__.py."""
2
+
3
+ from .datefixer import (
4
+ date_fix,
5
+ date_offset_foll,
6
+ do_resample_to_business_period_ends,
7
+ generate_calendar_date_range,
8
+ get_previous_business_day_before_today,
9
+ holiday_calendar,
10
+ offset_business_days,
11
+ )
12
+ from .frame import OpenFrame
13
+ from .load_plotly import load_plotly_dict
14
+ from .portfoliotools import (
15
+ constrain_optimized_portfolios,
16
+ efficient_frontier,
17
+ prepare_plot_data,
18
+ sharpeplot,
19
+ simulate_portfolios,
20
+ )
21
+ from .series import OpenTimeSeries, timeseries_chain
22
+ from .simulation import ReturnSimulation
23
+ from .types import ValueType
24
+
25
+ __all__ = [
26
+ "OpenFrame",
27
+ "constrain_optimized_portfolios",
28
+ "efficient_frontier",
29
+ "prepare_plot_data",
30
+ "sharpeplot",
31
+ "simulate_portfolios",
32
+ "date_fix",
33
+ "date_offset_foll",
34
+ "do_resample_to_business_period_ends",
35
+ "generate_calendar_date_range",
36
+ "get_previous_business_day_before_today",
37
+ "holiday_calendar",
38
+ "offset_business_days",
39
+ "load_plotly_dict",
40
+ "OpenTimeSeries",
41
+ "timeseries_chain",
42
+ "ReturnSimulation",
43
+ "ValueType",
44
+ ]
@@ -9,9 +9,10 @@ from math import ceil
9
9
  from pathlib import Path
10
10
  from secrets import choice
11
11
  from string import ascii_letters
12
- from typing import Any, Optional, Union, cast
12
+ from typing import Any, Optional, SupportsFloat, Union, cast
13
13
 
14
14
  from numpy import float64, inf, isnan, log, maximum, sqrt
15
+ from numpy.typing import NDArray
15
16
  from openpyxl.utils.dataframe import dataframe_to_rows
16
17
  from openpyxl.workbook.workbook import Workbook
17
18
  from openpyxl.worksheet.worksheet import Worksheet
@@ -1132,7 +1133,7 @@ class _CommonModel(BaseModel):
1132
1133
  )
1133
1134
 
1134
1135
  if self.tsdf.shape[1] == 1:
1135
- return float(result.iloc[0])
1136
+ return float(cast(SupportsFloat, result.iloc[0]))
1136
1137
  return Series(
1137
1138
  data=result,
1138
1139
  index=self.tsdf.columns,
@@ -1361,7 +1362,7 @@ class _CommonModel(BaseModel):
1361
1362
  label = f"Imp vol from VaR {level:.0%}"
1362
1363
 
1363
1364
  if self.tsdf.shape[1] == 1:
1364
- return float(result.iloc[0])
1365
+ return float(cast(SupportsFloat, result.iloc[0]))
1365
1366
  return Series(
1366
1367
  data=result,
1367
1368
  index=self.tsdf.columns,
@@ -1593,7 +1594,7 @@ class _CommonModel(BaseModel):
1593
1594
  from_dt=from_date,
1594
1595
  to_dt=to_date,
1595
1596
  )
1596
- result = skew(
1597
+ result: NDArray[float64] = skew(
1597
1598
  a=self.tsdf.loc[cast(int, earlier) : cast(int, later)]
1598
1599
  .pct_change(fill_method=cast(str, None))
1599
1600
  .to_numpy(),
@@ -1642,7 +1643,7 @@ class _CommonModel(BaseModel):
1642
1643
  from_dt=from_date,
1643
1644
  to_dt=to_date,
1644
1645
  )
1645
- result = kurtosis(
1646
+ result: NDArray[float64] = kurtosis(
1646
1647
  self.tsdf.loc[cast(int, earlier) : cast(int, later)].pct_change(
1647
1648
  fill_method=cast(str, None),
1648
1649
  ),
@@ -30,6 +30,16 @@ from openseries.types import (
30
30
  LiteralBizDayFreq,
31
31
  )
32
32
 
33
+ __all__ = [
34
+ "date_fix",
35
+ "date_offset_foll",
36
+ "do_resample_to_business_period_ends",
37
+ "generate_calendar_date_range",
38
+ "get_previous_business_day_before_today",
39
+ "holiday_calendar",
40
+ "offset_business_days",
41
+ ]
42
+
33
43
 
34
44
  def holiday_calendar(
35
45
  startyear: int,