research.notebook

Documentation for eth_defi.research.notebook Python module.

Jupyter notebook set up and formatting utilities.

Functions

set_large_plotly_chart_font([...])

Increase the default Plotly chart font sizes so that charts are readable on other mediums like mobile and PowerPoint.

set_notebook_logging([log_level])

Enable logging in notebooks.

setup_charting_and_output([mode, ...])

Sets charting and other output options for Jupyter Notebooks.

Classes

OutputMode

What is the output mode for the notebook visualisations.

class OutputMode

Bases: enum.Enum

What is the output mode for the notebook visualisations.

Interactive visualisations work only on the HTML pages that are able to load Plotly.js JavaScripts.

For examples see setup_charting_and_output().

static = 'static'

Output charts as static images

interactive = 'interactive'

Output charts as interactive Plotly.js visualisations

setup_charting_and_output(mode=OutputMode.interactive, image_format='svg', max_rows=1000, width=1500, height=1500, increase_font_size=False)

Sets charting and other output options for Jupyter Notebooks.

Interactive charts are better for local development, but are not compatible with most web-based notebook viewers.

Example how to set up default interactive output settings. Add early of your notebook do:

# Set Jupyter Notebook output mode parameters.
# For example, table max output rows is lifted from 20 to unlimited.
from tradeexecutor.utils.notebook import setup_charting_and_output

setup_charting_and_output()

Example how to set up static image rendering:

# Set charts to static image output, 1500 x 1000 pixels from tradeexecutor.utils.notebook import setup_charting_and_output, OutputMode setup_charting_and_output(OutputMode.static, image_format=”png”, width=1500, height=1000)

Parameters
  • mode (eth_defi.research.notebook.OutputMode) – What kind of viewing context we have for this notebook output

  • image_format

    Do we do SVG or PNG.

    SVG is better, but Github inline viewer cannot display it in the notebooks.

  • max_rows

    Do we remove the max_rows limitation from Pandas tables.

    Default 20 is too low to display summary tables.

  • increase_font_size – Make charts and tables more readable with larger fonts

set_large_plotly_chart_font(title_font_size=30, font_size=24, legend_font_size=24, line_width=3, axis_title_font_size=24, base_template='plotly')

Increase the default Plotly chart font sizes so that charts are readable on other mediums like mobile and PowerPoint.

Usage:

from tradeexecutor.utils.notebook import set_large_plotly_chart_font

set_large_plotly_chart_font()
set_notebook_logging(log_level=20)

Enable logging in notebooks.

  • Only needed to diagnose Client library bugs when running in notebook

Parameters

log_level (int | str) –