solanaexpert commited on
Commit
22a0f86
·
verified ·
1 Parent(s): 0559530

Update MLCryptoForecasterAllAssetsTPSL.py

Browse files
Files changed (1) hide show
  1. MLCryptoForecasterAllAssetsTPSL.py +9 -6
MLCryptoForecasterAllAssetsTPSL.py CHANGED
@@ -10,7 +10,6 @@ import ta
10
 
11
  # Function to log results to both console and file
12
  # Does not insert blank lines; blank lines added explicitly after each asset block
13
-
14
  def log_results(message, filename="predictions_results.txt"):
15
  print(message)
16
  with open(filename, "a") as f:
@@ -22,10 +21,14 @@ client = Client()
22
  # Settings
23
  interval = Client.KLINE_INTERVAL_4HOUR
24
  result_file = "predictions_results.txt"
25
- # Initialize result file header if it doesn't exist
26
- if not os.path.exists(result_file):
27
- with open(result_file, "w") as f:
28
- f.write("Asset,Accuracy,Optimal_UP_TP,Optimal_UP_SL,Optimal_DN_TP,Optimal_DN_SL\n")
 
 
 
 
29
 
30
  # Get USDT-quoted trading symbols
31
  symbols = [s['symbol'] for s in client.get_exchange_info()['symbols']
@@ -135,4 +138,4 @@ for symbol in symbols:
135
  f.write("\n")
136
 
137
  # End of processing
138
- log_results("All assets processed.", result_file)
 
10
 
11
  # Function to log results to both console and file
12
  # Does not insert blank lines; blank lines added explicitly after each asset block
 
13
  def log_results(message, filename="predictions_results.txt"):
14
  print(message)
15
  with open(filename, "a") as f:
 
21
  # Settings
22
  interval = Client.KLINE_INTERVAL_4HOUR
23
  result_file = "predictions_results.txt"
24
+
25
+ # Delete the results file if it exists for a fresh start
26
+ if os.path.exists(result_file):
27
+ os.remove(result_file)
28
+
29
+ # Initialize result file header
30
+ with open(result_file, "w") as f:
31
+ f.write("Asset,Accuracy,Optimal_UP_TP,Optimal_UP_SL,Optimal_DN_TP,Optimal_DN_SL\n")
32
 
33
  # Get USDT-quoted trading symbols
34
  symbols = [s['symbol'] for s in client.get_exchange_info()['symbols']
 
138
  f.write("\n")
139
 
140
  # End of processing
141
+ log_results("All assets processed.", result_file)