File size: 1,732 Bytes
8dac04d
 
 
 
 
 
 
e01d7ed
 
8dac04d
e01d7ed
 
8dac04d
 
 
 
 
 
 
e01d7ed
8dac04d
 
e01d7ed
8dac04d
e01d7ed
 
 
8dac04d
e01d7ed
8dac04d
 
 
 
21151ce
8dac04d
 
21151ce
8dac04d
 
 
 
 
 
e01d7ed
 
 
 
 
 
8dac04d
 
e01d7ed
8dac04d
e01d7ed
8dac04d
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
from __future__ import annotations

from typing import Any


def apply_recommendation_rules(edge_row: dict[str, Any]) -> dict[str, Any]:
    """
    Converts edge/confidence into recommendation tiers.
    Focuses on HR market first for now.
    """
    hr_edge = float(edge_row.get("hr_edge", 0.0) or 0.0)
    hr_bet_ev = float(edge_row.get("hr_bet_ev", 0.0) or 0.0)
    confidence = float(edge_row.get("confidence", 0.0) or 0.0)
    slot = str(edge_row.get("slot", "") or "").strip().lower()

    reason_tags = list(edge_row.get("reason_tags", []) or [])

    slot_boost = 0.0
    if slot == "on deck":
        slot_boost = 0.012
        reason_tags.append("On-deck priority")
    elif slot == "in hole":
        slot_boost = 0.006
        reason_tags.append("In-hole visibility")
    elif slot == "3 away":
        slot_boost = 0.0
        reason_tags.append("Farther from action window")

    adjusted_edge = hr_edge + slot_boost

    if confidence < 50:
        tier = "pass"
        reason_tags.append("Low confidence")
    elif adjusted_edge >= 0.035 and hr_bet_ev > 0 and confidence >= 72:
        tier = "bet"
        reason_tags.append("Strong positive edge")
    elif adjusted_edge >= 0.015 and confidence >= 58:
        tier = "watch"
        reason_tags.append("Watchlist edge")
    else:
        tier = "pass"
        reason_tags.append("Below action threshold")

    priority_score = adjusted_edge * 100 + (confidence / 10.0)
    if slot == "on deck":
        priority_score += 2.0
    elif slot == "in hole":
        priority_score += 1.0

    return {
        "recommendation_tier": tier,
        "reason_tags": reason_tags[:6],
        "adjusted_edge": adjusted_edge,
        "priority_score": priority_score,
    }