-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsv_analyser.py
47 lines (38 loc) · 1.43 KB
/
csv_analyser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from config import tp_percentage, sl_percentage, file_path
from config import position_volume
static_balance = position_volume
dynamic_balance = position_volume
def calculate_balance(closed_with_TP):
global static_balance
global dynamic_balance
global tp_percentage
global sl_percentage
if closed_with_TP:
dynamic_balance = dynamic_balance * (1 + tp_percentage)
static_balance += position_volume * tp_percentage
else:
dynamic_balance = dynamic_balance * (1 - sl_percentage)
static_balance -= position_volume * sl_percentage
def analyze_results(file_path):
total_trades = 0
correct_trades = 0
incorrect_trades = 0
with open(file_path, 'r') as file:
lines = file.readlines()
for line in lines[1:]:
date, result, prediction = line.strip().split(',')
total_trades += 1
if result == prediction:
correct_trades += 1
calculate_balance(True)
else:
incorrect_trades += 1
calculate_balance(False)
print(f"Total trades: {total_trades}")
print(f"Correct trades: {correct_trades}")
print(f"Incorrect trades: {incorrect_trades}")
accuracy = correct_trades / total_trades * 100 if total_trades > 0 else 0
print(f"Accuracy: {accuracy:.2f}%")
print(f"Dynamic balance: {round(dynamic_balance, 2)}")
print(f"Static balance: {round(static_balance, 2)}")
analyze_results(file_path)