{"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","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-11-04T04:30:32.258371Z","iopub.execute_input":"2021-11-04T04:30:32.258957Z","iopub.status.idle":"2021-11-04T04:30:32.287472Z","shell.execute_reply.started":"2021-11-04T04:30:32.258814Z","shell.execute_reply":"2021-11-04T04:30:32.286425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = pd.read_csv('../input/g-research-crypto-forecasting/train.csv')\nasset_data = pd.read_csv('../input/g-research-crypto-forecasting/asset_details.csv')","metadata":{"execution":{"iopub.status.busy":"2021-11-04T04:30:32.289117Z","iopub.execute_input":"2021-11-04T04:30:32.289879Z","iopub.status.idle":"2021-11-04T04:31:35.858462Z","shell.execute_reply.started":"2021-11-04T04:30:32.289835Z","shell.execute_reply":"2021-11-04T04:31:35.857735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## NA Values check","metadata":{}},{"cell_type":"code","source":"# Percentage of NA vlues in each column\n100*train_data.isna().sum()/train_data.shape[0]","metadata":{"execution":{"iopub.status.busy":"2021-11-04T04:31:35.860114Z","iopub.execute_input":"2021-11-04T04:31:35.860389Z","iopub.status.idle":"2021-11-04T04:31:36.319759Z","shell.execute_reply.started":"2021-11-04T04:31:35.860355Z","shell.execute_reply":"2021-11-04T04:31:36.318911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# We can't work with NA target. These entries shall be removed\ntrain_data.dropna(subset=['Target'],inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-11-04T04:31:36.322197Z","iopub.execute_input":"2021-11-04T04:31:36.323016Z","iopub.status.idle":"2021-11-04T04:31:37.640048Z","shell.execute_reply.started":"2021-11-04T04:31:36.322968Z","shell.execute_reply":"2021-11-04T04:31:37.639358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Recheck NA values.\n100*train_data.isna().sum()/train_data.shape[0]","metadata":{"execution":{"iopub.status.busy":"2021-11-04T04:31:37.641232Z","iopub.execute_input":"2021-11-04T04:31:37.641627Z","iopub.status.idle":"2021-11-04T04:31:38.067119Z","shell.execute_reply.started":"2021-11-04T04:31:37.641594Z","shell.execute_reply":"2021-11-04T04:31:38.066302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Unique Timestamps","metadata":{}},{"cell_type":"code","source":"n_unique_ts = len(train_data.timestamp.unique())\nprint(f'Number of unique timestamps {n_unique_ts}')\nprint(f'Avearage number of rows per each timestamp {train_data.shape[0]/n_unique_ts}')","metadata":{"execution":{"iopub.status.busy":"2021-11-04T04:31:38.068581Z","iopub.execute_input":"2021-11-04T04:31:38.068803Z","iopub.status.idle":"2021-11-04T04:31:38.567512Z","shell.execute_reply.started":"2021-11-04T04:31:38.068775Z","shell.execute_reply":"2021-11-04T04:31:38.566228Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Unique Assets","metadata":{}},{"cell_type":"code","source":"n_unique_as = len(train_data.Asset_ID.unique())\nprint(f'Number of unique assets {n_unique_as}')\nprint(f'Avg Number of rows per each asset {train_data.shape[0]/n_unique_as}')","metadata":{"execution":{"iopub.status.busy":"2021-11-04T04:31:38.569000Z","iopub.execute_input":"2021-11-04T04:31:38.569926Z","iopub.status.idle":"2021-11-04T04:31:38.709582Z","shell.execute_reply.started":"2021-11-04T04:31:38.569879Z","shell.execute_reply":"2021-11-04T04:31:38.708549Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Average number of trades and volume happened at each timestamp","metadata":{}},{"cell_type":"code","source":"print(f'Avg Number of trades {train_data.Count.mean()}')\nprint(f'Avg Volume of trades {train_data.Volume.mean()}')","metadata":{"execution":{"iopub.status.busy":"2021-11-04T04:31:38.711016Z","iopub.execute_input":"2021-11-04T04:31:38.711264Z","iopub.status.idle":"2021-11-04T04:31:38.796385Z","shell.execute_reply.started":"2021-11-04T04:31:38.711234Z","shell.execute_reply":"2021-11-04T04:31:38.795426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Asset Details","metadata":{}},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport gc\nfor i, d in train_data.groupby('Asset_ID'):\n    plt.figure(figsize=[16,3])\n    plt.subplot(1,4,1)\n    plt.plot(d.timestamp, d.Open, d.timestamp, d.Close, d.timestamp, d.VWAP)\n    plt.legend(['Open','Close', 'VWAP'])\n    plt.xlabel('Time stamp')\n    plt.ylabel('USD')\n    plt.grid()\n    plt.subplot(1,4,2)\n    plt.plot(d.timestamp, d.Volume)\n    plt.ylabel('Volume')\n    plt.xlabel('Time stamp')\n    plt.grid()\n    plt.subplot(1,4,3)\n    plt.plot(d.timestamp, d.High, d.timestamp, d.Low)\n    plt.legend(['High', 'Low'])\n    plt.ylabel('USD')\n    plt.xlabel('Time stamp')\n    plt.grid()\n    plt.subplot(1,4,4)\n    plt.plot(d.timestamp, d.Target)\n    plt.ylabel('Target')\n    plt.xlabel('Time stamp')\n    plt.grid()\n    plt.suptitle(asset_data[asset_data.Asset_ID==i]['Asset_Name'].tolist()[0])    \n    plt.tight_layout()\n    plt.show()\n    plt.close('all')\n    gc.collect()","metadata":{"execution":{"iopub.status.busy":"2021-11-04T05:15:02.563849Z","iopub.execute_input":"2021-11-04T05:15:02.564244Z","iopub.status.idle":"2021-11-04T05:18:22.112946Z","shell.execute_reply.started":"2021-11-04T05:15:02.564204Z","shell.execute_reply":"2021-11-04T05:18:22.111759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}