This commit is contained in:
Oleg Sheynin 2024-08-14 01:54:48 +00:00
parent 80319e0301
commit cd5c78d47f
4 changed files with 1055 additions and 227 deletions

View File

@ -0,0 +1,263 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "c7dac550-c0ed-4ec7-846e-8edb2086c9cc",
"metadata": {},
"source": [
"# Augmented Dickey-Fuller Test (ADF)\n",
"Stationarity Test"
]
},
{
"cell_type": "markdown",
"id": "778b9362-37e3-40e0-a20a-1ca5e2cddf05",
"metadata": {},
"source": [
"## Preparing The data"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "998ecc54-aaba-4761-bb98-1eda5c9fa091",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>tstamp</th>\n",
" <th>target</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722470400000000000</td>\n",
" <td>64640.679892</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722470460000000000</td>\n",
" <td>64652.991289</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722470520000000000</td>\n",
" <td>64660.005093</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722470580000000000</td>\n",
" <td>64653.482847</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722470640000000000</td>\n",
" <td>64687.458279</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1372</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722556500000000000</td>\n",
" <td>65439.307663</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1373</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722556560000000000</td>\n",
" <td>65445.733114</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1374</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722556620000000000</td>\n",
" <td>65446.371741</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1375</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722556680000000000</td>\n",
" <td>65420.879478</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1376</th>\n",
" <td>PAIR-BTC-USDT</td>\n",
" <td>1722556740000000000</td>\n",
" <td>65377.032222</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>1377 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" id tstamp target\n",
"0 PAIR-BTC-USDT 1722470400000000000 64640.679892\n",
"1 PAIR-BTC-USDT 1722470460000000000 64652.991289\n",
"2 PAIR-BTC-USDT 1722470520000000000 64660.005093\n",
"3 PAIR-BTC-USDT 1722470580000000000 64653.482847\n",
"4 PAIR-BTC-USDT 1722470640000000000 64687.458279\n",
"... ... ... ...\n",
"1372 PAIR-BTC-USDT 1722556500000000000 65439.307663\n",
"1373 PAIR-BTC-USDT 1722556560000000000 65445.733114\n",
"1374 PAIR-BTC-USDT 1722556620000000000 65446.371741\n",
"1375 PAIR-BTC-USDT 1722556680000000000 65420.879478\n",
"1376 PAIR-BTC-USDT 1722556740000000000 65377.032222\n",
"\n",
"[1377 rows x 3 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"from statsmodels.tsa.stattools import adfuller\n",
"import numpy as np\n",
"\n",
"def demo_example_data() -> pd.Series:\n",
" # Generate example time series data\n",
" # np.random.seed(0)\n",
" time_series_data = np.random.randn(100) # Random data for demonstration\n",
" \n",
" # Create a pandas Series\n",
" data = pd.Series(time_series_data)\n",
" \n",
" # Optionally, you can add a datetime index if you have time-indexed data\n",
" dates = pd.date_range(start='2020-01-01', periods=len(time_series_data), freq='D')\n",
" data = pd.Series(time_series_data, index=dates)\n",
"\n",
" # Display the first few rows of the data\n",
" print(data.head())\n",
" return data\n",
"\n",
"def load_df_from_db(file: str, query: str) -> pd.DataFrame:\n",
" import sqlite3 \n",
" \n",
" conn = sqlite3.connect(file)\n",
" df = pd.read_sql_query(query, conn)\n",
" df['timestamp'] = pd.to_datetime(df['tstamp'])\n",
" df.set_index('timestamp', inplace=True)\n",
" return df\n",
"\n",
"file_path = \"/workspace/data/crypto_md/20240801.mktdata.ohlcv.db\"\n",
"instrument_id='PAIR-BTC-USDT'\n",
"query = f\"\"\"\n",
"select \n",
" instrument_id as id, \n",
" tstamp, \n",
" vwap \n",
"from bnbspot_ohlcv_1min \n",
"where instrument_id = '{instrument_id}'\n",
"\"\"\"\n",
"\n",
"df = load_df_from_db(file=file_path, query=query)\n",
"df.rename(columns={'vwap': 'target'}, inplace=True)\n",
"# df[\"tstamp2\"] = df.index\n",
"df = df.reset_index()\n",
"df = df.drop([\"timestamp\"], axis=1) \n",
"df"
]
},
{
"cell_type": "markdown",
"id": "43e43154-5a04-4a1d-977c-7f930d62f241",
"metadata": {},
"source": [
"## Running Test"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b97d357f-787b-4cff-849f-b91b1ec35e7c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2020-01-01 -1.652908\n",
"2020-01-02 -0.157302\n",
"2020-01-03 -1.396187\n",
"2020-01-04 0.150374\n",
"2020-01-05 1.048603\n",
"Freq: D, dtype: float64\n",
"ADF Statistic: -9.985535987881171\n",
"p-value: 2.060269774403535e-17\n",
"Critical Values: {'1%': -3.498198082189098, '5%': -2.891208211860468, '10%': -2.5825959973472097}\n"
]
}
],
"source": [
"import pandas as pd\n",
"from statsmodels.tsa.stattools import adfuller\n",
"\n",
"# Example time series data\n",
"data = demo_example_data()\n",
"\n",
"# Perform the ADF test\n",
"result = adfuller(data)\n",
"\n",
"# Extract and print the results\n",
"print('ADF Statistic:', result[0])\n",
"print('p-value:', result[1])\n",
"print('Critical Values:', result[4])\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -10,7 +10,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 1,
"id": "6b269e64-be58-43b5-ad60-0fbd1d37861a", "id": "6b269e64-be58-43b5-ad60-0fbd1d37861a",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -46,56 +46,26 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 2,
"id": "7313a620-a0eb-4207-a12a-90aeee3cd980", "id": "7313a620-a0eb-4207-a12a-90aeee3cd980",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"('3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]',\n", "('3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]',\n",
" environ{'USER': 'oleg',\n", " environ{'PATH': '/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',\n",
" 'SSH_CLIENT': '100.102.18.30 39290 22',\n", " 'HOSTNAME': '30c1a1a6daca',\n",
" 'XDG_SESSION_TYPE': 'tty',\n", " 'JUPYTER_ENABLE_LAB': 'yes',\n",
" 'SHLVL': '1',\n", " 'PYTHONPATH': '/cvtt/prod',\n",
" 'MOTD_SHOWN': 'pam',\n", " 'NVIDIA_VISIBLE_DEVICES': 'all',\n",
" 'HOME': '/home/oleg',\n", " 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility',\n",
" 'OLDPWD': '/home/oleg/.vscode-server',\n", " 'LD_LIBRARY_PATH': '/usr/local/nvidia/lib:/usr/local/nvidia/lib64',\n",
" 'SSL_CERT_FILE': '/usr/lib/ssl/certs/ca-certificates.crt',\n", " 'PYTORCH_VERSION': '2.2.1',\n",
" 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus',\n", " 'HOME': '/root',\n",
" 'LOGNAME': 'oleg',\n", " 'LC_CTYPE': 'C.UTF-8',\n",
" '_': '/home/oleg/.pyenv/python3.10-venv/bin/python',\n", " 'JPY_SESSION_NAME': '/workspace/Testing GPU.ipynb',\n",
" 'XDG_SESSION_CLASS': 'user',\n", " 'JPY_PARENT_PID': '1',\n",
" 'VSCODE_CLI_REQUIRE_TOKEN': 'a18f8694-adf8-4fa9-a860-a18b2bdb3d92',\n",
" 'XDG_SESSION_ID': '149',\n",
" 'PATH': '/home/oleg/.pyenv/python3.10-venv/bin:/home/oleg/.vscode-server/cli/servers/Stable-dc96b837cf6bb4af9cd736aa3af08cf8279f7685/server/bin/remote-cli:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin',\n",
" 'VSCODE_AGENT_FOLDER': '/home/oleg/.vscode-server',\n",
" 'XDG_RUNTIME_DIR': '/run/user/1000',\n",
" 'SSL_CERT_DIR': '/usr/lib/ssl/certs',\n",
" 'LANG': 'en_US.UTF-8',\n",
" 'SHELL': '/bin/bash',\n",
" 'PWD': '/home/oleg',\n",
" 'SSH_CONNECTION': '100.102.18.30 39290 100.102.233.115 22',\n",
" 'XDG_DATA_DIRS': '/home/oleg/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share',\n",
" 'VSCODE_HANDLES_SIGPIPE': 'true',\n",
" 'LS_COLORS': '',\n",
" 'LESSCLOSE': '/usr/bin/lesspipe %s %s',\n",
" 'LESSOPEN': '| /usr/bin/lesspipe %s',\n",
" 'LD_LIBRARY_PATH': '/usr/local/cuda/lib64',\n",
" 'VSCODE_AMD_ENTRYPOINT': 'vs/workbench/api/node/extensionHostProcess',\n",
" 'VSCODE_HANDLES_UNCAUGHT_ERRORS': 'true',\n",
" 'VSCODE_NLS_CONFIG': '{\"locale\":\"en\",\"osLocale\":\"en\",\"availableLanguages\":{}}',\n",
" 'BROWSER': '/home/oleg/.vscode-server/cli/servers/Stable-dc96b837cf6bb4af9cd736aa3af08cf8279f7685/server/bin/helpers/browser.sh',\n",
" 'VSCODE_CWD': '/home/oleg',\n",
" 'ELECTRON_RUN_AS_NODE': '1',\n",
" 'VSCODE_IPC_HOOK_CLI': '/run/user/1000/vscode-ipc-c5d6268a-2e45-4659-9523-6fcffb529a08.sock',\n",
" 'PYTHONUNBUFFERED': '1',\n",
" 'VIRTUAL_ENV': '/home/oleg/.pyenv/python3.10-venv',\n",
" 'PYTHONIOENCODING': 'utf-8',\n",
" 'VIRTUAL_ENV_PROMPT': '(python3.10-venv) ',\n",
" 'PS1': '(python3.10-venv) ',\n",
" 'PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING': '1',\n",
" 'PYTHON_FROZEN_MODULES': 'on',\n",
" 'PYDEVD_USE_FRAME_EVAL': 'NO',\n", " 'PYDEVD_USE_FRAME_EVAL': 'NO',\n",
" 'TERM': 'xterm-color',\n", " 'TERM': 'xterm-color',\n",
" 'CLICOLOR': '1',\n", " 'CLICOLOR': '1',\n",
@ -107,7 +77,7 @@
" 'CUDA_MODULE_LOADING': 'LAZY'})" " 'CUDA_MODULE_LOADING': 'LAZY'})"
] ]
}, },
"execution_count": 10, "execution_count": 2,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -116,7 +86,7 @@
"import sys\n", "import sys\n",
"import os\n", "import os\n",
"\n", "\n",
"sys.path.append(\"/home/oleg/develop/cvtt2\")\n", "sys.path.append(\"/\")\n",
"sys.version,os.environ\n", "sys.version,os.environ\n",
"\n" "\n"
] ]
@ -131,7 +101,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 3,
"id": "95d9a2e6-3464-4dbe-9a97-0c2d5eb34193", "id": "95d9a2e6-3464-4dbe-9a97-0c2d5eb34193",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -160,14 +130,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 4,
"id": "eb38de31-fc19-4515-b08d-9cd7607ea958", "id": "eb38de31-fc19-4515-b08d-9cd7607ea958",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "4be0c8cc9c004ef6b32f044018434a85", "model_id": "54e9ddbe3f4349ca9ebbee5aaec14477",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
@ -188,10 +158,10 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"1718155463838047267" "1723585308075979805"
] ]
}, },
"execution_count": 12, "execution_count": 4,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -211,7 +181,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 5,
"id": "f46e46a7-9b57-44aa-9bc9-dcbcf643bc88", "id": "f46e46a7-9b57-44aa-9bc9-dcbcf643bc88",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -219,8 +189,15 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"jupyter-events==0.10.0\n",
"jupyter-lsp==2.2.5\n",
"jupyter_client==8.6.2\n", "jupyter_client==8.6.2\n",
"jupyter_core==5.7.2\n", "jupyter_core==5.7.2\n",
"jupyter_server==2.14.2\n",
"jupyter_server_terminals==0.5.3\n",
"jupyterlab==4.2.4\n",
"jupyterlab_pygments==0.3.0\n",
"jupyterlab_server==2.27.3\n",
"jupyterlab_widgets==3.0.11\n" "jupyterlab_widgets==3.0.11\n"
] ]
} }

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 2,
"id": "1023f2c1-e45f-4e1c-9a1b-66f59f128196", "id": "1023f2c1-e45f-4e1c-9a1b-66f59f128196",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -10,8 +10,23 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Panda Version: 2.2.2\n", "Panda Version: 2.2.2\n"
"Today date is: 2024-06-17\n" ]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-08-13 13:49:15.756217: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
"2024-08-13 13:49:15.773323: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
"2024-08-13 13:49:15.778526: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Today date is: 2024-08-13\n"
] ]
} }
], ],
@ -73,7 +88,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 3,
"id": "c09a37a6-f0d9-48e3-a1d1-65ddaf2c489c", "id": "c09a37a6-f0d9-48e3-a1d1-65ddaf2c489c",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -82,26 +97,23 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"/workspace/leo\n", "/workspace/leo\n",
"total 22016\n", "total 15712\n",
"drwxrwxr-x 1 1000 1000 848 Jun 17 10:00 .\n", "drwxrwxrwx 1 1000 1000 628 Aug 13 13:00 .\n",
"drwxrwxr-x 1 1000 1000 18 Jun 3 23:40 ..\n", "drwxrwxr-x 1 1000 1000 18 Jun 3 23:40 ..\n",
"-rw------- 1 1000 1000 1449984 Jun 4 00:49 20240601.mktdata.ohlcv.db\n", "drwxrwxr-x 1 1000 1000 1500 Aug 10 21:00 2024-06\n",
"-rw------- 1 1000 1000 1445888 Jun 3 23:44 20240602.mktdata.ohlcv.db\n", "drwxrwxr-x 1 1000 1000 1550 Aug 10 21:00 2024-07\n",
"-rw------- 1 1000 1000 1437696 Jun 4 16:45 20240603.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1425408 Aug 2 13:01 20240801.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1269760 Jun 5 10:00 20240604.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1396736 Aug 3 13:01 20240802.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1081344 Jun 6 10:00 20240605.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1384448 Aug 4 13:01 20240803.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1441792 Jun 7 10:00 20240606.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1318912 Aug 6 02:54 20240804.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1445888 Jun 8 10:00 20240607.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 2269184 Aug 10 17:04 20240805.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1449984 Jun 9 10:00 20240608.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1146880 Aug 10 20:59 20240806.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1437696 Jun 10 10:00 20240609.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1363968 Aug 8 13:01 20240807.mktdata.ohlcv.db\n",
"-rw-r--r-- 1 1000 1000 0 Jun 12 15:29 20240609.mktdata.ohlcvdb\n", "-rw------- 1 1000 1000 1187840 Aug 10 17:09 20240808.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1437696 Jun 11 10:00 20240610.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1028096 Aug 10 17:10 20240809.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1449984 Jun 12 10:01 20240611.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1187840 Aug 11 13:00 20240810.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1445888 Jun 13 10:01 20240612.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1187840 Aug 12 13:00 20240811.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1445888 Jun 14 10:01 20240613.mktdata.ohlcv.db\n", "-rw------- 1 1000 1000 1191936 Aug 13 13:00 20240812.mktdata.ohlcv.db\n"
"-rw------- 1 1000 1000 1404928 Jun 15 10:01 20240614.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1449984 Jun 16 10:00 20240615.mktdata.ohlcv.db\n",
"-rw------- 1 1000 1000 1449984 Jun 17 10:00 20240616.mktdata.ohlcv.db\n"
] ]
} }
], ],
@ -133,15 +145,26 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 4,
"id": "5d2aed0b-8c9d-4f5a-9166-785da4811390", "id": "5d2aed0b-8c9d-4f5a-9166-785da4811390",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "ename": "DatabaseError",
"output_type": "stream", "evalue": "Execution failed on sql 'select * from coinbase_ohlcv_1min': no such table: coinbase_ohlcv_1min",
"text": [ "output_type": "error",
"89716\n" "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mOperationalError\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m/usr/local/lib/python3.11/dist-packages/pandas/io/sql.py:2674\u001b[0m, in \u001b[0;36mSQLiteDatabase.execute\u001b[0;34m(self, sql, params)\u001b[0m\n\u001b[1;32m 2673\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 2674\u001b[0m \u001b[43mcur\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\u001b[43msql\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2675\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m cur\n",
"\u001b[0;31mOperationalError\u001b[0m: no such table: coinbase_ohlcv_1min",
"\nThe above exception was the direct cause of the following exception:\n",
"\u001b[0;31mDatabaseError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 32\u001b[0m\n\u001b[1;32m 29\u001b[0m conn \u001b[38;5;241m=\u001b[39m sqlite3\u001b[38;5;241m.\u001b[39mconnect(filename)\n\u001b[1;32m 31\u001b[0m \u001b[38;5;66;03m# Read the data into a DataFrame\u001b[39;00m\n\u001b[0;32m---> 32\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_sql_query\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mselect * from coinbase_ohlcv_1min\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconn\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 34\u001b[0m df_concat \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mconcat([df_concat, df], axis \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m,ignore_index \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m 35\u001b[0m \u001b[38;5;66;03m# Print the combined DataFrame\u001b[39;00m\n\u001b[1;32m 36\u001b[0m \u001b[38;5;66;03m# print(df_concat.shape[0])\u001b[39;00m\n\u001b[1;32m 37\u001b[0m \u001b[38;5;66;03m# print(df_concat.shape[1])\u001b[39;00m\n",
"File \u001b[0;32m/usr/local/lib/python3.11/dist-packages/pandas/io/sql.py:526\u001b[0m, in \u001b[0;36mread_sql_query\u001b[0;34m(sql, con, index_col, coerce_float, params, parse_dates, chunksize, dtype, dtype_backend)\u001b[0m\n\u001b[1;32m 523\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m dtype_backend \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mno_default\n\u001b[1;32m 525\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m pandasSQL_builder(con) \u001b[38;5;28;01mas\u001b[39;00m pandas_sql:\n\u001b[0;32m--> 526\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mpandas_sql\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_query\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 527\u001b[0m \u001b[43m \u001b[49m\u001b[43msql\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 528\u001b[0m \u001b[43m \u001b[49m\u001b[43mindex_col\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindex_col\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 529\u001b[0m \u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 530\u001b[0m \u001b[43m \u001b[49m\u001b[43mcoerce_float\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcoerce_float\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 531\u001b[0m \u001b[43m \u001b[49m\u001b[43mparse_dates\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparse_dates\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 532\u001b[0m \u001b[43m \u001b[49m\u001b[43mchunksize\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mchunksize\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 533\u001b[0m \u001b[43m \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdtype\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 534\u001b[0m \u001b[43m \u001b[49m\u001b[43mdtype_backend\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdtype_backend\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 535\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m/usr/local/lib/python3.11/dist-packages/pandas/io/sql.py:2738\u001b[0m, in \u001b[0;36mSQLiteDatabase.read_query\u001b[0;34m(self, sql, index_col, coerce_float, parse_dates, params, chunksize, dtype, dtype_backend)\u001b[0m\n\u001b[1;32m 2727\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread_query\u001b[39m(\n\u001b[1;32m 2728\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 2729\u001b[0m sql,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 2736\u001b[0m dtype_backend: DtypeBackend \u001b[38;5;241m|\u001b[39m Literal[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnumpy\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnumpy\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 2737\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m DataFrame \u001b[38;5;241m|\u001b[39m Iterator[DataFrame]:\n\u001b[0;32m-> 2738\u001b[0m cursor \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\u001b[43msql\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2739\u001b[0m columns \u001b[38;5;241m=\u001b[39m [col_desc[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m col_desc \u001b[38;5;129;01min\u001b[39;00m cursor\u001b[38;5;241m.\u001b[39mdescription]\n\u001b[1;32m 2741\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m chunksize \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
"File \u001b[0;32m/usr/local/lib/python3.11/dist-packages/pandas/io/sql.py:2686\u001b[0m, in \u001b[0;36mSQLiteDatabase.execute\u001b[0;34m(self, sql, params)\u001b[0m\n\u001b[1;32m 2683\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ex \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01minner_exc\u001b[39;00m\n\u001b[1;32m 2685\u001b[0m ex \u001b[38;5;241m=\u001b[39m DatabaseError(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExecution failed on sql \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00msql\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mexc\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m-> 2686\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ex \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n",
"\u001b[0;31mDatabaseError\u001b[0m: Execution failed on sql 'select * from coinbase_ohlcv_1min': no such table: coinbase_ohlcv_1min"
] ]
} }
], ],

File diff suppressed because one or more lines are too long