export_backtest_report#
API documentation for tradeexecutor.backtest.tearsheet.export_backtest_report Python function.
- export_backtest_report(state, universe, report_template=None, output_notebook=None, output_html=None, show_code=False, custom_css='\n/* trade-executor backtest report generator custom CSS */\nbody {\n padding: 0; \n}\n\n.prompt {\n display: none !important;\n}\n\n#notebook {\n padding-top: 0 !important;\n}\n\n#notebook-container {\n padding: 0 !important;\n box-shadow: none;\n width: auto;\n}\n\n.code_cell {\n padding: 0;\n}\n', custom_js='\nconsole.log("Dynamic iframe resizer loaded");\n\nfunction getDocHeight(doc) {\n // stackoverflow.com/questions/1145850/\n var body = doc.body, html = doc.documentElement;\n var height = Math.max( body.scrollHeight, body.offsetHeight, \n html.clientHeight, html.scrollHeight, html.offsetHeight );\n return height;\n}\n\nwindow.addEventListener("load", function(){\n if(window.self === window.top) return; // if w.self === w.top, we are not in an iframe \n send_height_to_parent_function = function(){\n //var height = document.getElementsByTagName("html")[0].clientHeight;\n //var height= document.getElementById(\'wrapper\').offsetHeight;\n const height = getDocHeight(document);\n console.log("Sending height as " + height + "px");\n parent.postMessage({"iframeContentHeight" : height }, "*");\n }\n // send message to parent about height updates\n send_height_to_parent_function(); //whenever the page is loaded\n window.addEventListener("resize", send_height_to_parent_function); // whenever the page is resized\n var observer = new MutationObserver(send_height_to_parent_function); // whenever DOM changes PT1\n var config = { attributes: true, childList: true, characterData: true, subtree:true}; // PT2\n observer.observe(window.document, config); // PT3 \n});\n')[source]#
Creates the backtest visual report.
Opens a master template notebook
Injects the backtested state to this notebook by modifying the first cell of the notebook and writes a temporary state file path there
Runs the notebook
Writes the output notebook if specified
Writes the output HTML file if specified
- Parameters:
show_code – For the HTML report, should we hide the code cells.
custom_css (str | None) – CSS code to inject to the resulting HTML file to override styles.
custom_js (str | None) – JS code to inject to the resulting HTML file to support iframe embedding.
state (State) –
universe (TradingStrategyUniverse) –
- Returns:
Returns the executed notebook contents
- Raises:
BacktestReportRunFailed – In the case the notebook had a run-time exception and Python code could not complete.
- Return type:
NotebookNode