{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Robustness evaluation\n",
"\n",
"Input is backtest results in the format:\n",
"- Parameter combination (multiindex)\n",
"- Profitability metrics (columns)\n",
"Lets explore various way to evaluate robustness.\n",
"\n",
"These are various areas to explore\n",
"\n",
"- [1](https://chatgpt.com/share/66fc06c0-edc4-8013-b228-16ee51dacff8)\n",
"- [2](https://chatgpt.com/share/66fc0ab7-2004-8013-86ca-299af96feb57)\n",
"- [3](https://chatgpt.com/share/66ffc5b3-6f10-8013-8ffa-38b09e778e0f)\n",
"- [4](https://chatgpt.com/share/66ffc5c4-6a28-8013-92ad-ea5bef243b39)\n",
"- [5](https://chatgpt.com/share/66ffc5d4-1100-8013-9cfb-3de2aa3cb136)\n",
"- [6](https://chatgpt.com/share/66ffc5e7-0550-8013-9f88-f5069c78f7f7)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#!pip install git+https://github.com/drew2323/lightweight-charts-python.git\n",
"#!pip install git+https://gitea.stratlab.dev/Stratlab/db.git\n",
"from lightweight_charts import Panel, chart, PlotSRAccessor, PlotDFAccessor\n",
"import pandas as pd\n",
"import numpy as np\n",
"import vectorbtpro as vbt\n",
"# from itables import init_notebook_mode, show\n",
"import datetime\n",
"from itertools import product\n",
"from IPython.display import display\n",
"# init_notebook_mode(all_interactive=True)\n",
"\n",
"vbt.settings.set_theme(\"dark\")\n",
"vbt.settings['plotting']['layout']['width'] = 1280\n",
"vbt.settings.plotting.auto_rangebreaks = True\n",
"# Set the option to display with pagination\n",
"pd.set_option('display.notebook_repr_html', True)\n",
"pd.set_option('display.max_rows', 10) # Number of rows per page"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0aa468b6ecdb4dc283eae910cef9b72f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"100%|##########| 1/1 [00:03<00:00, 3.21s/it, symbol=BAC]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#fetching US-STOCKS ohlcv_1s\n",
"from lib.db import Connection\n",
"SYMBOL = \"BAC\"\n",
"SCHEMA = \"ohlcv_1s\" #time based 1s other options ohlcv_vol_200 (volume based ohlcv with resolution of 200), ohlcv_renko_20 (renko with 20 bricks size) ...\n",
"DB = \"market_data\"\n",
"\n",
"con = Connection(db_name=DB, default_schema=SCHEMA, create_db=True)\n",
"basic_data = con.pull(symbols=[SYMBOL], schema=SCHEMA,start=\"2024-08-01\", end=\"2024-08-05\", tz_convert='America/New_York')\n",
"\n",
"#basic_data.data[SYMBOL].info()\n",
"\n",
"#1month 1s data - 15s - 24MB\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Error fetching main session\n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#basic_data.ohlcv.data[SYMBOL].lw.plot()\n",
"basic_data.ohlcv.data[SYMBOL].lw.plot(size=\"xs\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"