openseries 1.8.1__py3-none-any.whl → 1.8.2__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/series.py CHANGED
@@ -112,14 +112,14 @@ class OpenTimeSeries(_CommonModel):
112
112
  isin: str | None = None
113
113
  label: str | None = None
114
114
 
115
- @field_validator("domestic", mode="before")
115
+ @field_validator("domestic", mode="before") # type: ignore[misc]
116
116
  @classmethod
117
117
  def _validate_domestic(cls, value: CurrencyStringType) -> CurrencyStringType:
118
118
  """Pydantic validator to ensure domestic field is validated."""
119
119
  _ = Currency(ccy=value)
120
120
  return value
121
121
 
122
- @field_validator("countries", mode="before")
122
+ @field_validator("countries", mode="before") # type: ignore[misc]
123
123
  @classmethod
124
124
  def _validate_countries(cls, value: CountriesType) -> CountriesType:
125
125
  """Pydantic validator to ensure countries field is validated."""
@@ -184,7 +184,7 @@ class OpenTimeSeries(_CommonModel):
184
184
  local_ccy: bool, default: True
185
185
  Boolean flag indicating if timeseries is in local currency
186
186
 
187
- Returns
187
+ Returns:
188
188
  -------
189
189
  OpenTimeSeries
190
190
  An OpenTimeSeries object
@@ -234,7 +234,7 @@ class OpenTimeSeries(_CommonModel):
234
234
  local_ccy: bool, default: True
235
235
  Boolean flag indicating if timeseries is in local currency
236
236
 
237
- Returns
237
+ Returns:
238
238
  -------
239
239
  OpenTimeSeries
240
240
  An OpenTimeSeries object
@@ -266,9 +266,10 @@ class OpenTimeSeries(_CommonModel):
266
266
  msg = f"valuetype missing. Adding: {valuetype.value}"
267
267
  logger.warning(msg=msg)
268
268
  else:
269
- valuetype = dframe.columns.get_level_values(1).to_numpy()[
270
- column_nmbr
271
- ]
269
+ valuetype = cast(
270
+ "ValueType",
271
+ dframe.columns.get_level_values(1).to_numpy()[column_nmbr],
272
+ )
272
273
  else:
273
274
  label = cast("MultiIndex", dframe.columns).to_numpy()[column_nmbr]
274
275
  else:
@@ -333,7 +334,7 @@ class OpenTimeSeries(_CommonModel):
333
334
  local_ccy: bool, default: True
334
335
  Boolean flag indicating if timeseries is in local currency
335
336
 
336
- Returns
337
+ Returns:
337
338
  -------
338
339
  OpenTimeSeries
339
340
  An OpenTimeSeries object
@@ -374,7 +375,7 @@ class OpenTimeSeries(_CommonModel):
374
375
  def from_deepcopy(self: Self) -> Self:
375
376
  """Create copy of OpenTimeSeries object.
376
377
 
377
- Returns
378
+ Returns:
378
379
  -------
379
380
  OpenTimeSeries
380
381
  An OpenTimeSeries object
@@ -385,7 +386,7 @@ class OpenTimeSeries(_CommonModel):
385
386
  def pandas_df(self: Self) -> Self:
386
387
  """Populate .tsdf Pandas DataFrame from the .dates and .values lists.
387
388
 
388
- Returns
389
+ Returns:
389
390
  -------
390
391
  OpenTimeSeries
391
392
  An OpenTimeSeries object
@@ -412,7 +413,7 @@ class OpenTimeSeries(_CommonModel):
412
413
  properties: list[LiteralSeriesProps], optional
413
414
  The properties to calculate. Defaults to calculating all available.
414
415
 
415
- Returns
416
+ Returns:
416
417
  -------
417
418
  pandas.DataFrame
418
419
  Properties of the OpenTimeSeries
@@ -432,7 +433,7 @@ class OpenTimeSeries(_CommonModel):
432
433
  def value_to_ret(self: Self) -> Self:
433
434
  """Convert series of values into series of returns.
434
435
 
435
- Returns
436
+ Returns:
436
437
  -------
437
438
  OpenTimeSeries
438
439
  The returns of the values in the series
@@ -443,7 +444,7 @@ class OpenTimeSeries(_CommonModel):
443
444
  self.valuetype = ValueType.RTRN
444
445
  arrays = [[self.label], [self.valuetype]]
445
446
  returns.columns = MultiIndex.from_arrays(
446
- arrays=arrays # type: ignore[arg-type,unused-ignore]
447
+ arrays=arrays # type: ignore[arg-type]
447
448
  )
448
449
  self.tsdf = returns.copy()
449
450
  return self
@@ -457,7 +458,7 @@ class OpenTimeSeries(_CommonModel):
457
458
  The number of periods between observations over which difference
458
459
  is calculated
459
460
 
460
- Returns
461
+ Returns:
461
462
  -------
462
463
  OpenTimeSeries
463
464
  An OpenTimeSeries object
@@ -477,7 +478,7 @@ class OpenTimeSeries(_CommonModel):
477
478
  def to_cumret(self: Self) -> Self:
478
479
  """Convert series of returns into cumulative series of values.
479
480
 
480
- Returns
481
+ Returns:
481
482
  -------
482
483
  OpenTimeSeries
483
484
  An OpenTimeSeries object
@@ -512,7 +513,7 @@ class OpenTimeSeries(_CommonModel):
512
513
  divider: float, default 100.0
513
514
  Convenience divider for when the 1-day rate is not scaled correctly
514
515
 
515
- Returns
516
+ Returns:
516
517
  -------
517
518
  OpenTimeSeries
518
519
  An OpenTimeSeries object
@@ -522,7 +523,7 @@ class OpenTimeSeries(_CommonModel):
522
523
 
523
524
  deltas = array([i.days for i in self.tsdf.index[1:] - self.tsdf.index[:-1]])
524
525
  # noinspection PyTypeChecker
525
- arr = cumprod( # type: ignore[assignment,unused-ignore]
526
+ arr = cumprod( # type: ignore[assignment]
526
527
  a=insert(arr=1.0 + deltas * arr[:-1] / days_in_year, obj=0, values=1.0)
527
528
  )
528
529
 
@@ -549,7 +550,7 @@ class OpenTimeSeries(_CommonModel):
549
550
  freq: LiteralBizDayFreq | str, default "BME"
550
551
  The date offset string that sets the resampled frequency
551
552
 
552
- Returns
553
+ Returns:
553
554
  -------
554
555
  OpenTimeSeries
555
556
  An OpenTimeSeries object
@@ -576,7 +577,7 @@ class OpenTimeSeries(_CommonModel):
576
577
  method: LiteralPandasReindexMethod, default: nearest
577
578
  Controls the method used to align values across columns
578
579
 
579
- Returns
580
+ Returns:
580
581
  -------
581
582
  OpenTimeSeries
582
583
  An OpenTimeSeries object
@@ -622,7 +623,7 @@ class OpenTimeSeries(_CommonModel):
622
623
  periods_in_a_year_fixed : DaysInYearType, optional
623
624
  Allows locking the periods-in-a-year to simplify test cases and comparisons
624
625
 
625
- Returns
626
+ Returns:
626
627
  -------
627
628
  Pandas.Series[float]
628
629
  Series EWMA volatility
@@ -637,7 +638,7 @@ class OpenTimeSeries(_CommonModel):
637
638
  self.tsdf.columns.to_numpy()[0],
638
639
  ].count()
639
640
  fraction = (later - earlier).days / 365.25
640
- time_factor = how_many / fraction
641
+ time_factor = cast("int", how_many) / fraction
641
642
 
642
643
  data = self.tsdf.loc[cast("int", earlier) : cast("int", later)].copy()
643
644
 
@@ -682,7 +683,7 @@ class OpenTimeSeries(_CommonModel):
682
683
  The calculation divisor and
683
684
  assumed number of days in a calendar year
684
685
 
685
- Returns
686
+ Returns:
686
687
  -------
687
688
  OpenTimeSeries
688
689
  An OpenTimeSeries object
@@ -743,7 +744,7 @@ class OpenTimeSeries(_CommonModel):
743
744
  delete_lvl_one: bool, default: False
744
745
  If True the level one label is deleted
745
746
 
746
- Returns
747
+ Returns:
747
748
  -------
748
749
  OpenTimeSeries
749
750
  An OpenTimeSeries object
@@ -785,7 +786,7 @@ def timeseries_chain(
785
786
  old_fee: float, default: 0.0
786
787
  Fee to apply to earlier series
787
788
 
788
- Returns
789
+ Returns:
789
790
  -------
790
791
  TypeOpenTimeSeries
791
792
  An OpenTimeSeries object or a subclass thereof
@@ -810,9 +811,10 @@ def timeseries_chain(
810
811
 
811
812
  dates: list[str] = [x.strftime("%Y-%m-%d") for x in old.tsdf.index if x < first]
812
813
 
813
- old_values = old.tsdf.iloc[: len(dates), 0]
814
+ old_values = Series(old.tsdf.iloc[: len(dates), 0])
814
815
  old_values = old_values.mul(
815
- new.tsdf.iloc[:, 0].loc[first] / old.tsdf.iloc[:, 0].loc[first],
816
+ Series(new.tsdf.iloc[:, 0]).loc[first]
817
+ / Series(old.tsdf.iloc[:, 0]).loc[first],
816
818
  )
817
819
  values = append(old_values, new.tsdf.iloc[:, 0])
818
820
 
@@ -845,7 +847,7 @@ def _check_if_none(item: Any) -> bool: # noqa: ANN401
845
847
  item : Any
846
848
  variable to be checked
847
849
 
848
- Returns
850
+ Returns:
849
851
  -------
850
852
  bool
851
853
  Answer to whether the variable is None or equivalent
openseries/simulation.py CHANGED
@@ -43,7 +43,7 @@ def _random_generator(seed: int | None) -> Generator:
43
43
  seed: int, optional
44
44
  Random seed
45
45
 
46
- Returns
46
+ Returns:
47
47
  -------
48
48
  numpy.random.Generator
49
49
  Numpy random process generator
@@ -54,7 +54,7 @@ def _random_generator(seed: int | None) -> Generator:
54
54
  return Generator(bit_generator=bg)
55
55
 
56
56
 
57
- class ReturnSimulation(BaseModel):
57
+ class ReturnSimulation(BaseModel): # type: ignore[misc]
58
58
  """The class ReturnSimulation allows for simulating financial timeseries.
59
59
 
60
60
  Parameters
@@ -103,7 +103,7 @@ class ReturnSimulation(BaseModel):
103
103
  def results(self: Self) -> DataFrame:
104
104
  """Simulation data.
105
105
 
106
- Returns
106
+ Returns:
107
107
  -------
108
108
  pandas.DataFrame
109
109
  Simulation data
@@ -115,7 +115,7 @@ class ReturnSimulation(BaseModel):
115
115
  def realized_mean_return(self: Self) -> float:
116
116
  """Annualized arithmetic mean of returns.
117
117
 
118
- Returns
118
+ Returns:
119
119
  -------
120
120
  float
121
121
  Annualized arithmetic mean of returns
@@ -132,7 +132,7 @@ class ReturnSimulation(BaseModel):
132
132
  def realized_vol(self: Self) -> float:
133
133
  """Annualized volatility.
134
134
 
135
- Returns
135
+ Returns:
136
136
  -------
137
137
  float
138
138
  Annualized volatility
@@ -176,7 +176,7 @@ class ReturnSimulation(BaseModel):
176
176
  randomizer: numpy.random.Generator, optional
177
177
  Random process generator
178
178
 
179
- Returns
179
+ Returns:
180
180
  -------
181
181
  ReturnSimulation
182
182
  Normal distribution simulation
@@ -231,7 +231,7 @@ class ReturnSimulation(BaseModel):
231
231
  randomizer: numpy.random.Generator, optional
232
232
  Random process generator
233
233
 
234
- Returns
234
+ Returns:
235
235
  -------
236
236
  ReturnSimulation
237
237
  Lognormal distribution simulation
@@ -289,7 +289,7 @@ class ReturnSimulation(BaseModel):
289
289
  randomizer: numpy.random.Generator, optional
290
290
  Random process generator
291
291
 
292
- Returns
292
+ Returns:
293
293
  -------
294
294
  ReturnSimulation
295
295
  Geometric Brownian Motion simulation
@@ -360,7 +360,7 @@ class ReturnSimulation(BaseModel):
360
360
  randomizer: numpy.random.Generator, optional
361
361
  Random process generator
362
362
 
363
- Returns
363
+ Returns:
364
364
  -------
365
365
  ReturnSimulation
366
366
  Merton Jump-Diffusion model simulation
@@ -431,7 +431,7 @@ class ReturnSimulation(BaseModel):
431
431
  countries: CountriesType, default: "SE"
432
432
  (List of) country code(s) according to ISO 3166-1 alpha-2
433
433
 
434
- Returns
434
+ Returns:
435
435
  -------
436
436
  pandas.DataFrame
437
437
  The simulation(s) data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openseries
3
- Version: 1.8.1
3
+ Version: 1.8.2
4
4
  Summary: Tools for analyzing financial timeseries.
5
5
  License: # BSD 3-Clause License
6
6
 
@@ -71,14 +71,14 @@ Description-Content-Type: text/markdown
71
71
 
72
72
  [![PyPI version](https://img.shields.io/pypi/v/openseries.svg)](https://pypi.org/project/openseries/)
73
73
  [![Conda Version](https://img.shields.io/conda/vn/conda-forge/openseries.svg)](https://anaconda.org/conda-forge/openseries)
74
- [![Conda platforms](https://img.shields.io/conda/pn/conda-forge/openseries.svg)](https://anaconda.org/conda-forge/openseries)
75
- [![Code Sample](https://img.shields.io/badge/-Code%20Sample-blue)](https://nbviewer.org/github/karrmagadgeteer2/NoteBook/blob/master/openseriesnotebook.ipynb)
74
+ ![Platform](https://img.shields.io/badge/platforms-Windows%20%7C%20macOS%20%7C%20Linux-blue)
76
75
  [![Python version](https://img.shields.io/pypi/pyversions/openseries.svg)](https://www.python.org/)
77
76
  [![GitHub Action Test Suite](https://github.com/CaptorAB/openseries/actions/workflows/test.yml/badge.svg)](https://github.com/CaptorAB/openseries/actions/workflows/test.yml)
78
77
  [![Coverage](https://cdn.jsdelivr.net/gh/CaptorAB/openseries@master/coverage.svg)](https://github.com/CaptorAB/openseries/actions/workflows/test.yml)
79
78
  [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
80
79
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://beta.ruff.rs/docs/)
81
- [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
80
+ [![GitHub License](https://img.shields.io/github/license/CaptorAB/openseries)](https://github.com/CaptorAB/openseries/blob/master/LICENSE.md)
81
+ [![Code Sample](https://img.shields.io/badge/-Code%20Sample-blue)](https://nbviewer.org/github/karrmagadgeteer2/NoteBook/blob/master/openseriesnotebook.ipynb)
82
82
 
83
83
  This is a project with tools to analyze financial timeseries of a single
84
84
  asset or a group of assets. It is solely made for daily or less frequent data.
@@ -0,0 +1,16 @@
1
+ openseries/__init__.py,sha256=dKw_wEfgrCwwV1IRljesrtxjE9AVFwTyhE8k4CFIck8,1053
2
+ openseries/_common_model.py,sha256=wQ0tevEqrjckevW8UbTsx6I7t6unAYWAr4QkaIx7pHo,74522
3
+ openseries/_risk.py,sha256=lZzoP5yjq9vHtKhYe7kU3-iG8rADcu00bkT9kIgsi_E,2086
4
+ openseries/datefixer.py,sha256=5S4Ib9CRHfsVPKsDKcIW7x8G86zxkMJz2jZ_Sig2Asw,12535
5
+ openseries/frame.py,sha256=lqRwNNs82TCbl1rjVpy48VpndmIgRztIBNitjaHy2Mo,55859
6
+ openseries/load_plotly.py,sha256=VGDdS8ojPQK7AQr-dGi9IfShi5O0EfjM8kUQrJhG_Zw,2000
7
+ openseries/owntypes.py,sha256=rx0iINJhJDhe8_6udbhofNCyfrlfzEEGpoqm4h2FTjE,9091
8
+ openseries/plotly_captor_logo.json,sha256=F5nhMzEyxKywtjvQqMTKgKRCJQYMDIiBgDSxdte8Clo,178
9
+ openseries/plotly_layouts.json,sha256=FnC5le7YRSb1V8ed3aRr-dEqYtIeE1S6ihtYPpyBynU,1439
10
+ openseries/portfoliotools.py,sha256=6bgz64-B6qJVrHAE-pLp8JJCmJkO_JAExHL5G3AwPWE,19295
11
+ openseries/series.py,sha256=7le45RBcBqF9exDzfXfWbY8iiqgl70UUHNOWORvHAuQ,27221
12
+ openseries/simulation.py,sha256=WHmPU2sNl03YvaL7-Ots7i0I_ZZ9j0hBSCnDYWSypK0,13936
13
+ openseries-1.8.2.dist-info/LICENSE.md,sha256=wNupG-KLsG0aTncb_SMNDh1ExtrKXlpxSJ6RC-g-SWs,1516
14
+ openseries-1.8.2.dist-info/METADATA,sha256=NoHlH3cdCzJ7C6paTWqRS3yytteNOBqO6N8ZDY56UWc,45645
15
+ openseries-1.8.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
16
+ openseries-1.8.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.1
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,16 +0,0 @@
1
- openseries/__init__.py,sha256=dKw_wEfgrCwwV1IRljesrtxjE9AVFwTyhE8k4CFIck8,1053
2
- openseries/_common_model.py,sha256=x1CqaMjWo-nG-sRYxhKaIT_UBPGhfsNTGFF2x4tf3Gk,74451
3
- openseries/_risk.py,sha256=5Lu4vK2oQlDdtv5WKD2ZTGrMIlsa0TiPxk6opgtnVlA,2084
4
- openseries/datefixer.py,sha256=w_3lH9cmAm-Xl8t8-X3FdW22AA3zb5OqS0A4FrgS9vc,12479
5
- openseries/frame.py,sha256=j5kD6s6kXLDjlSQEpKaFzT1bDN9Pmb2PbAF-hSf-NGc,55894
6
- openseries/load_plotly.py,sha256=CzD-ZJNk6WGzIkzIHso4aULDpoWXsjH3xL7p7MP0lqY,1998
7
- openseries/owntypes.py,sha256=aqidJ09w3autlgLD6fVEtANbgzh28K53gWDB6j_P4T4,9047
8
- openseries/plotly_captor_logo.json,sha256=F5nhMzEyxKywtjvQqMTKgKRCJQYMDIiBgDSxdte8Clo,178
9
- openseries/plotly_layouts.json,sha256=im8QZPRB--zV_rOu1OiSbvJPA52oJ6QZRFzkwB1C708,1430
10
- openseries/portfoliotools.py,sha256=8XTjPMPHuazh20LeYj-y4hTZnGX8hrArLwS9Ot_MufM,19261
11
- openseries/series.py,sha256=rwd-J_cD1lElC7W65kt2xGLPHFRfmWAwxe_KEJvi3Pc,27099
12
- openseries/simulation.py,sha256=TLEsIZq8SzQ5BRQqjQMIeCY8ibPX5tkftnx4R-zLspQ,13905
13
- openseries-1.8.1.dist-info/LICENSE.md,sha256=wNupG-KLsG0aTncb_SMNDh1ExtrKXlpxSJ6RC-g-SWs,1516
14
- openseries-1.8.1.dist-info/METADATA,sha256=JcL-WQlrWAvJu2cfcxNwqDKsIrSgFrK6Uad2jqC-Xzs,45658
15
- openseries-1.8.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
16
- openseries-1.8.1.dist-info/RECORD,,