Spaces:
Running
Running
log why each source failed
Browse files- app/fetch.py +5 -1
app/fetch.py
CHANGED
|
@@ -36,6 +36,8 @@ def _yahoo(sym, days):
|
|
| 36 |
u = ("https://query1.finance.yahoo.com/v8/finance/chart/%s"
|
| 37 |
"?range=%s&interval=1d" % (sym, "10y" if days > 1200 else "5y"))
|
| 38 |
r = requests.get(u, headers=UA, timeout=25)
|
|
|
|
|
|
|
| 39 |
j = r.json()["chart"]["result"][0]
|
| 40 |
ts = j["timestamp"]
|
| 41 |
cl = j["indicators"]["quote"][0]["close"]
|
|
@@ -112,7 +114,9 @@ def daily(asset, days=1800):
|
|
| 112 |
if n >= MIN_BARS: # 0건은 성공이 아니다
|
| 113 |
return s.sort_index().iloc[-days:], name, trail
|
| 114 |
except Exception as e:
|
| 115 |
-
|
|
|
|
|
|
|
| 116 |
return None, None, trail
|
| 117 |
|
| 118 |
|
|
|
|
| 36 |
u = ("https://query1.finance.yahoo.com/v8/finance/chart/%s"
|
| 37 |
"?range=%s&interval=1d" % (sym, "10y" if days > 1200 else "5y"))
|
| 38 |
r = requests.get(u, headers=UA, timeout=25)
|
| 39 |
+
if r.status_code != 200:
|
| 40 |
+
raise ValueError("HTTP %d %s" % (r.status_code, r.text[:60]))
|
| 41 |
j = r.json()["chart"]["result"][0]
|
| 42 |
ts = j["timestamp"]
|
| 43 |
cl = j["indicators"]["quote"][0]["close"]
|
|
|
|
| 114 |
if n >= MIN_BARS: # 0건은 성공이 아니다
|
| 115 |
return s.sort_index().iloc[-days:], name, trail
|
| 116 |
except Exception as e:
|
| 117 |
+
# 🔴 예외 '종류'만 남기면 왜 막혔는지 모른다. 진단이 안 되는 로그는
|
| 118 |
+
# 없는 로그와 같다. 메시지까지 남긴다.
|
| 119 |
+
trail.append("%s:%s %s" % (name, type(e).__name__, str(e)[:90]))
|
| 120 |
return None, None, trail
|
| 121 |
|
| 122 |
|