Update src/app.py
Browse files- src/app.py +34 -24
src/app.py
CHANGED
|
@@ -1063,7 +1063,7 @@ def get_scan_prompt(target, tid="", owned=None, news=None, portfolio_context="")
|
|
| 1063 |
def get_owned_prompt(target, tid="", news=None, portfolio_context=""):
|
| 1064 |
date_s = datetime.now().strftime("%Yλ
%mμ %dμΌ")
|
| 1065 |
news_s = ""
|
| 1066 |
-
if news: news_s = "\n[μ΅κ·Ό λ΄μ€ β
|
| 1067 |
port_s = f"\n{portfolio_context}" if portfolio_context else ""
|
| 1068 |
return f"""[μ€μ₯κΈ° μ±μ₯μ£Ό 보μ μ§λ¨ μ λ¬Έκ° β {date_s} / ID:{tid}_{random.randint(100,999)}]
|
| 1069 |
{INVESTOR_PROFILE}
|
|
@@ -1353,8 +1353,8 @@ def render_owned_report(rpt, analyst_target_krw=0, current_price_krw=0):
|
|
| 1353 |
)
|
| 1354 |
render_confidence_bar(conf_score, conf_reason)
|
| 1355 |
|
| 1356 |
-
# ββ ν λΆλ¦¬: μμ½ /
|
| 1357 |
-
tab_sum, tab_thesis, tab_action, tab_target = st.tabs(["π μμ½", "π
|
| 1358 |
|
| 1359 |
# βββββββββββ ν 1: μμ½ βββββββββββ
|
| 1360 |
with tab_sum:
|
|
@@ -1378,7 +1378,7 @@ def render_owned_report(rpt, analyst_target_krw=0, current_price_krw=0):
|
|
| 1378 |
unsafe_allow_html=True
|
| 1379 |
)
|
| 1380 |
|
| 1381 |
-
# βββββββββββ ν 2:
|
| 1382 |
with tab_thesis:
|
| 1383 |
thesis = rpt.get("thesis_validity", {})
|
| 1384 |
if isinstance(thesis, dict):
|
|
@@ -1392,7 +1392,7 @@ def render_owned_report(rpt, analyst_target_krw=0, current_price_krw=0):
|
|
| 1392 |
'<div style="background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.08); '
|
| 1393 |
'border-radius:12px; padding:20px; margin-top:12px;">'
|
| 1394 |
'<div style="font-size:14px; color:#888888; line-height:1.9; margin-bottom:12px;">'
|
| 1395 |
-
'λ§€μ κ·Όκ±°λ₯Ό κΈ°λ‘νλ©΄ <b style="color:#EBEBEB;">
|
| 1396 |
'</div>'
|
| 1397 |
'<div style="font-size:12px; color:#444444; background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.08); border-radius:8px; padding:10px 14px;">'
|
| 1398 |
'π‘ ν¬νΈν΄λ¦¬μ€ λͺ©λ‘μμ <b style="color:#D8D8D8;">β― νΈμ§</b>μ λλ¬ λ§€μ κ·Όκ±°λ₯Ό μΆκ°νμΈμ.'
|
|
@@ -1412,7 +1412,7 @@ def render_owned_report(rpt, analyst_target_krw=0, current_price_krw=0):
|
|
| 1412 |
f'<div style="background:{verdict_bg}; border:1px solid {verdict_color}33; '
|
| 1413 |
f'border-radius:12px; padding:16px; margin-top:12px;">'
|
| 1414 |
f'<div style="display:flex; align-items:center; gap:10px; margin-bottom:14px;">'
|
| 1415 |
-
f'<span style="font-size:10px; font-weight:700; color:#444444; letter-spacing:1px; text-transform:uppercase;">λ§€μ
|
| 1416 |
f'<span style="font-size:13px; font-weight:900; color:{verdict_color}; background:{verdict_bg}; '
|
| 1417 |
f'border:1px solid {verdict_color}55; padding:3px 12px; border-radius:20px;">{verdict}</span>'
|
| 1418 |
f'</div>'
|
|
@@ -1592,7 +1592,7 @@ def render_scan_report(rpt, analyst_target_krw=0, current_price_krw=0):
|
|
| 1592 |
f'<div style="font-size:9px; color:#444444; margin-bottom:6px; text-transform:uppercase; letter-spacing:1px;">2μ°¨ μΆκ°λ§€μ</div>'
|
| 1593 |
f'<div style="font-size:13px; font-weight:700; color:#D8D8D8;">{z2}</div></div>'
|
| 1594 |
f'<div style="background:#0C0C0C; border-radius:8px; padding:14px; text-align:center;">'
|
| 1595 |
-
f'<div style="font-size:9px; color:#444444; margin-bottom:6px; text-transform:uppercase; letter-spacing:1px;">
|
| 1596 |
f'<div style="font-size:13px; font-weight:700; color:#E0E0E0;">{zs}</div></div>'
|
| 1597 |
f'</div>',
|
| 1598 |
unsafe_allow_html=True
|
|
@@ -1868,7 +1868,7 @@ def get_price_alert(action, current_price, target_price_str, avg_price, report=N
|
|
| 1868 |
if ("보μ " in action or "μΆκ°λ§€μ" in action) and current_price < avg_price:
|
| 1869 |
if verdict == "μ κ²νμ":
|
| 1870 |
loss_pct = (current_price / avg_price - 1) * 100
|
| 1871 |
-
return 'sl', f"
|
| 1872 |
|
| 1873 |
return None, None
|
| 1874 |
|
|
@@ -2666,7 +2666,7 @@ elif st.session_state.main_menu == "β€ μμ° μμΈ μ§λ¨":
|
|
| 2666 |
'<div style="font-size:11px; font-weight:700; color:#D8D8D8; letter-spacing:1.5px; '
|
| 2667 |
'text-transform:uppercase; margin-bottom:8px;">βοΈ λ§€μ κ·Όκ±° λ―ΈκΈ°λ‘</div>'
|
| 2668 |
'<div style="font-size:13px; color:#888888; line-height:1.8; margin-bottom:12px;">'
|
| 2669 |
-
'λ§€μ λΉμ μκ°μ μ μ΄λλ©΄ <b style="color:#EBEBEB;">
|
| 2670 |
'</div></div>',
|
| 2671 |
unsafe_allow_html=True
|
| 2672 |
)
|
|
@@ -2921,7 +2921,7 @@ elif st.session_state.main_menu == "β€ μμ° μμΈ μ§λ¨":
|
|
| 2921 |
act = rp.get("action_type", "보μ ")
|
| 2922 |
thesis = rp.get("thesis_validity", {})
|
| 2923 |
verdict = thesis.get("verdict", "") if isinstance(thesis, dict) else ""
|
| 2924 |
-
verdict_tag = f"/
|
| 2925 |
return f"- {row['μ’
λͺ©λͺ
']}({t}) [μΉν°:{sec}/Beta:{beta:.2f}]: μμ΅λ₯ {pct:.1f}%, [μ λ΅:{act}{verdict_tag}]"
|
| 2926 |
return f"- {row['μ’
λͺ©λͺ
']}({t}): μμ΅λ₯ {pct:.1f}%"
|
| 2927 |
|
|
@@ -2978,12 +2978,18 @@ elif st.session_state.main_menu == "β€ μμ° μμΈ μ§λ¨":
|
|
| 2978 |
hc_name, hc_edit, hc_sell, hc_del = st.columns([0.67, 0.11, 0.11, 0.11], vertical_alignment="center")
|
| 2979 |
|
| 2980 |
with hc_name:
|
| 2981 |
-
|
| 2982 |
-
|
| 2983 |
-
f
|
| 2984 |
-
|
| 2985 |
-
|
| 2986 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2987 |
|
| 2988 |
with hc_edit:
|
| 2989 |
if st.button("β", key=f"edit_btn_{idx}", use_container_width=True, help="νΈμ§"):
|
|
@@ -3002,15 +3008,19 @@ elif st.session_state.main_menu == "β€ μμ° μμΈ μ§λ¨":
|
|
| 3002 |
st.session_state.df = st.session_state.df.drop(idx).reset_index(drop=True)
|
| 3003 |
save_assets(); st.session_state.price_cache_ts = 0; st.rerun()
|
| 3004 |
|
| 3005 |
-
# ββ μΉ΄λ λ³Έλ¬Έ
|
| 3006 |
-
|
| 3007 |
preview = ("π " + buy_reason[:42] + ("..." if len(buy_reason) > 42 else "")) if buy_reason else ""
|
| 3008 |
-
|
| 3009 |
-
f
|
| 3010 |
-
f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3011 |
)
|
| 3012 |
-
|
| 3013 |
-
st.session_state.detail_ticker = t; st.rerun()
|
| 3014 |
|
| 3015 |
# ββ λ§€λ μΌμ§ νΌ (β ν΄λ¦ μ μΈλΌμΈ νμ)
|
| 3016 |
if st.session_state.get(f"log_mode_{idx}", False):
|
|
@@ -3018,7 +3028,7 @@ elif st.session_state.main_menu == "β€ μμ° μμΈ μ§λ¨":
|
|
| 3018 |
lc1, lc2 = st.columns(2)
|
| 3019 |
with lc1: sp = st.number_input("λ§€λ λ¨κ°(μ)", value=float(ck), step=100.0, key=f"sp_{idx}")
|
| 3020 |
with lc2: sq = st.number_input("λ§€λ μλ", value=float(row['μλ']), max_value=float(row['μλ']), min_value=0.01, step=1.0, key=f"sq_{idx}")
|
| 3021 |
-
tags = ["#λͺ©νκ°λλ¬_μ΅μ ","#
|
| 3022 |
stag = st.selectbox("μ λ΅ νκ·Έ", tags, key=f"tag_{idx}")
|
| 3023 |
memo = st.text_input("볡기 λ©λͺ¨", placeholder="μ: μ±μ₯ μ€ν 리 νΌμμΌλ‘ μμ ", key=f"memo_{idx}")
|
| 3024 |
if st.button("μΌμ§ μ μ₯", key=f"slog_{idx}", type="primary", use_container_width=True):
|
|
|
|
| 1063 |
def get_owned_prompt(target, tid="", news=None, portfolio_context=""):
|
| 1064 |
date_s = datetime.now().strftime("%Yλ
%mμ %dμΌ")
|
| 1065 |
news_s = ""
|
| 1066 |
+
if news: news_s = "\n[μ΅κ·Ό λ΄μ€ β ν΄μ μ ν¨μ± νλ¨μ λ°μ]\n" + "\n".join(news)
|
| 1067 |
port_s = f"\n{portfolio_context}" if portfolio_context else ""
|
| 1068 |
return f"""[μ€μ₯κΈ° μ±μ₯μ£Ό 보μ μ§λ¨ μ λ¬Έκ° β {date_s} / ID:{tid}_{random.randint(100,999)}]
|
| 1069 |
{INVESTOR_PROFILE}
|
|
|
|
| 1353 |
)
|
| 1354 |
render_confidence_bar(conf_score, conf_reason)
|
| 1355 |
|
| 1356 |
+
# ββ ν λΆλ¦¬: μμ½ / ν΄μ / μ‘μ
/ λͺ©νκ°
|
| 1357 |
+
tab_sum, tab_thesis, tab_action, tab_target = st.tabs(["π μμ½", "π ν΄μ", "β‘ μ‘μ
", "π― λͺ©νκ°"])
|
| 1358 |
|
| 1359 |
# βββββββββββ ν 1: μμ½ βββββββββββ
|
| 1360 |
with tab_sum:
|
|
|
|
| 1378 |
unsafe_allow_html=True
|
| 1379 |
)
|
| 1380 |
|
| 1381 |
+
# βββββββββββ ν 2: ν΄μ βββββββββββ
|
| 1382 |
with tab_thesis:
|
| 1383 |
thesis = rpt.get("thesis_validity", {})
|
| 1384 |
if isinstance(thesis, dict):
|
|
|
|
| 1392 |
'<div style="background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.08); '
|
| 1393 |
'border-radius:12px; padding:20px; margin-top:12px;">'
|
| 1394 |
'<div style="font-size:14px; color:#888888; line-height:1.9; margin-bottom:12px;">'
|
| 1395 |
+
'λ§€μ κ·Όκ±°λ₯Ό κΈ°λ‘νλ©΄ <b style="color:#EBEBEB;">ν΄μ μ ν¨μ±</b>μ μ νν νλ¨ν΄λ릴 μ μμ΄μ.'
|
| 1396 |
'</div>'
|
| 1397 |
'<div style="font-size:12px; color:#444444; background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.08); border-radius:8px; padding:10px 14px;">'
|
| 1398 |
'π‘ ν¬νΈν΄λ¦¬μ€ λͺ©λ‘μμ <b style="color:#D8D8D8;">β― νΈμ§</b>μ λλ¬ λ§€μ κ·Όκ±°λ₯Ό μΆκ°νμΈμ.'
|
|
|
|
| 1412 |
f'<div style="background:{verdict_bg}; border:1px solid {verdict_color}33; '
|
| 1413 |
f'border-radius:12px; padding:16px; margin-top:12px;">'
|
| 1414 |
f'<div style="display:flex; align-items:center; gap:10px; margin-bottom:14px;">'
|
| 1415 |
+
f'<span style="font-size:10px; font-weight:700; color:#444444; letter-spacing:1px; text-transform:uppercase;">λ§€μ ν΄μ μ ν¨μ±</span>'
|
| 1416 |
f'<span style="font-size:13px; font-weight:900; color:{verdict_color}; background:{verdict_bg}; '
|
| 1417 |
f'border:1px solid {verdict_color}55; padding:3px 12px; border-radius:20px;">{verdict}</span>'
|
| 1418 |
f'</div>'
|
|
|
|
| 1592 |
f'<div style="font-size:9px; color:#444444; margin-bottom:6px; text-transform:uppercase; letter-spacing:1px;">2μ°¨ μΆκ°λ§€μ</div>'
|
| 1593 |
f'<div style="font-size:13px; font-weight:700; color:#D8D8D8;">{z2}</div></div>'
|
| 1594 |
f'<div style="background:#0C0C0C; border-radius:8px; padding:14px; text-align:center;">'
|
| 1595 |
+
f'<div style="font-size:9px; color:#444444; margin-bottom:6px; text-transform:uppercase; letter-spacing:1px;">ν΄μ λΆκ΄΄μ </div>'
|
| 1596 |
f'<div style="font-size:13px; font-weight:700; color:#E0E0E0;">{zs}</div></div>'
|
| 1597 |
f'</div>',
|
| 1598 |
unsafe_allow_html=True
|
|
|
|
| 1868 |
if ("보μ " in action or "μΆκ°λ§€μ" in action) and current_price < avg_price:
|
| 1869 |
if verdict == "μ κ²νμ":
|
| 1870 |
loss_pct = (current_price / avg_price - 1) * 100
|
| 1871 |
+
return 'sl', f"ν΄μ μ κ²νμ + μμ€ μ€ ({loss_pct:+.1f}%) Β· οΏ½οΏ½μ§λ¨ κΆμ₯"
|
| 1872 |
|
| 1873 |
return None, None
|
| 1874 |
|
|
|
|
| 2666 |
'<div style="font-size:11px; font-weight:700; color:#D8D8D8; letter-spacing:1.5px; '
|
| 2667 |
'text-transform:uppercase; margin-bottom:8px;">βοΈ λ§€μ κ·Όκ±° λ―ΈκΈ°λ‘</div>'
|
| 2668 |
'<div style="font-size:13px; color:#888888; line-height:1.8; margin-bottom:12px;">'
|
| 2669 |
+
'λ§€μ λΉμ μκ°μ μ μ΄λλ©΄ <b style="color:#EBEBEB;">ν΄μ μ ν¨μ±</b>μ μ ννκ² νλ¨ν μ μμ΄μ.'
|
| 2670 |
'</div></div>',
|
| 2671 |
unsafe_allow_html=True
|
| 2672 |
)
|
|
|
|
| 2921 |
act = rp.get("action_type", "보μ ")
|
| 2922 |
thesis = rp.get("thesis_validity", {})
|
| 2923 |
verdict = thesis.get("verdict", "") if isinstance(thesis, dict) else ""
|
| 2924 |
+
verdict_tag = f"/ν΄μ:{verdict}" if verdict else ""
|
| 2925 |
return f"- {row['μ’
λͺ©λͺ
']}({t}) [μΉν°:{sec}/Beta:{beta:.2f}]: μμ΅λ₯ {pct:.1f}%, [μ λ΅:{act}{verdict_tag}]"
|
| 2926 |
return f"- {row['μ’
λͺ©λͺ
']}({t}): μμ΅λ₯ {pct:.1f}%"
|
| 2927 |
|
|
|
|
| 2978 |
hc_name, hc_edit, hc_sell, hc_del = st.columns([0.67, 0.11, 0.11, 0.11], vertical_alignment="center")
|
| 2979 |
|
| 2980 |
with hc_name:
|
| 2981 |
+
tv_tag = (
|
| 2982 |
+
f'<span style="font-size:9px;color:{tv_color};background:{tv_color}15;'
|
| 2983 |
+
f'border:1px solid {tv_color}33;padding:1px 6px;border-radius:3px;margin-left:6px;">{tv}</span>'
|
| 2984 |
+
) if tv else ""
|
| 2985 |
+
st.markdown(
|
| 2986 |
+
f'<div style="font-size:15px;font-weight:800;color:#EBEBEB;line-height:1.3;">'
|
| 2987 |
+
f'{row["μ’
λͺ©λͺ
"]} '
|
| 2988 |
+
f'<span style="font-size:10px;color:#D8D8D8;background:rgba(255,255,255,0.06);'
|
| 2989 |
+
f'padding:2px 6px;border-radius:4px;border:1px solid rgba(255,255,255,0.10);">{t}</span>'
|
| 2990 |
+
f'{tv_tag}</div>',
|
| 2991 |
+
unsafe_allow_html=True
|
| 2992 |
+
)
|
| 2993 |
|
| 2994 |
with hc_edit:
|
| 2995 |
if st.button("β", key=f"edit_btn_{idx}", use_container_width=True, help="νΈμ§"):
|
|
|
|
| 3008 |
st.session_state.df = st.session_state.df.drop(idx).reset_index(drop=True)
|
| 3009 |
save_assets(); st.session_state.price_cache_ts = 0; st.rerun()
|
| 3010 |
|
| 3011 |
+
# ββ μΉ΄λ λ³Έλ¬Έ
|
| 3012 |
+
tgp_html = f" Β· <span style='color:#D8D8D8;'>λͺ©ν {tgp}</span>" if tgp != "-" else ""
|
| 3013 |
preview = ("π " + buy_reason[:42] + ("..." if len(buy_reason) > 42 else "")) if buy_reason else ""
|
| 3014 |
+
card_body = (
|
| 3015 |
+
f'<div style="margin:6px 0 2px;font-size:13px;color:#888888;">'
|
| 3016 |
+
f'νλ¨ <b style="color:#EBEBEB;font-family:IBM Plex Mono,monospace;">{int(ap):,}</b>μ β '
|
| 3017 |
+
f'<b style="color:{pc};font-family:IBM Plex Mono,monospace;">{ck:,}</b>μ'
|
| 3018 |
+
f' <span style="font-size:12px;color:{pc};">{pa} {abs(pct):.1f}%</span>'
|
| 3019 |
+
f'{tgp_html}</div>'
|
| 3020 |
+
f'<div style="font-size:11px;color:#444444;margin-top:2px;">[{act}]'
|
| 3021 |
+
f'{" " + preview if preview else ""}</div>'
|
| 3022 |
)
|
| 3023 |
+
st.markdown(card_body, unsafe_allow_html=True)
|
|
|
|
| 3024 |
|
| 3025 |
# ββ λ§€λ μΌμ§ νΌ (β ν΄λ¦ μ μΈλΌμΈ νμ)
|
| 3026 |
if st.session_state.get(f"log_mode_{idx}", False):
|
|
|
|
| 3028 |
lc1, lc2 = st.columns(2)
|
| 3029 |
with lc1: sp = st.number_input("λ§€λ λ¨κ°(μ)", value=float(ck), step=100.0, key=f"sp_{idx}")
|
| 3030 |
with lc2: sq = st.number_input("λ§€λ μλ", value=float(row['μλ']), max_value=float(row['μλ']), min_value=0.01, step=1.0, key=f"sq_{idx}")
|
| 3031 |
+
tags = ["#λͺ©νκ°λλ¬_μ΅μ ","#ν΄μλΆκ΄΄_μμ ","#λΉμ€μ‘°μ ","#λλλ§€λ§€_λ°μ±","#μΆμΈμ΄ν","#ν΄μ΄λΌμ΄λ_μ€ν¨"]
|
| 3032 |
stag = st.selectbox("μ λ΅ νκ·Έ", tags, key=f"tag_{idx}")
|
| 3033 |
memo = st.text_input("볡기 λ©λͺ¨", placeholder="μ: μ±μ₯ μ€ν 리 νΌμμΌλ‘ μμ ", key=f"memo_{idx}")
|
| 3034 |
if st.button("μΌμ§ μ μ₯", key=f"slog_{idx}", type="primary", use_container_width=True):
|