Premchan369 commited on
Commit
b666cca
Β·
verified Β·
1 Parent(s): e91d63c

Upload metrics_guide.py

Browse files
Files changed (1) hide show
  1. metrics_guide.py +577 -0
metrics_guide.py ADDED
@@ -0,0 +1,577 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """AlphaForge Metrics Guide - Deep explanations of every metric and how to trade with them.
2
+
3
+ This module teaches you WHAT each number means, WHY it matters, and HOW to act on it.
4
+ Think of this as your quant trading playbook.
5
+ """
6
+
7
+ METRICS_GUIDE = {
8
+ "sharpe_ratio": {
9
+ "name": "Sharpe Ratio",
10
+ "formula": "(Portfolio Return - Risk-Free Rate) / Portfolio Volatility",
11
+ "what_it_means": """
12
+ The Sharpe Ratio tells you how much EXTRA return you get per unit of risk taken.
13
+ It's the #1 metric every hedge fund looks at first.
14
+
15
+ - Sharpe = 0.5 β†’ You're getting some reward for risk, but barely worth it
16
+ - Sharpe = 1.0 β†’ Good. You're getting $1 of return for every $1 of risk
17
+ - Sharpe = 1.5 β†’ Very good. Professional-grade
18
+ - Sharpe = 2.0+ β†’ Excellent. Top-quartile hedge fund territory
19
+ - Sharpe = 3.0+ β†’ Legendary. Renaissance Technologies territory
20
+ """,
21
+ "how_it_influences": """
22
+ ACTIONABLE RULES:
23
+ - If Sharpe < 0.5: STOP. Your strategy is broken. Reduce position sizes by 50% or stop trading.
24
+ - If Sharpe 0.5-1.0: CAUTION. You're making money but taking too much risk. Tighten stops, reduce leverage.
25
+ - If Sharpe 1.0-1.5: SOLID. This is your baseline. Keep doing what you're doing.
26
+ - If Sharpe 1.5-2.0: GREAT. Consider INCREASING position sizes by 20-30%.
27
+ - If Sharpe > 2.0: EXCEPTIONAL. This is when you go ALL IN. Max out your allocation.
28
+
29
+ TWO SIGMA BENCHMARK: Their flagship fund runs ~1.8 Sharpe
30
+ CITADEL BENCHMARK: Their equity fund runs ~2.1 Sharpe
31
+ YOUR GOAL: Consistently above 1.2 Sharpe
32
+ """,
33
+ "real_example": """
34
+ Example: Your strategy returned 15% with 12% volatility. Risk-free rate is 4%.
35
+ Sharpe = (15% - 4%) / 12% = 0.92
36
+
37
+ Verdict: Decent, but not amazing. You're getting $0.92 per $1 of risk.
38
+ To improve: Either increase return (better signals) or reduce volatility (hedging).
39
+ """,
40
+ "tier": "CRITICAL",
41
+ "weight": 0.25
42
+ },
43
+
44
+ "sortino_ratio": {
45
+ "name": "Sortino Ratio",
46
+ "formula": "(Portfolio Return - Risk-Free Rate) / Downside Volatility",
47
+ "what_it_means": """
48
+ Sortino is like Sharpe, but it ONLY counts bad volatility (losses).
49
+ Sharpe punishes you for ALL volatility β€” even the good kind (big upward jumps).
50
+ Sortino is smarter: it only cares about downside risk.
51
+
52
+ - Sortino < 1.0 β†’ Your losses are too frequent or too large
53
+ - Sortino 1.0-1.5 β†’ Acceptable. You handle downside okay
54
+ - Sortino 1.5-2.5 β†’ Strong. You make money while controlling losses
55
+ - Sortino 2.5+ β†’ Elite. You're a loss-cutting machine
56
+ """,
57
+ "how_it_influences": """
58
+ ACTIONABLE RULES:
59
+ - If Sortino < Sharpe: GOOD. Means your upside volatility is helping you.
60
+ - If Sortino β‰ˆ Sharpe: NEUTRAL. Your upside and downside are balanced.
61
+ - If Sortino > Sharpe by 0.5+: EXCELLENT. You have asymmetric upside β€” the holy grail.
62
+ - If Sortino drops below 0.8: RAISE STOPS IMMEDIATELY. Your downside is out of control.
63
+
64
+ PRO TIP: Always compare Sortino to Sharpe. The GAP between them tells you
65
+ if your strategy has positive skew (good) or negative skew (dangerous).
66
+ """,
67
+ "real_example": """
68
+ Example: Return = 12%, Downside volatility = 5%, Total volatility = 15%
69
+ Sharpe = (12-4)/15 = 0.53
70
+ Sortino = (12-4)/5 = 1.6
71
+
72
+ Verdict: Sharpe looks mediocre, but Sortino is strong! This means most of your
73
+ volatility is UPWARD (good jumps). Strategy has positive skew. KEEP TRADING.
74
+ """,
75
+ "tier": "CRITICAL",
76
+ "weight": 0.20
77
+ },
78
+
79
+ "information_coefficient": {
80
+ "name": "Information Coefficient (IC)",
81
+ "formula": "Rank correlation between predicted returns and actual returns",
82
+ "what_it_means": """
83
+ IC measures: "How good are my predictions ACTUALLY?"
84
+ It's the correlation between what your model PREDICTED and what REALLY happened.
85
+
86
+ - IC = 0.00 β†’ Your model is random. Coin-flip level.
87
+ - IC = 0.02 β†’ Barely useful. Weak but tradable at scale.
88
+ - IC = 0.05 β†’ Decent. This is where most quant strategies live.
89
+ - IC = 0.10 β†’ Strong. You're genuinely predicting better than chance.
90
+ - IC = 0.15+ β†’ Exceptional. Top-tier signal quality.
91
+
92
+ KEY INSIGHT: IC compounds. If you have 0.05 IC daily, that's MASSIVE over a year.
93
+ """,
94
+ "how_it_influences": """
95
+ ACTIONABLE RULES:
96
+ - If IC < 0.02: YOUR SIGNAL IS DEAD. Stop trading it. Retrain the model.
97
+ - If IC 0.02-0.05: WORKABLE. Trade smaller sizes. This is your bread-and-butter range.
98
+ - If IC 0.05-0.08: STRONG. Increase allocation to this signal. Scale up positions.
99
+ - If IC 0.08-0.12: EXCELLENT. This is your golden goose. Maximize exposure.
100
+ - If IC turns NEGATIVE: SIGNAL DECAY. Your model is now WRONG. FLIP THE SIGNAL or stop.
101
+
102
+ IC IR (IC / std(IC)):
103
+ - IC IR < 0.5: Unstable signal. Too noisy.
104
+ - IC IR 0.5-1.0: Decent stability.
105
+ - IC IR > 1.0: Rock solid. You can build a career on this.
106
+ """,
107
+ "real_example": """
108
+ Example: You predicted AAPL would return +2%, MSFT +1%, TSLA -1%.
109
+ Actual returns: AAPL +3%, MSFT 0%, TSLA -2%.
110
+
111
+ Your ranking was: AAPL > MSFT > TSLA
112
+ Actual ranking was: AAPL > MSFT > TSLA
113
+ IC = 1.0 (perfect!)
114
+
115
+ But if actual was: TSLA +5%, AAPL +1%, MSFT -1%
116
+ Then your ranking was wrong. IC would be negative.
117
+
118
+ This is why IC is rank-based β€” it cares about ORDER, not exact values.
119
+ """,
120
+ "tier": "CRITICAL",
121
+ "weight": 0.20
122
+ },
123
+
124
+ "max_drawdown": {
125
+ "name": "Maximum Drawdown",
126
+ "formula": "(Peak Value - Trough Value) / Peak Value",
127
+ "what_it_means": """
128
+ Max Drawdown is: "What's the worst losing streak I've ever had?"
129
+ It's the biggest drop from your highest point to your lowest point.
130
+
131
+ - Max DD < 5% β†’ You're a conservative saint
132
+ - Max DD 5-10% β†’ Conservative. Sleep-well-at-night level
133
+ - Max DD 10-20% β†’ Moderate. Normal for active strategies
134
+ - Max DD 20-30% β†’ Aggressive. You'll have sleepless nights
135
+ - Max DD 30-50% β†’ Dangerous. Most people panic-sell here
136
+ - Max DD > 50% β†’ You will blow up. Guaranteed.
137
+ """,
138
+ "how_it_influences": """
139
+ ACTIONABLE RULES:
140
+ - If Max DD exceeds your personal pain threshold: REDUCE RISK by 50%.
141
+ - If Max DD > 25%: Add hedges (buy puts, short index, reduce beta).
142
+ - If Max DD < 10% for 6 months: You can INCREASE leverage by 25%.
143
+ - If drawdown lasts > 3 months: Something is structurally broken. Review strategy.
144
+
145
+ THE PSYCHOLOGY RULE:
146
+ Most traders can handle 10% drawdown.
147
+ At 20%, they start questioning the strategy.
148
+ At 30%, they panic and sell the bottom.
149
+ At 40%, they quit trading forever.
150
+
151
+ Set your max pain level BEFORE you trade. AlphaForge suggests 15% as default.
152
+ """,
153
+ "real_example": """
154
+ Example: You started with $1M. Grew to $1.3M (peak). Then dropped to $1.1M (trough).
155
+ Max DD = ($1.3M - $1.1M) / $1.3M = 15.4%
156
+
157
+ This means at your worst moment, you were down $200K from your best moment.
158
+ Can you handle seeing $200K evaporate? If not, trade smaller.
159
+
160
+ RECOVERY MATH: After a 15.4% drawdown, you need +18.2% to get back to peak.
161
+ After a 50% drawdown, you need +100% just to break even. This is why drawdown KILLS.
162
+ """,
163
+ "tier": "CRITICAL",
164
+ "weight": 0.15
165
+ },
166
+
167
+ "calmar_ratio": {
168
+ "name": "Calmar Ratio",
169
+ "formula": "Annualized Return / |Max Drawdown|",
170
+ "what_it_means": """
171
+ Calmar answers: "How much return do I get relative to my worst nightmare?"
172
+ It compares your yearly gain to your maximum drawdown.
173
+
174
+ - Calmar < 1.0 β†’ Your drawdown is BIGGER than your annual return. Dangerous.
175
+ - Calmar 1.0-2.0 β†’ Decent. You're getting paid for the risk.
176
+ - Calmar 2.0-3.0 β†’ Strong. Good risk/reward balance.
177
+ - Calmar 3.0+ β†’ Excellent. Your returns dwarf your worst losses.
178
+
179
+ Calmar is MORE important than Sharpe for long-term survival.
180
+ """,
181
+ "how_it_influences": """
182
+ ACTIONABLE RULES:
183
+ - If Calmar < 1.0: EMERGENCY. Your strategy will eventually blow up. Cut size by 75%.
184
+ - If Calmar 1.0-1.5: CAUTION. You're surviving but not thriving. Add diversification.
185
+ - If Calmar 1.5-2.5: SOLID. This is sustainable long-term.
186
+ - If Calmar > 3.0: EXCEPTIONAL. You've found a gem. Scale up carefully.
187
+
188
+ THE SURVIVAL RULE: No strategy with Calmar < 1.0 survives 5 years. Period.
189
+ """,
190
+ "real_example": """
191
+ Example: Annual return = 20%, Max drawdown = 15%
192
+ Calmar = 20 / 15 = 1.33
193
+
194
+ Verdict: Okay but not great. You're making 20% but had a 15% nightmare.
195
+
196
+ Better: Annual return = 15%, Max drawdown = 5%
197
+ Calmar = 15 / 5 = 3.0
198
+
199
+ Verdict: MUCH better! Lower return but tiny drawdown. You'll compound wealth
200
+ steadily without panic-selling. THIS is the path to GOAT status.
201
+ """,
202
+ "tier": "HIGH",
203
+ "weight": 0.10
204
+ },
205
+
206
+ "win_rate": {
207
+ "name": "Win Rate",
208
+ "formula": "Number of winning days / Total trading days",
209
+ "what_it_means": """
210
+ Win Rate is: "How often am I right?"
211
+ But here's the SECRET: Win rate ALONE is meaningless.
212
+
213
+ A 30% win rate can be profitable (if wins are 3x bigger than losses).
214
+ A 70% win rate can be unprofitable (if losses are 3x bigger than wins).
215
+
216
+ What matters is: Win Rate Γ— Average Win / (1 - Win Rate) Γ— Average Loss
217
+ This is your EXPECTANCY. If it's > 0, you're profitable.
218
+ """,
219
+ "how_it_influences": """
220
+ ACTIONABLE RULES:
221
+ - If Win Rate < 40% but profitable: You have positive skew. Your wins are HUGE.
222
+ β†’ Keep going but prepare for long losing streaks mentally.
223
+ - If Win Rate > 60% but barely profitable: You have negative skew.
224
+ β†’ DANGER. One big loss wipes out 10 small wins. Tighten stops.
225
+ - If Win Rate 45-55% with good profits: BALANCED. The sweet spot.
226
+ - If Win Rate drops 10% from historical average: SIGNAL DECAY. Retrain.
227
+
228
+ THE MENTAL GAME:
229
+ A 50% win rate means you'll have 5 losses in a row ~3% of the time.
230
+ You'll have 10 losses in a row ~0.1% of the time (but it WILL happen).
231
+ Prepare mentally. This is why position sizing > prediction accuracy.
232
+ """,
233
+ "real_example": """
234
+ Example A: 40% win rate. Average win = $300, average loss = $100
235
+ Expectancy = (0.4 Γ— $300) - (0.6 Γ— $100) = $120 - $60 = +$60 per trade
236
+ Verdict: PROFITABLE despite low win rate!
237
+
238
+ Example B: 65% win rate. Average win = $100, average loss = $250
239
+ Expectancy = (0.65 Γ— $100) - (0.35 Γ— $250) = $65 - $87.50 = -$22.50 per trade
240
+ Verdict: LOSING despite high win rate! This is a classic trap.
241
+ """,
242
+ "tier": "MEDIUM",
243
+ "weight": 0.05
244
+ },
245
+
246
+ "profit_factor": {
247
+ "name": "Profit Factor",
248
+ "formula": "Gross Profits / Gross Losses",
249
+ "what_it_means": """
250
+ Profit Factor is: "For every $1 I lose, how much do I make?"
251
+
252
+ - PF < 1.0 β†’ You're losing money. Period.
253
+ - PF = 1.0 β†’ You're breaking even before costs. Losing money after costs.
254
+ - PF 1.0-1.5 β†’ Marginal. Profitable but fragile.
255
+ - PF 1.5-2.0 β†’ Good. Solid edge.
256
+ - PF 2.0-3.0 β†’ Strong. Professional grade.
257
+ - PF 3.0+ β†’ Exceptional. Don't tell anyone your secret.
258
+ """,
259
+ "how_it_influences": """
260
+ ACTIONABLE RULES:
261
+ - If PF < 1.0: STOP IMMEDIATELY. You have no edge.
262
+ - If PF 1.0-1.3: BARELY ALIVE. One bad streak kills you. Reduce size 50%.
263
+ - If PF 1.3-1.8: HEALTHY. This is sustainable.
264
+ - If PF > 2.0: ROBUST. You can survive multiple bad streaks.
265
+
266
+ THE COMPOUNDING RULE:
267
+ PF of 1.5 with 50% win rate = steady wealth builder
268
+ PF of 1.2 with 60% win rate = fragile, will eventually break
269
+
270
+ Higher PF > Higher Win Rate (for survival).
271
+ """,
272
+ "real_example": """
273
+ Example: Over 100 trades, your winners totaled $50,000. Your losers totaled $30,000.
274
+ Profit Factor = $50,000 / $30,000 = 1.67
275
+
276
+ Verdict: For every $1 you lost, you made $1.67. Solid.
277
+ After transaction costs (say $5,000), net PF = $45K/$35K = 1.29
278
+
279
+ Transaction costs dropped your PF from 1.67 to 1.29! This is why
280
+ keeping costs low is CRITICAL. Use low-cost brokers, trade less.
281
+ """,
282
+ "tier": "HIGH",
283
+ "weight": 0.05
284
+ },
285
+
286
+ "alpha": {
287
+ "name": "Alpha (Jensen's Alpha)",
288
+ "formula": "Portfolio Return - (Risk-Free Rate + Beta Γ— (Market Return - Risk-Free Rate))",
289
+ "what_it_means": """
290
+ Alpha is: "How much EXTRA return did I generate ABOVE what the market explains?"
291
+ If Beta = 1 and market goes up 10%, you "should" make 10%.
292
+ If you made 15%, your Alpha = 5%. That's YOUR skill.
293
+
294
+ - Alpha < 0% β†’ You're underperforming a simple index fund. Just buy SPY.
295
+ - Alpha 0-2% β†’ Matching the market. No edge.
296
+ - Alpha 2-5% β†’ Good. You're adding value.
297
+ - Alpha 5-10% β†’ Strong. Significant edge.
298
+ - Alpha 10%+ β†’ Elite. You're in the top 1% of managers.
299
+ """,
300
+ "how_it_influences": """
301
+ ACTIONABLE RULES:
302
+ - If Alpha < 0% for 6+ months: JUST BUY THE INDEX. You're wasting time and money.
303
+ - If Alpha 0-3%: You're a "closet indexer." Either commit to active or go passive.
304
+ - If Alpha 3-7%: SOLID EDGE. Keep refining but don't over-optimize.
305
+ - If Alpha > 7%: EXCEPTIONAL. Document your process. This edge won't last forever.
306
+
307
+ THE HUMBLING TRUTH:
308
+ 80% of active managers have NEGATIVE alpha after fees.
309
+ S&P 500 has returned ~10%/year for decades.
310
+ If you can't beat that, just buy SPY and enjoy life.
311
+ """,
312
+ "real_example": """
313
+ Example: You returned 18%. Market (SPY) returned 12%. Your Beta = 1.2. Risk-free = 4%.
314
+ Expected return = 4% + 1.2 Γ— (12% - 4%) = 4% + 9.6% = 13.6%
315
+ Alpha = 18% - 13.6% = 4.4%
316
+
317
+ Verdict: You beat what the market explains by 4.4%. That's YOUR skill.
318
+ But if you paid 2% in fees, net alpha = 2.4%. Still good, but fees HALVED it.
319
+
320
+ This is why hedge funds charge 2% + 20% β€” they claim to generate alpha.
321
+ Most don't. You can beat them with discipline.
322
+ """,
323
+ "tier": "HIGH",
324
+ "weight": 0.05
325
+ },
326
+
327
+ "beta": {
328
+ "name": "Beta",
329
+ "formula": "Covariance(Portfolio, Market) / Variance(Market)",
330
+ "what_it_means": """
331
+ Beta measures: "How much do I move when the market moves?"
332
+
333
+ - Beta = 0.0 β†’ You're market-neutral. Market crashes, you don't care.
334
+ - Beta = 0.5 β†’ You're conservative. Market up 10%, you up 5%.
335
+ - Beta = 1.0 β†’ You move exactly with the market (like SPY).
336
+ - Beta = 1.5 β†’ You're aggressive. Market up 10%, you up 15%. Market down 10%, you down 15%.
337
+ - Beta = -0.5 β†’ You move opposite to market. Market crashes, you gain.
338
+
339
+ Beta is NOT good or bad. It's a CHOICE based on your goals.
340
+ """,
341
+ "how_it_influences": """
342
+ ACTIONABLE RULES:
343
+ - If you want MARKET EXPOSURE (bullish): Target Beta 0.8-1.2
344
+ - If you want LOW RISK (wealth preservation): Target Beta 0.3-0.6
345
+ - If you want MARKET NEUTRAL (hedge fund style): Target Beta 0.0 Β± 0.1
346
+ - If you want INVERSE (betting on crash): Target Beta -0.5 to -1.0
347
+
348
+ DYNAMIC BETA MANAGEMENT:
349
+ - In bull markets (regime = 'bull'): Increase beta to 1.2-1.5 to capture upside
350
+ - In bear markets (regime = 'bear'): Reduce beta to 0.3-0.5 to protect capital
351
+ - In high volatility: Reduce beta to 0.0-0.3. Survive first, profit second.
352
+
353
+ THE BETA TRAP:
354
+ Most amateur traders have Beta > 1.5 without knowing it.
355
+ They think they're skilled, but they're just LEVERAGED to the market.
356
+ When the market crashes, they get destroyed.
357
+ """,
358
+ "real_example": """
359
+ Example: Market (SPY) drops 20% in a month.
360
+ - If your Beta = 0.3: You drop ~6%. Annoying but survivable.
361
+ - If your Beta = 1.5: You drop ~30%. Devastating.
362
+ - If your Beta = -0.2: You GAIN ~4%. You're the smart one.
363
+
364
+ This is why Beta management is MORE important than stock picking.
365
+ Being in the right "market exposure" at the right time beats being right about Apple.
366
+ """,
367
+ "tier": "HIGH",
368
+ "weight": 0.05
369
+ },
370
+
371
+ "information_ratio": {
372
+ "name": "Information Ratio",
373
+ "formula": "(Portfolio Return - Benchmark Return) / Tracking Error",
374
+ "what_it_means": """
375
+ Information Ratio measures: "How much excess return do I get per unit of ACTIVE risk?"
376
+ It's like Sharpe, but compares you to a BENCHMARK instead of risk-free rate.
377
+
378
+ - IR < 0.0 β†’ You're losing to the benchmark. Just buy the index.
379
+ - IR 0.0-0.3 β†’ Barely adding value. Probably not worth the effort.
380
+ - IR 0.3-0.5 β†’ Decent. You're adding some value.
381
+ - IR 0.5-1.0 β†’ Good. Meaningful active management skill.
382
+ - IR 1.0+ β†’ Excellent. Top-tier active manager.
383
+
384
+ THE GOLDEN RULE: IR > 0.5 means active management is WORTH the fees/time.
385
+ """,
386
+ "how_it_influences": """
387
+ ACTIONABLE RULES:
388
+ - If IR < 0: STOP ACTIVE TRADING. Buy SPY and save yourself the stress.
389
+ - If IR 0-0.3: You're "expensive index fund." Reduce active bets, increase passive.
390
+ - If IR 0.3-0.7: SOLID ACTIVE MANAGEMENT. Keep your current strategy.
391
+ - If IR > 0.7: EXCEPTIONAL. You have genuine skill. Consider managing money for others.
392
+
393
+ TRACKING ERROR:
394
+ Low tracking error + positive IR = "closet indexer with slight edge"
395
+ High tracking error + positive IR = "concentrated bets paying off"
396
+ High tracking error + negative IR = "you're gambling, not investing"
397
+ """,
398
+ "real_example": """
399
+ Example: You returned 14%. SPY returned 10%. Tracking error = 8%.
400
+ IR = (14% - 10%) / 8% = 0.5
401
+
402
+ Verdict: You're making 4% extra but with 8% of "different" risk.
403
+ IR = 0.5 means it's worth it, but barely.
404
+
405
+ Better scenario: You returned 16%. SPY returned 10%. Tracking error = 5%.
406
+ IR = (16% - 10%) / 5% = 1.2
407
+
408
+ Verdict: MUCH better! More excess return with LESS tracking error.
409
+ This is the definition of skill. IR > 1.0 is top 5% of all managers.
410
+ """,
411
+ "tier": "MEDIUM",
412
+ "weight": 0.05
413
+ },
414
+
415
+ "turnover": {
416
+ "name": "Portfolio Turnover",
417
+ "formula": "Sum of absolute weight changes / 2",
418
+ "what_it_means": """
419
+ Turnover measures: "How much of my portfolio did I trade?"
420
+ 100% turnover = You sold everything and bought new stuff.
421
+
422
+ - Turnover < 20%/year β†’ Very low. Buy-and-hold style.
423
+ - Turnover 20-50%/year β†’ Low. Long-term focused.
424
+ - Turnover 50-100%/year β†’ Moderate. Typical for active strategies.
425
+ - Turnover 100-200%/year β†’ High. Trading frequently.
426
+ - Turnover > 300%/year β†’ Very high. Day-trading territory.
427
+
428
+ HIGH TURNOVER = HIGH COSTS. Every trade costs money.
429
+ """,
430
+ "how_it_influences": """
431
+ ACTIONABLE RULES:
432
+ - If turnover > 150% but Sharpe < 1.0: You're trading too much. Reduce rebalancing frequency.
433
+ - If turnover < 30% but Sharpe > 1.5: Perfect. Low cost, high return.
434
+ - If transaction costs > 20% of gross profits: Your strategy is paying your broker, not you.
435
+
436
+ THE COST RULE:
437
+ At 3bps (0.03%) per trade + 150% annual turnover:
438
+ Total cost = 150% Γ— 0.03% Γ— 2 (buy + sell) = 0.09% per year
439
+
440
+ At 10bps + 300% turnover:
441
+ Total cost = 300% Γ— 0.10% Γ— 2 = 0.60% per year
442
+
443
+ This doesn't sound like much, but on $1M, that's $6,000/year in friction.
444
+ Over 20 years at 10% return, that's $40,000+ in lost compounding.
445
+ """,
446
+ "real_example": """
447
+ Example: Your strategy rebalances weekly. Each rebalance has 40% turnover.
448
+ Annual turnover = 40% Γ— 52 weeks = 2,080%
449
+
450
+ At 3bps cost: Annual friction = 2,080% Γ— 0.03% Γ— 2 = 1.25%
451
+
452
+ If your gross alpha is 3%, your NET alpha is 3% - 1.25% = 1.75%
453
+ You lost 42% of your edge to transaction costs!
454
+
455
+ SOLUTION: Rebalance monthly instead of weekly.
456
+ Annual turnover = 40% Γ— 12 = 480%
457
+ Annual friction = 480% Γ— 0.03% Γ— 2 = 0.29%
458
+ Net alpha = 3% - 0.29% = 2.71%
459
+
460
+ You DOUBLED your net alpha just by trading less! This is why patience pays.
461
+ """,
462
+ "tier": "MEDIUM",
463
+ "weight": 0.05
464
+ }
465
+ }
466
+
467
+
468
+ def get_metric_explanation(metric_key: str) -> dict:
469
+ """Get full explanation for a metric"""
470
+ return METRICS_GUIDE.get(metric_key, {})
471
+
472
+
473
+ def print_all_metrics():
474
+ """Print the complete metrics guide"""
475
+ print("=" * 80)
476
+ print("ALPHAFORGE METRICS GUIDE - YOUR PATH TO GOAT STATUS")
477
+ print("=" * 80)
478
+ print()
479
+
480
+ for key, info in METRICS_GUIDE.items():
481
+ print(f"\n{'='*80}")
482
+ print(f"πŸ“Š {info['name'].upper()} [{info['tier']} | Weight: {info['weight']*100:.0f}%]")
483
+ print(f"{'='*80}")
484
+ print(f"\nπŸ“ FORMULA:\n{info['formula']}")
485
+ print(f"\nπŸ’‘ WHAT IT MEANS:\n{info['what_it_means']}")
486
+ print(f"\n🎯 HOW IT INFLUENCES YOUR TRADING:\n{info['how_it_influences']}")
487
+ print(f"\nπŸ“– REAL EXAMPLE:\n{info['real_example']}")
488
+ print()
489
+
490
+
491
+ def get_goat_score(metrics: dict) -> dict:
492
+ """
493
+ Calculate a composite GOAT score based on all metrics.
494
+ This tells you how close you are to elite quant status.
495
+ """
496
+ score = 0
497
+ max_score = 0
498
+ breakdown = {}
499
+
500
+ weights = {
501
+ 'sharpe_ratio': 0.25,
502
+ 'sortino_ratio': 0.20,
503
+ 'information_coefficient': 0.20,
504
+ 'max_drawdown': 0.15,
505
+ 'calmar_ratio': 0.10,
506
+ 'win_rate': 0.05,
507
+ 'profit_factor': 0.05,
508
+ 'alpha': 0.05,
509
+ 'beta': 0.05,
510
+ 'information_ratio': 0.05,
511
+ 'turnover': 0.05
512
+ }
513
+
514
+ # Sharpe scoring
515
+ sharpe = metrics.get('sharpe_ratio', 0)
516
+ sharpe_score = min(sharpe / 2.0, 1.0) * 100
517
+ score += sharpe_score * weights['sharpe_ratio']
518
+ max_score += 100 * weights['sharpe_ratio']
519
+ breakdown['sharpe'] = {'value': sharpe, 'score': sharpe_score, 'max': 100}
520
+
521
+ # Sortino scoring
522
+ sortino = metrics.get('sortino_ratio', 0)
523
+ sortino_score = min(sortino / 2.5, 1.0) * 100
524
+ score += sortino_score * weights['sortino_ratio']
525
+ max_score += 100 * weights['sortino_ratio']
526
+ breakdown['sortino'] = {'value': sortino, 'score': sortino_score, 'max': 100}
527
+
528
+ # IC scoring
529
+ ic = metrics.get('ic_mean', metrics.get('mean_ic', 0))
530
+ ic_score = min(ic / 0.10, 1.0) * 100
531
+ score += ic_score * weights['information_coefficient']
532
+ max_score += 100 * weights['information_coefficient']
533
+ breakdown['ic'] = {'value': ic, 'score': ic_score, 'max': 100}
534
+
535
+ # Max DD scoring (inverted - lower is better)
536
+ mdd = abs(metrics.get('max_drawdown', 0))
537
+ mdd_score = max(0, (1 - mdd / 0.30)) * 100
538
+ score += mdd_score * weights['max_drawdown']
539
+ max_score += 100 * weights['max_drawdown']
540
+ breakdown['max_drawdown'] = {'value': mdd, 'score': mdd_score, 'max': 100}
541
+
542
+ # Calmar scoring
543
+ calmar = metrics.get('calmar_ratio', 0)
544
+ calmar_score = min(calmar / 3.0, 1.0) * 100
545
+ score += calmar_score * weights['calmar_ratio']
546
+ max_score += 100 * weights['calmar_ratio']
547
+ breakdown['calmar'] = {'value': calmar, 'score': calmar_score, 'max': 100}
548
+
549
+ total_score = (score / max_score * 100) if max_score > 0 else 0
550
+
551
+ # Determine tier
552
+ if total_score >= 85:
553
+ tier = "LEGENDARY GOAT"
554
+ emoji = "🐐"
555
+ elif total_score >= 70:
556
+ tier = "ELITE QUANT"
557
+ emoji = "⭐"
558
+ elif total_score >= 55:
559
+ tier = "SOLID PRO"
560
+ emoji = "πŸ’ͺ"
561
+ elif total_score >= 40:
562
+ tier = "DEVELOPING"
563
+ emoji = "πŸ“ˆ"
564
+ else:
565
+ tier = "NEEDS WORK"
566
+ emoji = "πŸ”§"
567
+
568
+ return {
569
+ 'total_score': total_score,
570
+ 'tier': tier,
571
+ 'emoji': emoji,
572
+ 'breakdown': breakdown
573
+ }
574
+
575
+
576
+ if __name__ == '__main__':
577
+ print_all_metrics()