{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "celkovy optimalizacni backtest na vetsim oknu 1 - 300\n", "a možná take to udělat jako parametr\n", "zkusit CV\n", "zobrazit nejak robustnost parametru" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Activating profile profile1\n",
       "
\n" ], "text/plain": [ "Activating profile profile1\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Profile profile1 loaded successfully.\n",
       "
\n" ], "text/plain": [ "Profile profile1 loaded successfully.\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Current values:\n",
       "{\n",
       "    'AGG_EXCLUDED_TRADES': ['C', 'O', '4', 'B', '7', 'V', 'P', 'W', 'U', 'Z', 'F'],\n",
       "    'BT_DELAYS': {\n",
       "        'trigger_to_strat': 0.02,\n",
       "        'strat_to_sub': 0.023,\n",
       "        'sub_to_fill': 0.008,\n",
       "        'fill_to_not': 0.023,\n",
       "        'limit_order_offset': 0\n",
       "    },\n",
       "    'BT_FILL_CONDITION_BUY_LIMIT': <FillCondition.SLOW: 'slow'>,\n",
       "    'BT_FILL_CONDITION_SELL_LIMIT': <FillCondition.SLOW: 'slow'>,\n",
       "    'BT_FILL_CONS_TRADES_REQUIRED': 2,\n",
       "    'BT_FILL_LOG_SURROUNDING_TRADES': 10,\n",
       "    'BT_FILL_PRICE_MARKET_ORDER_PREMIUM': 0.005,\n",
       "    'COUNT_API_REQUESTS': False,\n",
       "    'GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN': 0.003,\n",
       "    'ILOG_SAVE_LEVEL_FROM': 1,\n",
       "    'LIVE_DATA_FEED': 'sip',\n",
       "    'NORMALIZED_TICK_BASE_PRICE': 30.0,\n",
       "    'OFFLINE_MODE': False,\n",
       "    'PROD_SERVER_HOSTNAMES': ['tradingeastcoast', 'David-MacBook-Pro.local'],\n",
       "    'QUIET_MODE': True,\n",
       "    'TEST_SERVER_HOSTNAMES': ['tradingtest']\n",
       "}\n",
       "
\n" ], "text/plain": [ "Current values:\n", "\u001b[1m{\u001b[0m\n", " \u001b[32m'AGG_EXCLUDED_TRADES'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'C'\u001b[0m, \u001b[32m'O'\u001b[0m, \u001b[32m'4'\u001b[0m, \u001b[32m'B'\u001b[0m, \u001b[32m'7'\u001b[0m, \u001b[32m'V'\u001b[0m, \u001b[32m'P'\u001b[0m, \u001b[32m'W'\u001b[0m, \u001b[32m'U'\u001b[0m, \u001b[32m'Z'\u001b[0m, \u001b[32m'F'\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[32m'BT_DELAYS'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'trigger_to_strat'\u001b[0m: \u001b[1;36m0.02\u001b[0m,\n", " \u001b[32m'strat_to_sub'\u001b[0m: \u001b[1;36m0.023\u001b[0m,\n", " \u001b[32m'sub_to_fill'\u001b[0m: \u001b[1;36m0.008\u001b[0m,\n", " \u001b[32m'fill_to_not'\u001b[0m: \u001b[1;36m0.023\u001b[0m,\n", " \u001b[32m'limit_order_offset'\u001b[0m: \u001b[1;36m0\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'BT_FILL_CONDITION_BUY_LIMIT'\u001b[0m: \u001b[1m<\u001b[0m\u001b[1;95mFillCondition.SLOW:\u001b[0m\u001b[39m \u001b[0m\u001b[32m'slow'\u001b[0m\u001b[39m>,\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[32m'BT_FILL_CONDITION_SELL_LIMIT'\u001b[0m\u001b[39m: \u001b[0m,\n", " \u001b[32m'BT_FILL_CONS_TRADES_REQUIRED'\u001b[0m: \u001b[1;36m2\u001b[0m,\n", " \u001b[32m'BT_FILL_LOG_SURROUNDING_TRADES'\u001b[0m: \u001b[1;36m10\u001b[0m,\n", " \u001b[32m'BT_FILL_PRICE_MARKET_ORDER_PREMIUM'\u001b[0m: \u001b[1;36m0.005\u001b[0m,\n", " \u001b[32m'COUNT_API_REQUESTS'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", " \u001b[32m'GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN'\u001b[0m: \u001b[1;36m0.003\u001b[0m,\n", " \u001b[32m'ILOG_SAVE_LEVEL_FROM'\u001b[0m: \u001b[1;36m1\u001b[0m,\n", " \u001b[32m'LIVE_DATA_FEED'\u001b[0m: \u001b[32m'sip'\u001b[0m,\n", " \u001b[32m'NORMALIZED_TICK_BASE_PRICE'\u001b[0m: \u001b[1;36m30.0\u001b[0m,\n", " \u001b[32m'OFFLINE_MODE'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", " \u001b[32m'PROD_SERVER_HOSTNAMES'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'tradingeastcoast'\u001b[0m, \u001b[32m'David-MacBook-Pro.local'\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[32m'QUIET_MODE'\u001b[0m: \u001b[3;92mTrue\u001b[0m,\n", " \u001b[32m'TEST_SERVER_HOSTNAMES'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'tradingtest'\u001b[0m\u001b[1m]\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
config_handler.active_profile='profile1'\n",
       "
\n" ], "text/plain": [ "config_handler.\u001b[33mactive_profile\u001b[0m=\u001b[32m'profile1'\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
config handler initialized\n",
       "
\n" ], "text/plain": [ "config handler initialized\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Realtime Websocket connection will use FEED: sip and credential of ACCOUNT1\n" ] }, { "data": { "text/html": [ "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from v2realbot.tools.loadbatch import load_batch\n", "from v2realbot.utils.utils import zoneNY\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", "\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\n", "\n", "# Define the market open and close times\n", "market_open = datetime.time(9, 30)\n", "market_close = datetime.time(16, 0)\n", "entry_window_opens = 1\n", "entry_window_closes = 370\n", "\n", "forced_exit_start = 380\n", "forced_exit_end = 390\n", "\n", "res, df = load_batch(batch_id=\"f1ac6651\", #138170bc 0fb5043a bde6d0be f1ac6651\n", " space_resolution_evenly=False,\n", " indicators_columns=[\"Rsi14\"],\n", " main_session_only=True,\n", " verbose = False)\n", "if res < 0:\n", " print(\"Error\" + str(res) + str(df))\n", "df = df[\"bars\"]\n", "\n", "df\n", "\n", "basic_data = vbt.Data.from_data(vbt.symbol_dict({\"BAC\": df}), tz_convert=zoneNY)\n", "#m1_data = basic_data[['Open', 'High', 'Low', 'Close', 'Volume']]\n", "basic_data = basic_data.transform(lambda df: df.between_time('09:30', '16:00'))\n", "#basic_data.info()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "vbt.open_api_ref(vbt.base)\n", "\n", "vbt" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "
0
\n", "\n", "
\n", "Loading ITables v2.0.1 from the init_notebook_mode cell...\n", "(need help?)
\n", "\n" ], "text/plain": [ "Start 2024-01-02 09:30:00-05:00\n", "End 2024-02-28 15:59:59-05:00\n", "Period 5 days 18:15:46\n", "Start Value 100.0\n", "Min Value 99.766637\n", " ... \n", "Expectancy -0.058341\n", "Sharpe Ratio -3.597608\n", "Calmar Ratio -2.69309\n", "Omega Ratio 0.867176\n", "Sortino Ratio -4.934545\n", "Length: 29, dtype: object" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "##na toto udelat crosssvalidationu nebo alespon na testovacim ci jinem obdobi\n", "#take udelat long leg - tato je shortovaci\n", "\n", "#8\t-0.06\t-0.2\t0.0028\t0.0048\t4.156254\n", "\n", "#short combination ok for train(4)/test(0.1) (window 1-90, fe 95-100)\n", "#2,\t-0.02,\t-0.25,\t0.0018,\t0.0068\n", "\n", "#dalsi ok hodnota shortu for train/test 4/1\n", "#70,\t8,\t-0.06,\t-0.2,\t0.0013,\t0.0053\t\n", "\n", "\n", "#kombinace bez roc_th, train/test 7/-1.5\n", "#70\t7\t-0.07\t0.0033\t0.0063\n", "\n", "#opet bez roc_th, train(5.77)/test 0.9 - spolus tsl_stop + tsl_th\n", "#29\t7\t-0.09\t0.0033\t0.0068\n", "\n", "#bez roc_th a s trailing sl train/test 8.1/-0.8 \n", "#70\t2\t-0.05\t0.0018\t0.0068\n", "\n", "\n", "# TODO:\n", "#- vyzkouset zda nejvyhodnejsi kombinace krom train/testu funguje i na nasledujicich dnech po trainu\n", "# -zkusit najit v short datasetu neco vyhodneho co funguji i na testu\n", "# - dodelat kombinace pro long signaly\n", "# - zkusit walk forward\n", "# - vytvorit vysledkove totoznou na v2realbot\n", "# - podivat se jak detailne funguji tsl_stop a tsl_th\n", "\n", "#70,\t4,\t-0.07,\t0.0048,\t0.0068\t\n", "\n", "\n", "entry_window_closes, mom_timeperiod, mom_th, sl_stop, tp_stop = 8,\t3,\t0.07,\t0.0028,\t0.0033\t\n", "roc_th = 0\n", "momshort = vbt.indicator(\"talib:MOM\").run(basic_data.close, timeperiod=mom_timeperiod, short_name = \"slope_short\")\n", "rocp = vbt.indicator(\"talib:ROC\").run(basic_data.close, short_name = \"rocp\")\n", "#rate of change + momentum\n", "\n", "#momshort.plot rocp.real_crossed_below(roc_th) & \n", "short_signal = momshort.real_crossed_below(mom_th)\n", "\n", "long_signal = momshort.real_crossed_above(mom_th)\n", "\n", "# print(\"short signal\")\n", "# print(short_signal.value_counts())\n", "\n", "#forced_exit = pd.Series(False, index=close.index)\n", "forced_exit = basic_data.symbol_wrapper.fill(False)\n", "#entry_window_open = pd.Series(False, index=close.index)\n", "entry_window_open= basic_data.symbol_wrapper.fill(False)\n", "\n", "# Calculate the time difference in minutes from market open for each timestamp\n", "elapsed_min_from_open = (forced_exit.index.hour - market_open.hour) * 60 + (forced_exit.index.minute - market_open.minute)\n", "\n", "entry_window_open[(elapsed_min_from_open >= entry_window_opens) & (elapsed_min_from_open < entry_window_closes)] = True\n", "\n", "#print(entry_window_open.value_counts())\n", "\n", "forced_exit[(elapsed_min_from_open >= forced_exit_start) & (elapsed_min_from_open < forced_exit_end)] = True\n", "short_entries = (short_signal & entry_window_open)\n", "short_exits = forced_exit\n", "\n", "entries = (long_signal & entry_window_open)\n", "exits = forced_exit\n", "#long_entries.info()\n", "#number of trues and falses in long_entries\n", "# print(short_exits.value_counts())\n", "# print(short_entries.value_counts())\n", "\n", "#fig = plot_2y_close([],[momshort, rocp], close)\n", "#short_signal.vbt.signals.plot_as_entries(close, fig=fig, add_trace_kwargs=dict(secondary_y=False))\n", "#print(sl_stop)\n", "#short_entries=short_entries, short_exits=short_exits,\n", "pf = vbt.Portfolio.from_signals(close=basic_data, entries=entries, exits=exits, tsl_stop=sl_stop, tp_stop = tp_stop, fees=0.0167/100, freq=\"1s\") #sl_stop=sl_stop, tp_stop = sl_stop,\n", "\n", "pf.stats()\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "848b9b38239f4f10b8be10f60265ab6f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "FigureWidget({\n", " 'data': [{'close': array([33.44 , 33.445, 33.42 , ..., 34.325, 34.33 , 34.32 ]),\n", " 'decreasing': {'fillcolor': '#ee534f', 'line': {'color': '#ee534f'}},\n", " 'high': array([33.44 , 33.465, 33.45 , ..., 34.325, 34.33 , 34.33 ]),\n", " 'increasing': {'fillcolor': '#26a69a', 'line': {'color': '#26a69a'}},\n", " 'low': array([33.39, 33.44, 33.42, ..., 34.32, 34.32, 34.32]),\n", " 'name': 'OHLC',\n", " 'opacity': 0.5,\n", " 'open': array([33.39 , 33.46 , 33.45 , ..., 34.32 , 34.325, 34.325]),\n", " 'type': 'candlestick',\n", " 'uid': '62d2f920-d109-44ec-9c98-0def8e4b29b0',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x',\n", " 'yaxis': 'y'},\n", " {'customdata': array([['0', '2024-01-03 09:31:27-05:00', '2024-01-03 09:31:27-05:00',\n", " '2024-01-03 09:31:27-05:00', 2.978352778922679, 33.57,\n", " 0.0166972115656705, 'Market', 'None'],\n", " ['2', '2024-01-04 09:31:16-05:00', '2024-01-04 09:31:16-05:00',\n", " '2024-01-04 09:31:16-05:00', 2.96735984866213, 33.62,\n", " 0.016660360564713983, 'Market', 'None'],\n", " ['4', '2024-01-10 09:32:44-05:00', '2024-01-10 09:32:44-05:00',\n", " '2024-01-10 09:32:44-05:00', 3.0083218731755443, 33.36,\n", " 0.016759722154091605, 'Market', 'None'],\n", " ['6', '2024-01-12 09:31:01-05:00', '2024-01-12 09:31:01-05:00',\n", " '2024-01-12 09:31:01-05:00', 3.1068615104873154, 32.31,\n", " 0.01676391013243972, 'Market', 'None'],\n", " ['8', '2024-01-12 09:32:02-05:00', '2024-01-12 09:32:02-05:00',\n", " '2024-01-12 09:32:02-05:00', 3.100441294836864, 32.57,\n", " 0.016863889286469202, 'Market', 'None'],\n", " ['10', '2024-01-12 09:32:52-05:00', '2024-01-12 09:32:52-05:00',\n", " '2024-01-12 09:32:52-05:00', 3.092952048475304, 32.8484,\n", " 0.0169669538535544, 'Market', 'None'],\n", " ['12', '2024-01-16 09:31:40-05:00', '2024-01-16 09:31:40-05:00',\n", " '2024-01-16 09:31:40-05:00', 3.1376689038339736, 32.44,\n", " 0.016998258533149624, 'Market', 'None'],\n", " ['14', '2024-01-17 09:31:11-05:00', '2024-01-17 09:31:11-05:00',\n", " '2024-01-17 09:31:11-05:00', 3.225768247933234, 31.4927,\n", " 0.016965221334189096, 'Market', 'None'],\n", " ['16', '2024-01-19 09:31:17-05:00', '2024-01-19 09:31:17-05:00',\n", " '2024-01-19 09:31:17-05:00', 3.1852624849523656, 31.82,\n", " 0.016926293729284225, 'Market', 'None'],\n", " ['18', '2024-01-22 09:32:07-05:00', '2024-01-22 09:32:07-05:00',\n", " '2024-01-22 09:32:07-05:00', 3.1147021490903066, 32.43,\n", " 0.01686863504606606, 'Market', 'None'],\n", " ['20', '2024-01-30 09:32:47-05:00', '2024-01-30 09:32:47-05:00',\n", " '2024-01-30 09:32:47-05:00', 2.9763388468118293, 34.14,\n", " 0.016969238774436235, 'Market', 'None'],\n", " ['22', '2024-01-31 09:31:26-05:00', '2024-01-31 09:31:26-05:00',\n", " '2024-01-31 09:31:26-05:00', 2.914727712984091, 34.735,\n", " 0.016907592207459743, 'Market', 'None'],\n", " ['24', '2024-02-05 09:32:00-05:00', '2024-02-05 09:32:00-05:00',\n", " '2024-02-05 09:32:00-05:00', 3.071377439535155, 33.16,\n", " 0.01700842827446536, 'Market', 'None'],\n", " ['26', '2024-02-08 09:31:08-05:00', '2024-02-08 09:31:08-05:00',\n", " '2024-02-08 09:31:08-05:00', 3.068071063787448, 33.13,\n", " 0.016974747455336114, 'Market', 'None'],\n", " ['28', '2024-02-15 09:31:17-05:00', '2024-02-15 09:31:17-05:00',\n", " '2024-02-15 09:31:17-05:00', 3.0289452905084406, 33.4708,\n", " 0.016930664078941504, 'Market', 'None'],\n", " ['30', '2024-02-21 09:31:03-05:00', '2024-02-21 09:31:03-05:00',\n", " '2024-02-21 09:31:03-05:00', 3.0364974627410586, 33.59,\n", " 0.017033323612167806, 'Market', 'None'],\n", " ['32', '2024-02-21 09:32:53-05:00', '2024-02-21 09:32:53-05:00',\n", " '2024-02-21 09:32:53-05:00', 3.0264384972281606, 33.56,\n", " 0.016961735086482577, 'Market', 'None'],\n", " ['34', '2024-02-22 09:31:10-05:00', '2024-02-22 09:31:10-05:00',\n", " '2024-02-22 09:31:10-05:00', 3.014546202965763, 33.59,\n", " 0.01691018736192973, 'Market', 'None'],\n", " ['36', '2024-02-26 09:32:23-05:00', '2024-02-26 09:32:23-05:00',\n", " '2024-02-26 09:32:23-05:00', 2.97661511133949, 33.955,\n", " 0.01687885133962652, 'Market', 'None'],\n", " ['38', '2024-02-27 09:32:14-05:00', '2024-02-27 09:32:14-05:00',\n", " '2024-02-27 09:32:14-05:00', 2.981567760303421, 33.86,\n", " 0.01685963268876378, 'Market', 'None'],\n", " ['40', '2024-02-28 09:32:46-05:00', '2024-02-28 09:32:46-05:00',\n", " '2024-02-28 09:32:46-05:00', 2.942546727531348, 34.25,\n", " 0.016830631644793925, 'Market', 'None']], dtype=object),\n", " 'hovertemplate': ('
Order Id: %{customdata[0]}' ... 'br>Stop Type: %{customdata[8]}'),\n", " 'marker': {'color': '#37B13F',\n", " 'line': {'color': 'rgb(38,123,44)', 'width': 1},\n", " 'size': 8,\n", " 'symbol': 'triangle-up'},\n", " 'mode': 'markers',\n", " 'name': 'Buy',\n", " 'type': 'scatter',\n", " 'uid': '7d55d406-e8fc-4c82-b901-1efe2cc01e8a',\n", " 'x': array([datetime.datetime(2024, 1, 3, 9, 31, 27, tzinfo=),\n", " datetime.datetime(2024, 1, 4, 9, 31, 16, tzinfo=),\n", " datetime.datetime(2024, 1, 10, 9, 32, 44, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 31, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 32, 2, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 32, 52, tzinfo=),\n", " datetime.datetime(2024, 1, 16, 9, 31, 40, tzinfo=),\n", " datetime.datetime(2024, 1, 17, 9, 31, 11, tzinfo=),\n", " datetime.datetime(2024, 1, 19, 9, 31, 17, tzinfo=),\n", " datetime.datetime(2024, 1, 22, 9, 32, 7, tzinfo=),\n", " datetime.datetime(2024, 1, 30, 9, 32, 47, tzinfo=),\n", " datetime.datetime(2024, 1, 31, 9, 31, 26, tzinfo=),\n", " datetime.datetime(2024, 2, 5, 9, 32, tzinfo=),\n", " datetime.datetime(2024, 2, 8, 9, 31, 8, tzinfo=),\n", " datetime.datetime(2024, 2, 15, 9, 31, 17, tzinfo=),\n", " datetime.datetime(2024, 2, 21, 9, 31, 3, tzinfo=),\n", " datetime.datetime(2024, 2, 21, 9, 32, 53, tzinfo=),\n", " datetime.datetime(2024, 2, 22, 9, 31, 10, tzinfo=),\n", " datetime.datetime(2024, 2, 26, 9, 32, 23, tzinfo=),\n", " datetime.datetime(2024, 2, 27, 9, 32, 14, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 9, 32, 46, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x',\n", " 'y': array([33.57 , 33.62 , 33.36 , 32.31 , 32.57 , 32.8484, 32.44 , 31.4927,\n", " 31.82 , 32.43 , 34.14 , 34.735 , 33.16 , 33.13 , 33.4708, 33.59 ,\n", " 33.56 , 33.59 , 33.955 , 33.86 , 34.25 ]),\n", " 'yaxis': 'y'},\n", " {'customdata': array([['1', '2024-01-03 09:31:27-05:00', '2024-01-03 09:33:15-05:00',\n", " '2024-01-03 09:33:15-05:00', 2.978352778922679, 33.5071,\n", " 0.016665926054572896, 'Market', 'TSL'],\n", " ['3', '2024-01-04 09:31:16-05:00', '2024-01-04 09:33:03-05:00',\n", " '2024-01-04 09:33:03-05:00', 2.96735984866213, 33.83180599999999,\n", " 0.01676532083626513, 'Market', 'TP'],\n", " ['5', '2024-01-10 09:32:44-05:00', '2024-01-10 09:38:22-05:00',\n", " '2024-01-10 09:38:22-05:00', 3.0083218731755443, 33.379483,\n", " 0.016769510213639937, 'Market', 'TSL'],\n", " ['7', '2024-01-12 09:31:01-05:00', '2024-01-12 09:31:54-05:00',\n", " '2024-01-12 09:31:54-05:00', 3.1068615104873154, 32.513553,\n", " 0.016869522766276526, 'Market', 'TP'],\n", " ['9', '2024-01-12 09:32:02-05:00', '2024-01-12 09:32:35-05:00',\n", " '2024-01-12 09:32:35-05:00', 3.100441294836864, 32.78,\n", " 0.01697262176267365, 'Market', 'TP'],\n", " ['11', '2024-01-12 09:32:52-05:00', '2024-01-12 09:34:39-05:00',\n", " '2024-01-12 09:34:39-05:00', 3.092952048475304, 32.92,\n", " 0.017003936899779772, 'Market', 'TSL'],\n", " ['13', '2024-01-16 09:31:40-05:00', '2024-01-16 09:33:22-05:00',\n", " '2024-01-16 09:33:22-05:00', 3.1376689038339736, 32.3877665,\n", " 0.016970888664551508, 'Market', 'TSL'],\n", " ['15', '2024-01-17 09:31:11-05:00', '2024-01-17 09:33:03-05:00',\n", " '2024-01-17 09:33:03-05:00', 3.225768247933234, 31.4309345,\n", " 0.01693194805566586, 'Market', 'TSL'],\n", " ['17', '2024-01-19 09:31:17-05:00', '2024-01-19 09:33:56-05:00',\n", " '2024-01-19 09:33:56-05:00', 3.1852624849523656, 31.7222,\n", " 0.016874270111226043, 'Market', 'TSL'],\n", " ['19', '2024-01-22 09:32:07-05:00', '2024-01-22 09:34:31-05:00',\n", " '2024-01-22 09:34:31-05:00', 3.1147021490903066, 32.634309,\n", " 0.01697490744685498, 'Market', 'TP'],\n", " ['21', '2024-01-30 09:32:47-05:00', '2024-01-30 09:33:40-05:00',\n", " '2024-01-30 09:33:40-05:00', 2.9763388468118293, 34.027338,\n", " 0.016913240286480388, 'Market', 'TSL'],\n", " ['23', '2024-01-31 09:31:26-05:00', '2024-01-31 09:38:35-05:00',\n", " '2024-01-31 09:38:35-05:00', 2.914727712984091, 34.953830499999995,\n", " 0.01701411003836086, 'Market', 'TP'],\n", " ['25', '2024-02-05 09:32:00-05:00', '2024-02-05 09:39:03-05:00',\n", " '2024-02-05 09:39:03-05:00', 3.071377439535155, 33.105390500000006,\n", " 0.016980417967953142, 'Market', 'TSL'],\n", " ['27', '2024-02-08 09:31:08-05:00', '2024-02-08 09:34:25-05:00',\n", " '2024-02-08 09:34:25-05:00', 3.068071063787448, 33.055,\n", " 0.016936319865253513, 'Market', 'TSL'],\n", " ['29', '2024-02-15 09:31:17-05:00', '2024-02-15 09:33:50-05:00',\n", " '2024-02-15 09:33:50-05:00', 3.0289452905084406, 33.685,\n", " 0.01703901369249973, 'Market', 'TP'],\n", " ['31', '2024-02-21 09:31:03-05:00', '2024-02-21 09:32:43-05:00',\n", " '2024-02-21 09:32:43-05:00', 3.0364974627410586, 33.46,\n", " 0.016967401252253742, 'Market', 'TSL'],\n", " ['33', '2024-02-21 09:32:53-05:00', '2024-02-21 09:33:18-05:00',\n", " '2024-02-21 09:33:18-05:00', 3.0264384972281606, 33.469186,\n", " 0.016915836307875395, 'Market', 'TSL'],\n", " ['35', '2024-02-22 09:31:10-05:00', '2024-02-22 09:32:42-05:00',\n", " '2024-02-22 09:32:42-05:00', 3.014546202965763, 33.538955,\n", " 0.016884489817597163, 'Market', 'TSL'],\n", " ['37', '2024-02-26 09:32:23-05:00', '2024-02-26 09:39:15-05:00',\n", " '2024-02-26 09:39:15-05:00', 2.97661511133949, 33.927668,\n", " 0.01686526474663864, 'Market', 'TSL'],\n", " ['39', '2024-02-27 09:32:14-05:00', '2024-02-27 09:34:52-05:00',\n", " '2024-02-27 09:34:52-05:00', 2.981567760303421, 33.813047499999996,\n", " 0.016836254014702564, 'Market', 'TSL'],\n", " ['41', '2024-02-28 09:32:46-05:00', '2024-02-28 09:44:36-05:00',\n", " '2024-02-28 09:44:36-05:00', 2.942546727531348, 34.465775,\n", " 0.01693666462415965, 'Market', 'TP']], dtype=object),\n", " 'hovertemplate': ('
Order Id: %{customdata[0]}' ... 'br>Stop Type: %{customdata[8]}'),\n", " 'marker': {'color': '#EA4335',\n", " 'line': {'color': 'rgb(181,31,18)', 'width': 1},\n", " 'size': 8,\n", " 'symbol': 'triangle-down'},\n", " 'mode': 'markers',\n", " 'name': 'Sell',\n", " 'type': 'scatter',\n", " 'uid': '5f8e0347-ebd1-49e0-8fdf-adbf25f7f974',\n", " 'x': array([datetime.datetime(2024, 1, 3, 9, 33, 15, tzinfo=),\n", " datetime.datetime(2024, 1, 4, 9, 33, 3, tzinfo=),\n", " datetime.datetime(2024, 1, 10, 9, 38, 22, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 31, 54, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 32, 35, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 34, 39, tzinfo=),\n", " datetime.datetime(2024, 1, 16, 9, 33, 22, tzinfo=),\n", " datetime.datetime(2024, 1, 17, 9, 33, 3, tzinfo=),\n", " datetime.datetime(2024, 1, 19, 9, 33, 56, tzinfo=),\n", " datetime.datetime(2024, 1, 22, 9, 34, 31, tzinfo=),\n", " datetime.datetime(2024, 1, 30, 9, 33, 40, tzinfo=),\n", " datetime.datetime(2024, 1, 31, 9, 38, 35, tzinfo=),\n", " datetime.datetime(2024, 2, 5, 9, 39, 3, tzinfo=),\n", " datetime.datetime(2024, 2, 8, 9, 34, 25, tzinfo=),\n", " datetime.datetime(2024, 2, 15, 9, 33, 50, tzinfo=),\n", " datetime.datetime(2024, 2, 21, 9, 32, 43, tzinfo=),\n", " datetime.datetime(2024, 2, 21, 9, 33, 18, tzinfo=),\n", " datetime.datetime(2024, 2, 22, 9, 32, 42, tzinfo=),\n", " datetime.datetime(2024, 2, 26, 9, 39, 15, tzinfo=),\n", " datetime.datetime(2024, 2, 27, 9, 34, 52, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 9, 44, 36, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x',\n", " 'y': array([33.5071 , 33.831806 , 33.379483 , 32.513553 , 32.78 , 32.92 ,\n", " 32.3877665, 31.4309345, 31.7222 , 32.634309 , 34.027338 , 34.9538305,\n", " 33.1053905, 33.055 , 33.685 , 33.46 , 33.469186 , 33.538955 ,\n", " 33.927668 , 33.8130475, 34.465775 ]),\n", " 'yaxis': 'y'},\n", " {'customdata': array([['1', '1', '2024-01-04 09:33:03-05:00', 0.5950789387047365,\n", " 0.0059649478999997795],\n", " ['2', '2', '2024-01-10 09:38:22-05:00', 0.025081902687342218,\n", " 0.000249925249969912],\n", " ['3', '3', '2024-01-12 09:31:54-05:00', 0.5987775481455146,\n", " 0.0059649479000000874],\n", " ['4', '4', '2024-01-12 09:32:35-05:00', 0.6172561608666053,\n", " 0.00611257445501997],\n", " ['5', '5', '2024-01-12 09:34:39-05:00', 0.18748447591751835,\n", " 0.0018453464156550673],\n", " ['9', '9', '2024-01-22 09:34:31-05:00', 0.6025181388855818,\n", " 0.0059649479000001004],\n", " ['11', '11', '2024-01-31 09:38:35-05:00', 0.6039096205503393,\n", " 0.0059649478999998905],\n", " ['14', '14', '2024-02-15 09:33:50-05:00', 0.6148304034554822,\n", " 0.006064539282001115],\n", " ['20', '20', '2024-02-28 09:44:36-05:00', 0.6011607238641207,\n", " 0.00596494790000001]], dtype=object),\n", " 'hovertemplate': ('
Exit Trade Id: %{customdat' ... 'br>Return: %{customdata[4]:,%}'),\n", " 'marker': {'color': '#37B13F',\n", " 'line': {'color': 'rgb(38,123,44)', 'width': 1},\n", " 'opacity': array([0.89622287, 0.75 , 0.89622287, 0.9 , 0.79081997, 0.89622287,\n", " 0.89622287, 0.89877099, 0.89622287]),\n", " 'size': array([13.82373397, 7. , 13.82373397, 14. , 8.90493201,\n", " 13.82373397, 13.82373397, 13.94264603, 13.82373397]),\n", " 'symbol': 'circle'},\n", " 'mode': 'markers',\n", " 'name': 'Closed - Profit',\n", " 'type': 'scatter',\n", " 'uid': '20d3a161-d4fc-47e6-bf90-8819c520dfb6',\n", " 'x': array([datetime.datetime(2024, 1, 4, 9, 33, 3, tzinfo=),\n", " datetime.datetime(2024, 1, 10, 9, 38, 22, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 31, 54, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 32, 35, tzinfo=),\n", " datetime.datetime(2024, 1, 12, 9, 34, 39, tzinfo=),\n", " datetime.datetime(2024, 1, 22, 9, 34, 31, tzinfo=),\n", " datetime.datetime(2024, 1, 31, 9, 38, 35, tzinfo=),\n", " datetime.datetime(2024, 2, 15, 9, 33, 50, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 9, 44, 36, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x2',\n", " 'y': array([0.00596495, 0.00024993, 0.00596495, 0.00611257, 0.00184535, 0.00596495,\n", " 0.00596495, 0.00606454, 0.00596495]),\n", " 'yaxis': 'y2'},\n", " {'customdata': array([['0', '0', '2024-01-03 09:33:15-05:00', -0.22070152741447807,\n", " -0.002207383845695563],\n", " ['6', '6', '2024-01-16 09:33:22-05:00', -0.1978605758861028,\n", " -0.0019438883170622393],\n", " ['7', '7', '2024-01-17 09:33:03-05:00', -0.2331383581075762,\n", " -0.0022949365078733363],\n", " ['8', '8', '2024-01-19 09:33:56-05:00', -0.34531923486884847,\n", " -0.0034070253739785636],\n", " ['10', '10', '2024-01-30 09:33:40-05:00', -0.3692027662204353,\n", " -0.0036334489000000446],\n", " ['12', '12', '2024-02-05 09:39:03-05:00', -0.20171523252669066,\n", " -0.001980573589067957],\n", " ['13', '13', '2024-02-08 09:34:25-05:00', -0.26401639710465635,\n", " -0.00259743118019938],\n", " ['15', '15', '2024-02-21 09:32:43-05:00', -0.42874539502076375,\n", " -0.004203553140815744],\n", " ['16', '16', '2024-02-21 09:33:18-05:00', -0.30872055708164403,\n", " -0.0030395671651371197],\n", " ['17', '17', '2024-02-22 09:32:42-05:00', -0.18767218810991249,\n", " -0.0018533949236380408],\n", " ['18', '18', '2024-02-26 09:39:15-05:00', -0.11510096030940233,\n", " -0.0011388132986600787],\n", " ['19', '19', '2024-02-27 09:34:52-05:00', -0.17368794696912138,\n", " -0.0017204341090520333]], dtype=object),\n", " 'hovertemplate': ('
Exit Trade Id: %{customdat' ... 'br>Return: %{customdata[4]:,%}'),\n", " 'marker': {'color': '#EA4335',\n", " 'line': {'color': 'rgb(181,31,18)', 'width': 1},\n", " 'opacity': array([0.80008295, 0.79334124, 0.80232305, 0.83077663, 0.83656983, 0.79427985,\n", " 0.81006259, 0.85115635, 0.82137495, 0.7910259 , 0.77274283, 0.787624 ]),\n", " 'size': array([ 9.33720451, 9.02259099, 9.44174234, 10.76957585, 11.03992542,\n", " 9.06639319, 9.80292082, 11.72062958, 10.33083095, 8.91454193,\n", " 8.06133185, 8.75578679]),\n", " 'symbol': 'circle'},\n", " 'mode': 'markers',\n", " 'name': 'Closed - Loss',\n", " 'type': 'scatter',\n", " 'uid': '38ec9cd1-8a39-4443-b9de-94b6ce3de315',\n", " 'x': array([datetime.datetime(2024, 1, 3, 9, 33, 15, tzinfo=),\n", " datetime.datetime(2024, 1, 16, 9, 33, 22, tzinfo=),\n", " datetime.datetime(2024, 1, 17, 9, 33, 3, tzinfo=),\n", " datetime.datetime(2024, 1, 19, 9, 33, 56, tzinfo=),\n", " datetime.datetime(2024, 1, 30, 9, 33, 40, tzinfo=),\n", " datetime.datetime(2024, 2, 5, 9, 39, 3, tzinfo=),\n", " datetime.datetime(2024, 2, 8, 9, 34, 25, tzinfo=),\n", " datetime.datetime(2024, 2, 21, 9, 32, 43, tzinfo=),\n", " datetime.datetime(2024, 2, 21, 9, 33, 18, tzinfo=),\n", " datetime.datetime(2024, 2, 22, 9, 32, 42, tzinfo=),\n", " datetime.datetime(2024, 2, 26, 9, 39, 15, tzinfo=),\n", " datetime.datetime(2024, 2, 27, 9, 34, 52, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x2',\n", " 'y': array([-0.00220738, -0.00194389, -0.00229494, -0.00340703, -0.00363345,\n", " -0.00198057, -0.00259743, -0.00420355, -0.00303957, -0.00185339,\n", " -0.00113881, -0.00172043]),\n", " 'yaxis': 'y2'},\n", " {'legendgroup': '0',\n", " 'line': {'color': '#7f7f7f'},\n", " 'mode': 'lines',\n", " 'name': 'Benchmark',\n", " 'showlegend': True,\n", " 'type': 'scatter',\n", " 'uid': 'b3f84fa4-cb7f-41f1-b96c-9c24f5aa46da',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x3',\n", " 'y': array([1. , 1.00014952, 0.99940191, ..., 1.02646531, 1.02661483,\n", " 1.02631579]),\n", " 'yaxis': 'y3'},\n", " {'hoverinfo': 'skip',\n", " 'line': {'color': 'rgba(0, 0, 0, 0)', 'width': 0},\n", " 'mode': 'lines',\n", " 'opacity': 0,\n", " 'showlegend': False,\n", " 'type': 'scatter',\n", " 'uid': 'bb8dec5c-74b0-482b-a783-9272535513e5',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x3',\n", " 'y': array([1, 1, 1, ..., 1, 1, 1]),\n", " 'yaxis': 'y3'},\n", " {'connectgaps': False,\n", " 'fill': 'tonexty',\n", " 'fillcolor': 'rgba(0, 128, 0, 0.25)',\n", " 'hoverinfo': 'skip',\n", " 'line': {'color': 'rgba(0, 0, 0, 0)', 'width': 0},\n", " 'mode': 'lines',\n", " 'opacity': 0,\n", " 'showlegend': False,\n", " 'type': 'scatter',\n", " 'uid': '4bc24efb-89ee-450f-a511-aa169477de90',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x3',\n", " 'y': array([1. , 1. , 1. , ..., 1.01400217, 1.01400217,\n", " 1.01400217]),\n", " 'yaxis': 'y3'},\n", " {'hoverinfo': 'skip',\n", " 'line': {'color': 'rgba(0, 0, 0, 0)', 'width': 0},\n", " 'mode': 'lines',\n", " 'opacity': 0,\n", " 'showlegend': False,\n", " 'type': 'scatter',\n", " 'uid': '1c409fe2-0526-4777-adf2-b287135a36b9',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x3',\n", " 'y': array([1, 1, 1, ..., 1, 1, 1]),\n", " 'yaxis': 'y3'},\n", " {'connectgaps': False,\n", " 'fill': 'tonexty',\n", " 'fillcolor': 'rgba(255, 0, 0, 0.25)',\n", " 'hoverinfo': 'skip',\n", " 'line': {'color': 'rgba(0, 0, 0, 0)', 'width': 0},\n", " 'mode': 'lines',\n", " 'opacity': 0,\n", " 'showlegend': False,\n", " 'type': 'scatter',\n", " 'uid': '19e679ec-6091-4d93-930e-7269833d92a3',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x3',\n", " 'y': array([1., 1., 1., ..., 1., 1., 1.]),\n", " 'yaxis': 'y3'},\n", " {'legendgroup': '1',\n", " 'line': {'color': '#9467bd'},\n", " 'mode': 'lines',\n", " 'name': 'Value',\n", " 'showlegend': True,\n", " 'type': 'scatter',\n", " 'uid': 'f8a1d4e0-d6f3-46ce-9d3e-df09f8d7a206',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x3',\n", " 'y': array([1. , 1. , 1. , ..., 1.01400217, 1.01400217,\n", " 1.01400217]),\n", " 'yaxis': 'y3'},\n", " {'hoverinfo': 'skip',\n", " 'line': {'color': 'rgba(0, 0, 0, 0)', 'width': 0},\n", " 'mode': 'lines',\n", " 'opacity': 0.0,\n", " 'showlegend': False,\n", " 'type': 'scatter',\n", " 'uid': 'fcc468a9-d6f9-416b-abbe-d59fcd5e9118',\n", " 'x': array([datetime.datetime(2024, 1, 2, 9, 30, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 1, tzinfo=),\n", " datetime.datetime(2024, 1, 2, 9, 30, 2, tzinfo=),\n", " ...,\n", " datetime.datetime(2024, 2, 28, 15, 59, 57, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 58, tzinfo=),\n", " datetime.datetime(2024, 2, 28, 15, 59, 59, tzinfo=)],\n", " dtype=object),\n", " 'xaxis': 'x3',\n", " 'y': array([1, 1, 1, ..., 1, 1, 1]),\n", " 'yaxis': 'y3'}],\n", " 'layout': {'annotations': [{'font': {'size': 16},\n", " 'showarrow': False,\n", " 'text': 'Orders',\n", " 'x': 0.5,\n", " 'xanchor': 'center',\n", " 'xref': 'paper',\n", " 'y': 1.0,\n", " 'yanchor': 'bottom',\n", " 'yref': 'paper'},\n", " {'font': {'size': 16},\n", " 'showarrow': False,\n", " 'text': 'Trade PnL',\n", " 'x': 0.5,\n", " 'xanchor': 'center',\n", " 'xref': 'paper',\n", " 'y': 0.6527777777777777,\n", " 'yanchor': 'bottom',\n", " 'yref': 'paper'},\n", " {'font': {'size': 16},\n", " 'showarrow': False,\n", " 'text': 'Cumulative Returns',\n", " 'x': 0.5,\n", " 'xanchor': 'center',\n", " 'xref': 'paper',\n", " 'y': 0.3055555555555555,\n", " 'yanchor': 'bottom',\n", " 'yref': 'paper'}],\n", " 'height': 960,\n", " 'legend': {'orientation': 'h',\n", " 'traceorder': 'normal',\n", " 'x': 1,\n", " 'xanchor': 'right',\n", " 'y': 1.0416666666666667,\n", " 'yanchor': 'bottom'},\n", " 'margin': {'b': 30, 'l': 30, 'r': 30, 't': 30},\n", " 'shapes': [{'line': {'color': 'gray', 'dash': 'dash'},\n", " 'type': 'line',\n", " 'x0': 0.0,\n", " 'x1': 1.0,\n", " 'xref': 'paper',\n", " 'y0': 0,\n", " 'y1': 0,\n", " 'yref': 'y2'},\n", " {'line': {'color': 'gray', 'dash': 'dash'},\n", " 'type': 'line',\n", " 'x0': 0.0,\n", " 'x1': 1.0,\n", " 'xref': 'paper',\n", " 'y0': 1,\n", " 'y1': 1,\n", " 'yref': 'y3'}],\n", " 'showlegend': True,\n", " 'template': '...',\n", " 'width': 1330,\n", " 'xaxis': {'anchor': 'y',\n", " 'domain': [0.0, 1.0],\n", " 'matches': 'x3',\n", " 'rangeslider': {'visible': False},\n", " 'showticklabels': False},\n", " 'xaxis2': {'anchor': 'y2', 'domain': [0.0, 1.0], 'matches': 'x3', 'showticklabels': False},\n", " 'xaxis3': {'anchor': 'y3', 'domain': [0.0, 1.0], 'title': {'text': 'Index'}},\n", " 'yaxis': {'anchor': 'x', 'domain': [0.6944444444444444, 1.0], 'title': {'text': 'Price'}},\n", " 'yaxis2': {'anchor': 'x2',\n", " 'domain': [0.3472222222222222, 0.6527777777777777],\n", " 'tickformat': '.2%',\n", " 'title': {'text': 'Trade PnL'}},\n", " 'yaxis3': {'anchor': 'x3', 'domain': [0.0, 0.3055555555555555], 'title': {'text': 'Cumulative returns'}}}\n", "})" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pf.plot()" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "
Drawdown IdColumnStart IndexValley IndexEnd IndexStart ValueValley ValueEnd ValueStatus
\n", "\n", "
\n", "Loading ITables v2.0.1 from the init_notebook_mode cell...\n", "(need help?)
\n", "\n" ], "text/plain": [ " Drawdown Id Column Start Index \\\n", "0 0 (0.0018, 0.0068) 2024-01-03 09:31:04-05:00 \n", "1 1 (0.0018, 0.0068) 2024-01-03 09:31:07-05:00 \n", "2 2 (0.0018, 0.0068) 2024-01-03 09:31:11-05:00 \n", "3 3 (0.0018, 0.0068) 2024-01-03 09:31:18-05:00 \n", "4 4 (0.0018, 0.0068) 2024-01-03 09:48:07-05:00 \n", ".. ... ... ... \n", "34 34 (0.0018, 0.0068) 2024-01-12 12:23:26-05:00 \n", "35 35 (0.0018, 0.0068) 2024-01-12 12:23:31-05:00 \n", "36 36 (0.0018, 0.0068) 2024-01-12 12:32:23-05:00 \n", "37 37 (0.0018, 0.0068) 2024-01-12 12:32:27-05:00 \n", "38 38 (0.0018, 0.0068) 2024-01-12 12:32:36-05:00 \n", "\n", " Valley Index End Index Start Value \\\n", "0 2024-01-03 09:31:05-05:00 2024-01-03 09:31:06-05:00 100.000000 \n", "1 2024-01-03 09:31:10-05:00 2024-01-03 09:31:11-05:00 100.057784 \n", "2 2024-01-03 09:31:13-05:00 2024-01-03 09:31:16-05:00 100.102472 \n", "3 2024-01-03 09:32:39-05:00 2024-01-03 09:48:05-05:00 100.162057 \n", "4 2024-01-03 09:48:08-05:00 2024-01-03 09:48:11-05:00 100.186396 \n", ".. ... ... ... \n", "34 2024-01-12 12:23:28-05:00 2024-01-12 12:23:29-05:00 100.981534 \n", "35 2024-01-12 12:26:27-05:00 2024-01-12 12:32:23-05:00 101.089545 \n", "36 2024-01-12 12:32:24-05:00 2024-01-12 12:32:25-05:00 101.089545 \n", "37 2024-01-12 12:32:28-05:00 2024-01-12 12:32:36-05:00 101.104975 \n", "38 2024-02-21 09:35:15-05:00 2024-02-28 15:59:59-05:00 101.104975 \n", "\n", " Valley Value End Value Status \n", "0 99.983303 100.057784 Recovered \n", "1 100.042888 100.102472 Recovered \n", "2 100.057784 100.102472 Recovered \n", "3 99.650958 100.171522 Recovered \n", "4 100.171522 100.201269 Recovered \n", ".. ... ... ... \n", "34 100.968881 101.043254 Recovered \n", "35 100.858092 101.089545 Recovered \n", "36 101.074115 101.089545 Recovered \n", "37 101.089545 101.104975 Recovered \n", "38 99.788058 99.788058 Active \n", "\n", "[39 rows x 9 columns]" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pf.get_drawdowns().records_readable" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "
Order IdColumnSignal IndexCreation IndexFill IndexSizePriceFeesSideTypeStop Type
\n", "\n", "
\n", "Loading ITables v2.0.1 from the init_notebook_mode cell...\n", "(need help?)
\n", "\n" ], "text/plain": [ " Order Id Column Signal Index Creation Index \\\n", "0 0 0 2024-01-03 09:31:06-05:00 2024-01-03 09:31:06-05:00 \n", "1 1 0 2024-01-03 09:31:06-05:00 2024-01-03 09:48:40-05:00 \n", "2 2 0 2024-01-04 09:33:14-05:00 2024-01-04 09:33:14-05:00 \n", "3 3 0 2024-01-04 09:33:14-05:00 2024-01-04 09:43:31-05:00 \n", "4 4 0 2024-01-05 09:31:23-05:00 2024-01-05 09:31:23-05:00 \n", ".. ... ... ... ... \n", "51 51 0 2024-02-21 09:34:52-05:00 2024-02-21 09:45:00-05:00 \n", "52 52 0 2024-02-22 09:31:22-05:00 2024-02-22 09:31:22-05:00 \n", "53 53 0 2024-02-22 09:31:22-05:00 2024-02-22 09:38:13-05:00 \n", "54 54 0 2024-02-23 09:31:25-05:00 2024-02-23 09:31:25-05:00 \n", "55 55 0 2024-02-23 09:31:25-05:00 2024-02-23 09:35:02-05:00 \n", "\n", " Fill Index Size Price Fees Side Type \\\n", "0 2024-01-03 09:31:06-05:00 2.981461 33.535000 0.016697 Sell Market \n", "1 2024-01-03 09:48:40-05:00 2.981461 33.357264 0.016609 Buy Market \n", "2 2024-01-04 09:33:14-05:00 2.976739 33.755000 0.016780 Sell Market \n", "3 2024-01-04 09:43:31-05:00 2.976739 33.821568 0.016813 Buy Market \n", "4 2024-01-05 09:31:23-05:00 2.972516 33.725000 0.016741 Sell Market \n", ".. ... ... ... ... ... ... \n", "51 2024-02-21 09:45:00-05:00 3.023216 33.334240 0.016830 Buy Market \n", "52 2024-02-22 09:31:22-05:00 3.001125 33.580000 0.016830 Sell Market \n", "53 2024-02-22 09:38:13-05:00 3.001125 33.620000 0.016850 Buy Market \n", "54 2024-02-23 09:31:25-05:00 2.990315 33.650000 0.016804 Sell Market \n", "55 2024-02-23 09:35:02-05:00 2.990315 33.654100 0.016806 Buy Market \n", "\n", " Stop Type \n", "0 None \n", "1 TP \n", "2 None \n", "3 TSL \n", "4 None \n", ".. ... \n", "51 TSL \n", "52 None \n", "53 TSL \n", "54 None \n", "55 TSL \n", "\n", "[56 rows x 11 columns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pf.orders.records_readable" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.11" } }, "nbformat": 4, "nbformat_minor": 2 }