Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"args": [
"-x",
"-vvv",
"quantflow_tests/test_jump_diffusion.py",
"quantflow_tests/test_vault.py",
]
},
]
Expand Down
2,216 changes: 1,180 additions & 1,036 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 @@
[project]
name = "quantflow"
version = "0.4.1"
version = "0.4.2"
description = "quantitative analysis"
authors = [{ name = "Luca Sbardella", email = "[email protected]" }]
license = "BSD-3-Clause"
Expand Down Expand Up @@ -49,7 +49,7 @@ optional = true
[tool.poetry.group.book.dependencies]
jupyter-book = "^1.0.0"
jupytext = "^1.13.8"
plotly = "^5.20.0"
plotly = "^6.2.0"
jupyterlab = "^4.0.2"
sympy = "^1.12"
ipywidgets = "^8.0.7"
Expand Down
2 changes: 1 addition & 1 deletion quantflow/options/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def plot(
max_moneyness_ttm=max_moneyness_ttm, support=support
)
return plot.plot_vol_surface(
pd.DataFrame([d._asdict() for d in options]),
pd.DataFrame([d.info_dict() for d in options]),
model=model.df,
**kwargs,
)
Expand Down
5 changes: 3 additions & 2 deletions quantflow/options/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,11 @@ def calculate_price(self) -> OptionPrice:
)
return self

def _asdict(self) -> dict[str, Any]:
def info_dict(self) -> dict[str, Any]:
return dict(
strike=float(self.strike),
forward=float(self.forward),
maturity=self.maturity,
moneyness=self.moneyness,
moneyness_ttm=self.moneyness / np.sqrt(self.ttm),
ttm=self.ttm,
Expand Down Expand Up @@ -595,7 +596,7 @@ def options_df(
initial_vol=initial_vol,
converged=converged,
)
return pd.DataFrame([d._asdict() for d in data])
return pd.DataFrame([d.info_dict() for d in data])

def as_array(
self,
Expand Down
34 changes: 34 additions & 0 deletions quantflow_tests/test_vault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import tempfile
from pathlib import Path

import pytest

from quantflow.data.vault import Vault


@pytest.fixture
def vault():
with tempfile.TemporaryDirectory() as temp_dir:
yield Vault(Path(temp_dir) / "test_vault")


def test_vault(vault: Vault) -> None:
assert vault.path
assert not vault.data
vault.add("hello", "world")
assert vault.data
assert vault.get("hello") == "world"

v2 = Vault(vault.path)
assert v2.path == vault.path
assert v2.data == vault.data
assert v2.get("hello") == "world"

assert vault.keys() == ["hello"]

vault.add("foo", "bar")
assert vault.keys() == ["foo", "hello"]
assert vault.delete("foo")
assert vault.keys() == ["hello"]
assert not vault.delete("foo")
assert vault.keys() == ["hello"]