{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":84493,"databundleVersionId":9871156,"sourceType":"competition"}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\n\nimport pandas as pd\nimport polars as pl\n\ndf = pd.read_parquet('/kaggle/input/jane-street-real-time-market-data-forecasting/train.parquet/partition_id=0/part-0.parquet')\n\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:24:27.685630Z","iopub.execute_input":"2024-11-01T01:24:27.686206Z","iopub.status.idle":"2024-11-01T01:24:32.620201Z","shell.execute_reply.started":"2024-11-01T01:24:27.686137Z","shell.execute_reply":"2024-11-01T01:24:32.616896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.describe()","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'Number of rows in 1 partition: {len(df.index)}')\nprint(f'Number of columns: {len(df.columns)}')","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:24:32.623447Z","iopub.execute_input":"2024-11-01T01:24:32.625279Z","iopub.status.idle":"2024-11-01T01:24:32.633585Z","shell.execute_reply.started":"2024-11-01T01:24:32.625187Z","shell.execute_reply":"2024-11-01T01:24:32.632152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df.columns)","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:24:32.635253Z","iopub.execute_input":"2024-11-01T01:24:32.635754Z","iopub.status.idle":"2024-11-01T01:24:32.652683Z","shell.execute_reply.started":"2024-11-01T01:24:32.635698Z","shell.execute_reply":"2024-11-01T01:24:32.651277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\nfor i in range(92):\n    df.iloc[:, i].hist() # Select the first column by index\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:24:32.656178Z","iopub.execute_input":"2024-11-01T01:24:32.656927Z","iopub.status.idle":"2024-11-01T01:24:55.991455Z","shell.execute_reply.started":"2024-11-01T01:24:32.656885Z","shell.execute_reply":"2024-11-01T01:24:55.990098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import gc \n\nfor i in range(9):\n    fig, ax = plt.subplots(figsize=(15, 5))\n    balance= pd.Series(df[f'responder_{i}']).cumsum()\n    ax.set_xlabel (\"Trade\", fontsize=18)\n    ax.set_ylabel (f\"Responder {i}\", fontsize=18);\n    balance.plot(lw=3);\n    del balance\n    gc.collect();","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:24:55.993631Z","iopub.execute_input":"2024-11-01T01:24:55.994137Z","iopub.status.idle":"2024-11-01T01:25:02.739634Z","shell.execute_reply.started":"2024-11-01T01:24:55.994080Z","shell.execute_reply":"2024-11-01T01:25:02.738428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# ['date_id', 'time_id', 'symbol_id', 'weight', 'feature_00']\ndf['date_id'].unique()","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:25:02.741089Z","iopub.execute_input":"2024-11-01T01:25:02.741439Z","iopub.status.idle":"2024-11-01T01:25:02.762841Z","shell.execute_reply.started":"2024-11-01T01:25:02.741405Z","shell.execute_reply":"2024-11-01T01:25:02.761570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['time_id'].unique()","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:25:02.764416Z","iopub.execute_input":"2024-11-01T01:25:02.764901Z","iopub.status.idle":"2024-11-01T01:25:02.786190Z","shell.execute_reply.started":"2024-11-01T01:25:02.764850Z","shell.execute_reply":"2024-11-01T01:25:02.785012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['symbol_id'].unique()","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:25:02.788018Z","iopub.execute_input":"2024-11-01T01:25:02.788422Z","iopub.status.idle":"2024-11-01T01:25:02.809856Z","shell.execute_reply.started":"2024-11-01T01:25:02.788382Z","shell.execute_reply":"2024-11-01T01:25:02.808700Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['weight'].unique()","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:25:02.811201Z","iopub.execute_input":"2024-11-01T01:25:02.811606Z","iopub.status.idle":"2024-11-01T01:25:02.839392Z","shell.execute_reply.started":"2024-11-01T01:25:02.811568Z","shell.execute_reply":"2024-11-01T01:25:02.838131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"moving_average = df.rolling(\n    window=169,       # 169-day window\n    center=True,      # puts the average at the center of the window\n).mean() ","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:25:02.843086Z","iopub.execute_input":"2024-11-01T01:25:02.844180Z","iopub.status.idle":"2024-11-01T01:25:07.797146Z","shell.execute_reply.started":"2024-11-01T01:25:02.844130Z","shell.execute_reply":"2024-11-01T01:25:07.795826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2024-11-01T01:25:14.499982Z","iopub.execute_input":"2024-11-01T01:25:14.500377Z","iopub.status.idle":"2024-11-01T01:25:14.528351Z","shell.execute_reply.started":"2024-11-01T01:25:14.500336Z","shell.execute_reply":"2024-11-01T01:25:14.527017Z"},"trusted":true},"execution_count":null,"outputs":[]}]}