{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Crypto Playground\n\nThe notebook where I learn crypto, time series, technical analysis, etc and develop my initial models.\n\n<a id=\"toc\"></a>\n\n# Table of Contents\n\n- [Import Libraries](#import-libraries)\n- [Configuration](#configuration)\n- [Load Data](#load-data)\n- [Missing Values](#missing-values)\n- [Summary Statistics](#summary-statistics)\n\n\n\n# Sources\n\n1. [Crypto Prediction: Technical Analysis Features](https://www.kaggle.com/yamqwe/crypto-prediction-technical-analysis-features)\n2. [Tutorial to the G-Research Crypto Competition](https://www.kaggle.com/cstein06/tutorial-to-the-g-research-crypto-competition) - The Starter Notebook\n3. [volatility plots](https://www.kaggle.com/pashadude/volatility-plots)\n4. [G-Research - Plotly/Cufflinks Interactive Plots](https://www.kaggle.com/dschettler8845/g-research-plotly-cufflinks-interactive-plots)\n5. [Feature Engineering: Rolling Aggregations](https://www.kaggle.com/yamqwe/feature-engineering-rolling-aggregations/notebook)\n6. [PurgedGroupTimeSeries CV with Extra Data | NN](https://www.kaggle.com/yamqwe/purgedgrouptimeseries-cv-with-extra-data-nn)\n7. [Crypto Prediction: XGB Regressor](https://www.kaggle.com/yamqwe/crypto-prediction-xgb-regressor)\n8. [💲 G-Research Plots + EDA 💲](https://www.kaggle.com/odins0n/g-research-plots-eda)\n9. [Crypto Forecasting - Intro EDA](https://www.kaggle.com/lucasmorin/crypto-forecasting-intro-eda)\n10. [Simple Exploration Notebook - Crypto Forecasting](https://www.kaggle.com/sudalairajkumar/simple-exploration-notebook-crypto-forecasting)\n\n# Time Series Tutorials\n\n- https://www.kaggle.com/iamleonie/time-series-interpreting-acf-and-pacf\n- https://www.kaggle.com/iamleonie/intro-to-time-series-forecasting","metadata":{}},{"cell_type":"markdown","source":"<a id=\"import-libraries\"></a>\n\n# **<span style=\"color:#d5a500;\">Import Libraries</span>**\n\n - [TOC](#toc)","metadata":{}},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nfrom pathlib import Path\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport plotly.graph_objects as go # Candlesticks\n\n\nfrom datetime import datetime # timestamp support\n","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:32:14.111223Z","iopub.execute_input":"2021-11-17T14:32:14.112208Z","iopub.status.idle":"2021-11-17T14:32:15.014167Z","shell.execute_reply.started":"2021-11-17T14:32:14.112084Z","shell.execute_reply":"2021-11-17T14:32:15.013152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"configuration\"></a>\n\n# **<span style=\"color:#d5a500;\">Configuration</span>**","metadata":{}},{"cell_type":"code","source":"data_dir = Path('../input/g-research-crypto-forecasting')\n!ls $data_dir","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:32:15.018166Z","iopub.execute_input":"2021-11-17T14:32:15.018424Z","iopub.status.idle":"2021-11-17T14:32:15.807566Z","shell.execute_reply.started":"2021-11-17T14:32:15.018393Z","shell.execute_reply":"2021-11-17T14:32:15.806731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Date and Time Utilities","metadata":{}},{"cell_type":"markdown","source":"## totimestamp()\n\n- https://www.kaggle.com/cstein06/tutorial-to-the-g-research-crypto-competition?scriptVersionId=78721864&cellId=35","metadata":{}},{"cell_type":"code","source":"# https://www.kaggle.com/cstein06/tutorial-to-the-g-research-crypto-competition?scriptVersionId=78721864&cellId=35\nimport time\n\n# auxiliary function, from datetime to timestamp\ntotimestamp = lambda s: np.int32(time.mktime(datetime.strptime(s, \"%d/%m/%Y\").timetuple()))","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:32:15.809095Z","iopub.execute_input":"2021-11-17T14:32:15.809434Z","iopub.status.idle":"2021-11-17T14:32:15.814981Z","shell.execute_reply.started":"2021-11-17T14:32:15.809388Z","shell.execute_reply":"2021-11-17T14:32:15.814164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Example of How to Use Method","metadata":{}},{"cell_type":"code","source":"totimestamp(\"1/1/2018\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:32:15.815976Z","iopub.execute_input":"2021-11-17T14:32:15.816213Z","iopub.status.idle":"2021-11-17T14:32:15.832463Z","shell.execute_reply.started":"2021-11-17T14:32:15.816176Z","shell.execute_reply":"2021-11-17T14:32:15.831621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"load-data\"></a>\n\n# **<span style=\"color:#d5a500;\">Load Data</span>**","metadata":{"execution":{"iopub.status.busy":"2021-11-13T12:58:22.944747Z","iopub.execute_input":"2021-11-13T12:58:22.945055Z","iopub.status.idle":"2021-11-13T12:58:22.951866Z","shell.execute_reply.started":"2021-11-13T12:58:22.945021Z","shell.execute_reply":"2021-11-13T12:58:22.950559Z"}}},{"cell_type":"markdown","source":"## Datatable\n\nLoads the data faster but I'm not familar with it so I'm still doing to use Pandas too.","metadata":{}},{"cell_type":"code","source":"%%time\n\nimport datatable as dt\n\ndt = dt.fread(data_dir / \"train.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:32:15.836764Z","iopub.execute_input":"2021-11-17T14:32:15.837388Z","iopub.status.idle":"2021-11-17T14:32:44.939242Z","shell.execute_reply.started":"2021-11-17T14:32:15.837339Z","shell.execute_reply":"2021-11-17T14:32:44.938238Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dt","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:32:44.940550Z","iopub.execute_input":"2021-11-17T14:32:44.940795Z","iopub.status.idle":"2021-11-17T14:32:44.946896Z","shell.execute_reply.started":"2021-11-17T14:32:44.940767Z","shell.execute_reply":"2021-11-17T14:32:44.945991Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Load with Pandas","metadata":{}},{"cell_type":"code","source":"%%time\ndtype={'Asset_ID': 'int8', 'Count': 'int32', 'row_id': 'int32', 'Count': 'int32',\n       'Open': 'float32', 'High': 'float32', 'Low': 'float32', 'Close': 'float32',\n       'Volume': 'float32', 'VWAP': 'float32'}\n\n# train_df = pd.read_csv('../input/g-research-crypto-forecasting/train.csv', low_memory=False, parse_dates=['date'], dtype=dtype)\ntrain_df = pd.read_csv( data_dir / \"train.csv\", low_memory=False, parse_dates=True)","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:32:44.948310Z","iopub.execute_input":"2021-11-17T14:32:44.948541Z","iopub.status.idle":"2021-11-17T14:33:26.551948Z","shell.execute_reply.started":"2021-11-17T14:32:44.948515Z","shell.execute_reply":"2021-11-17T14:33:26.551012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:26.553426Z","iopub.execute_input":"2021-11-17T14:33:26.554066Z","iopub.status.idle":"2021-11-17T14:33:26.579883Z","shell.execute_reply.started":"2021-11-17T14:33:26.554025Z","shell.execute_reply":"2021-11-17T14:33:26.578976Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"# Asset Details","metadata":{}},{"cell_type":"code","source":"asset_details = pd.read_csv(data_dir / \"asset_details.csv\")\nasset_details","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:26.581151Z","iopub.execute_input":"2021-11-17T14:33:26.581639Z","iopub.status.idle":"2021-11-17T14:33:26.610373Z","shell.execute_reply.started":"2021-11-17T14:33:26.581598Z","shell.execute_reply":"2021-11-17T14:33:26.609443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Working with Bitcoin","metadata":{}},{"cell_type":"code","source":"bitcoin = train_df[train_df[\"Asset_ID\"] == 1]\nbitcoin.head(3)","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:26.612036Z","iopub.execute_input":"2021-11-17T14:33:26.612333Z","iopub.status.idle":"2021-11-17T14:33:26.952281Z","shell.execute_reply.started":"2021-11-17T14:33:26.612295Z","shell.execute_reply":"2021-11-17T14:33:26.951456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:26.953331Z","iopub.execute_input":"2021-11-17T14:33:26.953521Z","iopub.status.idle":"2021-11-17T14:33:26.970005Z","shell.execute_reply.started":"2021-11-17T14:33:26.953497Z","shell.execute_reply":"2021-11-17T14:33:26.968973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.loc[train_df.High < 14052.3 , \"timestamp\"] # ['timestamp'] #.fromtimestamp(timestamp).strftime(\"%d/%m/%y\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:26.971150Z","iopub.execute_input":"2021-11-17T14:33:26.971735Z","iopub.status.idle":"2021-11-17T14:33:27.216246Z","shell.execute_reply.started":"2021-11-17T14:33:26.971697Z","shell.execute_reply":"2021-11-17T14:33:27.215403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.loc[2, 'timestamp']","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.217603Z","iopub.execute_input":"2021-11-17T14:33:27.217824Z","iopub.status.idle":"2021-11-17T14:33:27.293417Z","shell.execute_reply.started":"2021-11-17T14:33:27.217799Z","shell.execute_reply":"2021-11-17T14:33:27.292643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Unix Date Format Conversion\n\n- https://stackoverflow.com/questions/3682748/converting-unix-timestamp-string-to-readable-date","metadata":{}},{"cell_type":"code","source":"datetime.fromtimestamp(train_df.loc[2, 'timestamp']).strftime(\"%d/%m/%Y %H:%M:%S\") # ","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.297875Z","iopub.execute_input":"2021-11-17T14:33:27.298259Z","iopub.status.idle":"2021-11-17T14:33:27.305082Z","shell.execute_reply.started":"2021-11-17T14:33:27.298217Z","shell.execute_reply":"2021-11-17T14:33:27.304235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin.iloc[2] # ['timestamp'] #.fromtimestamp(timestamp).strftime(\"%d/%m/%y\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.306221Z","iopub.execute_input":"2021-11-17T14:33:27.306984Z","iopub.status.idle":"2021-11-17T14:33:27.320467Z","shell.execute_reply.started":"2021-11-17T14:33:27.306951Z","shell.execute_reply":"2021-11-17T14:33:27.319380Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin.loc[2,'timestamp'] #.fromtimestamp(timestamp).strftime(\"%d/%m/%y\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.322382Z","iopub.execute_input":"2021-11-17T14:33:27.322880Z","iopub.status.idle":"2021-11-17T14:33:27.561502Z","shell.execute_reply.started":"2021-11-17T14:33:27.322841Z","shell.execute_reply":"2021-11-17T14:33:27.560619Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Get 2017 Bitcoin Data","metadata":{}},{"cell_type":"code","source":"totimestamp(\"1/1/2018\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.562803Z","iopub.execute_input":"2021-11-17T14:33:27.563019Z","iopub.status.idle":"2021-11-17T14:33:27.569100Z","shell.execute_reply.started":"2021-11-17T14:33:27.562993Z","shell.execute_reply":"2021-11-17T14:33:27.568048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin_2021 = bitcoin.loc[totimestamp('01/06/2021'):totimestamp('01/07/2021')]\nbitcoin_2020 = bitcoin.loc[totimestamp('01/01/2020'):totimestamp('01/01/2021')]\n","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.570756Z","iopub.execute_input":"2021-11-17T14:33:27.571395Z","iopub.status.idle":"2021-11-17T14:33:27.582360Z","shell.execute_reply.started":"2021-11-17T14:33:27.571342Z","shell.execute_reply":"2021-11-17T14:33:27.581417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin_2020","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.583748Z","iopub.execute_input":"2021-11-17T14:33:27.584013Z","iopub.status.idle":"2021-11-17T14:33:27.601999Z","shell.execute_reply.started":"2021-11-17T14:33:27.583984Z","shell.execute_reply":"2021-11-17T14:33:27.601074Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# datetime.fromtimestamp(btc2017.index[1].timestamp).strftime(\"%d/%m/%y\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.603363Z","iopub.execute_input":"2021-11-17T14:33:27.603704Z","iopub.status.idle":"2021-11-17T14:33:27.609705Z","shell.execute_reply.started":"2021-11-17T14:33:27.603662Z","shell.execute_reply":"2021-11-17T14:33:27.608758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin = bitcoin.set_index(\"timestamp\")\nbitcoin_last7 = bitcoin.iloc[-7:]\nbitcoin_last30 = bitcoin.iloc[-30:]\nbitcoin_last200 = bitcoin.iloc[-200:]","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.611052Z","iopub.execute_input":"2021-11-17T14:33:27.611363Z","iopub.status.idle":"2021-11-17T14:33:27.680690Z","shell.execute_reply.started":"2021-11-17T14:33:27.611321Z","shell.execute_reply":"2021-11-17T14:33:27.679718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin_last7","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.681905Z","iopub.execute_input":"2021-11-17T14:33:27.682149Z","iopub.status.idle":"2021-11-17T14:33:27.698271Z","shell.execute_reply.started":"2021-11-17T14:33:27.682119Z","shell.execute_reply":"2021-11-17T14:33:27.697702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"{bitcoin_last7.iloc[0]['Open']}, {bitcoin_last7.iloc[0]['Close']}\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.699389Z","iopub.execute_input":"2021-11-17T14:33:27.699665Z","iopub.status.idle":"2021-11-17T14:33:27.705532Z","shell.execute_reply.started":"2021-11-17T14:33:27.699627Z","shell.execute_reply":"2021-11-17T14:33:27.704662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# bitcoin_last7.index[0].fromtimestamp(timestamp).strftime(\"%d/%m/%y\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.706613Z","iopub.execute_input":"2021-11-17T14:33:27.707183Z","iopub.status.idle":"2021-11-17T14:33:27.718010Z","shell.execute_reply.started":"2021-11-17T14:33:27.707138Z","shell.execute_reply":"2021-11-17T14:33:27.717109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Last 7 Dates","metadata":{}},{"cell_type":"code","source":"# fromtimestamp(timestamp).strftime(\"%d/%m/%y\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.719094Z","iopub.execute_input":"2021-11-17T14:33:27.719664Z","iopub.status.idle":"2021-11-17T14:33:27.728471Z","shell.execute_reply.started":"2021-11-17T14:33:27.719630Z","shell.execute_reply":"2021-11-17T14:33:27.727815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"datetime.fromtimestamp(train_df.loc[2, 'timestamp']).strftime(\"%d/%m/%Y %H:%M:%S\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.730008Z","iopub.execute_input":"2021-11-17T14:33:27.730258Z","iopub.status.idle":"2021-11-17T14:33:27.745297Z","shell.execute_reply.started":"2021-11-17T14:33:27.730229Z","shell.execute_reply":"2021-11-17T14:33:27.744308Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin.index","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.746416Z","iopub.execute_input":"2021-11-17T14:33:27.746677Z","iopub.status.idle":"2021-11-17T14:33:27.757100Z","shell.execute_reply.started":"2021-11-17T14:33:27.746648Z","shell.execute_reply":"2021-11-17T14:33:27.756472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin_last7.reset_index(inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.758481Z","iopub.execute_input":"2021-11-17T14:33:27.758991Z","iopub.status.idle":"2021-11-17T14:33:27.768298Z","shell.execute_reply.started":"2021-11-17T14:33:27.758946Z","shell.execute_reply":"2021-11-17T14:33:27.767362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin_last7","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.769931Z","iopub.execute_input":"2021-11-17T14:33:27.770177Z","iopub.status.idle":"2021-11-17T14:33:27.791052Z","shell.execute_reply.started":"2021-11-17T14:33:27.770143Z","shell.execute_reply":"2021-11-17T14:33:27.790024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin_last7['Date'] = bitcoin_last7.loc[:,'timestamp'].apply(datetime.fromtimestamp)\nbitcoin_last7","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.792094Z","iopub.execute_input":"2021-11-17T14:33:27.792651Z","iopub.status.idle":"2021-11-17T14:33:27.818123Z","shell.execute_reply.started":"2021-11-17T14:33:27.792601Z","shell.execute_reply":"2021-11-17T14:33:27.817475Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# datetime.fromtimestamp(bitcoin_last7.timestamp).strftime(\"%d/%m/%Y %H:%M:%S\")","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.819257Z","iopub.execute_input":"2021-11-17T14:33:27.820047Z","iopub.status.idle":"2021-11-17T14:33:27.823350Z","shell.execute_reply.started":"2021-11-17T14:33:27.820015Z","shell.execute_reply":"2021-11-17T14:33:27.822727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# bitcoin_last7['date'] = datetime.fromtimestamp(bitcoin_last7.timestamp).strftime(\"%d/%m/%Y %H:%M:%S\")\n# bitcoin_last7.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.824388Z","iopub.execute_input":"2021-11-17T14:33:27.825062Z","iopub.status.idle":"2021-11-17T14:33:27.835055Z","shell.execute_reply.started":"2021-11-17T14:33:27.825023Z","shell.execute_reply":"2021-11-17T14:33:27.834252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Candlestick Charts\n\n## References\n\n- https://www.investopedia.com/trading/candlestick-charting-what-is-it/\n- https://www.investopedia.com/articles/active-trading/092315/5-most-powerful-candlestick-patterns.asp\n- https://en.wikipedia.org/wiki/Candlestick_pattern","metadata":{}},{"cell_type":"code","source":"fig = go.Figure(data=[go.Candlestick(x = bitcoin_last7.Date, \n                                     open=bitcoin_last7['Open'],\n                                     high=bitcoin_last7['High'], \n                                     low=bitcoin_last7['Low'], \n                                     close=bitcoin_last7['Close'])])\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.836194Z","iopub.execute_input":"2021-11-17T14:33:27.836390Z","iopub.status.idle":"2021-11-17T14:33:27.972868Z","shell.execute_reply.started":"2021-11-17T14:33:27.836365Z","shell.execute_reply":"2021-11-17T14:33:27.972054Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Last 30 Dates","metadata":{}},{"cell_type":"code","source":"fig = go.Figure(data=[go.Candlestick(x=bitcoin_last30.index, \n                                     open=bitcoin_last30['Open'],\n                                     high=bitcoin_last30['High'], \n                                     low=bitcoin_last30['Low'], \n                                     close=bitcoin_last30['Close'])])\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.974057Z","iopub.execute_input":"2021-11-17T14:33:27.974295Z","iopub.status.idle":"2021-11-17T14:33:27.987364Z","shell.execute_reply.started":"2021-11-17T14:33:27.974267Z","shell.execute_reply":"2021-11-17T14:33:27.986691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin.index[0].astype('datetime64[s]')","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.988926Z","iopub.execute_input":"2021-11-17T14:33:27.989541Z","iopub.status.idle":"2021-11-17T14:33:27.996259Z","shell.execute_reply.started":"2021-11-17T14:33:27.989495Z","shell.execute_reply":"2021-11-17T14:33:27.995400Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"begin_bitcoin = bitcoin.index[0].astype('datetime64[s]')\nend_bitcoin = bitcoin.index[-1].astype('datetime64[s]')\n\nprint('Bitcoin data goes from ', begin_bitcoin, 'to ', end_bitcoin)","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:27.997791Z","iopub.execute_input":"2021-11-17T14:33:27.998265Z","iopub.status.idle":"2021-11-17T14:33:28.006606Z","shell.execute_reply.started":"2021-11-17T14:33:27.998222Z","shell.execute_reply":"2021-11-17T14:33:28.005970Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin_last30.Close.plot();","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:28.007673Z","iopub.execute_input":"2021-11-17T14:33:28.008142Z","iopub.status.idle":"2021-11-17T14:33:28.427423Z","shell.execute_reply.started":"2021-11-17T14:33:28.008112Z","shell.execute_reply":"2021-11-17T14:33:28.426541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# parse_dates=[['Date','Time']]\nplt.figure(figsize=(12,8))\nplt.plot(bitcoin_last30.Low)\nplt.plot(bitcoin_last30.High)\nplt.xlim([0,0.5])\n# xlim(0,0.5)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:28.428970Z","iopub.execute_input":"2021-11-17T14:33:28.429470Z","iopub.status.idle":"2021-11-17T14:33:28.633288Z","shell.execute_reply.started":"2021-11-17T14:33:28.429426Z","shell.execute_reply":"2021-11-17T14:33:28.632344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Open/High/Low/Close Chart","metadata":{}},{"cell_type":"code","source":" ohlc = go.Figure(data = [go.Ohlc(x=bitcoin_last7.index, \n                                               open = bitcoin_last7[('Open')], \n                                               high = bitcoin_last7[('High')], \n                                               low = bitcoin_last7[('Low')], \n                                               close = bitcoin_last7[('Close')])])\nohlc.update_xaxes(title_text = 'Time',\n                             rangeslider_visible = False)","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:28.635073Z","iopub.execute_input":"2021-11-17T14:33:28.635588Z","iopub.status.idle":"2021-11-17T14:33:28.685327Z","shell.execute_reply.started":"2021-11-17T14:33:28.635524Z","shell.execute_reply":"2021-11-17T14:33:28.684326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# f = plt.figure(figsize=(7,8))\n\n# ax = f.add_subplot(211)\n# plt.plot(btc_mini_2021['Close'], label='btc')\n# plt.legend()\n# plt.xlabel('Time')\n# plt.ylabel('Bitcoin Close')\n\n# ax2 = f.add_subplot(212)\n# ax2.plot(eth_mini_2021['Close'], color='red', label='eth')\n# plt.legend()\n# plt.xlabel('Time')\n# plt.ylabel('Ethereum Close')\n\n# plt.tight_layout()\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-17T14:33:28.686393Z","iopub.execute_input":"2021-11-17T14:33:28.686648Z","iopub.status.idle":"2021-11-17T14:33:28.690771Z","shell.execute_reply.started":"2021-11-17T14:33:28.686620Z","shell.execute_reply":"2021-11-17T14:33:28.689855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Technical Analysis\n\nTraditional Stock Trading Analysis applied to Crypto\n\n- MACD\n- Moving Average\n  - SMA\n  - 50 Day MA\n  - 200 Day MA\n- Volatility (Variance)\n  - Bollinger Bands- Bollinger Bands\n- Momentum Indicators\n  - Momentum Rate Of Change (ROCMomentum Rate Of Change (ROC\n  - RSI- RSI\n  - Stochastic Oscillator MomentumStochastic Oscillator Momentum","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}