{"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":"code","source":"!pip -q install mplfinance\nimport mplfinance as mpf","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-11-09T08:36:34.868725Z","iopub.execute_input":"2021-11-09T08:36:34.869250Z","iopub.status.idle":"2021-11-09T08:36:45.950264Z","shell.execute_reply.started":"2021-11-09T08:36:34.869139Z","shell.execute_reply":"2021-11-09T08:36:45.949216Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom datetime import date","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:36:45.952184Z","iopub.execute_input":"2021-11-09T08:36:45.952471Z","iopub.status.idle":"2021-11-09T08:36:45.957796Z","shell.execute_reply.started":"2021-11-09T08:36:45.952430Z","shell.execute_reply":"2021-11-09T08:36:45.956953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"../input/g-research-crypto-forecasting/train.csv\")\nasset_details = pd.read_csv(\"../input/g-research-crypto-forecasting/asset_details.csv\")\n\nmapping = dict(asset_details[['Asset_ID', 'Asset_Name']].values)\ntrain[\"Asset name\"] = train[\"Asset_ID\"].map(mapping)","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:36:45.959307Z","iopub.execute_input":"2021-11-09T08:36:45.961176Z","iopub.status.idle":"2021-11-09T08:37:47.207963Z","shell.execute_reply.started":"2021-11-09T08:36:45.961126Z","shell.execute_reply":"2021-11-09T08:37:47.207126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.head())\nprint(asset_details.head())\nprint(mapping)","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:47.210292Z","iopub.execute_input":"2021-11-09T08:37:47.210636Z","iopub.status.idle":"2021-11-09T08:37:47.229919Z","shell.execute_reply.started":"2021-11-09T08:37:47.210590Z","shell.execute_reply":"2021-11-09T08:37:47.228742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin = train.query(\"Asset_ID == 1\").reset_index(drop = True)\nbitcoin['timestamp'] = pd.to_datetime(bitcoin['timestamp'], unit='s')\nbitcoin = bitcoin.set_index('timestamp')","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:47.233785Z","iopub.execute_input":"2021-11-09T08:37:47.234495Z","iopub.status.idle":"2021-11-09T08:37:47.959066Z","shell.execute_reply.started":"2021-11-09T08:37:47.234461Z","shell.execute_reply":"2021-11-09T08:37:47.958067Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:47.960414Z","iopub.execute_input":"2021-11-09T08:37:47.960645Z","iopub.status.idle":"2021-11-09T08:37:47.989958Z","shell.execute_reply.started":"2021-11-09T08:37:47.960618Z","shell.execute_reply":"2021-11-09T08:37:47.989351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"wednesday_morning = bitcoin.loc['2021-04-14 05:45:00':'2021-04-14 07:00:00']","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:47.991045Z","iopub.execute_input":"2021-11-09T08:37:47.991379Z","iopub.status.idle":"2021-11-09T08:37:48.036588Z","shell.execute_reply.started":"2021-11-09T08:37:47.991341Z","shell.execute_reply":"2021-11-09T08:37:48.035851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mpf.plot(wednesday_morning, # the dataframe containing the OHLC (Open, High, Low and Close) data\n         type='candle', # use candlesticks \n         volume=True, # also show the volume\n         mav=(3,6,9), # use three different moving averages\n         figratio=(3,1), # set the ratio of the figure\n         style='yahoo',  # choose the yahoo style\n         title='Bitcoin on Wednesday morning');","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:48.037810Z","iopub.execute_input":"2021-11-09T08:37:48.038164Z","iopub.status.idle":"2021-11-09T08:37:48.724604Z","shell.execute_reply.started":"2021-11-09T08:37:48.038135Z","shell.execute_reply":"2021-11-09T08:37:48.723708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"october_16 = bitcoin.loc['2019-10-16 06:00:00':'2019-10-16 18:30:00']\nmpf.plot(october_16, # the dataframe containing the OHLC (Open, High, Low and Close) data\n         type='candle', # use candlesticks \n         volume=True, # also show the volume\n         mav=(3,6,9), # use three different moving averages\n         figratio=(3,1), # set the ratio of the figure\n         style='yahoo',  # choose the yahoo style\n         title='2019-10-16: Bitcoin Price Falls Under $8K');","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:48.726774Z","iopub.execute_input":"2021-11-09T08:37:48.727110Z","iopub.status.idle":"2021-11-09T08:37:50.056794Z","shell.execute_reply.started":"2021-11-09T08:37:48.727076Z","shell.execute_reply":"2021-11-09T08:37:50.056069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"october_23 = bitcoin.loc['2019-10-23 10:30:00':'2019-10-23 17:00:00']\nmpf.plot(october_23, # the dataframe containing the OHLC (Open, High, Low and Close) data\n         type='candle', # use candlesticks \n         volume=True, # also show the volume\n         mav=(3,6,9), # use three different moving averages\n         figratio=(3,1), # set the ratio of the figure\n         style='yahoo',  # choose the yahoo style\n         title='2019-10-23: Bitcoin Price Crashed');","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:50.058011Z","iopub.execute_input":"2021-11-09T08:37:50.059017Z","iopub.status.idle":"2021-11-09T08:37:50.991330Z","shell.execute_reply.started":"2021-11-09T08:37:50.058878Z","shell.execute_reply":"2021-11-09T08:37:50.990712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!mkdir /kaggle/output","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:50.992346Z","iopub.execute_input":"2021-11-09T08:37:50.992773Z","iopub.status.idle":"2021-11-09T08:37:51.756608Z","shell.execute_reply.started":"2021-11-09T08:37:50.992737Z","shell.execute_reply":"2021-11-09T08:37:51.755340Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"wednesday_morning.to_csv(\"/kaggle/output/wednesday_morning_submission.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:37:51.758844Z","iopub.execute_input":"2021-11-09T08:37:51.759211Z","iopub.status.idle":"2021-11-09T08:37:51.771513Z","shell.execute_reply.started":"2021-11-09T08:37:51.759164Z","shell.execute_reply":"2021-11-09T08:37:51.770418Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"october_16.to_csv(\"/kaggle/output/october_16_submission.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:38:40.715338Z","iopub.execute_input":"2021-11-09T08:38:40.715666Z","iopub.status.idle":"2021-11-09T08:38:40.728402Z","shell.execute_reply.started":"2021-11-09T08:38:40.715624Z","shell.execute_reply":"2021-11-09T08:38:40.727499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"october_23.to_csv(\"/kaggle/output/october_23_submission.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2021-11-09T08:39:05.100285Z","iopub.execute_input":"2021-11-09T08:39:05.100664Z","iopub.status.idle":"2021-11-09T08:39:05.114454Z","shell.execute_reply.started":"2021-11-09T08:39:05.100610Z","shell.execute_reply":"2021-11-09T08:39:05.113520Z"},"trusted":true},"execution_count":null,"outputs":[]}]}