-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
198 lines (171 loc) · 7.3 KB
/
Copy pathconfig.py
File metadata and controls
198 lines (171 loc) · 7.3 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
"""
Deep-Risk-OPP — Shared Configuration
=====================================
All framework parameters, circuit breakers, and data source definitions.
Modify thresholds only with strong historical evidence.
"""
# ============================================================
# GOR SEISMOGRAPH
# ============================================================
# GOR = Gold($/oz) / WTI($/bbl)
GOR_EXTREME = 45 # Extreme opportunity: oil deeply undervalued
GOR_RECOVERY = 30 # Recovery cycle floor
GOR_FAIR_VALUE = 20 # Fair value: historical equilibrium (15-25)
GOR_ZONES = {
"extreme": {"min": 45, "max": 999, "label": "Extreme Opportunity", "color": "#ff4444"},
"recovery": {"min": 30, "max": 45, "label": "Recovery Cycle", "color": "#ffaa00"},
"fair_value": {"min": 20, "max": 30, "label": "Fair Value", "color": "#00cc66"},
"oil_bubble": {"min": 0, "max": 20, "label": "Oil Bubble", "color": "#4488ff"},
}
# ============================================================
# CIRCUIT BREAKERS (Non-Negotiable)
# ============================================================
# --- Dynamic Hard Stop (v2.1: replaces static $75 rule) ---
# Rationale: A static $75 hard stop was too conservative during
# supply-driven oil declines (e.g., Iran peace deal, June 2026).
# The new dynamic rule only triggers during demand-shock crashes.
#
# Rule: Hard stop triggers ONLY when ALL of:
# 1. WTI < 60-day SMA × HARD_STOP_MA_MULTIPLIER (price collapse)
# 2. GOR did NOT increase significantly (ruling out supply shock)
# → Supply shock: oil drops, gold holds → GOR↑ → framework signal strengthens
# → Demand shock: everything drops → GOR flat/↓ → hard stop triggers
#
# Legacy static threshold retained as absolute floor:
# WTI < WTI_ABSOLUTE_FLOOR → hard stop ALWAYS triggers (no exceptions)
HARD_STOP_MA_PERIOD = 60 # 60-day simple moving average
HARD_STOP_MA_MULTIPLIER = 0.85 # Trigger if WTI < 85% of 60-day MA
GOR_SUPPLY_SHOCK_RISE = 0.05 # GOR ↑ > 5% in 5 days = supply shock (override)
VIX_DEMAND_CONFIRM = 20 # VIX > 20 = fear confirms demand shock
WTI_ABSOLUTE_FLOOR = 60 # Below this: hard stop always triggers (absolute floor)
# Legacy static threshold (deprecated in favor of dynamic rule, kept as reference)
WTI_HARD_STOP = 75 # [DEPRECATED v2.1] Replaced by dynamic rule above
DXY_THRESHOLD = 99 # Strong USD: total position -10%
YIELD_THRESHOLD = 4.3 # High rates (10Y): total position -10%
VIX_PANIC = 25 # Vol explosion: all risk positions -50%
PBOC_GOLD_FLOOR = 2 # PBoC monthly gold buy (tons): gold floor >= 15%
# ============================================================
# ALLOCATION BASELINE (by GOR zone, before risk corrections)
# ============================================================
BASE_ALLOCATION = {
"extreme": {
"total": 70,
"oil": 38,
"gold": 10,
"a_shares": 12,
"copper": 3,
"cash": 37,
},
"recovery": {
"total": 50,
"oil": 20,
"gold": 15,
"a_shares": 15,
"copper": 0,
"cash": 50,
},
"fair_value": {
"total": 30,
"oil": 0,
"gold": 15,
"a_shares": 20,
"copper": 0,
"cash": 65,
},
"oil_bubble": {
"total": 10,
"oil": 0,
"gold": 7,
"a_shares": 3,
"copper": 0,
"cash": 90,
},
}
# ============================================================
# PRIORITY CHAIN (lower number = higher priority)
# ============================================================
CIRCUIT_BREAKER_PRIORITY = 1 # Always wins
RISK_CALENDAR_PRIORITY = 2 # FOMC / OPEC+ / election overrides
BAGHOLDER_PRIORITY = 3 # Bagholder >= 7: all positions x 0.7
CAPITAL_FLOW_PRIORITY = 4 # Centripetal collapse: cash >= 40%
GOR_DIRECTION_PRIORITY = 5 # Default allocation baseline
MASTER_CONSENSUS_PRIORITY = 6 # Advisory only, does not override
# ============================================================
# OIL TARGET / STOP ZONES
# ============================================================
OIL_ACCUMULATION_ZONE = (75, 85) # WTI range for low-absorb
OIL_TARGET_ZONE = (95, 105) # WTI take-profit range
OIL_HARD_STOP = 75 # [DEPRECATED v2.1] Replaced by dynamic rule
# ============================================================
# CAPITAL THREE-FLOWS THRESHOLDS
# ============================================================
DXY_CENTRIPETAL = 99 # DXY above this = centripetal
DXY_CENTRIFUGAL = 98 # DXY below this = centrifugal
VIX_ACCELERATING = 20 # VIX above this = flow speed accelerating
VIX_PANIC = 25 # VIX above this = panic
# ============================================================
# DATA SOURCES
# ============================================================
GOLD_SOURCE = "Yahoo Finance (GC=F)"
WTI_SOURCE = "Yahoo Finance (CL=F)"
BRENT_SOURCE = "Yahoo Finance (BZ=F)"
DXY_SOURCE = "ICE (DX-Y.NYB) + FRED (DTWEXBGS)"
YIELD_10Y_SOURCE = "CBOE (^TNX) + FRED (DGS10)"
YIELD_30Y_SOURCE = "CBOE (^TYX) + FRED (DGS30)"
VIX_SOURCE = "CBOE (^VIX)"
COPPER_SOURCE = "COMEX (HG=F)"
# API endpoints for gor_daily.py
API_ENDPOINTS = {
"gold": "GC=F",
"wti": "CL=F",
"brent": "BZ=F",
"dxy": "DX-Y.NYB",
"ten_year": "^TNX",
"vix": "^VIX",
"copper": "HG=F",
}
# ============================================================
# FRED API CONFIGURATION (Federal Reserve Economic Data)
# ============================================================
# FRED API key loaded from .env file (never committed to repo)
# See .env.example for setup instructions
FRED_SERIES = {
"DGS10": "10-Year Treasury Constant Maturity Rate",
"DGS30": "30-Year Treasury Constant Maturity Rate",
"DFF": "Federal Funds Effective Rate",
"DTWEXBGS": "Trade Weighted U.S. Dollar Index (Broad)",
"CPIAUCSL": "Consumer Price Index (All Urban Consumers)",
"PCEPILFE": "Core PCE Price Index (excl. Food & Energy)",
"WALCL": "Federal Reserve Total Assets",
"M2SL": "M2 Money Supply",
"GFDEBTN": "Federal Debt: Total Public Debt",
"VIXCLS": "CBOE Volatility Index (VIX)",
"DCOILWTICO": "WTI Crude Oil Spot Price",
"GOLDAMGBD228NLBR": "Gold Fixing Price (London, USD/oz)",
}
# ============================================================
# FILE PATHS
# ============================================================
OUTPUT_DIR = "./看板日志"
GOR_LATEST = "./gor_latest.json"
CAPITAL_FLOWS_LATEST = "./capital_flows_latest.json"
DECISION_CARD_TEMPLATE = "./每日资讯/📊 GOR 今日决策卡.md"
WTI_HISTORY = "./wti_history.json" # Rolling 60-day WTI/GOR/VIX for dynamic hard stop
# ============================================================
# MCP / CLAUDE CODE INTEGRATION
# ============================================================
SKILL_NAME = "Deep-Risk-OPP"
SKILL_VERSION = "2.0.0"
SKILL_TRIGGERS = [
"macro risk",
"GOR",
"gold oil ratio",
"capital flows",
"what to allocate",
"Deep-Risk",
]
if __name__ == "__main__":
print(f"Deep-Risk-OPP v{SKILL_VERSION}")
print(f"GOR Extreme threshold: >= {GOR_EXTREME}")
print(f"WTI Hard Stop: ${WTI_HARD_STOP}")
print(f"Priority levels: {CIRCUIT_BREAKER_PRIORITY} (breaker) to {MASTER_CONSENSUS_PRIORITY} (masters)")