Skip to content

Commit

Permalink
Merge pull request #3 from quantmind/ls-fix
Browse files Browse the repository at this point in the history
Fix missing plotly
  • Loading branch information
lsbardel committed Jul 20, 2023
2 parents 9a0537f + bf87825 commit ef09419
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: pip install -U pip poetry
- name: Install dependencies no book
run: poetry install
- name: run tests no book
run: make tests
- name: Install dependencies
run: make install-dev
- name: run lint
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "quantflow"
version = "0.2.2"
version = "0.2.3"
description = "quantitative analysis"
authors = ["Luca <[email protected]>"]
license = "BSD-3-Clause"
Expand Down
2 changes: 1 addition & 1 deletion quantflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Quantitative analysis and pricing"""
__version__ = "0.2.2"
__version__ = "0.2.3"
2 changes: 1 addition & 1 deletion quantflow/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def plot_vol_cross(
data2: pd.DataFrame | None = None,
series: str = "implied_vol",
marker_size: int = 10,
fig: go.Figure | None = None,
fig: Any | None = None,
name: str = "model",
**kwargs: Any
) -> Any:
Expand Down
11 changes: 8 additions & 3 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import pytest

from quantflow.data.fmp import FMP

pytestmark = pytest.mark.skipif(FMP().key is None, reason="No FMP API key found")
try:
from quantflow.data.fmp import FMP
except ImportError:
FMP = None # type: ignore

pytestmark = pytest.mark.skipif(
FMP is None or FMP().key is None, reason="No FMP API key found"
)


@pytest.fixture
Expand Down
4 changes: 3 additions & 1 deletion tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
surface_from_inputs,
)
from quantflow.sp.heston import Heston
from tests.utils import has_plotly

a = np.asarray
CROSS_SECTIONS = 8
Expand Down Expand Up @@ -132,4 +133,5 @@ def test_calibration(vol_surface: VolSurface, heston: OptionPricer[Heston]):
pricer=heston, vol_surface=vol_surface
).remove_implied_above(0.95)
cal.fit()
assert cal.plot(index=2) is not None
if has_plotly:
assert cal.plot(index=2) is not None
2 changes: 2 additions & 0 deletions tests/test_options_pricer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

from quantflow.options.pricer import OptionPricer
from quantflow.sp.heston import HestonJ
from tests.utils import has_plotly


@pytest.fixture
def pricer() -> OptionPricer[HestonJ]:
return OptionPricer(HestonJ.create(vol=0.5, kappa=1, sigma=0.8, rho=0))


@pytest.mark.skipif(not has_plotly, reason="Plotly not installed")
def test_plot_surface(pricer: OptionPricer):
fig = pricer.plot3d()
surface = fig.data[0]
Expand Down
7 changes: 7 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

from quantflow.sp.base import StochasticProcess1D
from quantflow.utils.marginal import Marginal1D
from quantflow.utils.plot import check_plotly

try:
check_plotly()
has_plotly = True
except ImportError:
has_plotly = False


def characteristic_tests(m: Marginal1D):
Expand Down

0 comments on commit ef09419

Please sign in to comment.