{"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":"### Correlograms of 14 cryptocurrencies using the very last day of data\nIn this short notebook we shall plot the [correlograms](https://en.wikipedia.org/wiki/Correlogram), using pandas [autocorrelation_plot](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.plotting.autocorrelation_plot.html), for the last day for each of the 14 cryptocurrencies provided in the dataset associated with the kaggle [G-Research Crypto Forecasting ](https://www.kaggle.com/c/g-research-crypto-forecasting) competition.","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\nimport matplotlib.pyplot as plt\n#plt.style.use('fivethirtyeight')\nplt.rcParams.update({'font.size': 12})\nplt.rcParams[\"figure.figsize\"] = (16, 5)\nfrom datetime import date\n\n# read in the data\ntrain = pd.read_csv(\"../input/g-research-crypto-forecasting/train.csv\")\nasset_details = pd.read_csv(\"../input/g-research-crypto-forecasting/asset_details.csv\")\ntrain['timestamp'] = pd.to_datetime(train['timestamp'], unit='s')\ntrain = train.set_index('timestamp')\nmapping = dict(asset_details[['Asset_ID', 'Asset_Name']].values)\ntrain[\"Asset_name\"] = train[\"Asset_ID\"].map(mapping)\ncryptocurrencies = asset_details['Asset_Name'].unique()\n\n# extract the last day of data\nlast_day = train.loc['2021-09-20 00:00:00':'2021-09-21 00:00:00']\n\nfor cryptocurrency in cryptocurrencies:\n    df = last_day.query('Asset_name == @cryptocurrency ')\n    diff_train_data_close = df['Close'].diff()\n    # drop the initial nan\n    diff_train_data_close = diff_train_data_close.dropna()\n    # now for the autocorrelation plots\n    pd.plotting.autocorrelation_plot(diff_train_data_close)\n    plt.title(cryptocurrency)\n    plt.show();","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-11-13T13:04:53.714612Z","iopub.execute_input":"2021-11-13T13:04:53.715340Z","iopub.status.idle":"2021-11-13T13:06:00.699666Z","shell.execute_reply.started":"2021-11-13T13:04:53.715194Z","shell.execute_reply":"2021-11-13T13:06:00.698611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We are seeing very little in the way of autocorrelation at any value of lag, thus we are potentially dealing with data similar to that created by a [random walk](https://en.wikipedia.org/wiki/Random_walk).\n### Related reading\n* [Eugene F. Fama \"*Random Walks in Stock Market Prices*\", Financial Analysts Journal **vol. 21** pp. 55-59 (1965)](https://doi.org/10.2469/faj.v21.n5.55)","metadata":{}}]}