diff --git a/notebook/crawl_data.ipynb b/notebook/crawl_data.ipynb new file mode 100644 index 0000000..63c328e --- /dev/null +++ b/notebook/crawl_data.ipynb @@ -0,0 +1,1602 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/root/code_Bao/stock_price_4_fun/notebook\n" + ] + } + ], + "source": [ + "import os\n", + "try:\n", + " print(file_path)\n", + "except:\n", + " file_path = os.path.abspath('')\n", + " os.chdir(os.path.dirname(file_path))\n", + " print(file_path)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import shutil\n", + "import numpy as np # linear algebra\n", + "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", + "pd.set_option('display.max_columns', None)\n", + "from src.trading_record import *" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "from selenium import webdriver\n", + "from selenium.webdriver.common.keys import Keys\n", + "from selenium.webdriver.common.by import By\n", + "from selenium.webdriver.chrome.options import Options\n", + "from selenium.webdriver.chrome.service import Service\n" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "class TradeScraper:\n", + " def __init__(self, username, password):\n", + " # How to run selenium on linux\n", + " # https://cloudbytes.dev/snippets/run-selenium-and-chrome-on-wsl2#:~:text=With%20Selenium%20libraries%2C%20Python%20can,using%20Python%20and%20Selenium%20webdriver.\n", + " self.username = username\n", + " self.password = password\n", + " chrome_options = Options()\n", + " chrome_options.add_argument(\"--headless\") # Ensure GUI is off\n", + " chrome_options.add_argument(\"--no-sandbox\")\n", + " homedir = os.path.expanduser(\"~\")\n", + " webdriver_service = Service(f\"{homedir}/chromedriver/stable/chromedriver-linux64/chromedriver\")\n", + "\n", + " # Choose Chrome Browser\n", + " self.driver = webdriver.Chrome(service=webdriver_service, options=chrome_options)\n", + "\n", + " # self.driver = webdriver.Chrome(options=options)\n", + " # self.driver = webdriver.Chrome()\n", + "\n", + " def signin(self):\n", + " # Step 1: Navigate to URL\n", + " self.driver.get(\"https://accounts.fpts.com.vn/Login?href=eztrade\")\n", + "\n", + " # Step 2: Find and fill in the username and password fields\n", + " username_input = self.driver.find_element(By.ID, 'txtAccountNo')\n", + " password_input = self.driver.find_element(By.ID, \"txtPassword\")\n", + "\n", + " username_input.send_keys(self.username)\n", + " password_input.send_keys(self.password)\n", + "\n", + " # Step 3: Submit the form\n", + " password_input.send_keys(Keys.RETURN)\n", + "\n", + " def scrape_buy_sell_log(self, start_date = \"27/10/2023\", end_date = \"27/11/2023\"):\n", + " # Step 1: Navigate to TradeLog URL\n", + " self.signin()\n", + " self.driver.get(\"https://eztrade.fpts.com.vn/report/TradeLog\")\n", + "\n", + " # Step 2: Find and fill in the start and end date fields\n", + " start_date_input = self.driver.find_element(By.ID, 'txtDateFrom')\n", + " end_date_input = self.driver.find_element(By.ID, 'txtDateTo')\n", + "\n", + " start_date_input.send_keys(start_date)\n", + " # end_date_input.send_keys(end_date)\n", + "\n", + "\n", + " # Step 3: Find the button or link to download the report\n", + " download_button = self.driver.find_element(By.ID, \"imgExcel_CA\")\n", + "\n", + " # Step 4: Click the download button\n", + " download_button.click()\n", + " download_file = 'LichSuKhopLenh_058C' + self.username + '.xls'\n", + " source_folder = os.path.expanduser(\"./\") # Assuming the default Downloads folder\n", + " destination_folder = \"data\" # Specify your destination folder\n", + " self.moveDownloadedFile(source_folder, destination_folder, download_file)\n", + " self.rename_xls_html(file_path=f'data/{download_file}')\n", + "\n", + " def moveDownloadedFile(self, source_folder, destination_folder, file_name):\n", + " source_path = os.path.join(source_folder, file_name)\n", + " shutil.move(source_path, destination_folder)\n", + "\n", + " def rename_xls_html(self, file_path =\"data/LichSuKhopLenh_058C647873.xls\"):\n", + " file_name, file_extension = os.path.splitext(file_path)\n", + " html_file_name = file_name + \".html\"\n", + " shutil.move(file_path, html_file_name)\n", + " df = pd.read_html(html_file_name)[0]\n", + " df.to_csv(file_name + '.csv', index=False)\n", + " # os.remove(html_file_name)\n", + " \n", + " def closeBrowser(self):\n", + " # Close the browser window\n", + " self.driver.quit()" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [], + "source": [ + "TRADE_USER= os.getenv('TRADE_USER')\n", + "TRADE_PASS= os.getenv('TRADE_PASS')\n", + "# Create an instance of TradeScraper\n", + "scraper = TradeScraper(TRADE_USER, TRADE_PASS)\n", + "scraper.scrape_buy_sell_log(start_date=\"20/11/2023\", end_date=\"27/11/2023\")\n", + "scraper.closeBrowser()" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [], + "source": [ + "buysell_analyzer = BuySellAnalyzer(buy_sell_df_path='data/LichSuKhopLenh_058C647873.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
timeactiontickervolpricevaluetax_from_transfertax_from_capitalplatform_feetotal_fee
832023-11-24sellHHV400.014200.05680000.05680.00.04999.010679.0
852023-11-24buyGEX300.021400.06420000.00.00.05649.05649.0
872023-11-27sellHHV200.015000.03000000.03000.00.02640.05640.0
892023-11-28buyPDR200.026000.05200000.00.00.04576.04576.0
902023-11-28buyVIX400.015800.06320000.00.00.05561.05561.0
\n", + "
" + ], + "text/plain": [ + " time action ticker vol price value tax_from_transfer \\\n", + "83 2023-11-24 sell HHV 400.0 14200.0 5680000.0 5680.0 \n", + "85 2023-11-24 buy GEX 300.0 21400.0 6420000.0 0.0 \n", + "87 2023-11-27 sell HHV 200.0 15000.0 3000000.0 3000.0 \n", + "89 2023-11-28 buy PDR 200.0 26000.0 5200000.0 0.0 \n", + "90 2023-11-28 buy VIX 400.0 15800.0 6320000.0 0.0 \n", + "\n", + " tax_from_capital platform_fee total_fee \n", + "83 0.0 4999.0 10679.0 \n", + "85 0.0 5649.0 5649.0 \n", + "87 0.0 2640.0 5640.0 \n", + "89 0.0 4576.0 4576.0 \n", + "90 0.0 5561.0 5561.0 " + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "buysell_analyzer.df.tail()" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [], + "source": [ + "symbol ='VIX'" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "close": [ + 13650, + 13850, + 13650, + 14600, + 15600, + 15750, + 15950, + 16149, + 16350, + 16800, + 16200, + 16900, + 17000, + 17200, + 16000, + 16600, + 16100, + 16250 + ], + "decreasing": { + "line": { + "color": "red" + } + }, + "high": [ + 14100, + 13900, + 14100, + 14600, + 15600, + 16450, + 16200, + 16700, + 16900, + 16800, + 17050, + 17000, + 17250, + 17300, + 17500, + 16600, + 16600, + 16300 + ], + "increasing": { + "line": { + "color": "green" + } + }, + "low": [ + 13400, + 13500, + 13500, + 13650, + 15000, + 15350, + 15250, + 16000, + 16100, + 16050, + 16000, + 15800, + 16750, + 16750, + 16000, + 15600, + 16050, + 15500 + ], + "open": [ + 13800, + 13850, + 13650, + 13750, + 15150, + 15400, + 15950, + 16400, + 16850, + 16149, + 16800, + 15800, + 17100, + 17000, + 17400, + 16300, + 16600, + 16100 + ], + "type": "candlestick", + "x": [ + "2023-11-03T00:00:00", + "2023-11-06T00:00:00", + "2023-11-07T00:00:00", + "2023-11-08T00:00:00", + "2023-11-09T00:00:00", + "2023-11-10T00:00:00", + "2023-11-13T00:00:00", + "2023-11-14T00:00:00", + "2023-11-15T00:00:00", + "2023-11-16T00:00:00", + "2023-11-17T00:00:00", + "2023-11-20T00:00:00", + "2023-11-21T00:00:00", + "2023-11-22T00:00:00", + "2023-11-23T00:00:00", + "2023-11-24T00:00:00", + "2023-11-27T00:00:00", + "2023-11-28T00:00:00" + ] + }, + { + "marker": { + "color": "black", + "size": 12, + "symbol": "triangle-up" + }, + "mode": "markers", + "name": "Buy Actions", + "text": [ + 600, + 400, + 400 + ], + "type": "scatter", + "x": [ + "2023-11-15T00:00:00", + "2023-11-17T00:00:00", + "2023-11-28T00:00:00" + ], + "y": [ + 16600, + 16300, + 15800 + ] + }, + { + "marker": { + "color": "brown", + "size": 12, + "symbol": "triangle-down" + }, + "mode": "markers", + "name": "Sell Actions", + "text": [], + "type": "scatter", + "x": [], + "y": [] + } + ], + "layout": { + "height": 800, + "paper_bgcolor": "#F6F5F5", + "plot_bgcolor": "#F6F5F5", + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "rgb(36,36,36)" + }, + "error_y": { + "color": "rgb(36,36,36)" + }, + "marker": { + "line": { + "color": "rgb(234,234,242)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(234,234,242)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "rgb(36,36,36)", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "rgb(36,36,36)" + }, + "baxis": { + "endlinecolor": "rgb(36,36,36)", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "rgb(36,36,36)" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "colorscale": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "colorscale": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "colorscale": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "colorscale": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "colorscale": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + }, + "colorscale": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "rgb(231,231,240)" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "rgb(183,183,191)" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "rgb(67,103,167)" + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "tickcolor": "rgb(36,36,36)", + "ticklen": 8, + "ticks": "outside", + "tickwidth": 2 + } + }, + "colorscale": { + "sequential": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ], + "sequentialminus": [ + [ + 0, + "rgb(2,4,25)" + ], + [ + 0.06274509803921569, + "rgb(24,15,41)" + ], + [ + 0.12549019607843137, + "rgb(47,23,57)" + ], + [ + 0.18823529411764706, + "rgb(71,28,72)" + ], + [ + 0.25098039215686274, + "rgb(97,30,82)" + ], + [ + 0.3137254901960784, + "rgb(123,30,89)" + ], + [ + 0.3764705882352941, + "rgb(150,27,91)" + ], + [ + 0.4392156862745098, + "rgb(177,22,88)" + ], + [ + 0.5019607843137255, + "rgb(203,26,79)" + ], + [ + 0.5647058823529412, + "rgb(223,47,67)" + ], + [ + 0.6274509803921569, + "rgb(236,76,61)" + ], + [ + 0.6901960784313725, + "rgb(242,107,73)" + ], + [ + 0.7529411764705882, + "rgb(244,135,95)" + ], + [ + 0.8156862745098039, + "rgb(245,162,122)" + ], + [ + 0.8784313725490196, + "rgb(246,188,153)" + ], + [ + 0.9411764705882353, + "rgb(247,212,187)" + ], + [ + 1, + "rgb(250,234,220)" + ] + ] + }, + "colorway": [ + "rgb(76,114,176)", + "rgb(221,132,82)", + "rgb(85,168,104)", + "rgb(196,78,82)", + "rgb(129,114,179)", + "rgb(147,120,96)", + "rgb(218,139,195)", + "rgb(140,140,140)", + "rgb(204,185,116)", + "rgb(100,181,205)" + ], + "font": { + "color": "rgb(36,36,36)" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "rgb(234,234,242)", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "paper_bgcolor": "white", + "plot_bgcolor": "rgb(234,234,242)", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "showgrid": true, + "ticks": "" + }, + "bgcolor": "rgb(234,234,242)", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "showgrid": true, + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(234,234,242)", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "showgrid": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "rgb(234,234,242)", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "showgrid": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "rgb(234,234,242)", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "showgrid": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "fillcolor": "rgb(67,103,167)", + "line": { + "width": 0 + }, + "opacity": 0.5 + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "showgrid": true, + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "showgrid": true, + "ticks": "" + }, + "bgcolor": "rgb(234,234,242)", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "showgrid": true, + "ticks": "" + } + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "showgrid": true, + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white" + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "showgrid": true, + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white" + } + } + }, + "title": { + "text": "Candlestick Chart with Buy and Sell Actions" + }, + "width": 1000, + "xaxis": { + "title": { + "text": "Date" + } + }, + "yaxis": { + "title": { + "text": "Price" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "buysell_analyzer.plot_buy_sell_of_stock(symbol)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/notebook/trading_record.ipynb b/notebook/trading_record.ipynb index 341bb75..7491678 100644 --- a/notebook/trading_record.ipynb +++ b/notebook/trading_record.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"code","execution_count":1,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["/root/code_Bao/stock_price_4_fun/notebook\n"]}],"source":["import os\n","try:\n"," print(file_path)\n","except:\n"," file_path = os.path.abspath('')\n"," os.chdir(os.path.dirname(file_path))\n"," print(file_path)"]},{"cell_type":"code","execution_count":2,"metadata":{"execution":{"iopub.execute_input":"2023-11-04T09:03:08.955921Z","iopub.status.busy":"2023-11-04T09:03:08.954978Z","iopub.status.idle":"2023-11-04T09:03:11.674906Z","shell.execute_reply":"2023-11-04T09:03:11.674030Z","shell.execute_reply.started":"2023-11-04T09:03:08.955887Z"},"trusted":true},"outputs":[],"source":["import numpy as np # linear algebra\n","import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n","pd.set_option('display.max_columns', None)\n","from src.trading_record import *\n","from src.stock_class import Stock\n","import plotly.graph_objects as go\n","import plotly.express as px\n","import os\n","from vnstock import * #import all functions, including functions that provide OHLC data for charting\n","# from vnstock.chart import * # import chart functions"]},{"cell_type":"code","execution_count":3,"metadata":{},"outputs":[],"source":["winloss_analyzer = WinLossAnalyzer(win_loss_df_path='data/BaoCaoLaiLo_058C647873.csv')"]},{"cell_type":"code","execution_count":4,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["Strategy Analysis Report:\n","--------------------------------------------------\n","Win Ratio: 62.57\n","Payoff Ratio: 1.39\n","Largest Winning Trade: 2057498.00\n","Largest Losing Trade: -1906250.00\n","Largest Winning Trade percent: 2487.00\n","Largest Losing Trade percent: -1694.00\n","Average Winning Trade: 330680.57\n","Average Losing Trade: -237881.21\n","Largest % Drawdown: -57.66\n","Average % Drawdown: -17.98\n","Total Days: 180\n","total_sell_value: 2076951650.00\n","total_capital: 2047500200.00\n","delta_sell_capital: 29451450.00\n","delta_sell_capital_percent: 1.44\n","Average Trading Frequency per Month: 37.43\n","Top Best Stock: [('VIX', 13405075.0)]\n","Top Worst Stock: [('ORS', -3005000.0)]\n"]}],"source":["winloss_analyzer.get_report()"]},{"cell_type":"code","execution_count":5,"metadata":{},"outputs":[{"data":{"text/html":[" \n"," "]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.plotly.v1+json":{"config":{"plotlyServerURL":"https://plot.ly"},"data":[{"hovertemplate":"Date=%{x}
win_loss_value=%{y}","legendgroup":"","line":{"color":"#636efa","dash":"solid","shape":"linear"},"marker":{"symbol":"circle"},"mode":"lines","name":"","orientation":"v","showlegend":false,"type":"scatter","x":["2023-05-24T00:00:00","2023-05-25T00:00:00","2023-05-26T00:00:00","2023-05-29T00:00:00","2023-05-30T00:00:00","2023-05-31T00:00:00","2023-06-01T00:00:00","2023-06-02T00:00:00","2023-06-05T00:00:00","2023-06-06T00:00:00","2023-06-07T00:00:00","2023-06-08T00:00:00","2023-06-09T00:00:00","2023-06-12T00:00:00","2023-06-16T00:00:00","2023-06-19T00:00:00","2023-06-20T00:00:00","2023-06-21T00:00:00","2023-06-22T00:00:00","2023-06-23T00:00:00","2023-06-26T00:00:00","2023-06-27T00:00:00","2023-06-28T00:00:00","2023-06-29T00:00:00","2023-06-30T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-10T00:00:00","2023-07-11T00:00:00","2023-07-12T00:00:00","2023-07-13T00:00:00","2023-07-14T00:00:00","2023-07-24T00:00:00","2023-07-27T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-08-01T00:00:00","2023-08-02T00:00:00","2023-08-03T00:00:00","2023-08-04T00:00:00","2023-08-11T00:00:00","2023-08-16T00:00:00","2023-08-17T00:00:00","2023-08-18T00:00:00","2023-08-21T00:00:00","2023-08-28T00:00:00","2023-08-29T00:00:00","2023-08-30T00:00:00","2023-08-31T00:00:00","2023-09-06T00:00:00","2023-09-08T00:00:00","2023-09-11T00:00:00","2023-09-12T00:00:00","2023-09-25T00:00:00","2023-09-27T00:00:00","2023-10-13T00:00:00","2023-10-16T00:00:00","2023-10-18T00:00:00","2023-11-08T00:00:00","2023-11-10T00:00:00","2023-11-13T00:00:00","2023-11-14T00:00:00","2023-11-20T00:00:00"],"xaxis":"x","y":[-7096,-121003,-562500,-15402,140029,198462,303917,-978360,1672551,-128000,253894,3887108,-757850,-139412,60000,-354000,-324000,186333,335000,122222,988116,229286,198611,-212500,287807,735701,473000,2371471,1871531,596044,708000,1852020,1208510,820667,90000,60000,2174643,706887,466376,1450307,448039,1963040,-956071,1628948,3204152,-635000,-2402028,325000,691334,829334,2706866,691111,1833535,4158641,349181,-4963036,-2651964,-245000,440000,-1765000,840000,1098846,1865153,116000,-968000],"yaxis":"y"}],"layout":{"height":800,"legend":{"tracegroupgap":0},"showlegend":true,"template":{"data":{"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"sequentialminus":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","radialaxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","caxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}},"title":{"text":"Daily Aggregated win_loss_value"},"width":1000,"xaxis":{"anchor":"y","domain":[0,1],"title":{"text":"Date"}},"yaxis":{"anchor":"x","domain":[0,1],"title":{"text":"Value"}}}},"text/html":["
"]},"metadata":{},"output_type":"display_data"}],"source":["winloss_analyzer.plot_return(col='win_loss_value', figsize=(1000,800))"]},{"cell_type":"code","execution_count":6,"metadata":{},"outputs":[],"source":["buysell_analyzer = BuySellAnalyzer(buy_sell_df_path='data/LichSuKhopLenh.csv')"]},{"cell_type":"code","execution_count":7,"metadata":{},"outputs":[{"data":{"text/plain":["7232809.0"]},"execution_count":7,"metadata":{},"output_type":"execute_result"}],"source":["buysell_analyzer.sum_total_fee()"]},{"cell_type":"code","execution_count":8,"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"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
timeactiontickervolpricevaluetax_from_transfertax_from_capitalplatform_feetotal_fee
02023-05-26sellDIG100.020400.02040000.02040.00.02652.04692.0
12023-05-26sellFCN200.014700.02940000.02940.00.03822.06762.0
22023-05-26sellOCB1100.016700.018370000.018370.00.023882.042252.0
52023-05-26sellVIB500.020900.010450000.010450.00.013586.024036.0
72023-05-26buyBMP200.078250.015650000.00.00.020345.020345.0
.................................
7112023-11-17buyVIX400.016300.06520000.00.00.05737.05737.0
7132023-11-20sellSHS1000.017200.017200000.017200.00.015136.032336.0
7172023-11-20buyCTR100.084900.08490000.00.00.07471.07471.0
7182023-11-20buyGEX300.021600.06480000.00.00.05703.05703.0
7192023-11-20buyHHV600.015250.09150000.00.00.08053.08053.0
\n","

367 rows × 10 columns

\n","
"],"text/plain":[" time action ticker vol price value tax_from_transfer \\\n","0 2023-05-26 sell DIG 100.0 20400.0 2040000.0 2040.0 \n","1 2023-05-26 sell FCN 200.0 14700.0 2940000.0 2940.0 \n","2 2023-05-26 sell OCB 1100.0 16700.0 18370000.0 18370.0 \n","5 2023-05-26 sell VIB 500.0 20900.0 10450000.0 10450.0 \n","7 2023-05-26 buy BMP 200.0 78250.0 15650000.0 0.0 \n",".. ... ... ... ... ... ... ... \n","711 2023-11-17 buy VIX 400.0 16300.0 6520000.0 0.0 \n","713 2023-11-20 sell SHS 1000.0 17200.0 17200000.0 17200.0 \n","717 2023-11-20 buy CTR 100.0 84900.0 8490000.0 0.0 \n","718 2023-11-20 buy GEX 300.0 21600.0 6480000.0 0.0 \n","719 2023-11-20 buy HHV 600.0 15250.0 9150000.0 0.0 \n","\n"," tax_from_capital platform_fee total_fee \n","0 0.0 2652.0 4692.0 \n","1 0.0 3822.0 6762.0 \n","2 0.0 23882.0 42252.0 \n","5 0.0 13586.0 24036.0 \n","7 0.0 20345.0 20345.0 \n",".. ... ... ... \n","711 0.0 5737.0 5737.0 \n","713 0.0 15136.0 32336.0 \n","717 0.0 7471.0 7471.0 \n","718 0.0 5703.0 5703.0 \n","719 0.0 8053.0 8053.0 \n","\n","[367 rows x 10 columns]"]},"execution_count":8,"metadata":{},"output_type":"execute_result"}],"source":["buysell_analyzer.df"]},{"cell_type":"code","execution_count":9,"metadata":{},"outputs":[],"source":["symbol = 'FRT'"]},{"cell_type":"code","execution_count":10,"metadata":{},"outputs":[{"data":{"text/plain":["61"]},"execution_count":10,"metadata":{},"output_type":"execute_result"}],"source":["buysell_analyzer.trading_frequency()"]},{"cell_type":"code","execution_count":11,"metadata":{},"outputs":[{"data":{"application/vnd.plotly.v1+json":{"config":{"plotlyServerURL":"https://plot.ly"},"data":[{"close":[54370,54540,56000,54970,56000,56950,56610,57300,57500,57200,58100,62100,61900,61700,62500,62000,62800,64200,66700,66500,67800,69000,68600,68000,68000,67000,71600,71200,71200,72800,72800,75000,75000,74500,74500,75200,75500,76800,76000,76400,77200,79300,78000,77000,76500,77200,77000,76700,76500,78000,78300,78300,76400,76400,76200,76400,79000,79000,81000,79100,77500,74000,75000,74200,74300,73200,71600,68200,72700,74800,74000,77000,77000,80800,81000,81000,83300,83500,82600,84800,84200,86000,85000,86500,84400,84400,86000,86500,87000,89200,88500,89000,86500,83900,85000,85200,89000,90000,89000,95200,94400,97500,96000,95100,96000,96000,97400,97000,94500,95000,94000,94700,92900,93900,95000,92900,92800,86400,87000,88000,92800,96000,97000,96000,100000,104500,103300,103300,104000,104900,103500,102900,101500],"decreasing":{"line":{"color":"red"}},"high":[54800,54970,56350,56260,56000,57390,58250,58600,57900,57900,58100,62100,63100,62400,63200,64000,63500,64300,67200,66900,68200,69100,69900,69000,69000,68100,71600,73400,73400,73400,73400,77000,77000,76300,76300,76500,76500,77000,77500,78100,77600,81300,80000,79200,78400,78400,77900,79400,77600,78300,79700,79700,77000,77000,78000,77000,80700,80200,82500,81500,79100,78500,75000,75500,75000,74600,73100,71500,72900,74800,74800,77400,77600,82000,81500,81500,84500,83800,83700,86000,85100,86000,87000,86500,89000,85300,87100,86500,87100,92000,90200,89500,89300,86500,85000,86500,90500,90900,91000,95200,96000,99000,97400,96500,97000,98400,97400,99300,98500,96000,94700,95000,94200,94100,97000,92900,93000,92500,87900,88000,93000,96200,97000,98000,101000,104800,106900,105500,104600,105000,104400,103500,102900],"increasing":{"line":{"color":"green"}},"low":[53930,54370,54620,54970,54970,55660,56610,57000,56700,57100,56600,58200,61700,61000,61400,61800,61800,62400,64200,66000,66000,66000,68500,67800,67800,67000,67100,70200,70200,71000,71000,73000,73000,74500,74500,74200,74600,75200,75500,76000,76200,77300,77700,76900,76500,75800,75800,76000,76100,76300,78300,78300,75000,75000,75700,75600,76100,78600,78700,79100,77500,74000,73000,73900,74000,73100,71600,68000,68000,70000,73000,73500,76100,77100,79100,79100,80800,82400,82000,82500,84000,83600,85000,84600,82900,83700,84600,85000,84100,87000,88000,83900,84100,83500,80700,83900,85700,88800,86100,87000,94200,93200,95300,94000,95100,95000,95000,96000,94500,89000,92000,89000,91000,92500,92900,89000,90000,86400,84600,84400,88100,90200,95000,95600,95600,99300,102700,102000,103000,102700,101000,99000,100000],"open":[54370,54970,54620,56000,55230,56090,58250,57300,57700,57500,57400,58300,62700,62200,61400,63000,62300,62400,64200,66600,66000,67500,69500,68500,68500,68000,67100,72500,72500,71300,71300,73800,73800,75000,75000,74200,74900,75600,77500,76200,76200,77400,79100,78000,76600,76100,77200,77000,77000,77000,78800,78800,76000,76000,76500,75600,76100,78600,79100,81500,78700,78400,73000,74500,74000,74500,73100,71300,68000,72600,74800,74000,76500,77100,80500,80500,81000,83000,83000,83000,84000,84000,86200,84900,86500,84400,85000,85000,86500,87300,88800,86000,88000,83500,84000,85000,86100,89000,88000,87000,95000,95000,95600,96000,95100,97500,95500,97400,97000,95100,94000,92000,94200,93000,94000,92800,91000,92500,84600,87000,90500,92400,95100,97000,95600,100200,103200,103300,104500,105000,104000,102100,100000],"type":"candlestick","x":["2023-05-26T00:00:00","2023-05-29T00:00:00","2023-05-30T00:00:00","2023-05-31T00:00:00","2023-06-01T00:00:00","2023-06-02T00:00:00","2023-06-05T00:00:00","2023-06-06T00:00:00","2023-06-07T00:00:00","2023-06-08T00:00:00","2023-06-09T00:00:00","2023-06-12T00:00:00","2023-06-13T00:00:00","2023-06-14T00:00:00","2023-06-15T00:00:00","2023-06-16T00:00:00","2023-06-19T00:00:00","2023-06-20T00:00:00","2023-06-21T00:00:00","2023-06-22T00:00:00","2023-06-23T00:00:00","2023-06-26T00:00:00","2023-06-27T00:00:00","2023-06-28T00:00:00","2023-06-28T00:00:00","2023-06-29T00:00:00","2023-06-30T00:00:00","2023-07-03T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-06T00:00:00","2023-07-07T00:00:00","2023-07-10T00:00:00","2023-07-11T00:00:00","2023-07-12T00:00:00","2023-07-13T00:00:00","2023-07-14T00:00:00","2023-07-17T00:00:00","2023-07-18T00:00:00","2023-07-19T00:00:00","2023-07-20T00:00:00","2023-07-21T00:00:00","2023-07-24T00:00:00","2023-07-25T00:00:00","2023-07-26T00:00:00","2023-07-27T00:00:00","2023-07-28T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-07-31T00:00:00","2023-08-01T00:00:00","2023-08-02T00:00:00","2023-08-03T00:00:00","2023-08-04T00:00:00","2023-08-07T00:00:00","2023-08-08T00:00:00","2023-08-09T00:00:00","2023-08-10T00:00:00","2023-08-11T00:00:00","2023-08-14T00:00:00","2023-08-15T00:00:00","2023-08-16T00:00:00","2023-08-17T00:00:00","2023-08-18T00:00:00","2023-08-21T00:00:00","2023-08-22T00:00:00","2023-08-23T00:00:00","2023-08-24T00:00:00","2023-08-25T00:00:00","2023-08-28T00:00:00","2023-08-29T00:00:00","2023-08-29T00:00:00","2023-08-30T00:00:00","2023-08-31T00:00:00","2023-09-05T00:00:00","2023-09-06T00:00:00","2023-09-07T00:00:00","2023-09-08T00:00:00","2023-09-11T00:00:00","2023-09-12T00:00:00","2023-09-13T00:00:00","2023-09-14T00:00:00","2023-09-15T00:00:00","2023-09-18T00:00:00","2023-09-19T00:00:00","2023-09-20T00:00:00","2023-09-21T00:00:00","2023-09-22T00:00:00","2023-09-25T00:00:00","2023-09-26T00:00:00","2023-09-27T00:00:00","2023-09-28T00:00:00","2023-09-29T00:00:00","2023-10-02T00:00:00","2023-10-03T00:00:00","2023-10-04T00:00:00","2023-10-05T00:00:00","2023-10-06T00:00:00","2023-10-09T00:00:00","2023-10-10T00:00:00","2023-10-11T00:00:00","2023-10-12T00:00:00","2023-10-13T00:00:00","2023-10-16T00:00:00","2023-10-17T00:00:00","2023-10-18T00:00:00","2023-10-19T00:00:00","2023-10-20T00:00:00","2023-10-23T00:00:00","2023-10-24T00:00:00","2023-10-25T00:00:00","2023-10-26T00:00:00","2023-10-27T00:00:00","2023-10-30T00:00:00","2023-10-31T00:00:00","2023-11-01T00:00:00","2023-11-02T00:00:00","2023-11-03T00:00:00","2023-11-06T00:00:00","2023-11-07T00:00:00","2023-11-08T00:00:00","2023-11-09T00:00:00","2023-11-10T00:00:00","2023-11-13T00:00:00","2023-11-14T00:00:00","2023-11-15T00:00:00","2023-11-16T00:00:00","2023-11-17T00:00:00","2023-11-20T00:00:00"]},{"marker":{"color":"black","size":12,"symbol":"triangle-up"},"mode":"markers","name":"Buy Actions","text":[300,100,100,200,100,400,300,300,200,100,100,200,100,200,100,200,100,300],"type":"scatter","x":["2023-06-13T00:00:00","2023-06-22T00:00:00","2023-06-27T00:00:00","2023-06-28T00:00:00","2023-06-29T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-10T00:00:00","2023-07-19T00:00:00","2023-07-21T00:00:00","2023-07-24T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-08-24T00:00:00","2023-08-25T00:00:00","2023-08-29T00:00:00"],"y":[62067,66600,68700,68050,67800,70925,72567,75433,75800,74900,77700,76900,76400,79400,75400,77300,76800,79767]},{"marker":{"color":"brown","size":12,"symbol":"triangle-down"},"mode":"markers","name":"Sell Actions","text":[100,100,100,100,100,200,300,500,400,200,200,100,100,200,100,100,100,100,300],"type":"scatter","x":["2023-06-21T00:00:00","2023-06-23T00:00:00","2023-06-28T00:00:00","2023-06-30T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-12T00:00:00","2023-07-13T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-08-01T00:00:00","2023-08-02T00:00:00","2023-08-03T00:00:00","2023-08-28T00:00:00","2023-08-29T00:00:00","2023-08-30T00:00:00","2023-08-31T00:00:00"],"y":[65300,66000,68000,71600,71700,73100,75633,75200,76150,76800,79600,76200,77900,76000,76600,78600,80800,81600,82467]}],"layout":{"height":800,"paper_bgcolor":"#F6F5F5","plot_bgcolor":"#F6F5F5","template":{"data":{"bar":[{"error_x":{"color":"rgb(36,36,36)"},"error_y":{"color":"rgb(36,36,36)"},"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"baxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(231,231,240)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(183,183,191)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"rgb(67,103,167)"},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"colorscale":{"sequential":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"sequentialminus":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]]},"colorway":["rgb(76,114,176)","rgb(221,132,82)","rgb(85,168,104)","rgb(196,78,82)","rgb(129,114,179)","rgb(147,120,96)","rgb(218,139,195)","rgb(140,140,140)","rgb(204,185,116)","rgb(100,181,205)"],"font":{"color":"rgb(36,36,36)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"rgb(234,234,242)","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","paper_bgcolor":"white","plot_bgcolor":"rgb(234,234,242)","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","radialaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"scene":{"xaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"fillcolor":"rgb(67,103,167)","line":{"width":0},"opacity":0.5},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","caxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"}}},"title":{"text":"Candlestick Chart with Buy and Sell Actions"},"width":1000,"xaxis":{"title":{"text":"Date"}},"yaxis":{"title":{"text":"Price"}}}},"text/html":["
"]},"metadata":{},"output_type":"display_data"}],"source":["buysell_analyzer.plot_buy_sell_of_stock(symbol=symbol)"]}],"metadata":{"kernelspec":{"display_name":"Python 3","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.6"}},"nbformat":4,"nbformat_minor":4} +{"cells":[{"cell_type":"code","execution_count":1,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["/root/code_Bao/stock_price_4_fun/notebook\n"]}],"source":["import os\n","try:\n"," print(file_path)\n","except:\n"," file_path = os.path.abspath('')\n"," os.chdir(os.path.dirname(file_path))\n"," print(file_path)"]},{"cell_type":"code","execution_count":2,"metadata":{"execution":{"iopub.execute_input":"2023-11-04T09:03:08.955921Z","iopub.status.busy":"2023-11-04T09:03:08.954978Z","iopub.status.idle":"2023-11-04T09:03:11.674906Z","shell.execute_reply":"2023-11-04T09:03:11.674030Z","shell.execute_reply.started":"2023-11-04T09:03:08.955887Z"},"trusted":true},"outputs":[],"source":["import numpy as np # linear algebra\n","import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n","pd.set_option('display.max_columns', None)\n","from src.trading_record import *\n","from src.stock_class import Stock\n","import plotly.graph_objects as go\n","import plotly.express as px\n","import os\n","from vnstock import * #import all functions, including functions that provide OHLC data for charting\n","# from vnstock.chart import * # import chart functions"]},{"cell_type":"code","execution_count":3,"metadata":{},"outputs":[],"source":["winloss_analyzer = WinLossAnalyzer(win_loss_df_path='data/BaoCaoLaiLo_058C647873.csv')"]},{"cell_type":"code","execution_count":4,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["Strategy Analysis Report:\n","--------------------------------------------------\n","Win Ratio: 62.57\n","Payoff Ratio: 1.39\n","Largest Winning Trade: 2057498.00\n","Largest Losing Trade: -1906250.00\n","Largest Winning Trade percent: 2487.00\n","Largest Losing Trade percent: -1694.00\n","Average Winning Trade: 330680.57\n","Average Losing Trade: -237881.21\n","Largest % Drawdown: -57.66\n","Average % Drawdown: -17.98\n","Total Days: 180\n","total_sell_value: 2076951650.00\n","total_capital: 2047500200.00\n","delta_sell_capital: 29451450.00\n","delta_sell_capital_percent: 1.44\n","Average Trading Frequency per Month: 37.43\n","Top Best Stock: [('VIX', 13405075.0)]\n","Top Worst Stock: [('ORS', -3005000.0)]\n"]}],"source":["winloss_analyzer.get_report()"]},{"cell_type":"code","execution_count":5,"metadata":{},"outputs":[{"data":{"text/html":[" \n"," "]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.plotly.v1+json":{"config":{"plotlyServerURL":"https://plot.ly"},"data":[{"hovertemplate":"Date=%{x}
win_loss_value=%{y}","legendgroup":"","line":{"color":"#636efa","dash":"solid","shape":"linear"},"marker":{"symbol":"circle"},"mode":"lines","name":"","orientation":"v","showlegend":false,"type":"scatter","x":["2023-05-24T00:00:00","2023-05-25T00:00:00","2023-05-26T00:00:00","2023-05-29T00:00:00","2023-05-30T00:00:00","2023-05-31T00:00:00","2023-06-01T00:00:00","2023-06-02T00:00:00","2023-06-05T00:00:00","2023-06-06T00:00:00","2023-06-07T00:00:00","2023-06-08T00:00:00","2023-06-09T00:00:00","2023-06-12T00:00:00","2023-06-16T00:00:00","2023-06-19T00:00:00","2023-06-20T00:00:00","2023-06-21T00:00:00","2023-06-22T00:00:00","2023-06-23T00:00:00","2023-06-26T00:00:00","2023-06-27T00:00:00","2023-06-28T00:00:00","2023-06-29T00:00:00","2023-06-30T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-10T00:00:00","2023-07-11T00:00:00","2023-07-12T00:00:00","2023-07-13T00:00:00","2023-07-14T00:00:00","2023-07-24T00:00:00","2023-07-27T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-08-01T00:00:00","2023-08-02T00:00:00","2023-08-03T00:00:00","2023-08-04T00:00:00","2023-08-11T00:00:00","2023-08-16T00:00:00","2023-08-17T00:00:00","2023-08-18T00:00:00","2023-08-21T00:00:00","2023-08-28T00:00:00","2023-08-29T00:00:00","2023-08-30T00:00:00","2023-08-31T00:00:00","2023-09-06T00:00:00","2023-09-08T00:00:00","2023-09-11T00:00:00","2023-09-12T00:00:00","2023-09-25T00:00:00","2023-09-27T00:00:00","2023-10-13T00:00:00","2023-10-16T00:00:00","2023-10-18T00:00:00","2023-11-08T00:00:00","2023-11-10T00:00:00","2023-11-13T00:00:00","2023-11-14T00:00:00","2023-11-20T00:00:00"],"xaxis":"x","y":[-7096,-121003,-562500,-15402,140029,198462,303917,-978360,1672551,-128000,253894,3887108,-757850,-139412,60000,-354000,-324000,186333,335000,122222,988116,229286,198611,-212500,287807,735701,473000,2371471,1871531,596044,708000,1852020,1208510,820667,90000,60000,2174643,706887,466376,1450307,448039,1963040,-956071,1628948,3204152,-635000,-2402028,325000,691334,829334,2706866,691111,1833535,4158641,349181,-4963036,-2651964,-245000,440000,-1765000,840000,1098846,1865153,116000,-968000],"yaxis":"y"}],"layout":{"height":800,"legend":{"tracegroupgap":0},"showlegend":true,"template":{"data":{"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"sequentialminus":[[0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","radialaxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","caxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}},"title":{"text":"Daily Aggregated win_loss_value"},"width":1000,"xaxis":{"anchor":"y","domain":[0,1],"title":{"text":"Date"}},"yaxis":{"anchor":"x","domain":[0,1],"title":{"text":"Value"}}}},"text/html":["
"]},"metadata":{},"output_type":"display_data"}],"source":["winloss_analyzer.plot_return(col='win_loss_value', figsize=(1000,800))"]},{"cell_type":"code","execution_count":6,"metadata":{},"outputs":[],"source":["buysell_analyzer = BuySellAnalyzer(buy_sell_df_path='data/LichSuKhopLenh.csv')"]},{"cell_type":"code","execution_count":7,"metadata":{},"outputs":[{"data":{"text/plain":["7232809.0"]},"execution_count":7,"metadata":{},"output_type":"execute_result"}],"source":["buysell_analyzer.sum_total_fee()"]},{"cell_type":"code","execution_count":8,"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"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
timeactiontickervolpricevaluetax_from_transfertax_from_capitalplatform_feetotal_fee
02023-05-26sellDIG100.020400.02040000.02040.00.02652.04692.0
12023-05-26sellFCN200.014700.02940000.02940.00.03822.06762.0
22023-05-26sellOCB1100.016700.018370000.018370.00.023882.042252.0
52023-05-26sellVIB500.020900.010450000.010450.00.013586.024036.0
72023-05-26buyBMP200.078250.015650000.00.00.020345.020345.0
.................................
7112023-11-17buyVIX400.016300.06520000.00.00.05737.05737.0
7132023-11-20sellSHS1000.017200.017200000.017200.00.015136.032336.0
7172023-11-20buyCTR100.084900.08490000.00.00.07471.07471.0
7182023-11-20buyGEX300.021600.06480000.00.00.05703.05703.0
7192023-11-20buyHHV600.015250.09150000.00.00.08053.08053.0
\n","

367 rows × 10 columns

\n","
"],"text/plain":[" time action ticker vol price value tax_from_transfer \\\n","0 2023-05-26 sell DIG 100.0 20400.0 2040000.0 2040.0 \n","1 2023-05-26 sell FCN 200.0 14700.0 2940000.0 2940.0 \n","2 2023-05-26 sell OCB 1100.0 16700.0 18370000.0 18370.0 \n","5 2023-05-26 sell VIB 500.0 20900.0 10450000.0 10450.0 \n","7 2023-05-26 buy BMP 200.0 78250.0 15650000.0 0.0 \n",".. ... ... ... ... ... ... ... \n","711 2023-11-17 buy VIX 400.0 16300.0 6520000.0 0.0 \n","713 2023-11-20 sell SHS 1000.0 17200.0 17200000.0 17200.0 \n","717 2023-11-20 buy CTR 100.0 84900.0 8490000.0 0.0 \n","718 2023-11-20 buy GEX 300.0 21600.0 6480000.0 0.0 \n","719 2023-11-20 buy HHV 600.0 15250.0 9150000.0 0.0 \n","\n"," tax_from_capital platform_fee total_fee \n","0 0.0 2652.0 4692.0 \n","1 0.0 3822.0 6762.0 \n","2 0.0 23882.0 42252.0 \n","5 0.0 13586.0 24036.0 \n","7 0.0 20345.0 20345.0 \n",".. ... ... ... \n","711 0.0 5737.0 5737.0 \n","713 0.0 15136.0 32336.0 \n","717 0.0 7471.0 7471.0 \n","718 0.0 5703.0 5703.0 \n","719 0.0 8053.0 8053.0 \n","\n","[367 rows x 10 columns]"]},"execution_count":8,"metadata":{},"output_type":"execute_result"}],"source":["buysell_analyzer.df"]},{"cell_type":"code","execution_count":9,"metadata":{},"outputs":[],"source":["symbol = 'FRT'"]},{"cell_type":"code","execution_count":10,"metadata":{},"outputs":[{"data":{"text/plain":["61"]},"execution_count":10,"metadata":{},"output_type":"execute_result"}],"source":["buysell_analyzer.trading_frequency()"]},{"cell_type":"code","execution_count":11,"metadata":{},"outputs":[{"data":{"application/vnd.plotly.v1+json":{"config":{"plotlyServerURL":"https://plot.ly"},"data":[{"close":[54370,54540,56000,54970,56000,56950,56610,57300,57500,57200,58100,62100,61900,61700,62500,62000,62800,64200,66700,66500,67800,69000,68600,68000,68000,67000,71600,71200,71200,72800,72800,75000,75000,74500,74500,75200,75500,76800,76000,76400,77200,79300,78000,77000,76500,77200,77000,76700,76500,78000,78300,78300,76400,76400,76200,76400,79000,79000,81000,79100,77500,74000,75000,74200,74300,73200,71600,68200,72700,74800,74000,77000,77000,80800,81000,81000,83300,83500,82600,84800,84200,86000,85000,86500,84400,84400,86000,86500,87000,89200,88500,89000,86500,83900,85000,85200,89000,90000,89000,95200,94400,97500,96000,95100,96000,96000,97400,97000,94500,95000,94000,94700,92900,93900,95000,92900,92800,86400,87000,88000,92800,96000,97000,96000,100000,104500,103300,103300,104000,104900,103500,102900,101500],"decreasing":{"line":{"color":"red"}},"high":[54800,54970,56350,56260,56000,57390,58250,58600,57900,57900,58100,62100,63100,62400,63200,64000,63500,64300,67200,66900,68200,69100,69900,69000,69000,68100,71600,73400,73400,73400,73400,77000,77000,76300,76300,76500,76500,77000,77500,78100,77600,81300,80000,79200,78400,78400,77900,79400,77600,78300,79700,79700,77000,77000,78000,77000,80700,80200,82500,81500,79100,78500,75000,75500,75000,74600,73100,71500,72900,74800,74800,77400,77600,82000,81500,81500,84500,83800,83700,86000,85100,86000,87000,86500,89000,85300,87100,86500,87100,92000,90200,89500,89300,86500,85000,86500,90500,90900,91000,95200,96000,99000,97400,96500,97000,98400,97400,99300,98500,96000,94700,95000,94200,94100,97000,92900,93000,92500,87900,88000,93000,96200,97000,98000,101000,104800,106900,105500,104600,105000,104400,103500,102900],"increasing":{"line":{"color":"green"}},"low":[53930,54370,54620,54970,54970,55660,56610,57000,56700,57100,56600,58200,61700,61000,61400,61800,61800,62400,64200,66000,66000,66000,68500,67800,67800,67000,67100,70200,70200,71000,71000,73000,73000,74500,74500,74200,74600,75200,75500,76000,76200,77300,77700,76900,76500,75800,75800,76000,76100,76300,78300,78300,75000,75000,75700,75600,76100,78600,78700,79100,77500,74000,73000,73900,74000,73100,71600,68000,68000,70000,73000,73500,76100,77100,79100,79100,80800,82400,82000,82500,84000,83600,85000,84600,82900,83700,84600,85000,84100,87000,88000,83900,84100,83500,80700,83900,85700,88800,86100,87000,94200,93200,95300,94000,95100,95000,95000,96000,94500,89000,92000,89000,91000,92500,92900,89000,90000,86400,84600,84400,88100,90200,95000,95600,95600,99300,102700,102000,103000,102700,101000,99000,100000],"open":[54370,54970,54620,56000,55230,56090,58250,57300,57700,57500,57400,58300,62700,62200,61400,63000,62300,62400,64200,66600,66000,67500,69500,68500,68500,68000,67100,72500,72500,71300,71300,73800,73800,75000,75000,74200,74900,75600,77500,76200,76200,77400,79100,78000,76600,76100,77200,77000,77000,77000,78800,78800,76000,76000,76500,75600,76100,78600,79100,81500,78700,78400,73000,74500,74000,74500,73100,71300,68000,72600,74800,74000,76500,77100,80500,80500,81000,83000,83000,83000,84000,84000,86200,84900,86500,84400,85000,85000,86500,87300,88800,86000,88000,83500,84000,85000,86100,89000,88000,87000,95000,95000,95600,96000,95100,97500,95500,97400,97000,95100,94000,92000,94200,93000,94000,92800,91000,92500,84600,87000,90500,92400,95100,97000,95600,100200,103200,103300,104500,105000,104000,102100,100000],"type":"candlestick","x":["2023-05-26T00:00:00","2023-05-29T00:00:00","2023-05-30T00:00:00","2023-05-31T00:00:00","2023-06-01T00:00:00","2023-06-02T00:00:00","2023-06-05T00:00:00","2023-06-06T00:00:00","2023-06-07T00:00:00","2023-06-08T00:00:00","2023-06-09T00:00:00","2023-06-12T00:00:00","2023-06-13T00:00:00","2023-06-14T00:00:00","2023-06-15T00:00:00","2023-06-16T00:00:00","2023-06-19T00:00:00","2023-06-20T00:00:00","2023-06-21T00:00:00","2023-06-22T00:00:00","2023-06-23T00:00:00","2023-06-26T00:00:00","2023-06-27T00:00:00","2023-06-28T00:00:00","2023-06-28T00:00:00","2023-06-29T00:00:00","2023-06-30T00:00:00","2023-07-03T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-06T00:00:00","2023-07-07T00:00:00","2023-07-10T00:00:00","2023-07-11T00:00:00","2023-07-12T00:00:00","2023-07-13T00:00:00","2023-07-14T00:00:00","2023-07-17T00:00:00","2023-07-18T00:00:00","2023-07-19T00:00:00","2023-07-20T00:00:00","2023-07-21T00:00:00","2023-07-24T00:00:00","2023-07-25T00:00:00","2023-07-26T00:00:00","2023-07-27T00:00:00","2023-07-28T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-07-31T00:00:00","2023-08-01T00:00:00","2023-08-02T00:00:00","2023-08-03T00:00:00","2023-08-04T00:00:00","2023-08-07T00:00:00","2023-08-08T00:00:00","2023-08-09T00:00:00","2023-08-10T00:00:00","2023-08-11T00:00:00","2023-08-14T00:00:00","2023-08-15T00:00:00","2023-08-16T00:00:00","2023-08-17T00:00:00","2023-08-18T00:00:00","2023-08-21T00:00:00","2023-08-22T00:00:00","2023-08-23T00:00:00","2023-08-24T00:00:00","2023-08-25T00:00:00","2023-08-28T00:00:00","2023-08-29T00:00:00","2023-08-29T00:00:00","2023-08-30T00:00:00","2023-08-31T00:00:00","2023-09-05T00:00:00","2023-09-06T00:00:00","2023-09-07T00:00:00","2023-09-08T00:00:00","2023-09-11T00:00:00","2023-09-12T00:00:00","2023-09-13T00:00:00","2023-09-14T00:00:00","2023-09-15T00:00:00","2023-09-18T00:00:00","2023-09-19T00:00:00","2023-09-20T00:00:00","2023-09-21T00:00:00","2023-09-22T00:00:00","2023-09-25T00:00:00","2023-09-26T00:00:00","2023-09-27T00:00:00","2023-09-28T00:00:00","2023-09-29T00:00:00","2023-10-02T00:00:00","2023-10-03T00:00:00","2023-10-04T00:00:00","2023-10-05T00:00:00","2023-10-06T00:00:00","2023-10-09T00:00:00","2023-10-10T00:00:00","2023-10-11T00:00:00","2023-10-12T00:00:00","2023-10-13T00:00:00","2023-10-16T00:00:00","2023-10-17T00:00:00","2023-10-18T00:00:00","2023-10-19T00:00:00","2023-10-20T00:00:00","2023-10-23T00:00:00","2023-10-24T00:00:00","2023-10-25T00:00:00","2023-10-26T00:00:00","2023-10-27T00:00:00","2023-10-30T00:00:00","2023-10-31T00:00:00","2023-11-01T00:00:00","2023-11-02T00:00:00","2023-11-03T00:00:00","2023-11-06T00:00:00","2023-11-07T00:00:00","2023-11-08T00:00:00","2023-11-09T00:00:00","2023-11-10T00:00:00","2023-11-13T00:00:00","2023-11-14T00:00:00","2023-11-15T00:00:00","2023-11-16T00:00:00","2023-11-17T00:00:00","2023-11-20T00:00:00"]},{"marker":{"color":"black","size":12,"symbol":"triangle-up"},"mode":"markers","name":"Buy Actions","text":[300,100,100,200,100,400,300,300,200,100,100,200,100,200,100,200,100,300],"type":"scatter","x":["2023-06-13T00:00:00","2023-06-22T00:00:00","2023-06-27T00:00:00","2023-06-28T00:00:00","2023-06-29T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-10T00:00:00","2023-07-19T00:00:00","2023-07-21T00:00:00","2023-07-24T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-08-24T00:00:00","2023-08-25T00:00:00","2023-08-29T00:00:00"],"y":[62067,66600,68700,68050,67800,70925,72567,75433,75800,74900,77700,76900,76400,79400,75400,77300,76800,79767]},{"marker":{"color":"brown","size":12,"symbol":"triangle-down"},"mode":"markers","name":"Sell Actions","text":[100,100,100,100,100,200,300,500,400,200,200,100,100,200,100,100,100,100,300],"type":"scatter","x":["2023-06-21T00:00:00","2023-06-23T00:00:00","2023-06-28T00:00:00","2023-06-30T00:00:00","2023-07-03T00:00:00","2023-07-04T00:00:00","2023-07-05T00:00:00","2023-07-06T00:00:00","2023-07-12T00:00:00","2023-07-13T00:00:00","2023-07-28T00:00:00","2023-07-31T00:00:00","2023-08-01T00:00:00","2023-08-02T00:00:00","2023-08-03T00:00:00","2023-08-28T00:00:00","2023-08-29T00:00:00","2023-08-30T00:00:00","2023-08-31T00:00:00"],"y":[65300,66000,68000,71600,71700,73100,75633,75200,76150,76800,79600,76200,77900,76000,76600,78600,80800,81600,82467]}],"layout":{"height":800,"paper_bgcolor":"#F6F5F5","plot_bgcolor":"#F6F5F5","template":{"data":{"bar":[{"error_x":{"color":"rgb(36,36,36)"},"error_y":{"color":"rgb(36,36,36)"},"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"baxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(231,231,240)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(183,183,191)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"rgb(67,103,167)"},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"colorscale":{"sequential":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]],"sequentialminus":[[0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1,"rgb(250,234,220)"]]},"colorway":["rgb(76,114,176)","rgb(221,132,82)","rgb(85,168,104)","rgb(196,78,82)","rgb(129,114,179)","rgb(147,120,96)","rgb(218,139,195)","rgb(140,140,140)","rgb(204,185,116)","rgb(100,181,205)"],"font":{"color":"rgb(36,36,36)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"rgb(234,234,242)","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","paper_bgcolor":"white","plot_bgcolor":"rgb(234,234,242)","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","radialaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"scene":{"xaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"fillcolor":"rgb(67,103,167)","line":{"width":0},"opacity":0.5},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","caxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"}}},"title":{"text":"Candlestick Chart with Buy and Sell Actions"},"width":1000,"xaxis":{"title":{"text":"Date"}},"yaxis":{"title":{"text":"Price"}}}},"text/html":["
"]},"metadata":{},"output_type":"display_data"}],"source":["buysell_analyzer.plot_buy_sell_of_stock(symbol=symbol)"]}],"metadata":{"kernelspec":{"display_name":"Python 3","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.6"}},"nbformat":4,"nbformat_minor":4} diff --git a/src/trading_record.py b/src/trading_record.py index f13e7d1..0537994 100644 --- a/src/trading_record.py +++ b/src/trading_record.py @@ -232,15 +232,15 @@ def __init__(self, buy_sell_df_path:str = 'data/LichSuKhopLenh.csv', if self.start_date is not None or self.end_date is not None: self.df = self.filter_data() - def load_data(self): - df = pd.read_csv(self.buy_sell_df_path, encoding='latin1', skiprows=1) + df = pd.read_csv(self.buy_sell_df_path) df.columns = self.column_order df = self._preprocess_data(df) return df def _preprocess_data(self, df): df[self.time_col].ffill(inplace=True) + df = df[(df['action'] == 'Mua') | (df['action'] == 'Bán') ] df = df[df['ticker'].notna()] df = df.fillna(0) df[self.num_cols] = df[self.num_cols].replace(',', '', regex=True).astype(float)