{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nfrom datetime import datetime\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-06-12T14:46:09.596853Z","iopub.execute_input":"2022-06-12T14:46:09.597370Z","iopub.status.idle":"2022-06-12T14:46:09.606054Z","shell.execute_reply.started":"2022-06-12T14:46:09.597294Z","shell.execute_reply":"2022-06-12T14:46:09.605285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_folder = \"../input/g-research-crypto-forecasting/\"\n!ls $data_folder","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:46:09.625926Z","iopub.execute_input":"2022-06-12T14:46:09.626808Z","iopub.status.idle":"2022-06-12T14:46:10.396167Z","shell.execute_reply.started":"2022-06-12T14:46:09.626756Z","shell.execute_reply":"2022-06-12T14:46:10.395180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"crypto_df = pd.read_csv(data_folder + 'train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:46:10.398632Z","iopub.execute_input":"2022-06-12T14:46:10.399326Z","iopub.status.idle":"2022-06-12T14:46:52.819418Z","shell.execute_reply.started":"2022-06-12T14:46:10.399275Z","shell.execute_reply":"2022-06-12T14:46:52.818443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"asset_details = pd.read_csv(data_folder + 'asset_details.csv')\n","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:46:52.820649Z","iopub.execute_input":"2022-06-12T14:46:52.821039Z","iopub.status.idle":"2022-06-12T14:46:52.829729Z","shell.execute_reply.started":"2022-06-12T14:46:52.820984Z","shell.execute_reply":"2022-06-12T14:46:52.828714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"crypto_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:46:52.832050Z","iopub.execute_input":"2022-06-12T14:46:52.832465Z","iopub.status.idle":"2022-06-12T14:46:52.857206Z","shell.execute_reply.started":"2022-06-12T14:46:52.832431Z","shell.execute_reply":"2022-06-12T14:46:52.856269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"btc = crypto_df.loc[crypto_df.Asset_ID == asset_details.loc[asset_details.Asset_Name==\"Bitcoin\"].iloc[0, 0]]\nbtc = btc.set_index(\"timestamp\")\nbtc_mini = btc.iloc[-200:] #last 200 minutes\n\nimport plotly.graph_objects as go\n\nfig = go.Figure(data=[go.Candlestick(x=btc_mini.index, \n                    open=btc_mini['Open'],\n                    high=btc_mini['High'], \n                    low=btc_mini['Low'], \n                    close=btc_mini['Close'])])\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:48:02.403743Z","iopub.execute_input":"2022-06-12T14:48:02.404179Z","iopub.status.idle":"2022-06-12T14:48:02.900950Z","shell.execute_reply.started":"2022-06-12T14:48:02.404145Z","shell.execute_reply":"2022-06-12T14:48:02.899837Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"beg_btc = btc.index[0].astype('datetime64[s]')\nend_btc = btc.index[-1].astype('datetime64[s]')\n\nprint('BTC data goes from ', beg_btc, 'to ', end_btc)","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:48:29.538190Z","iopub.execute_input":"2022-06-12T14:48:29.538867Z","iopub.status.idle":"2022-06-12T14:48:29.547227Z","shell.execute_reply.started":"2022-06-12T14:48:29.538815Z","shell.execute_reply":"2022-06-12T14:48:29.545935Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"target missed data","metadata":{}},{"cell_type":"code","source":"btc.info(show_counts =True)","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:48:29.765313Z","iopub.execute_input":"2022-06-12T14:48:29.766919Z","iopub.status.idle":"2022-06-12T14:48:29.825230Z","shell.execute_reply.started":"2022-06-12T14:48:29.766843Z","shell.execute_reply":"2022-06-12T14:48:29.824063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"btc.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:48:30.137335Z","iopub.execute_input":"2022-06-12T14:48:30.137901Z","iopub.status.idle":"2022-06-12T14:48:30.184622Z","shell.execute_reply.started":"2022-06-12T14:48:30.137856Z","shell.execute_reply":"2022-06-12T14:48:30.183467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"series missed rows ","metadata":{}},{"cell_type":"code","source":"(btc.index[1:]-btc.index[:-1]).value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-06-12T14:48:40.179928Z","iopub.execute_input":"2022-06-12T14:48:40.181259Z","iopub.status.idle":"2022-06-12T14:48:40.207869Z","shell.execute_reply.started":"2022-06-12T14:48:40.181212Z","shell.execute_reply":"2022-06-12T14:48:40.206738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"*   **Count**: Total number of trades in the time interval (last minute).\n*   **Volume**:\tQuantity of asset bought or sold, displayed in base currency USD.\n*   **VWAP**: The average price of the asset over the time interval, weighted by volume. VWAP is an aggregated form of trade data. ","metadata":{}},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\nf = plt.figure(figsize=(15,8))\n\nax1 = f.add_subplot(311)\nplt.plot(btc['VWAP'], label='BTC')\nplt.legend()\nplt.xlabel('Time')\nplt.ylabel('VWAP-Price')\n\nax2 = f.add_subplot(312)\nplt.plot(btc['Volume'], label='BTC', color='r')\nplt.legend()\nplt.xlabel('Time')\nplt.ylabel(\"Volume(USD)\")\n\nax3 = f.add_subplot(313)\nplt.plot(btc['Count'], label='BTC', color='g')\nplt.legend()\nplt.xlabel('Time')\nplt.ylabel(\"#Trades\")\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-06-12T15:05:55.186998Z","iopub.execute_input":"2022-06-12T15:05:55.187465Z","iopub.status.idle":"2022-06-12T15:06:00.333973Z","shell.execute_reply.started":"2022-06-12T15:05:55.187424Z","shell.execute_reply":"2022-06-12T15:06:00.333313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"we can see there was a market maker(since few no. of traders) who trade with big capital to get the spark","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}