diff --git a/research/notebooks/pt_sliding.ipynb b/research/notebooks/pt_sliding.ipynb index e793cee..f1c70cf 100644 --- a/research/notebooks/pt_sliding.ipynb +++ b/research/notebooks/pt_sliding.ipynb @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -224,7 +224,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -311,7 +311,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ @@ -371,7 +371,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ @@ -416,7 +416,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 28, "metadata": {}, "outputs": [], "source": [ @@ -508,7 +508,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -578,7 +578,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -633,6 +633,7 @@ " # Create subplots with price charts at bottom\n", " fig = make_subplots(\n", " rows=4, cols=1,\n", + " row_heights=[0.33, 0.1, 0.33, 0.33],\n", " subplot_titles=[\n", " f'Testing Period: Scaled Dis-equilibrium with Trading Thresholds ({TRD_DATE})',\n", " f'Trading Signal Timeline ({TRD_DATE})',\n", @@ -714,17 +715,9 @@ " row=1, col=1\n", " )\n", "\n", + " # ----------------------------- \n", " # 2. Trading signals timeline if available - using consistent timeline\n", " if pair_trades is not None and len(pair_trades) > 0:\n", - " # Separate trades by action and status for different colors\n", - " # buy_open_trades = pair_trades[(pair_trades['action'].str.contains('BUY', na=False)) & \n", - " # (pair_trades['status'] == 'OPEN')]\n", - " # buy_close_trades = pair_trades[(pair_trades['action'].str.contains('BUY', na=False)) & \n", - " # (pair_trades['status'] == 'CLOSE')]\n", - " # sell_open_trades = pair_trades[(pair_trades['action'].str.contains('SELL', na=False)) & \n", - " # (pair_trades['status'] == 'OPEN')]\n", - " # sell_close_trades = pair_trades[(pair_trades['action'].str.contains('SELL', na=False)) & \n", - " # (pair_trades['status'] == 'CLOSE')]\n", " \n", " open_trades = pair_trades[(pair_trades['status'] == 'OPEN')]\n", " close_trades = pair_trades[(pair_trades['status'] == 'CLOSE')]\n", @@ -735,14 +728,9 @@ " ones = [1] * len(pair_trades)\n", "\n", " # Add trading signals with different colors based on action and status\n", - " # if len(buy_open_trades) > 0:\n", " if len(open_trades) > 0:\n", - " # buy_open_indices = [i for i, (_, row) in enumerate(pair_trades.iterrows()) \n", - " # if 'BUY' in row['action'] and row['status'] == 'OPEN']\n", " fig.add_trace(\n", " go.Scatter(\n", - " # x=buy_open_trades['time'],\n", - " # y=buy_open_indices,\n", " x=open_trades['time'],\n", " y=zeroes,\n", " mode='markers',\n", @@ -752,14 +740,9 @@ " row=2, col=1\n", " )\n", " \n", - " # if len(buy_close_trades) > 0:\n", " if len(close_trades) > 0:\n", - " # buy_close_indices = [i for i, (_, row) in enumerate(pair_trades.iterrows()) \n", - " # if 'BUY' in row['action'] and row['status'] == 'CLOSE']\n", " fig.add_trace(\n", " go.Scatter(\n", - " # x=buy_close_trades['time'],\n", - " # y=buy_close_indices,\n", " x=close_trades['time'],\n", " y=ones,\n", " mode='markers',\n", @@ -768,37 +751,7 @@ " ),\n", " row=2, col=1\n", " )\n", - " \n", - " # if len(sell_open_trades) > 0:\n", - " # sell_open_indices = [i for i, (_, row) in enumerate(pair_trades.iterrows()) \n", - " # if 'SELL' in row['action'] and row['status'] == 'OPEN']\n", - " # fig.add_trace(\n", - " # go.Scatter(\n", - " # x=sell_open_trades['time'],\n", - " # # y=sell_open_indices,\n", - " # y=zeroes,\n", - " # mode='markers',\n", - " # name='SELL OPEN',\n", - " # marker=dict(color='blue', size=10, symbol='circle')\n", - " # ),\n", - " # row=2, col=1\n", - " # )\n", - " \n", - " # if len(sell_close_trades) > 0:\n", - " # sell_close_indices = [i for i, (_, row) in enumerate(pair_trades.iterrows()) \n", - " # if 'SELL' in row['action'] and row['status'] == 'CLOSE']\n", - " # fig.add_trace(\n", - " # go.Scatter(\n", - " # x=sell_close_trades['time'],\n", - " # # y=sell_close_indices,\n", - " # y=ones,\n", - " # mode='markers',\n", - " # name='SELL CLOSE',\n", - " # marker=dict(color='purple', size=10, symbol='circle')\n", - " # ),\n", - " # row=2, col=1\n", - " # )\n", - "\n", + " # ----------------------------- \n", " fig.add_trace(\n", " go.Scatter(\n", " x=symbol_a_data['tstamp'],\n", @@ -895,8 +848,6 @@ " )\n", " \n", " # Add trading signals for Symbol_B if available\n", - " # if pair_trades is not None and len(pair_trades) > 0:\n", - " # Filter trades for Symbol_B\n", " symbol_b_trades = pair_trades[pair_trades['symbol'] == SYMBOL_B]\n", " \n", " if len(symbol_b_trades) > 0:\n", @@ -1175,7 +1126,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -1245,7 +1196,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -1326,7 +1277,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -6597,7 +6548,7 @@ "x": 0.5, "xanchor": "center", "xref": "paper", - "y": 0.7350000000000001, + "y": 0.691743119266055, "yanchor": "bottom", "yref": "paper" }, @@ -6610,7 +6561,7 @@ "x": 0.5, "xanchor": "center", "xref": "paper", - "y": 0.47000000000000003, + "y": 0.5565137614678899, "yanchor": "bottom", "yref": "paper" }, @@ -6623,7 +6574,7 @@ "x": 0.5, "xanchor": "center", "xref": "paper", - "y": 0.20500000000000002, + "y": 0.24825688073394497, "yanchor": "bottom", "yref": "paper" } @@ -7537,7 +7488,7 @@ "yaxis": { "anchor": "x", "domain": [ - 0.7949999999999999, + 0.7517431192660551, 1 ], "title": { @@ -7547,8 +7498,8 @@ "yaxis2": { "anchor": "x2", "domain": [ - 0.53, - 0.7350000000000001 + 0.6165137614678899, + 0.691743119266055 ], "title": { "text": "Open/Close Actions" @@ -7557,8 +7508,8 @@ "yaxis3": { "anchor": "x3", "domain": [ - 0.265, - 0.47000000000000003 + 0.30825688073394497, + 0.5565137614678899 ], "title": { "text": "BTC-USDT Price ($)" @@ -7568,7 +7519,7 @@ "anchor": "x4", "domain": [ 0, - 0.20500000000000002 + 0.24825688073394497 ], "title": { "text": "ETH-USDT Price ($)" @@ -7578,9 +7529,9 @@ }, "text/html": [ "