Skip to content

Commit

Permalink
__run_all_jupyter_notebooks.py
Browse files Browse the repository at this point in the history
  • Loading branch information
omartinsky committed Apr 30, 2017
1 parent 6330294 commit 4b627f0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions __run_all_jupyter_notebooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from nbconvert import HTMLExporter

def tohtml(input, output=None):
if output is None:
output = input + ".html"

print("Converting %s --> %s" % (input, output))
ep = ExecutePreprocessor(timeout=300, kernel_name='python3')

with open(input) as f:
nb = nbformat.read(f, as_version=4)

ep.preprocess(nb, {'metadata': {'path': './'}})

#filename_output = input + ".executed.ipynb"
#with open(filename_output, 'wt') as f:
# nbformat.write(nb, f)

exportHTML = HTMLExporter()
(body, resources) = exportHTML.from_notebook_node(nb)

with open(output, 'wt') as f:
f.write(body)

print("Done")


tohtml("binomial_option_pricing/binomial_option_pricing.ipynb")
tohtml("black_litterman/black_litterman.ipynb")

0 comments on commit 4b627f0

Please sign in to comment.