forked from Drakkar-Software/Triangular-Arbitrage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain_gnn.sh
More file actions
executable file
Β·158 lines (144 loc) Β· 4.32 KB
/
train_gnn.sh
File metadata and controls
executable file
Β·158 lines (144 loc) Β· 4.32 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# GNN Training Helper Script
# This script helps you train and monitor the GNN optimizer
set -e
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}π§ GNN Training & Monitoring Tool${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Function to show current GNN status
show_status() {
echo -e "${GREEN}π Current GNN Status:${NC}"
python3 << 'EOF'
from triangular_arbitrage.gnn_optimizer import GNNArbitrageOptimizer
import os
if not os.path.exists("logs/gnn_state.json"):
print(" β οΈ No training data yet (logs/gnn_state.json not found)")
print(" π‘ Run option 1 or 2 to start training")
else:
gnn = GNNArbitrageOptimizer()
stats = gnn.get_statistics()
print(f" β
Tracked edges: {stats['tracked_edges']}")
print(f" β
Unique cycles: {stats['unique_cycles']}")
print(f" β
Total trades: {stats['total_trades']}")
# Training level
trades = stats['total_trades']
if trades == 0:
level = "Not Started"
emoji = "βͺ"
elif trades < 20:
level = "Beginner"
emoji = "π‘"
elif trades < 50:
level = "Learning"
emoji = "π "
elif trades < 100:
level = "Intermediate"
emoji = "π΅"
else:
level = "Expert"
emoji = "π’"
print(f"\n {emoji} Training Level: {level} ({trades} trades)")
EOF
echo ""
}
# Function to show top learned cycles
show_learned() {
echo -e "${GREEN}π Top Learned Cycles:${NC}"
python3 << 'EOF'
from triangular_arbitrage.gnn_optimizer import GNNArbitrageOptimizer
import os
if os.path.exists("logs/gnn_state.json"):
gnn = GNNArbitrageOptimizer()
# Get some example scores
test_cycles = [
["BTC", "ETH", "USDT"],
["ETH", "BNB", "USDT"],
["DOGE", "SHIB", "USDT"],
["BTC", "SOL", "USDT"],
]
print(" Cycle Score Status")
print(" " + "-" * 45)
for cycle in test_cycles:
score = gnn.get_cycle_score(cycle)
status = "β
APPROVED" if score >= 1.0 else "β BLOCKED"
cycle_str = "->".join(cycle)
print(f" {cycle_str:20} {score:6.4f} {status}")
else:
print(" β οΈ No training data yet")
EOF
echo ""
}
# Show current status
show_status
# Menu
echo -e "${YELLOW}Choose training option:${NC}"
echo " 1) Quick Test Training (30 sample trades, ~1 second)"
echo " 2) Paper Trading (Safe, no real money)"
echo " 3) Live Trading (Real money, use after paper training)"
echo " 4) Show Detailed GNN State"
echo " 5) Show Learning Progress"
echo " 6) Reset GNN (Clear all training)"
echo " 7) Exit"
echo ""
read -p "Enter choice [1-7]: " choice
case $choice in
1)
echo -e "${BLUE}π§ͺ Running quick test training...${NC}"
python tests/integration/test_gnn_scoring.py
echo ""
show_status
show_learned
;;
2)
echo -e "${BLUE}π Starting paper trading...${NC}"
echo -e "${YELLOW}π‘ Press Ctrl+C to stop${NC}"
echo ""
python run_clean.py cex --paper
;;
3)
echo -e "${RED}β οΈ WARNING: This uses REAL MONEY!${NC}"
read -p "Are you sure? Type 'YES' to continue: " confirm
if [ "$confirm" = "YES" ]; then
echo -e "${BLUE}π° Starting live trading...${NC}"
python run_clean.py cex --live
else
echo "Cancelled."
fi
;;
4)
echo -e "${BLUE}π GNN State File:${NC}"
if [ -f "logs/gnn_state.json" ]; then
cat logs/gnn_state.json | python -m json.tool | head -100
else
echo "No state file found yet."
fi
;;
5)
echo -e "${BLUE}π Learning Progress:${NC}"
show_learned
;;
6)
echo -e "${RED}β οΈ This will delete all training data!${NC}"
read -p "Are you sure? Type 'YES' to confirm: " confirm
if [ "$confirm" = "YES" ]; then
rm -f logs/gnn_state.json
echo -e "${GREEN}β
GNN reset complete${NC}"
else
echo "Cancelled."
fi
;;
7)
echo "Goodbye!"
exit 0
;;
*)
echo -e "${RED}Invalid choice${NC}"
exit 1
;;
esac