{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "5430b28f", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "plt.style.use('fivethirtyeight')\n", "from numpy.random import default_rng" ] }, { "cell_type": "markdown", "id": "b5774118", "metadata": {}, "source": [ "# Project #02 - NYSE random walk predictor\n", "\n", "In the [Stats and Monte Carlo](../module_02/04_Stats_and_Montecarlo) module, you created a Brownian motion model to predict the motion of particles in a fluid. The Monte Carlo model took steps in the x- and y-directions with random magnitudes. \n", "\n", "This [random walk](https://en.wikipedia.org/wiki/Random_walk_hypothesis) can be used to predict stock prices. Let's take a look at some data from the New York Stock Exchange [NYSE](https://www.kaggle.com/dgawlik/nyse) from 2010 through 2017. \n", "\n", "> __Important Note__: \n", "> I am not a financial advisor and these models are _purely_ for academic exercises. If you decide to use anything in these notebooks to make financial decisions, it is _at your own risk_. _I am not an economist/financial advisor/etc., I am just a Professor who likes to learn and exeriment._\n", "\n", "Here, I will show an example workflow to analyze and predict the Google\n", "stock price [[GOOGL]](https://en.wikipedia.org/wiki/Alphabet_Inc.) from\n", "2010 - 2014. Then, you can choose your own stock price to evaluate and\n", "create a predictive model.\n", "\n", "1. Explore data and select data of interest\n", "2. Find statistical description of data: mean and standard deviation\n", "3. Create random variables\n", "4. Generate random walk for [[GOOGL]](https://en.wikipedia.org/wiki/Alphabet_Inc.) stock opening price" ] }, { "cell_type": "markdown", "id": "926af8b8", "metadata": {}, "source": [ "## 1. Explore data\n", "\n", "Here, I load the data into a Pandas dataframe to see what headings and values are available. I see two columns that I want to analyze\n", "- 'date'\n", "- 'open'" ] }, { "cell_type": "code", "execution_count": 2, "id": "497cc2ce", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | date | \n", "symbol | \n", "open | \n", "close | \n", "low | \n", "high | \n", "volume | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "2016-01-05 | \n", "WLTW | \n", "123.430000 | \n", "125.839996 | \n", "122.309998 | \n", "126.250000 | \n", "2163600.0 | \n", "
1 | \n", "2016-01-06 | \n", "WLTW | \n", "125.239998 | \n", "119.980003 | \n", "119.940002 | \n", "125.540001 | \n", "2386400.0 | \n", "
2 | \n", "2016-01-07 | \n", "WLTW | \n", "116.379997 | \n", "114.949997 | \n", "114.930000 | \n", "119.739998 | \n", "2489500.0 | \n", "
3 | \n", "2016-01-08 | \n", "WLTW | \n", "115.480003 | \n", "116.620003 | \n", "113.500000 | \n", "117.440002 | \n", "2006300.0 | \n", "
4 | \n", "2016-01-11 | \n", "WLTW | \n", "117.010002 | \n", "114.970001 | \n", "114.089996 | \n", "117.330002 | \n", "1408600.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
851259 | \n", "2016-12-30 | \n", "ZBH | \n", "103.309998 | \n", "103.199997 | \n", "102.849998 | \n", "103.930000 | \n", "973800.0 | \n", "
851260 | \n", "2016-12-30 | \n", "ZION | \n", "43.070000 | \n", "43.040001 | \n", "42.689999 | \n", "43.310001 | \n", "1938100.0 | \n", "
851261 | \n", "2016-12-30 | \n", "ZTS | \n", "53.639999 | \n", "53.529999 | \n", "53.270000 | \n", "53.740002 | \n", "1701200.0 | \n", "
851262 | \n", "2016-12-30 | \n", "AIV | \n", "44.730000 | \n", "45.450001 | \n", "44.410000 | \n", "45.590000 | \n", "1380900.0 | \n", "
851263 | \n", "2016-12-30 | \n", "FTV | \n", "54.200001 | \n", "53.630001 | \n", "53.389999 | \n", "54.480000 | \n", "705100.0 | \n", "
851264 rows × 7 columns
\n", "