diff --git a/notebooks/options-historical-test5.ipynb b/notebooks/options-historical-test5.ipynb index 152e344..7580364 100644 --- a/notebooks/options-historical-test5.ipynb +++ b/notebooks/options-historical-test5.ipynb @@ -11,7 +11,7 @@ "output_type": "stream", "text": [ "INFO: Pandarallel will run on 12 workers.\n", - "INFO: Pandarallel will use standard multiprocessing data transfer (pipe) to transfer data between the main process and workers.\n" + "INFO: Pandarallel will use Memory file system to transfer data between the main process and workers.\n" ] } ], @@ -36,6 +36,643 @@ "data_directory = \"data/spy-options-data-2020-2022/\"" ] }, + { + "cell_type": "code", + "execution_count": 4, + "id": "7eb118a6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + " | QUOTE_UNIXTIME | \n", + "QUOTE_TIME_HOURS | \n", + "UNDERLYING_LAST | \n", + "EXPIRE_UNIX | \n", + "DTE | \n", + "C_DELTA | \n", + "C_GAMMA | \n", + "C_VEGA | \n", + "C_THETA | \n", + "C_RHO | \n", + "C_IV | \n", + "C_VOLUME | \n", + "C_LAST | \n", + "C_BID | \n", + "C_ASK | \n", + "STRIKE | \n", + "P_BID | \n", + "P_ASK | \n", + "P_LAST | \n", + "P_DELTA | \n", + "P_GAMMA | \n", + "P_VEGA | \n", + "P_THETA | \n", + "P_RHO | \n", + "P_IV | \n", + "P_VOLUME | \n", + "STRIKE_DISTANCE | \n", + "STRIKE_DISTANCE_PCT | \n", + "OPTION_ID | \n", + "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2455495 | \n", + "2020-01-03 00:00:00+00:00 | \n", + "16.0 | \n", + "324.87 | \n", + "2020-01-03 21:00:00+00:00 | \n", + "1.0 | \n", + "1.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "-0.00041 | \n", + "0.01423 | \n", + "NaN | \n", + "1.0 | \n", + "53.48 | \n", + "64.56 | \n", + "64.76 | \n", + "260.0 | \n", + "0.00 | \n", + "0.00 | \n", + "0.03 | \n", + "-0.00049 | \n", + "0.00016 | \n", + "0.00057 | \n", + "-0.00476 | \n", + "0.00000 | \n", + "0.96296 | \n", + "NaN | \n", + "64.9 | \n", + "0.200 | \n", + "-16219963448717015 | \n", + "
2455496 | \n", + "2020-01-03 00:00:00+00:00 | \n", + "16.0 | \n", + "324.87 | \n", + "2020-01-03 21:00:00+00:00 | \n", + "1.0 | \n", + "1.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "0.01476 | \n", + "NaN | \n", + "NaN | \n", + "0.00 | \n", + "59.49 | \n", + "59.73 | \n", + "265.0 | \n", + "0.00 | \n", + "0.02 | \n", + "0.01 | \n", + "-0.00086 | \n", + "0.00017 | \n", + "0.00097 | \n", + "-0.00515 | \n", + "-0.00023 | \n", + "0.88540 | \n", + "1.0 | \n", + "59.9 | \n", + "0.184 | \n", + "-701381295899092907 | \n", + "
2455497 | \n", + "2020-01-03 00:00:00+00:00 | \n", + "16.0 | \n", + "324.87 | \n", + "2020-01-03 21:00:00+00:00 | \n", + "1.0 | \n", + "1.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "0.01467 | \n", + "NaN | \n", + "NaN | \n", + "0.00 | \n", + "54.50 | \n", + "54.70 | \n", + "270.0 | \n", + "0.00 | \n", + "0.01 | \n", + "0.01 | \n", + "-0.00109 | \n", + "0.00016 | \n", + "0.00060 | \n", + "-0.00514 | \n", + "0.00000 | \n", + "0.81007 | \n", + "0.0 | \n", + "54.9 | \n", + "0.169 | \n", + "6061307834470536317 | \n", + "
2455498 | \n", + "2020-01-03 00:00:00+00:00 | \n", + "16.0 | \n", + "324.87 | \n", + "2020-01-03 21:00:00+00:00 | \n", + "1.0 | \n", + "1.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "-0.00042 | \n", + "0.01498 | \n", + "NaN | \n", + "NaN | \n", + "0.00 | \n", + "52.00 | \n", + "52.24 | \n", + "272.5 | \n", + "0.00 | \n", + "0.01 | \n", + "0.01 | \n", + "-0.00059 | \n", + "0.00013 | \n", + "0.00058 | \n", + "-0.00510 | \n", + "-0.00028 | \n", + "0.77271 | \n", + "100.0 | \n", + "52.4 | \n", + "0.161 | \n", + "-1220682253960080101 | \n", + "
2455499 | \n", + "2020-01-03 00:00:00+00:00 | \n", + "16.0 | \n", + "324.87 | \n", + "2020-01-03 21:00:00+00:00 | \n", + "1.0 | \n", + "1.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "-0.00027 | \n", + "0.01538 | \n", + "NaN | \n", + "1.0 | \n", + "42.41 | \n", + "49.49 | \n", + "49.67 | \n", + "275.0 | \n", + "0.00 | \n", + "0.01 | \n", + "0.01 | \n", + "-0.00115 | \n", + "0.00018 | \n", + "0.00033 | \n", + "-0.00535 | \n", + "0.00000 | \n", + "0.73608 | \n", + "0.0 | \n", + "49.9 | \n", + "0.154 | \n", + "1653060084193980450 | \n", + "
... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "
975120 | \n", + "2022-12-31 00:00:00+00:00 | \n", + "16.0 | \n", + "382.44 | \n", + "2025-12-19 21:00:00+00:00 | \n", + "1085.0 | \n", + "0.10595 | \n", + "0.00150 | \n", + "1.19348 | \n", + "-0.01204 | \n", + "1.05129 | \n", + "0.17770 | \n", + "2.0 | \n", + "5.71 | \n", + "0.59 | \n", + "10.00 | \n", + "630.0 | \n", + "243.00 | \n", + "250.50 | \n", + "0.00 | \n", + "-1.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "0.00000 | \n", + "NaN | \n", + "NaN | \n", + "247.6 | \n", + "0.647 | \n", + "8828685382305019902 | \n", + "
975121 | \n", + "2022-12-31 00:00:00+00:00 | \n", + "16.0 | \n", + "382.44 | \n", + "2025-12-19 21:00:00+00:00 | \n", + "1085.0 | \n", + "0.09392 | \n", + "0.00140 | \n", + "1.09723 | \n", + "-0.01082 | \n", + "0.94207 | \n", + "0.17304 | \n", + "NaN | \n", + "0.00 | \n", + "2.00 | \n", + "7.00 | \n", + "635.0 | \n", + "247.66 | \n", + "257.50 | \n", + "0.00 | \n", + "-0.89431 | \n", + "0.00307 | \n", + "0.72687 | \n", + "-0.00434 | \n", + "-0.20330 | \n", + "0.29557 | \n", + "NaN | \n", + "252.6 | \n", + "0.660 | \n", + "9084648476515366252 | \n", + "
975122 | \n", + "2022-12-31 00:00:00+00:00 | \n", + "16.0 | \n", + "382.44 | \n", + "2025-12-19 21:00:00+00:00 | \n", + "1085.0 | \n", + "0.09279 | \n", + "0.00137 | \n", + "1.08956 | \n", + "-0.01114 | \n", + "0.93199 | \n", + "0.17558 | \n", + "NaN | \n", + "0.00 | \n", + "2.00 | \n", + "7.00 | \n", + "640.0 | \n", + "253.00 | \n", + "262.50 | \n", + "0.00 | \n", + "-0.88536 | \n", + "0.00298 | \n", + "0.78662 | \n", + "-0.00524 | \n", + "-1.78777 | \n", + "0.30289 | \n", + "NaN | \n", + "257.6 | \n", + "0.673 | \n", + "-5359425724938520695 | \n", + "
975123 | \n", + "2022-12-31 00:00:00+00:00 | \n", + "16.0 | \n", + "382.44 | \n", + "2025-12-19 21:00:00+00:00 | \n", + "1085.0 | \n", + "0.09938 | \n", + "0.00147 | \n", + "1.14502 | \n", + "-0.01128 | \n", + "0.99068 | \n", + "0.18239 | \n", + "3.0 | \n", + "4.33 | \n", + "0.12 | \n", + "10.00 | \n", + "645.0 | \n", + "258.00 | \n", + "267.50 | \n", + "0.00 | \n", + "-0.88264 | \n", + "0.00287 | \n", + "0.79928 | \n", + "-0.00538 | \n", + "-1.82985 | \n", + "0.30699 | \n", + "NaN | \n", + "262.6 | \n", + "0.687 | \n", + "-9164642606529368658 | \n", + "
975124 | \n", + "2022-12-31 00:00:00+00:00 | \n", + "16.0 | \n", + "382.44 | \n", + "2025-12-19 21:00:00+00:00 | \n", + "1085.0 | \n", + "0.11433 | \n", + "0.00149 | \n", + "1.25917 | \n", + "-0.01324 | \n", + "1.11689 | \n", + "0.19561 | \n", + "2.0 | \n", + "4.15 | \n", + "2.60 | \n", + "10.00 | \n", + "650.0 | \n", + "262.75 | \n", + "272.50 | \n", + "0.00 | \n", + "-0.88467 | \n", + "0.00288 | \n", + "0.78257 | \n", + "-0.00516 | \n", + "-0.63195 | \n", + "0.31007 | \n", + "NaN | \n", + "267.6 | \n", + "0.700 | \n", + "6543885475790529709 | \n", + "
3589079 rows × 29 columns
\n", + "6705104 rows × 24 columns
\n", + "5183446 rows × 24 columns
\n", "" ], "text/plain": [ " option_id option_type quote_unixtime \\\n", - "0 8228026009228119508 call 2020-01-03 00:00:00+00:00 \n", - "1 8388765138564423602 put 2020-01-03 00:00:00+00:00 \n", - "2 1027550724891153287 call 2020-01-03 00:00:00+00:00 \n", - "3 -1534760388604062099 put 2020-01-03 00:00:00+00:00 \n", - "4 -6171319654666929667 call 2020-01-03 00:00:00+00:00 \n", + "0 4169629807363267195 call 2020-01-03 00:00:00+00:00 \n", + "1 -1427193746298712266 put 2020-01-03 00:00:00+00:00 \n", + "2 -880651805349778471 call 2020-01-03 00:00:00+00:00 \n", + "3 1419493114519967095 put 2020-01-03 00:00:00+00:00 \n", + "4 6851796185238463050 call 2020-01-03 00:00:00+00:00 \n", "... ... ... ... \n", - "6705099 2688229576149051334 put 2022-12-31 00:00:00+00:00 \n", - "6705100 4933943145329079888 call 2022-12-31 00:00:00+00:00 \n", - "6705101 -7427531086436162822 put 2022-12-31 00:00:00+00:00 \n", - "6705102 4838387660868289251 call 2022-12-31 00:00:00+00:00 \n", - "6705103 -1358283876510909960 put 2022-12-31 00:00:00+00:00 \n", + "5183441 8337812745454405911 put 2022-12-31 00:00:00+00:00 \n", + "5183442 7184827014735111024 call 2022-12-31 00:00:00+00:00 \n", + "5183443 5837551170542630138 put 2022-12-31 00:00:00+00:00 \n", + "5183444 -5828408511425543838 call 2022-12-31 00:00:00+00:00 \n", + "5183445 -4446696192614616184 put 2022-12-31 00:00:00+00:00 \n", "\n", " expire_unixtime days_to_expire underlying_last strike \\\n", - "0 2020-01-31 21:00:00+00:00 29.00 324.87 255.0 \n", - "1 2020-01-31 21:00:00+00:00 29.00 324.87 255.0 \n", - "2 2020-01-31 21:00:00+00:00 29.00 324.87 260.0 \n", - "3 2020-01-31 21:00:00+00:00 29.00 324.87 260.0 \n", - "4 2020-01-31 21:00:00+00:00 29.00 324.87 265.0 \n", + "0 2020-02-14 21:00:00+00:00 43.0 324.87 270.0 \n", + "1 2020-02-14 21:00:00+00:00 43.0 324.87 270.0 \n", + "2 2020-02-14 21:00:00+00:00 43.0 324.87 275.0 \n", + "3 2020-02-14 21:00:00+00:00 43.0 324.87 275.0 \n", + "4 2020-02-14 21:00:00+00:00 43.0 324.87 280.0 \n", "... ... ... ... ... \n", - "6705099 2025-03-21 20:00:00+00:00 811.96 382.44 590.0 \n", - "6705100 2025-03-21 20:00:00+00:00 811.96 382.44 595.0 \n", - "6705101 2025-03-21 20:00:00+00:00 811.96 382.44 595.0 \n", - "6705102 2025-03-21 20:00:00+00:00 811.96 382.44 600.0 \n", - "6705103 2025-03-21 20:00:00+00:00 811.96 382.44 600.0 \n", + "5183441 2025-01-17 21:00:00+00:00 749.0 382.44 590.0 \n", + "5183442 2025-01-17 21:00:00+00:00 749.0 382.44 595.0 \n", + "5183443 2025-01-17 21:00:00+00:00 749.0 382.44 595.0 \n", + "5183444 2025-01-17 21:00:00+00:00 749.0 382.44 600.0 \n", + "5183445 2025-01-17 21:00:00+00:00 749.0 382.44 600.0 \n", "\n", " strike_distance strike_distance_pct delta gamma vega \\\n", - "0 69.9 0.215 0.99254 0.00067 0.01952 \n", - "1 69.9 0.215 -0.00379 0.00033 0.01031 \n", - "2 64.9 0.200 0.98654 0.00101 0.03238 \n", - "3 64.9 0.200 -0.00465 0.00052 0.01345 \n", - "4 59.9 0.184 0.97933 0.00146 0.04691 \n", + "0 54.9 0.169 0.96247 0.00230 0.09124 \n", + "1 54.9 0.169 -0.01684 0.00147 0.04655 \n", + "2 49.9 0.154 0.95833 0.00278 0.10050 \n", + "3 49.9 0.154 -0.02157 0.00193 0.05840 \n", + "4 44.9 0.138 0.94983 0.00341 0.11693 \n", "... ... ... ... ... ... \n", - "6705099 207.6 0.543 -1.00000 0.00000 0.00000 \n", - "6705100 212.6 0.556 0.09466 0.00169 0.96298 \n", - "6705101 212.6 0.556 -0.90719 0.00326 0.61124 \n", - "6705102 217.6 0.569 0.09424 0.00161 0.95513 \n", - "6705103 217.6 0.569 -1.00000 0.00000 0.00000 \n", + "5183441 207.6 0.543 -0.87442 0.00305 0.81016 \n", + "5183442 212.6 0.556 0.08891 0.00157 0.88126 \n", + "5183443 212.6 0.556 -0.86806 0.00287 0.84727 \n", + "5183444 217.6 0.569 0.07545 0.00142 0.77750 \n", + "5183445 217.6 0.569 -0.86402 0.00281 0.86975 \n", "\n", - " theta rho iv volume last bid ask max_ask \\\n", - "0 -0.01130 0.20686 0.35727 1.0 66.82 69.87 70.05 77.27 \n", - "1 -0.00484 -0.00110 0.32142 16.0 0.03 0.03 0.04 0.04 \n", - "2 -0.01868 0.20993 0.36143 10.0 60.50 64.94 65.13 72.30 \n", - "3 -0.00650 -0.00176 0.30648 3.0 0.04 0.04 0.05 0.05 \n", - "4 -0.02728 0.21135 0.35875 NaN 0.00 60.01 60.26 67.28 \n", - "... ... ... ... ... ... ... ... ... \n", - "6705099 0.00000 0.00000 NaN NaN 0.00 202.75 210.00 NaN \n", - "6705100 -0.01292 0.72396 0.17885 NaN 0.00 1.73 6.50 NaN \n", - "6705101 -0.00505 -1.24251 0.28500 NaN 0.00 207.82 217.78 NaN \n", - "6705102 -0.01327 0.71483 0.18161 0.0 4.60 2.25 6.00 NaN \n", - "6705103 0.00000 0.00000 NaN NaN 0.00 212.54 220.50 NaN \n", + " theta rho iv volume last bid ask max_ask \\\n", + "0 -0.03148 0.31026 0.30852 10.0 53.85 55.31 55.51 67.91 \n", + "1 -0.01293 -0.00678 0.25518 NaN 0.00 0.17 0.17 0.23 \n", + "2 -0.03230 0.31394 0.28566 NaN 0.00 50.34 50.53 62.89 \n", + "3 -0.01595 -0.00872 0.24238 1.0 0.28 0.21 0.23 0.30 \n", + "4 -0.03563 0.31725 0.26822 NaN 0.00 45.41 45.66 57.90 \n", + "... ... ... ... ... ... ... ... ... \n", + "5183441 -0.00808 -1.71905 0.29992 0.0 193.26 205.00 212.60 NaN \n", + "5183442 -0.01276 0.62712 0.18258 0.0 6.80 2.00 5.50 NaN \n", + "5183443 -0.00847 -1.81885 0.30789 NaN 0.00 210.50 217.50 NaN \n", + "5183444 -0.01128 0.53365 0.17619 12.0 2.55 2.50 3.45 NaN \n", + "5183445 -0.00938 -1.88504 0.31386 0.0 220.69 215.50 222.75 NaN \n", "\n", " min_ask fear_greed_index fear_greed_index_max fear_greed_index_min \n", - "0 67.22 NaN NaN NaN \n", + "0 52.30 NaN NaN NaN \n", "1 0.01 NaN NaN NaN \n", - "2 62.23 NaN NaN NaN \n", + "2 47.75 NaN NaN NaN \n", "3 0.01 NaN NaN NaN \n", - "4 57.21 NaN NaN NaN \n", + "4 42.79 NaN NaN NaN \n", "... ... ... ... ... \n", - "6705099 NaN 37.0 76.0 36.0 \n", - "6705100 NaN 37.0 76.0 36.0 \n", - "6705101 NaN 37.0 76.0 36.0 \n", - "6705102 NaN 37.0 76.0 36.0 \n", - "6705103 NaN 37.0 76.0 36.0 \n", + "5183441 NaN 37.0 61.0 36.0 \n", + "5183442 NaN 37.0 61.0 36.0 \n", + "5183443 NaN 37.0 61.0 36.0 \n", + "5183444 NaN 37.0 61.0 36.0 \n", + "5183445 NaN 37.0 61.0 36.0 \n", "\n", - "[6705104 rows x 24 columns]" + "[5183446 rows x 24 columns]" ] }, "execution_count": 2, @@ -467,16 +1104,16 @@ } ], "source": [ - "periods = 20\n", - "# periods = 30 # BEST RESULT\n", - "fear_greed_window = 40\n", + "# periods = 20\n", + "periods = 30 # BEST RESULT\n", + "fear_greed_window = 20 # BEST RESULT\n", "\n", "refresh_formatted_data = False\n", "refresh_processed_data = False\n", "\n", "raw_data_path = data_directory + \"spy_2020_2022.csv\"\n", - "formatted_data_path = data_directory + \"spy_2020_2022_formatted.csv\"\n", - "processed_data_path = data_directory + \"spy_2020_2022_processed.csv\"\n", + "formatted_data_path = data_directory + f\"spy_2020_2022_formatted_{periods}_{fear_greed_window}.csv\"\n", + "processed_data_path = data_directory + f\"spy_2020_2022_processed_{periods}_{fear_greed_window}.csv\"\n", "\n", "if not refresh_processed_data and os.path.isfile(processed_data_path):\n", " df_options = pd.read_csv(processed_data_path, low_memory=False)\n", @@ -671,6 +1308,59 @@ { "cell_type": "code", "execution_count": 3, + "id": "d3d1b213", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "36592 rows × 24 columns
\n", + "39778 rows × 24 columns
\n", "" ], "text/plain": [ " option_id option_type quote_unixtime \\\n", - "3412233 -7284403565423334204 put 2021-07-14 00:00:00+00:00 \n", - "3412237 -6900012193074301262 put 2021-07-14 00:00:00+00:00 \n", - "3412239 6126913891936646503 put 2021-07-14 00:00:00+00:00 \n", - "3412243 -8542137146864587244 put 2021-07-14 00:00:00+00:00 \n", - "3412245 8889578099934366041 put 2021-07-14 00:00:00+00:00 \n", + "3217819 3008663547997449213 put 2021-06-15 00:00:00+00:00 \n", + "3217821 -6871348143934581290 put 2021-06-15 00:00:00+00:00 \n", + "3217825 -7643848508642364201 put 2021-06-15 00:00:00+00:00 \n", + "3217827 3936499674942118164 put 2021-06-15 00:00:00+00:00 \n", + "3217829 681636405473264716 put 2021-06-15 00:00:00+00:00 \n", "... ... ... ... \n", - "6588412 8926636401208964267 call 2022-12-02 00:00:00+00:00 \n", - "6588414 -8802341623244967839 call 2022-12-02 00:00:00+00:00 \n", - "6588418 -6999102162049648074 call 2022-12-02 00:00:00+00:00 \n", - "6588426 -4637813185526554528 call 2022-12-02 00:00:00+00:00 \n", - "6588428 -7903130375213156883 call 2022-12-02 00:00:00+00:00 \n", + "6588412 3074973442818116841 call 2022-12-02 00:00:00+00:00 \n", + "6588414 243829186492752650 call 2022-12-02 00:00:00+00:00 \n", + "6588418 5941774315107753797 call 2022-12-02 00:00:00+00:00 \n", + "6588426 8230302027418419949 call 2022-12-02 00:00:00+00:00 \n", + "6588428 -390721989138427125 call 2022-12-02 00:00:00+00:00 \n", "\n", " expire_unixtime days_to_expire underlying_last strike \\\n", - "3412233 2021-08-13 20:00:00+00:00 31.0 435.72 395.0 \n", - "3412237 2021-08-13 20:00:00+00:00 31.0 435.72 397.0 \n", - "3412239 2021-08-13 20:00:00+00:00 31.0 435.72 398.0 \n", - "3412243 2021-08-13 20:00:00+00:00 31.0 435.72 400.0 \n", - "3412245 2021-08-13 20:00:00+00:00 31.0 435.72 401.0 \n", + "3217819 2021-07-16 20:00:00+00:00 32.0 425.33 385.0 \n", + "3217821 2021-07-16 20:00:00+00:00 32.0 425.33 386.0 \n", + "3217825 2021-07-16 20:00:00+00:00 32.0 425.33 388.0 \n", + "3217827 2021-07-16 20:00:00+00:00 32.0 425.33 389.0 \n", + "3217829 2021-07-16 20:00:00+00:00 32.0 425.33 390.0 \n", "... ... ... ... ... \n", "6588412 2023-02-17 21:00:00+00:00 78.0 407.40 437.0 \n", "6588414 2023-02-17 21:00:00+00:00 78.0 407.40 438.0 \n", @@ -1391,11 +2081,11 @@ "6588428 2023-02-17 21:00:00+00:00 78.0 407.40 445.0 \n", "\n", " strike_distance strike_distance_pct delta gamma vega \\\n", - "3412233 40.7 0.093 -0.07773 0.00470 0.18849 \n", - "3412237 38.7 0.089 -0.08554 0.00515 0.20168 \n", - "3412239 37.7 0.087 -0.08839 0.00531 0.20656 \n", - "3412243 35.7 0.082 -0.09611 0.00578 0.22012 \n", - "3412245 34.7 0.080 -0.10012 0.00609 0.22682 \n", + "3217819 40.3 0.095 -0.07572 0.00487 0.18310 \n", + "3217821 39.3 0.092 -0.07912 0.00508 0.18874 \n", + "3217825 37.3 0.088 -0.08590 0.00551 0.19974 \n", + "3217827 36.3 0.085 -0.08957 0.00576 0.20590 \n", + "3217829 35.3 0.083 -0.09293 0.00601 0.21253 \n", "... ... ... ... ... ... \n", "6588412 29.6 0.073 0.22074 0.00895 0.56191 \n", "6588414 30.6 0.075 0.21088 0.00880 0.54746 \n", @@ -1404,11 +2094,11 @@ "6588428 37.6 0.092 0.15195 0.00740 0.44562 \n", "\n", " theta rho iv volume last bid ask max_ask \\\n", - "3412233 -0.07067 -0.02999 0.24072 120.0 1.08 1.11 1.13 2.28 \n", - "3412237 -0.07453 -0.03375 0.23642 116.0 1.22 1.21 1.24 2.47 \n", - "3412239 -0.07547 -0.03429 0.23418 135.0 1.18 1.26 1.27 2.58 \n", - "3412243 -0.07855 -0.03787 0.22859 153.0 1.37 1.36 1.37 2.77 \n", - "3412245 -0.07972 -0.03952 0.22649 118.0 1.42 1.41 1.43 2.88 \n", + "3217819 -0.06656 -0.03038 0.22962 3686.0 1.08 1.03 1.04 1.97 \n", + "3217821 -0.06780 -0.03140 0.22702 121.0 1.22 1.06 1.08 2.06 \n", + "3217825 -0.07036 -0.03406 0.22108 2414.0 1.15 1.14 1.15 2.23 \n", + "3217827 -0.07159 -0.03513 0.21832 243.0 1.21 1.18 1.19 2.34 \n", + "3217829 -0.07323 -0.03721 0.21591 5567.0 1.25 1.23 1.24 2.39 \n", "... ... ... ... ... ... ... ... ... \n", "6588412 -0.06749 0.18591 0.17425 146.0 4.04 4.01 4.05 3.59 \n", "6588414 -0.06536 0.17741 0.17288 127.0 3.83 3.77 3.79 3.37 \n", @@ -1417,22 +2107,22 @@ "6588428 -0.05121 0.12878 0.16816 137.0 2.41 2.43 2.45 2.10 \n", "\n", " min_ask fear_greed_index fear_greed_index_max fear_greed_index_min \n", - "3412233 0.02 30.0 54.0 27.0 \n", - "3412237 0.02 30.0 54.0 27.0 \n", - "3412239 0.02 30.0 54.0 27.0 \n", - "3412243 0.03 30.0 54.0 27.0 \n", - "3412245 0.03 30.0 54.0 27.0 \n", + "3217819 0.03 54.0 54.0 27.0 \n", + "3217821 0.03 54.0 54.0 27.0 \n", + "3217825 0.03 54.0 54.0 27.0 \n", + "3217827 0.03 54.0 54.0 27.0 \n", + "3217829 0.04 54.0 54.0 27.0 \n", "... ... ... ... ... \n", - "6588412 0.24 76.0 76.0 16.0 \n", - "6588414 0.22 76.0 76.0 16.0 \n", - "6588418 0.19 76.0 76.0 16.0 \n", - "6588426 0.14 76.0 76.0 16.0 \n", - "6588428 0.14 76.0 76.0 16.0 \n", + "6588412 0.24 76.0 76.0 54.0 \n", + "6588414 0.22 76.0 76.0 54.0 \n", + "6588418 0.19 76.0 76.0 54.0 \n", + "6588426 0.14 76.0 76.0 54.0 \n", + "6588428 0.14 76.0 76.0 54.0 \n", "\n", - "[36592 rows x 24 columns]" + "[39778 rows x 24 columns]" ] }, - "execution_count": 193, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -1445,10 +2135,10 @@ "max_dte = 90 # BEST RESULT\n", "max_ask = 10\n", "# min_ask = max_ask / 10\n", - "min_ask = 0.2\n", + "min_ask = 0.1\n", "min_volume = 100\n", "max_strike_distance_pct = 0.1\n", - "target_profit = 1.1\n", + "target_profit = 1.2\n", "\n", "df_options_filtered = df_options.loc[\n", " (df_options.fear_greed_index_max.notnull())\n", @@ -1516,7 +2206,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "5f4f3e03", "metadata": {}, "outputs": [], @@ -1532,7 +2222,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "65a3b9cc", "metadata": {}, "outputs": [], @@ -1544,7 +2234,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "fc3ac1db", "metadata": {}, "outputs": [], @@ -1563,7 +2253,7 @@ }, { "cell_type": "code", - "execution_count": 194, + "execution_count": 34, "id": "d97801cf", "metadata": {}, "outputs": [ @@ -1571,22 +2261,22 @@ "name": "stdout", "output_type": "stream", "text": [ - "Total gains: $291584.90\n", - "Total losses: $-20822.20\n", - "Total profit: $270762.70\n" + "Total gains: $577804.00\n", + "Total losses: $-54070.80\n", + "Total profit: $523733.20\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "/var/folders/86/qt4jnsg167j7h7mqgbpp44kh0000gn/T/ipykernel_180/2931737422.py:19: SettingWithCopyWarning: \n", + "/tmp/ipykernel_61923/1660768581.py:19: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " df_options_filtered[\"did_buy\"] = (\n", - "/var/folders/86/qt4jnsg167j7h7mqgbpp44kh0000gn/T/ipykernel_180/2931737422.py:35: SettingWithCopyWarning: \n", + "/tmp/ipykernel_61923/1660768581.py:44: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", @@ -1625,25 +2315,25 @@ "\n", - " | id | \n", - "money | \n", - "price | \n", - "options | \n", - "days_to_expire | \n", - "diff | \n", - "pct_change | \n", - "
---|---|---|---|---|---|---|---|
count | \n", - "238.0 | \n", - "238.0 | \n", - "238.0 | \n", - "238.0 | \n", - "238.0 | \n", - "121.0 | \n", - "121.0 | \n", - "
mean | \n", - "1.088679911937857e+18 | \n", - "4363.226890756303 | \n", - "748.3781512605042 | \n", - "0.8865546218487395 | \n", - "32.564033613445375 | \n", - "62.88429752066115 | \n", - "7.358488549399297 | \n", - "
std | \n", - "4.863282538880341e+18 | \n", - "2241.079703005496 | \n", - "349.2388104057368 | \n", - "0.7684083357314562 | \n", - "2.18777821881706 | \n", - "248.59576257057174 | \n", - "37.31522437169087 | \n", - "
min | \n", - "-8.996070546301766e+18 | \n", - "49.0 | \n", - "44.0 | \n", - "0.0 | \n", - "30.04 | \n", - "-567.9999999999998 | \n", - "-70.06802721088435 | \n", - "
25% | \n", - "-1.9728861802265032e+18 | \n", - "2496.5 | \n", - "507.75 | \n", - "0.0 | \n", - "31.0 | \n", - "-151.0 | \n", - "-21.79627601314349 | \n", - "
50% | \n", - "1.1411129678916947e+18 | \n", - "4715.0 | \n", - "807.0 | \n", - "1.0 | \n", - "32.0 | \n", - "88.0 | \n", - "15.02890173410405 | \n", - "
75% | \n", - "5.089659152631614e+18 | \n", - "6089.75 | \n", - "980.75 | \n", - "1.0 | \n", - "33.0 | \n", - "263.0 | \n", - "38.46153846153848 | \n", - "
max | \n", - "9.107928447585857e+18 | \n", - "8372.0 | \n", - "1761.0 | \n", - "4.0 | \n", - "44.0 | \n", - "797.9999999999999 | \n", - "86.20689655172413 | \n", - "