@@ -76,9 +76,7 @@ def load_prices(input_dir):
7676 """
7777 csv_files = glob .glob (os .path .join (input_dir , "*.csv" ))
7878 if not csv_files :
79- raise FileNotFoundError (
80- f"No CSV files found in '{ input_dir } '. Run fetch_data.py first."
81- )
79+ raise FileNotFoundError (f"No CSV files found in '{ input_dir } '. Run fetch_data.py first." )
8280
8381 adj_close_data = {}
8482 for file in csv_files :
@@ -95,9 +93,7 @@ def load_prices(input_dir):
9593 elif "Close" in df .columns :
9694 adj_close_data [ticker ] = df ["Close" ]
9795 else :
98- print (
99- f" ⚠ Could not find Close prices for { ticker } . Columns: { list (df .columns )} "
100- )
96+ print (f" ⚠ Could not find Close prices for { ticker } . Columns: { list (df .columns )} " )
10197
10298 if not adj_close_data :
10399 raise ValueError ("No valid price data could be loaded from any CSV file." )
@@ -201,13 +197,9 @@ def compute_correlation(returns_df):
201197 print (f" Mean correlation: { corr_flat .mean ():.4f} " )
202198
203199 if corr_flat .mean () > 0.6 :
204- print (
205- "\n 💡 Portfolio Insight: HIGH average correlation → Limited diversification"
206- )
200+ print ("\n 💡 Portfolio Insight: HIGH average correlation → Limited diversification" )
207201 elif corr_flat .mean () > 0.4 :
208- print (
209- "\n 💡 Portfolio Insight: MODERATE average correlation → Some diversification"
210- )
202+ print ("\n 💡 Portfolio Insight: MODERATE average correlation → Some diversification" )
211203 else :
212204 print ("\n 💡 Portfolio Insight: LOW average correlation → Good diversification" )
213205
@@ -276,19 +268,15 @@ def plot_return_distributions(returns_df, results_dir):
276268 axes = axes .flatten ()
277269
278270 for idx , stock in enumerate (returns_df .columns ):
279- axes [idx ].hist (
280- returns_df [stock ], bins = 50 , alpha = 0.7 , color = "steelblue" , edgecolor = "black"
281- )
271+ axes [idx ].hist (returns_df [stock ], bins = 50 , alpha = 0.7 , color = "steelblue" , edgecolor = "black" )
282272 axes [idx ].axvline (
283273 returns_df [stock ].mean (),
284274 color = "red" ,
285275 linestyle = "--" ,
286276 linewidth = 2 ,
287277 label = "Mean" ,
288278 )
289- axes [idx ].set_title (
290- f"{ stock } – Daily Log Return Distribution" , fontweight = "bold"
291- )
279+ axes [idx ].set_title (f"{ stock } – Daily Log Return Distribution" , fontweight = "bold" )
292280 axes [idx ].set_xlabel ("Daily Log Return" )
293281 axes [idx ].set_ylabel ("Frequency" )
294282 axes [idx ].legend ()
0 commit comments