50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
|
|
import csv
|
|
import sys
|
|
import os
|
|
|
|
def analyze():
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
results_file = os.path.join(current_dir, "optimization_results.csv")
|
|
|
|
if not os.path.exists(results_file):
|
|
print(f"File not found: {results_file}")
|
|
return
|
|
|
|
print(f"Analyzing {results_file}...")
|
|
|
|
best_pnl = -float('inf')
|
|
best_config = None
|
|
|
|
rows = []
|
|
|
|
with open(results_file, 'r') as f:
|
|
reader = csv.DictReader(f)
|
|
for row in reader:
|
|
rows.append(row)
|
|
|
|
pnl = float(row['TOTAL_PNL'])
|
|
uni_fees = float(row['UNI_FEES'])
|
|
hl_pnl = float(row['HL_PNL'])
|
|
|
|
print(f"Config: Range={row['RANGE_WIDTH_PCT']}, Thresh={row['BASE_REBALANCE_THRESHOLD_PCT']} | PnL: ${pnl:.2f} (Fees: ${uni_fees:.2f}, Hedge: ${hl_pnl:.2f})")
|
|
|
|
if pnl > best_pnl:
|
|
best_pnl = pnl
|
|
best_config = row
|
|
|
|
print("\n" + "="*40)
|
|
print(f"🏆 BEST CONFIGURATION")
|
|
print("="*40)
|
|
if best_config:
|
|
print(f"Range Width: {float(best_config['RANGE_WIDTH_PCT'])*100:.2f}%")
|
|
print(f"Rebalance Thresh: {float(best_config['BASE_REBALANCE_THRESHOLD_PCT'])*100:.0f}%")
|
|
print(f"Total PnL: ${float(best_config['TOTAL_PNL']):.2f}")
|
|
print(f" > Uni Fees: ${float(best_config['UNI_FEES']):.2f}")
|
|
print(f" > Hedge PnL: ${float(best_config['HL_PNL']):.2f}")
|
|
else:
|
|
print("No valid results found.")
|
|
|
|
if __name__ == "__main__":
|
|
analyze()
|