GoshawkVortexAI commited on
Commit
4e05c95
·
verified ·
1 Parent(s): c24b1eb

Create scorer.py

Browse files
Files changed (1) hide show
  1. scorer.py +69 -0
scorer.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from typing import Dict, Any
3
+
4
+
5
+ def compute_structure_score(regime_data: Dict[str, Any]) -> float:
6
+ trend = regime_data.get("trend", "ranging")
7
+ structure = regime_data.get("structure", 0)
8
+ vol_expanding = regime_data.get("volatility_expanding", False)
9
+
10
+ if trend == "bullish":
11
+ base = 1.0
12
+ elif trend == "ranging":
13
+ base = 0.4
14
+ else:
15
+ base = 0.1
16
+
17
+ if structure == 1:
18
+ base = min(1.0, base + 0.2)
19
+ elif structure == -1:
20
+ base = max(0.0, base - 0.2)
21
+
22
+ if vol_expanding:
23
+ base = max(0.0, base - 0.15)
24
+
25
+ return float(np.clip(base, 0.0, 1.0))
26
+
27
+
28
+ def score_token(
29
+ regime_data: Dict[str, Any],
30
+ volume_data: Dict[str, Any],
31
+ vetoed: bool,
32
+ ) -> Dict[str, float]:
33
+ if vetoed:
34
+ return {
35
+ "regime_score": 0.0,
36
+ "volume_score": 0.0,
37
+ "structure_score": 0.0,
38
+ "total_score": 0.0,
39
+ }
40
+
41
+ regime_score = float(np.clip(regime_data.get("regime_score", 0.0), 0.0, 1.0))
42
+ volume_score = float(np.clip(volume_data.get("volume_score", 0.0), 0.0, 1.0))
43
+ structure_score = compute_structure_score(regime_data)
44
+
45
+ regime_weight = 0.40
46
+ volume_weight = 0.35
47
+ structure_weight = 0.25
48
+
49
+ total_score = (
50
+ regime_score * regime_weight
51
+ + volume_score * volume_weight
52
+ + structure_score * structure_weight
53
+ )
54
+
55
+ return {
56
+ "regime_score": round(regime_score, 4),
57
+ "volume_score": round(volume_score, 4),
58
+ "structure_score": round(structure_score, 4),
59
+ "total_score": round(float(total_score), 4),
60
+ }
61
+
62
+
63
+ def rank_tokens(scored_tokens: Dict[str, Dict[str, Any]]) -> list:
64
+ ranked = sorted(
65
+ scored_tokens.items(),
66
+ key=lambda x: x[1].get("total_score", 0.0),
67
+ reverse=True,
68
+ )
69
+ return ranked