Syntrex commited on
Commit
f32a125
Β·
verified Β·
1 Parent(s): 6da08a5

Update SQL

Browse files
Files changed (1) hide show
  1. SQL +253 -11
SQL CHANGED
@@ -1,11 +1,253 @@
1
- SELECT 'recommendation_logs' AS table_name, MAX(created_at) AS latest_entry FROM recommendation_logs
2
- UNION ALL
3
- SELECT 'recommendation_outcomes', MAX(created_at) FROM recommendation_outcomes
4
- UNION ALL
5
- SELECT 'game_outcomes', MAX(created_at) FROM game_outcomes
6
- UNION ALL
7
- SELECT 'batter_prop_outcomes', MAX(created_at) FROM batter_prop_outcomes
8
- UNION ALL
9
- SELECT 'upcoming_hr_props', MAX(created_at) FROM upcoming_hr_props
10
- UNION ALL
11
- SELECT 'feedback_submissions', MAX(created_at) FROM feedback_submissions;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ TIER 5A β€” EXECUTION LAYER (ALPHA RELEASE)
2
+
3
+ Context
4
+
5
+ We are implementing Tier 5A: execution-layer improvements.
6
+
7
+ This is NOT a modeling pass.
8
+ This is NOT a simulation pass.
9
+
10
+ This pass operates ONLY on already computed outputs:
11
+ - model probabilities
12
+ - sportsbook odds
13
+ - existing features
14
+
15
+ The goal is to improve:
16
+ - edge selection
17
+ - signal quality
18
+ - execution clarity
19
+ - debug visibility
20
+
21
+ ------------------------------------------------------------
22
+ HARD RULES (DO NOT VIOLATE)
23
+ ------------------------------------------------------------
24
+
25
+ - DO NOT modify simulation logic
26
+ - DO NOT modify probability calculations
27
+ - DO NOT modify matchup models
28
+ - DO NOT modify pitcher/batter models
29
+ - DO NOT change database schemas unless strictly additive
30
+ - DO NOT break any existing UI pages
31
+ - DO NOT remove any debug fields
32
+ - DO NOT introduce external APIs
33
+
34
+ This pass must be:
35
+ - additive
36
+ - bounded
37
+ - fully explainable
38
+
39
+ ------------------------------------------------------------
40
+ SCOPE
41
+ ------------------------------------------------------------
42
+
43
+ Work only in layers AFTER probability is computed.
44
+
45
+ Primary files likely involved:
46
+ - analytics/props_mapper.py
47
+ - visualization/props_page.py
48
+ - recommendation layer (if exists)
49
+ - debug_page.py (or equivalent)
50
+
51
+ ------------------------------------------------------------
52
+ TASK 1 β€” MARKET DISAGREEMENT LAYER
53
+ ------------------------------------------------------------
54
+
55
+ Using current odds across books (DK, FD, MGM, Caesars):
56
+
57
+ For each prop:
58
+
59
+ 1. Compute:
60
+ - best_price
61
+ - worst_price
62
+ - median_price
63
+
64
+ 2. Create flags:
65
+
66
+ market_outlier_flag:
67
+ True if best_price deviates significantly from median
68
+
69
+ market_width:
70
+ absolute difference between best and worst implied probabilities
71
+
72
+ stale_book_flag:
73
+ True if one book is clearly lagging (price far from cluster)
74
+
75
+ 3. Optional:
76
+ soft_vs_sharp_flag:
77
+ If one book consistently offers better price than others
78
+
79
+ Add fields:
80
+ - best_price
81
+ - median_price
82
+ - market_width
83
+ - market_outlier_flag
84
+ - stale_book_flag
85
+
86
+ All calculations must be lightweight and use ONLY current odds.
87
+
88
+ ------------------------------------------------------------
89
+ TASK 2 β€” EDGE QUALITY FILTERS
90
+ ------------------------------------------------------------
91
+
92
+ Build a post-model filter layer.
93
+
94
+ For each prop:
95
+
96
+ Compute:
97
+
98
+ 1. confidence_score
99
+ Based on:
100
+ - availability of matchup data
101
+ - rolling form availability
102
+ - non-null critical inputs
103
+
104
+ 2. volatility_score
105
+ Proxy using:
106
+ - difference between model components
107
+ OR
108
+ - spread between contributing signals
109
+
110
+ 3. signal_strength_score
111
+ Based on:
112
+ - matchup strength
113
+ - trend alignment
114
+ - environment contribution
115
+
116
+ Then apply filters:
117
+
118
+ - suppress low confidence (< threshold)
119
+ - penalize high volatility
120
+ - suppress weak signal combinations
121
+
122
+ Create:
123
+
124
+ edge_raw
125
+ edge_filtered
126
+
127
+ Where:
128
+ edge_filtered = edge_raw adjusted by penalties
129
+
130
+ Also create:
131
+ - edge_filter_flags (list or string summary)
132
+
133
+ DO NOT delete rows β€” only adjust scores.
134
+
135
+ ------------------------------------------------------------
136
+ TASK 3 β€” TIMING HEURISTICS (LIGHT)
137
+ ------------------------------------------------------------
138
+
139
+ Without using historical snapshots:
140
+
141
+ Create:
142
+
143
+ price_aggressiveness_flag:
144
+ True if price is significantly better than market median
145
+
146
+ if timestamps exist:
147
+ detect potential_recent_move_flag
148
+
149
+ Otherwise:
150
+ skip safely
151
+
152
+ Create:
153
+ - timing_flag
154
+ - timing_reason
155
+
156
+ ------------------------------------------------------------
157
+ TASK 4 β€” CORRELATION AWARENESS (LIGHT)
158
+ ------------------------------------------------------------
159
+
160
+ Detect basic correlations:
161
+
162
+ Examples:
163
+ - hitter HR ↔ team total
164
+ - pitcher Ks ↔ opposing hitters
165
+ - same-game batter stacking
166
+
167
+ For each prop:
168
+
169
+ Create:
170
+ - correlation_flag
171
+ - correlation_direction (positive / negative / neutral)
172
+
173
+ No pricing adjustments yet β€” tagging only.
174
+
175
+ ------------------------------------------------------------
176
+ TASK 5 β€” FINAL EXECUTION SCORE
177
+ ------------------------------------------------------------
178
+
179
+ Create:
180
+
181
+ final_recommendation_score
182
+
183
+ Based on:
184
+ - edge_filtered
185
+ - confidence_score
186
+ - volatility_score
187
+ - market_width
188
+ - timing_flag
189
+
190
+ Keep formula SIMPLE and bounded.
191
+
192
+ Example structure:
193
+ score = edge_filtered * confidence_weight
194
+ - volatility_penalty
195
+ + market_bonus
196
+ + timing_bonus
197
+
198
+ Clamp output to reasonable range.
199
+
200
+ ------------------------------------------------------------
201
+ TASK 6 β€” DEBUG / VISIBILITY LAYER (CRITICAL)
202
+ ------------------------------------------------------------
203
+
204
+ Every prop must now include:
205
+
206
+ - edge_raw
207
+ - edge_filtered
208
+ - confidence_score
209
+ - volatility_score
210
+ - signal_strength_score
211
+ - market_width
212
+ - market_outlier_flag
213
+ - stale_book_flag
214
+ - timing_flag
215
+ - correlation_flag
216
+ - final_recommendation_score
217
+ - edge_filter_flags
218
+
219
+ Update Debug Dashboard:
220
+
221
+ Add section:
222
+ "Execution Layer"
223
+
224
+ Display:
225
+ - all above fields
226
+ - sorted by final_recommendation_score
227
+
228
+ Ensure:
229
+ - no crashes if fields missing
230
+ - None-safe handling everywhere
231
+
232
+ ------------------------------------------------------------
233
+ CONSTRAINTS
234
+ ------------------------------------------------------------
235
+
236
+ - All logic must be None-safe
237
+ - All scores must be bounded
238
+ - No division-by-zero possible
239
+ - No heavy computation
240
+ - No loops over large datasets beyond current props
241
+
242
+ ------------------------------------------------------------
243
+ DELIVERABLE
244
+ ------------------------------------------------------------
245
+
246
+ - All fields added to prop outputs
247
+ - Props page continues to function
248
+ - Debug page shows execution layer clearly
249
+ - No regression in existing outputs
250
+
251
+ This is an additive pass only.
252
+
253
+ Do not refactor unrelated code.