diff options
author | sotech117 <michael_foiani@brown.edu> | 2025-09-03 13:54:19 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2025-09-03 13:54:19 -0400 |
commit | ea05658d9868b775fef74fba79a69bd21a43f93d (patch) | |
tree | 6c73e814224b9ea9fa756fb93b5c32c7501b62c1 /analysis.py | |
parent | 5bf22fc7e3c392c8bd44315ca2d06d7dca7d084e (diff) |
new fft algo with laplacian range of convergencemain
Diffstat (limited to 'analysis.py')
-rw-r--r-- | analysis.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/analysis.py b/analysis.py index 912eb0a..ca409b0 100644 --- a/analysis.py +++ b/analysis.py @@ -1,6 +1,7 @@ import json import datetime import os +import pandas as pd def summarize_results(batch_name): """ @@ -34,17 +35,22 @@ def summarize_results(batch_name): if algo_key not in algos_to_results: algos_to_results[algo_key] = { 'percent_gains': [], - 'stock_orders': [] + 'stock_orders': [], + 'file_names': [], + 'url_params': [] } algos_to_results[algo_key]['percent_gains'].append(result['percent_gain']) stock_ticker = result_data['url_params']['ticker'] algos_to_results[algo_key]['stock_orders'].append(stock_ticker) - - # summarize the results for each algo + algos_to_results[algo_key]['file_names'].append(file_path.split('/')[-1]) + algos_to_results[algo_key]['url_params'].append(result_data['url_params']) + for algo_name, result in algos_to_results.items(): algo_params = algo_name.split('_')[1] # Extract params from the key + algo_name_alone = algo_name.split('_')[0] # Extract name from the key + if not result['percent_gains'] and not result['percent_losses']: continue # Skip if no gains or losses @@ -60,7 +66,7 @@ def summarize_results(batch_name): # Append the summarized data results_summary.append([ - algo_name, + algo_name_alone, algo_params, avg_percent_gain, best_stock_order @@ -69,9 +75,15 @@ def summarize_results(batch_name): # Sort the results by average percent gain in descending order results_summary.sort(key=lambda x: x[2], reverse=True) - print(algos_to_results) - - return results_summary + print("Results Summary:") + + # Return the summarized results as a DataFrame + return pd.DataFrame(results_summary, columns=[ + 'algo_name', + 'algo_params', + 'avg_percent_gain', + 'best_stock_for_gain' + ]), algos_to_results def test(): """ @@ -79,12 +91,7 @@ def test(): """ batch_name = 'test-1-ema' results = summarize_results(batch_name) - if results: - print("Results Summary:") - for row in results: - print(row) - else: - print("No results found.") + print(results) test() |