Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,11 +21,26 @@ import io
|
|
| 21 |
import os
|
| 22 |
import re
|
| 23 |
import contextlib
|
|
|
|
| 24 |
|
| 25 |
import gradio as gr
|
| 26 |
|
| 27 |
import confirm_sell_backtest as BT # μ λλ§€λ ν΅μ¬ λ‘μ§/μ€μ κ·Έλλ‘
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 30 |
MAP_PATH = os.path.join(HERE, "market_map.csv")
|
| 31 |
BOLL_PATH = os.path.join(HERE, "bollinger_count_debug.py")
|
|
@@ -140,6 +155,7 @@ def check_one(code):
|
|
| 140 |
return {
|
| 141 |
"code": code, "market": market, "ok": True,
|
| 142 |
"price_now": float(stock[last_i]),
|
|
|
|
| 143 |
"recent": recent,
|
| 144 |
"last_sell": sells[-1] if sells else None,
|
| 145 |
"cur": cur,
|
|
@@ -169,11 +185,13 @@ def run_monitor(text):
|
|
| 169 |
f"240{_band(BT.FLAT_MIN_240, BT.FLAT_MAX_240)}\n\n---\n")
|
| 170 |
out = [head]
|
| 171 |
alerts = []
|
|
|
|
| 172 |
for code in codes:
|
| 173 |
res = check_one(code)
|
| 174 |
if not res["ok"]:
|
| 175 |
out.append(f"- {_label(code)} ({res['market']}) β {res['msg']}")
|
| 176 |
continue
|
|
|
|
| 177 |
if res["recent"]:
|
| 178 |
s = res["recent"][-1]
|
| 179 |
alerts.append(_label(code))
|
|
@@ -192,6 +210,8 @@ def run_monitor(text):
|
|
| 192 |
f"- μν: {_status_line(res)}\n")
|
| 193 |
|
| 194 |
out.append("\n---\n")
|
|
|
|
|
|
|
| 195 |
if alerts:
|
| 196 |
out.append(f"**μ€λ νμΈ νμ: {len(alerts)}μ’
λͺ© β {', '.join(alerts)}**")
|
| 197 |
else:
|
|
|
|
| 21 |
import os
|
| 22 |
import re
|
| 23 |
import contextlib
|
| 24 |
+
from datetime import datetime, timezone, timedelta
|
| 25 |
|
| 26 |
import gradio as gr
|
| 27 |
|
| 28 |
import confirm_sell_backtest as BT # μ λλ§€λ ν΅μ¬ λ‘μ§/μ€μ κ·Έλλ‘
|
| 29 |
|
| 30 |
+
KST = timezone(timedelta(hours=9))
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def asof_label(last_date):
|
| 34 |
+
"""λ§μ§λ§ λ°μ΄ν°κ° 'μ€λ'μ΄κ³ μ₯μ€μ΄λ©΄ 'μ₯μ€ νμ¬κ°(HH:MM)', μλλ©΄ 'μ’
κ°'. νκ΅ μ₯ 09:00~15:30 KST."""
|
| 35 |
+
now = datetime.now(KST)
|
| 36 |
+
today = now.strftime("%Y-%m-%d")
|
| 37 |
+
intraday = (last_date == today
|
| 38 |
+
and now.weekday() < 5
|
| 39 |
+
and (9 * 60) <= (now.hour * 60 + now.minute) <= (15 * 60 + 30))
|
| 40 |
+
if intraday:
|
| 41 |
+
return f"{last_date} μ₯μ€ νμ¬κ° ({now:%H:%M} KST κΈ°μ€, μ’
κ° μλ)"
|
| 42 |
+
return f"{last_date} μ’
κ° κΈ°μ€"
|
| 43 |
+
|
| 44 |
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 45 |
MAP_PATH = os.path.join(HERE, "market_map.csv")
|
| 46 |
BOLL_PATH = os.path.join(HERE, "bollinger_count_debug.py")
|
|
|
|
| 155 |
return {
|
| 156 |
"code": code, "market": market, "ok": True,
|
| 157 |
"price_now": float(stock[last_i]),
|
| 158 |
+
"last_date": r["dates"][last_i], # μν κΈ°μ€μΌ
|
| 159 |
"recent": recent,
|
| 160 |
"last_sell": sells[-1] if sells else None,
|
| 161 |
"cur": cur,
|
|
|
|
| 185 |
f"240{_band(BT.FLAT_MIN_240, BT.FLAT_MAX_240)}\n\n---\n")
|
| 186 |
out = [head]
|
| 187 |
alerts = []
|
| 188 |
+
asof = None
|
| 189 |
for code in codes:
|
| 190 |
res = check_one(code)
|
| 191 |
if not res["ok"]:
|
| 192 |
out.append(f"- {_label(code)} ({res['market']}) β {res['msg']}")
|
| 193 |
continue
|
| 194 |
+
asof = res.get("last_date")
|
| 195 |
if res["recent"]:
|
| 196 |
s = res["recent"][-1]
|
| 197 |
alerts.append(_label(code))
|
|
|
|
| 210 |
f"- μν: {_status_line(res)}\n")
|
| 211 |
|
| 212 |
out.append("\n---\n")
|
| 213 |
+
if asof:
|
| 214 |
+
out.append(f"*μν κΈ°μ€: {asof_label(asof)}*\n")
|
| 215 |
if alerts:
|
| 216 |
out.append(f"**μ€λ νμΈ νμ: {len(alerts)}μ’
λͺ© β {', '.join(alerts)}**")
|
| 217 |
else:
|