{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to load and save data to remote database\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "None\n", "Loaded env variables from file None\n" ] }, { "data": { "text/html": [ "
Activating profile profile1\n",
"\n"
],
"text/plain": [
"Activating profile profile1\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from lightweight_charts import Panel, chart, PlotDFAccessor\n",
"from v2realbot.utils.utils import zoneNY\n",
"import pandas as pd\n",
"import numpy as np\n",
"import vectorbtpro as vbt\n",
"# from itables import init_notebook_mode, show\n",
"import datetime\n",
"from itertools import product\n",
"from v2realbot.config import DATA_DIR\n",
"from IPython.display import display\n",
"\n",
"# init_notebook_mode(all_interactive=True)\n",
"\n",
"vbt.settings.set_theme(\"dark\")\n",
"vbt.settings['plotting']['layout']['width'] = 1280\n",
"vbt.settings.plotting.auto_rangebreaks = True\n",
"# Set the option to display with pagination\n",
"pd.set_option('display.notebook_repr_html', True)\n",
"pd.set_option('display.max_rows', 10) # Number of rows per page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Fetch STOCKS from db"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ac5230e6571e4664ad606c118fa0e9f5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"100%|##########| 1/1 [00:10<00:00, 10.52s/it, symbol=BAC]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"| \n", " | open | \n", "high | \n", "low | \n", "close | \n", "volume | \n", "vwap | \n", "buyvolume | \n", "trades | \n", "sellvolume | \n", "
|---|---|---|---|---|---|---|---|---|---|
| time | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
| 2024-02-12 09:30:00-05:00 | \n", "33.000 | \n", "33.00 | \n", "33.00 | \n", "33.000 | \n", "800.0 | \n", "33.000000 | \n", "0.0 | \n", "2.0 | \n", "0.0 | \n", "
| 2024-02-12 09:30:01-05:00 | \n", "33.020 | \n", "33.05 | \n", "33.00 | \n", "33.010 | \n", "267365.0 | \n", "33.020039 | \n", "265765.0 | \n", "25.0 | \n", "1000.0 | \n", "
| 2024-02-12 09:30:02-05:00 | \n", "33.000 | \n", "33.02 | \n", "33.00 | \n", "33.015 | \n", "1100.0 | \n", "33.009545 | \n", "500.0 | \n", "9.0 | \n", "600.0 | \n", "
| 2024-02-12 09:30:03-05:00 | \n", "33.005 | \n", "33.08 | \n", "32.99 | \n", "33.080 | \n", "7508.0 | \n", "33.027898 | \n", "1970.0 | \n", "32.0 | \n", "3638.0 | \n", "
| 2024-02-12 09:30:05-05:00 | \n", "33.060 | \n", "33.06 | \n", "33.06 | \n", "33.060 | \n", "500.0 | \n", "33.060000 | \n", "0.0 | \n", "5.0 | \n", "100.0 | \n", "