Skip to content

Commit 7d0bf90

Browse files
committed
release
1 parent c796174 commit 7d0bf90

File tree

8 files changed

+652
-612
lines changed

8 files changed

+652
-612
lines changed

poetry.lock

Lines changed: 626 additions & 594 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "quantflow"
3-
version = "0.2.8"
3+
version = "0.2.9"
44
description = "quantitative analysis"
55
authors = ["Luca <luca@quantmind.com>"]
66
license = "BSD-3-Clause"
@@ -30,7 +30,7 @@ pytest-cov = "^6.0.0"
3030
mypy = "^1.13.0"
3131
ghp-import = "^2.0.2"
3232
ruff = "^0.8.1"
33-
pytest-asyncio = "^0.24.0"
33+
pytest-asyncio = "^0.25.0"
3434

3535

3636
[tool.poetry.extras]

quantflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Quantitative analysis and pricing"""
22

3-
__version__ = "0.2.8"
3+
__version__ = "0.2.9"

quantflow/options/pricer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass, field
4-
from typing import Any, Generic, NamedTuple, TypeVar
4+
from typing import Any, Generic, NamedTuple, TypeVar, cast
55

66
import numpy as np
77
import pandas as pd
@@ -156,7 +156,7 @@ def plot3d(
156156
moneyness_ttm = np.linspace(-max_moneyness_ttm, max_moneyness_ttm, support)
157157
implied = np.zeros((len(ttm), len(moneyness_ttm)))
158158
for i, t in enumerate(ttm):
159-
maturity = self.maturity(t)
159+
maturity = self.maturity(cast(float, t))
160160
implied[i, :] = maturity.interp(moneyness_ttm * np.sqrt(t)).implied_vols
161161
properties: dict = dict(
162162
xaxis_title="moneyness_ttm",

quantflow/sp/ou.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from ..utils.distributions import Exponential
1111
from ..utils.paths import Paths
12-
from ..utils.types import FloatArrayLike, Vector
12+
from ..utils.types import FloatArrayLike, Vector, Float
1313
from .base import Im, IntensityProcess
1414
from .poisson import CompoundPoissonProcess, D
1515
from .weiner import WeinerProcess
@@ -139,7 +139,12 @@ def sample(self, n: int, time_horizon: float = 1, time_steps: int = 100) -> Path
139139
return Paths(t=time_horizon, data=paths)
140140

141141
def _advance(
142-
self, i: int, pp: np.ndarray, dt: float, arrival: float = 0, jump: float = 0
142+
self,
143+
i: int,
144+
pp: np.ndarray,
145+
dt: Float,
146+
arrival: Float = 0,
147+
jump: Float = 0,
143148
) -> int:
144149
x = pp[i - 1]
145150
kappa = self.kappa

quantflow/utils/bins.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, Sequence
1+
from typing import Sequence, cast, Any
22

33
import numpy as np
44
from pandas import DataFrame
@@ -13,9 +13,9 @@ def pdf(
1313
symmetric: float | None = None,
1414
precision: int = 6,
1515
) -> DataFrame:
16-
max_value = np.max(data)
17-
min_value = np.min(data)
18-
domain = max(abs(data)) if symmetric is not None else max_value - min_value
16+
max_value = cast(float, np.max(data))
17+
min_value = cast(float, np.min(data))
18+
domain: float = max(abs(data)) if symmetric is not None else max_value - min_value # type: ignore
1919
if num_bins is None:
2020
if not delta:
2121
num_bins = 50
@@ -39,7 +39,9 @@ def pdf(
3939
return DataFrame(dict(pdf=pdf), index=x[1:-1])
4040

4141

42-
def event_density(df: DataFrame, columns: Sequence, num: int = 10) -> Dict:
42+
def event_density(
43+
df: DataFrame, columns: Sequence[str], num: int = 10
44+
) -> dict[str, Any]:
4345
"""Calculate the probability density of the number of events
4446
in the dataframe columns
4547
"""
@@ -48,5 +50,5 @@ def event_density(df: DataFrame, columns: Sequence, num: int = 10) -> Dict:
4850
for col in columns:
4951
counts, _ = np.histogram(df[col], bins=bins)
5052
counts = counts / np.sum(counts)
51-
data[col] = counts[:num]
53+
data[col] = counts[:num] # type: ignore
5254
return data

quantflow/utils/paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def xs(self) -> list[np.ndarray]:
5151
@property
5252
def ys(self) -> list[list[float]]:
5353
"""Paths as list of list (for visualization tools)"""
54-
return self.data.transpose().tolist()
54+
return self.data.transpose().tolist() # type: ignore
5555

5656
def mean(self) -> FloatArray:
5757
"""Mean of paths"""

quantflow/utils/types.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
from decimal import Decimal
2-
from typing import Optional, Union
2+
from typing import Optional, Union, Any
33

44
import pandas as pd
55
import numpy as np
66
import numpy.typing as npt
77

88
Number = Decimal
9-
Numbers = Union[int, float, np.number]
9+
Float = float | np.floating[Any]
10+
Numbers = Union[int, Float, np.number]
1011
NumberType = Union[float, int, str, Number]
1112
Vector = Union[int, float, complex, np.ndarray, pd.Series]
12-
FloatArray = npt.NDArray[np.float64]
13-
IntArray = npt.NDArray[np.int_]
13+
FloatArray = npt.NDArray[np.floating[Any]]
14+
IntArray = npt.NDArray[np.signedinteger[Any]]
1415
FloatArrayLike = FloatArray | float
1516

1617

0 commit comments

Comments
 (0)