@@ -41,15 +41,15 @@ def do_show_analysis():
4141 plt .legend ()
4242 plt .show ()
4343
44- for symbol , group in grouped :
45- plt .plot (group ['offset' ], group ['stock_traded_rel' ], linestyle = '-' , label = symbol )
46- plt .xlabel ("Offset" )
47- plt .ylabel ("Relative Change" )
48- plt .title ("Relative Change vs Offset for Multiple Symbols" )
49- plt .axhline (0 , color = 'gray' , linestyle = '--' , linewidth = 0.8 ) # Add a horizontal line at y=0
50- plt .grid (True )
51- plt .legend ()
52- plt .show ()
44+ # for symbol, group in grouped:
45+ # plt.plot(group['offset'], group['stock_traded_rel'], linestyle='-', label=symbol)
46+ # plt.xlabel("Offset")
47+ # plt.ylabel("Relative Change")
48+ # plt.title("Relative Change vs Offset for Multiple Symbols")
49+ # plt.axhline(0, color='gray', linestyle='--', linewidth=0.8) # Add a horizontal line at y=0
50+ # plt.grid(True)
51+ # plt.legend()
52+ # plt.show()
5353
5454 print ("done" )
5555
@@ -59,7 +59,40 @@ def do_show_analysis():
5959
6060
6161if __name__ == "__main__" :
62- # sp500_stock_quality.display_sp500_quality_of_year(2024)
63- candidates = preprocessing .get_sp500_candidates (datetime (2023 , 10 , 18 ))
62+ sp500_stock_quality .display_sp500_quality_of_year (2024 )
63+ sp500_stock_quality .display_sp500_quality_of_year (2025 )
64+ check_date = datetime (2024 , 7 , 8 )
65+ candidates = preprocessing .get_sp500_candidates (check_date , 12 , 0 )
6466 print ("Candidates found: " , len (candidates ))
65- print ("List of candidates: " , candidates )
67+ # print("List of candidates: ", candidates)
68+ sp500_entries = [(symbol , check_date ) for symbol in candidates ]
69+ stock_data = pd .DataFrame ()
70+ stock_data : pd .DataFrame
71+ for symbol , date in sp500_entries :
72+ if stock_data is pd .DataFrame .empty :
73+ stock_data = data_extract .extract_market_data (symbol , date , 40 , 10 )
74+ else :
75+ symbol_stock_data = data_extract .extract_market_data (symbol , date , 40 , 10 )
76+ stock_data = pd .concat ([stock_data , symbol_stock_data ])
77+
78+ # Group by symbol
79+ grouped = stock_data .groupby ('symbol' )
80+ for symbol , group in grouped :
81+ plt .plot (group ['offset' ], group ['stock_price_rel' ], linestyle = '-' , label = symbol )
82+ plt .xlabel ("Offset" )
83+ plt .ylabel ("Relative Change" )
84+ plt .title ("Relative Change vs Offset for Multiple Symbols" )
85+ plt .axhline (0 , color = 'gray' , linestyle = '--' , linewidth = 0.8 ) # Add a horizontal line at y=0
86+ plt .grid (True )
87+ plt .legend ()
88+ plt .show ()
89+
90+ # for symbol, group in grouped:
91+ # plt.plot(group['offset'], group['stock_traded_rel'], linestyle='-', label=symbol)
92+ # plt.xlabel("Offset")
93+ # plt.ylabel("Relative Change")
94+ # plt.title("Relative Change vs Offset for Multiple Symbols")
95+ # plt.axhline(0, color='gray', linestyle='--', linewidth=0.8) # Add a horizontal line at y=0
96+ # plt.grid(True)
97+ # plt.legend()
98+ # plt.show()
0 commit comments