{"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":"import numpy as np \nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom datetime import date","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-11-07T08:11:37.143253Z","iopub.execute_input":"2021-11-07T08:11:37.144070Z","iopub.status.idle":"2021-11-07T08:11:37.173452Z","shell.execute_reply.started":"2021-11-07T08:11:37.143961Z","shell.execute_reply":"2021-11-07T08:11:37.172182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip -q install mplfinance\nimport mplfinance as mpf","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-output":true,"execution":{"iopub.status.busy":"2021-11-07T08:11:52.270373Z","iopub.execute_input":"2021-11-07T08:11:52.270798Z","iopub.status.idle":"2021-11-07T08:12:04.776607Z","shell.execute_reply.started":"2021-11-07T08:11:52.270759Z","shell.execute_reply":"2021-11-07T08:12:04.775507Z"},"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-07T08:12:46.203478Z","iopub.execute_input":"2021-11-07T08:12:46.203799Z","iopub.status.idle":"2021-11-07T08:13:48.372605Z","shell.execute_reply.started":"2021-11-07T08:12:46.203770Z","shell.execute_reply":"2021-11-07T08:13:48.371601Z"},"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-07T08:13:56.607003Z","iopub.execute_input":"2021-11-07T08:13:56.607308Z","iopub.status.idle":"2021-11-07T08:13:56.626036Z","shell.execute_reply.started":"2021-11-07T08:13:56.607266Z","shell.execute_reply":"2021-11-07T08:13:56.624798Z"},"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-07T08:14:09.896465Z","iopub.execute_input":"2021-11-07T08:14:09.896762Z","iopub.status.idle":"2021-11-07T08:14:10.416826Z","shell.execute_reply.started":"2021-11-07T08:14:09.896730Z","shell.execute_reply":"2021-11-07T08:14:10.415945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bitcoin","metadata":{"execution":{"iopub.status.busy":"2021-11-07T08:14:19.655934Z","iopub.execute_input":"2021-11-07T08:14:19.656640Z","iopub.status.idle":"2021-11-07T08:14:19.684495Z","shell.execute_reply.started":"2021-11-07T08:14:19.656596Z","shell.execute_reply":"2021-11-07T08:14:19.683639Z"},"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-07T08:14:28.060757Z","iopub.execute_input":"2021-11-07T08:14:28.061196Z","iopub.status.idle":"2021-11-07T08:14:28.108177Z","shell.execute_reply.started":"2021-11-07T08:14:28.061165Z","shell.execute_reply":"2021-11-07T08:14:28.107419Z"},"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-07T08:14:37.252449Z","iopub.execute_input":"2021-11-07T08:14:37.252747Z","iopub.status.idle":"2021-11-07T08:14:37.963267Z","shell.execute_reply.started":"2021-11-07T08:14:37.252713Z","shell.execute_reply":"2021-11-07T08:14:37.962460Z"},"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":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-11-07T08:14:47.430259Z","iopub.execute_input":"2021-11-07T08:14:47.430833Z","iopub.status.idle":"2021-11-07T08:14:48.803022Z","shell.execute_reply.started":"2021-11-07T08:14:47.430798Z","shell.execute_reply":"2021-11-07T08:14:48.802120Z"},"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":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-11-07T08:15:07.701983Z","iopub.execute_input":"2021-11-07T08:15:07.702260Z","iopub.status.idle":"2021-11-07T08:15:08.645268Z","shell.execute_reply.started":"2021-11-07T08:15:07.702230Z","shell.execute_reply":"2021-11-07T08:15:08.644377Z"},"trusted":true},"execution_count":null,"outputs":[]}]}