From ea05658d9868b775fef74fba79a69bd21a43f93d Mon Sep 17 00:00:00 2001 From: sotech117 Date: Wed, 3 Sep 2025 13:54:19 -0400 Subject: new fft algo with laplacian range of convergence --- analysis.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'analysis.py') 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() -- cgit v1.2.3-70-g09d2