Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
lsbardel committed Dec 20, 2024
1 parent c796174 commit 7d0bf90
Show file tree
Hide file tree
Showing 8 changed files with 652 additions and 612 deletions.
1,220 changes: 626 additions & 594 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "quantflow"
version = "0.2.8"
version = "0.2.9"
description = "quantitative analysis"
authors = ["Luca <luca@quantmind.com>"]
license = "BSD-3-Clause"
Expand Down Expand Up @@ -30,7 +30,7 @@ pytest-cov = "^6.0.0"
mypy = "^1.13.0"
ghp-import = "^2.0.2"
ruff = "^0.8.1"
pytest-asyncio = "^0.24.0"
pytest-asyncio = "^0.25.0"


[tool.poetry.extras]
Expand Down
2 changes: 1 addition & 1 deletion quantflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Quantitative analysis and pricing"""

__version__ = "0.2.8"
__version__ = "0.2.9"
4 changes: 2 additions & 2 deletions quantflow/options/pricer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any, Generic, NamedTuple, TypeVar
from typing import Any, Generic, NamedTuple, TypeVar, cast

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -156,7 +156,7 @@ def plot3d(
moneyness_ttm = np.linspace(-max_moneyness_ttm, max_moneyness_ttm, support)
implied = np.zeros((len(ttm), len(moneyness_ttm)))
for i, t in enumerate(ttm):
maturity = self.maturity(t)
maturity = self.maturity(cast(float, t))
implied[i, :] = maturity.interp(moneyness_ttm * np.sqrt(t)).implied_vols
properties: dict = dict(
xaxis_title="moneyness_ttm",
Expand Down
9 changes: 7 additions & 2 deletions quantflow/sp/ou.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

def _advance(
self, i: int, pp: np.ndarray, dt: float, arrival: float = 0, jump: float = 0
self,
i: int,
pp: np.ndarray,
dt: Float,
arrival: Float = 0,
jump: Float = 0,
) -> int:
x = pp[i - 1]
kappa = self.kappa
Expand Down
14 changes: 8 additions & 6 deletions quantflow/utils/bins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Sequence
from typing import Sequence, cast, Any

import numpy as np
from pandas import DataFrame
Expand All @@ -13,9 +13,9 @@ def pdf(
symmetric: float | None = None,
precision: int = 6,
) -> DataFrame:
max_value = np.max(data)
min_value = np.min(data)
domain = max(abs(data)) if symmetric is not None else max_value - min_value
max_value = cast(float, np.max(data))
min_value = cast(float, np.min(data))
domain: float = max(abs(data)) if symmetric is not None else max_value - min_value # type: ignore
if num_bins is None:
if not delta:
num_bins = 50
Expand All @@ -39,7 +39,9 @@ def pdf(
return DataFrame(dict(pdf=pdf), index=x[1:-1])


def event_density(df: DataFrame, columns: Sequence, num: int = 10) -> Dict:
def event_density(
df: DataFrame, columns: Sequence[str], num: int = 10
) -> dict[str, Any]:
"""Calculate the probability density of the number of events
in the dataframe columns
"""
Expand All @@ -48,5 +50,5 @@ def event_density(df: DataFrame, columns: Sequence, num: int = 10) -> Dict:
for col in columns:
counts, _ = np.histogram(df[col], bins=bins)
counts = counts / np.sum(counts)
data[col] = counts[:num]
data[col] = counts[:num] # type: ignore
return data
2 changes: 1 addition & 1 deletion quantflow/utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def xs(self) -> list[np.ndarray]:
@property
def ys(self) -> list[list[float]]:
"""Paths as list of list (for visualization tools)"""
return self.data.transpose().tolist()
return self.data.transpose().tolist() # type: ignore

def mean(self) -> FloatArray:
"""Mean of paths"""
Expand Down
9 changes: 5 additions & 4 deletions quantflow/utils/types.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from decimal import Decimal
from typing import Optional, Union
from typing import Optional, Union, Any

import pandas as pd
import numpy as np
import numpy.typing as npt

Number = Decimal
Numbers = Union[int, float, np.number]
Float = float | np.floating[Any]
Numbers = Union[int, Float, np.number]
NumberType = Union[float, int, str, Number]
Vector = Union[int, float, complex, np.ndarray, pd.Series]
FloatArray = npt.NDArray[np.float64]
IntArray = npt.NDArray[np.int_]
FloatArray = npt.NDArray[np.floating[Any]]
IntArray = npt.NDArray[np.signedinteger[Any]]
FloatArrayLike = FloatArray | float


Expand Down

0 comments on commit 7d0bf90

Please sign in to comment.