Skip to content

Commit

Permalink
BUG: fix tears dates (#3)
Browse files Browse the repository at this point in the history
* gitignore venv

* fix tear sheets dates  and tests missing path
  • Loading branch information
MBounouar authored Sep 1, 2021
1 parent c31829e commit 8371e12
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# virutalenv
.venv

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
32 changes: 28 additions & 4 deletions pyfolio/tears.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,13 @@ def create_simple_tear_sheet(
plotting.plot_txn_time_hist(transactions, ax=ax_txn_timings)

for ax in fig.axes:
plt.setp(ax.get_xticklabels(), visible=True)
ax.tick_params(
axis="x",
which="major",
bottom=True,
top=False,
labelbottom=True,
)


@plotting.customize
Expand Down Expand Up @@ -642,7 +648,13 @@ def create_returns_tear_sheet(
raise ValueError("bootstrap requires passing of benchmark_rets.")

for ax in fig.axes:
plt.setp(ax.get_xticklabels(), visible=True)
ax.tick_params(
axis="x",
which="major",
bottom=True,
top=False,
labelbottom=True,
)

if return_fig:
return fig
Expand Down Expand Up @@ -746,7 +758,13 @@ def create_position_tear_sheet(
)

for ax in fig.axes:
plt.setp(ax.get_xticklabels(), visible=True)
ax.tick_params(
axis="x",
which="major",
bottom=True,
top=False,
labelbottom=True,
)

if return_fig:
return fig
Expand Down Expand Up @@ -841,7 +859,13 @@ def create_txn_tear_sheet(
ax=ax_slippage_sensitivity,
)
for ax in fig.axes:
plt.setp(ax.get_xticklabels(), visible=True)
ax.tick_params(
axis="x",
which="major",
bottom=True,
top=False,
labelbottom=True,
)

if return_fig:
return fig
Expand Down
11 changes: 5 additions & 6 deletions pyfolio/tests/test_nbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
Each cell is submitted to the kernel, and checked for errors.
"""

import os
import glob
from pathlib import Path
from runipy.notebook_runner import NotebookRunner

from pyfolio.utils import pyfolio_root
from pyfolio.ipycompat import read as read_notebook

EXAMPLES_PATH = Path(__file__).resolve().parent.parent / "examples"


def test_nbs():
path = os.path.join(pyfolio_root(), "examples", "*.ipynb")
for ipynb in glob.glob(path):
for ipynb in EXAMPLES_PATH.glob("*.ipynb"):
print(ipynb)
with open(ipynb) as f:
nb = read_notebook(f, "json")
nb_runner = NotebookRunner(nb)
Expand Down

0 comments on commit 8371e12

Please sign in to comment.