diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000..2fd6442 --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/.ipynb_checkpoints/data_collection-checkpoint.py b/.ipynb_checkpoints/data_collection-checkpoint.py new file mode 100644 index 0000000..8ea9f3a --- /dev/null +++ b/.ipynb_checkpoints/data_collection-checkpoint.py @@ -0,0 +1 @@ +import requests \ No newline at end of file diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 0000000..50e9302 --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,130 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "from pathlib import Path\n", + "import datetime" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "csv_path = Path('WSM.csv')\n", + "wsm_data = pd.read_csv(csv_path, infer_datetime_format = True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "wsm_data.set_index('Date')" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "wsm_data['Date'] = pd.to_datetime(wsm_data['Date'])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mwsm_data\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresample\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"M\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mresample\u001b[1;34m(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base, on, level)\u001b[0m\n\u001b[0;32m 8447\u001b[0m \u001b[0mbase\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mbase\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8448\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mon\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 8449\u001b[1;33m \u001b[0mlevel\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlevel\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 8450\u001b[0m )\n\u001b[0;32m 8451\u001b[0m return _maybe_process_deprecations(\n", + "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\resample.py\u001b[0m in \u001b[0;36mresample\u001b[1;34m(obj, kind, **kwds)\u001b[0m\n\u001b[0;32m 1304\u001b[0m \"\"\"\n\u001b[0;32m 1305\u001b[0m \u001b[0mtg\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mTimeGrouper\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1306\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mtg\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_resampler\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkind\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkind\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1307\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1308\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\resample.py\u001b[0m in \u001b[0;36m_get_resampler\u001b[1;34m(self, obj, kind)\u001b[0m\n\u001b[0;32m 1441\u001b[0m \u001b[1;34m\"Only valid with DatetimeIndex, \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1442\u001b[0m \u001b[1;34m\"TimedeltaIndex or PeriodIndex, \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1443\u001b[1;33m \u001b[1;34m\"but got an instance of %r\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0max\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1444\u001b[0m )\n\u001b[0;32m 1445\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mTypeError\u001b[0m: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'" + ] + } + ], + "source": [ + "wsm_data.resample(\"M\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mwsm_data\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresample\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"M\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mresample\u001b[1;34m(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base, on, level)\u001b[0m\n\u001b[0;32m 8447\u001b[0m \u001b[0mbase\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mbase\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8448\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mon\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 8449\u001b[1;33m \u001b[0mlevel\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlevel\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 8450\u001b[0m )\n\u001b[0;32m 8451\u001b[0m return _maybe_process_deprecations(\n", + "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\resample.py\u001b[0m in \u001b[0;36mresample\u001b[1;34m(obj, kind, **kwds)\u001b[0m\n\u001b[0;32m 1304\u001b[0m \"\"\"\n\u001b[0;32m 1305\u001b[0m \u001b[0mtg\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mTimeGrouper\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1306\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mtg\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_resampler\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkind\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkind\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1307\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1308\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\resample.py\u001b[0m in \u001b[0;36m_get_resampler\u001b[1;34m(self, obj, kind)\u001b[0m\n\u001b[0;32m 1441\u001b[0m \u001b[1;34m\"Only valid with DatetimeIndex, \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1442\u001b[0m \u001b[1;34m\"TimedeltaIndex or PeriodIndex, \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1443\u001b[1;33m \u001b[1;34m\"but got an instance of %r\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0max\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1444\u001b[0m )\n\u001b[0;32m 1445\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mTypeError\u001b[0m: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'" + ] + } + ], + "source": [ + "wsm_data.resample(\"M\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "date_time_str = wsm_data['Date']\n", + "date_time_obj = datetime.datetime.strptime(date_time_str, '%m/%d/%Y')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/WSM.csv b/WSM.csv new file mode 100644 index 0000000..5e39619 --- /dev/null +++ b/WSM.csv @@ -0,0 +1,253 @@ +Date,Close +2/11/2019,53.939999 +2/12/2019,55.639999 +2/13/2019,55.68 +2/14/2019,55.5 +2/15/2019,55.720001 +2/19/2019,55.68 +2/20/2019,56.43 +2/21/2019,55.419998 +2/22/2019,55.529999 +2/25/2019,57.189999 +2/26/2019,56.889999 +2/27/2019,58.919998 +2/28/2019,58.16 +3/1/2019,58.849998 +3/4/2019,58.049999 +3/5/2019,58.330002 +3/6/2019,58.41 +3/7/2019,57.82 +3/8/2019,57.029999 +3/11/2019,57.610001 +3/12/2019,57.529999 +3/13/2019,56.990002 +3/14/2019,56.209999 +3/15/2019,56.189999 +3/18/2019,56.439999 +3/19/2019,56.740002 +3/20/2019,56.849998 +3/21/2019,59.220001 +3/22/2019,57 +3/25/2019,57.939999 +3/26/2019,57.330002 +3/27/2019,57.18 +3/28/2019,57.27 +3/29/2019,56.27 +4/1/2019,57.02 +4/2/2019,57.639999 +4/3/2019,58.43 +4/4/2019,59.360001 +4/5/2019,60.240002 +4/8/2019,60.150002 +4/9/2019,59.060001 +4/10/2019,59.810001 +4/11/2019,58.700001 +4/12/2019,57.720001 +4/15/2019,56.529999 +4/16/2019,57.080002 +4/17/2019,57.619999 +4/18/2019,57.310001 +4/22/2019,56.330002 +4/23/2019,56.720001 +4/24/2019,58 +4/25/2019,56.299999 +4/26/2019,56.18 +4/29/2019,56.75 +4/30/2019,57.169998 +5/1/2019,55.349998 +5/2/2019,56.779999 +5/3/2019,56.639999 +5/6/2019,56.009998 +5/7/2019,54.09 +5/8/2019,54.75 +5/9/2019,55.040001 +5/10/2019,54.860001 +5/13/2019,52.259998 +5/14/2019,53.200001 +5/15/2019,53.200001 +5/16/2019,53.73 +5/17/2019,53.27 +5/20/2019,53.599998 +5/21/2019,54.580002 +5/22/2019,54.23 +5/23/2019,51.689999 +5/24/2019,52.080002 +5/28/2019,52.509998 +5/29/2019,51.130001 +5/30/2019,51.59 +5/31/2019,58.5 +6/3/2019,58.299999 +6/4/2019,59.439999 +6/5/2019,58.919998 +6/6/2019,57.540001 +6/7/2019,56.779999 +6/10/2019,56.279999 +6/11/2019,58.380001 +6/12/2019,58.450001 +6/13/2019,61.279999 +6/14/2019,61.27 +6/17/2019,60.990002 +6/18/2019,61.759998 +6/19/2019,62.02 +6/20/2019,61.5 +6/21/2019,61.32 +6/24/2019,61.639999 +6/25/2019,62.700001 +6/26/2019,62.98 +6/27/2019,64.260002 +6/28/2019,65 +7/1/2019,64.57 +7/2/2019,64.349998 +7/3/2019,64.43 +7/5/2019,64.839996 +7/8/2019,63.779999 +7/9/2019,61.970001 +7/10/2019,63.150002 +7/11/2019,63.75 +7/12/2019,65.440002 +7/15/2019,69.099998 +7/16/2019,70.260002 +7/17/2019,69.559998 +7/18/2019,69.599998 +7/19/2019,69.260002 +7/22/2019,69 +7/23/2019,69.089996 +7/24/2019,70.209999 +7/25/2019,67.699997 +7/26/2019,68.019997 +7/29/2019,67.43 +7/30/2019,67.330002 +7/31/2019,66.68 +8/1/2019,64.150002 +8/2/2019,64.040001 +8/5/2019,63.830002 +8/6/2019,64.949997 +8/7/2019,64.839996 +8/8/2019,65.709999 +8/9/2019,64.150002 +8/12/2019,65.230003 +8/13/2019,66.099998 +8/14/2019,62.189999 +8/15/2019,62.889999 +8/16/2019,63.299999 +8/19/2019,65.099998 +8/20/2019,64.699997 +8/21/2019,65.459999 +8/22/2019,68.32 +8/23/2019,67.309998 +8/26/2019,67.419998 +8/27/2019,68.400002 +8/28/2019,68.779999 +8/29/2019,64.160004 +8/30/2019,65.800003 +9/3/2019,62.709999 +9/4/2019,62.959999 +9/5/2019,64.830002 +9/6/2019,65.260002 +9/9/2019,66.839996 +9/10/2019,69.25 +9/11/2019,68.480003 +9/12/2019,67.260002 +9/13/2019,67.989998 +9/16/2019,67.370003 +9/17/2019,67.190002 +9/18/2019,65.279999 +9/19/2019,65.07 +9/20/2019,65.110001 +9/23/2019,67.300003 +9/24/2019,67.18 +9/25/2019,67.43 +9/26/2019,66.970001 +9/27/2019,67.93 +9/30/2019,67.980003 +10/1/2019,67.809998 +10/2/2019,65.099998 +10/3/2019,64.949997 +10/4/2019,65.550003 +10/7/2019,64.809998 +10/8/2019,63.970001 +10/9/2019,65.029999 +10/10/2019,65.760002 +10/11/2019,68.610001 +10/14/2019,68.040001 +10/15/2019,69.919998 +10/16/2019,69.849998 +10/17/2019,70.290001 +10/18/2019,69.260002 +10/21/2019,70.489998 +10/22/2019,71.230003 +10/23/2019,69.769997 +10/24/2019,67.760002 +10/25/2019,69.040001 +10/28/2019,68.25 +10/29/2019,68.620003 +10/30/2019,67.730003 +10/31/2019,66.790001 +11/1/2019,66.790001 +11/4/2019,67.480003 +11/5/2019,68.089996 +11/6/2019,68.529999 +11/7/2019,69.230003 +11/8/2019,69.239998 +11/11/2019,71.370003 +11/12/2019,70.470001 +11/13/2019,71.169998 +11/14/2019,72.459999 +11/15/2019,72.860001 +11/18/2019,72.940002 +11/19/2019,70.040001 +11/20/2019,68.599998 +11/21/2019,68.75 +11/22/2019,67.419998 +11/25/2019,69.230003 +11/26/2019,71.339996 +11/27/2019,70.709999 +11/29/2019,69.400002 +12/2/2019,67.970001 +12/3/2019,67.470001 +12/4/2019,68.040001 +12/5/2019,68.150002 +12/6/2019,70.379997 +12/9/2019,69.839996 +12/10/2019,69.470001 +12/11/2019,70.059998 +12/12/2019,70.110001 +12/13/2019,69.230003 +12/16/2019,70.220001 +12/17/2019,71.32 +12/18/2019,72.610001 +12/19/2019,72.879997 +12/20/2019,72.82 +12/23/2019,73.610001 +12/24/2019,73.18 +12/26/2019,74.010002 +12/27/2019,73.019997 +12/30/2019,73.440002 +12/31/2019,73.440002 +1/2/2020,72.639999 +1/3/2020,72.110001 +1/6/2020,72.379997 +1/7/2020,73.760002 +1/8/2020,74.25 +1/9/2020,75.099998 +1/10/2020,74.370003 +1/13/2020,75.519997 +1/14/2020,76.010002 +1/15/2020,75.57 +1/16/2020,76.519997 +1/17/2020,76.589996 +1/21/2020,76.160004 +1/22/2020,75.720001 +1/23/2020,75.470001 +1/24/2020,74.989998 +1/27/2020,73.349998 +1/28/2020,74.720001 +1/29/2020,73.650002 +1/30/2020,72.75 +1/31/2020,70.080002 +2/3/2020,70.190002 +2/4/2020,71.260002 +2/5/2020,74.230003 +2/6/2020,72.019997 +2/7/2020,71.059998 +2/10/2020,71.510002 diff --git a/prepfile.py b/prepfile.py new file mode 100644 index 0000000..e69de29