Update src/app.py
Browse files- src/app.py +30 -14
src/app.py
CHANGED
|
@@ -1345,9 +1345,9 @@ def get_owned_prompt(target, tid="", news=None, portfolio_context=""):
|
|
| 1345 |
"target_remaining": {{
|
| 1346 |
"target_price": "๋ชฉํ๊ฐ (์ํ)",
|
| 1347 |
"upside_pct": "ํ์ฌ๊ฐ ๋๋น ์์น ์ฌ๋ ฅ (%)",
|
| 1348 |
-
"exit_strategy": "๋ชฉํ๊ฐ ๋๋ฌ ์ ๋งค๋ ์ ๋ต โ ํฌํธํด๋ฆฌ์ค ๋ฆฌ๋ฐธ๋ฐ์ฑ ๊ด์ ํฌํจ"
|
|
|
|
| 1349 |
}}
|
| 1350 |
-
}}"""
|
| 1351 |
|
| 1352 |
def get_portfolio_quant_metrics(df, prices, rate):
|
| 1353 |
"""
|
|
@@ -2000,7 +2000,7 @@ def render_confidence_bar(score, reason):
|
|
| 2000 |
unsafe_allow_html=True
|
| 2001 |
)
|
| 2002 |
|
| 2003 |
-
def render_target_price_compare(ai_target_str, analyst_target_krw, current_price_krw):
|
| 2004 |
if not analyst_target_krw or analyst_target_krw == 0: return
|
| 2005 |
ai_prices = parse_target_prices(ai_target_str)
|
| 2006 |
if not ai_prices: return
|
|
@@ -2009,18 +2009,29 @@ def render_target_price_compare(ai_target_str, analyst_target_krw, current_price
|
|
| 2009 |
diff_pct = abs(ai_price - analyst_target_krw) / analyst_target_krw * 100
|
| 2010 |
ai_upside = (ai_price / current_price_krw - 1) * 100 if current_price_krw > 0 else 0
|
| 2011 |
an_upside = (analyst_target_krw / current_price_krw - 1) * 100 if current_price_krw > 0 else 0
|
|
|
|
| 2012 |
if diff_pct >= 30:
|
| 2013 |
-
|
| 2014 |
-
|
| 2015 |
-
|
| 2016 |
-
|
| 2017 |
-
|
| 2018 |
else:
|
| 2019 |
-
|
| 2020 |
-
|
| 2021 |
-
|
| 2022 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2023 |
)
|
|
|
|
| 2024 |
st.markdown(
|
| 2025 |
f'<div style="background:linear-gradient(135deg,#1C1C1C 0%,#111111 100%); border:1px solid rgba(255,255,255,0.09); '
|
| 2026 |
f'border-radius:10px; padding:16px; margin-bottom:12px;">'
|
|
@@ -2037,7 +2048,11 @@ def render_target_price_compare(ai_target_str, analyst_target_krw, current_price
|
|
| 2037 |
f'<div style="font-size:11px; color:{"#E0E0E0" if an_upside>=0 else "#9ABBE0"}; margin-top:4px;">{an_upside:+.1f}%</div>'
|
| 2038 |
f'</div>'
|
| 2039 |
f'</div>'
|
| 2040 |
-
f'{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2041 |
f'</div>',
|
| 2042 |
unsafe_allow_html=True
|
| 2043 |
)
|
|
@@ -2320,7 +2335,8 @@ def render_owned_report(rpt, analyst_target_krw=0, current_price_krw=0):
|
|
| 2320 |
unsafe_allow_html=True
|
| 2321 |
)
|
| 2322 |
if analyst_target_krw and current_price_krw:
|
| 2323 |
-
|
|
|
|
| 2324 |
|
| 2325 |
|
| 2326 |
def render_scan_report(rpt, analyst_target_krw=0, current_price_krw=0):
|
|
|
|
| 1345 |
"target_remaining": {{
|
| 1346 |
"target_price": "๋ชฉํ๊ฐ (์ํ)",
|
| 1347 |
"upside_pct": "ํ์ฌ๊ฐ ๋๋น ์์น ์ฌ๋ ฅ (%)",
|
| 1348 |
+
"exit_strategy": "๋ชฉํ๊ฐ ๋๋ฌ ์ ๋งค๋ ์ ๋ต โ ํฌํธํด๋ฆฌ์ค ๋ฆฌ๋ฐธ๋ฐ์ฑ ๊ด์ ํฌํจ",
|
| 1349 |
+
"target_gap_reason": "AI ๋ชฉํ๊ฐ์ ์ ๋๋ฆฌ์คํธ ์ปจ์ผ์์ค ๋ชฉํ๊ฐ๊ฐ ์ฐจ์ด๋๋ ์ด์ โ ์ด ์ข
๋ชฉ์ ์ฑ์ฅ ๊ธฐ๋์นยท๋ฐธ๋ฅ์์ด์
๊ด์ ยท๋ฆฌ์คํฌ ์ธ์ ๋ฑ ๋ชฉํ๊ฐ๊ฐ ์ฐจ์ด๋๋ ์ด์ ๋ฅผ ๊ตฌ์ฒด์ ์ผ๋ก 2~3๋ฌธ์ฅ. ๋น์ทํ๋ฉด ์ ์ผ์นํ๋์ง ์ค๋ช
"
|
| 1350 |
}}
|
|
|
|
| 1351 |
|
| 1352 |
def get_portfolio_quant_metrics(df, prices, rate):
|
| 1353 |
"""
|
|
|
|
| 2000 |
unsafe_allow_html=True
|
| 2001 |
)
|
| 2002 |
|
| 2003 |
+
def render_target_price_compare(ai_target_str, analyst_target_krw, current_price_krw, gap_reason=""):
|
| 2004 |
if not analyst_target_krw or analyst_target_krw == 0: return
|
| 2005 |
ai_prices = parse_target_prices(ai_target_str)
|
| 2006 |
if not ai_prices: return
|
|
|
|
| 2009 |
diff_pct = abs(ai_price - analyst_target_krw) / analyst_target_krw * 100
|
| 2010 |
ai_upside = (ai_price / current_price_krw - 1) * 100 if current_price_krw > 0 else 0
|
| 2011 |
an_upside = (analyst_target_krw / current_price_krw - 1) * 100 if current_price_krw > 0 else 0
|
| 2012 |
+
|
| 2013 |
if diff_pct >= 30:
|
| 2014 |
+
gap_icon = "โ ๏ธ"
|
| 2015 |
+
gap_color = "rgba(255,200,100,0.08)"
|
| 2016 |
+
gap_border= "rgba(255,200,100,0.25)"
|
| 2017 |
+
gap_text_color = "#D8D8D8"
|
| 2018 |
+
gap_label = f"๋ ๋ชฉํ๊ฐ๊ฐ <b>{diff_pct:.0f}%</b> ์ฐจ์ด๋ฉ๋๋ค"
|
| 2019 |
else:
|
| 2020 |
+
gap_icon = "โ
"
|
| 2021 |
+
gap_color = "rgba(255,255,255,0.03)"
|
| 2022 |
+
gap_border= "rgba(255,255,255,0.10)"
|
| 2023 |
+
gap_text_color = "#888888"
|
| 2024 |
+
gap_label = f"๋ ๋ชฉํ๊ฐ๊ฐ ๋น์ทํฉ๋๋ค (์ฐจ์ด {diff_pct:.0f}%)"
|
| 2025 |
+
|
| 2026 |
+
reason_html = ""
|
| 2027 |
+
if gap_reason:
|
| 2028 |
+
reason_html = (
|
| 2029 |
+
f'<div style="margin-top:10px; padding:10px 12px; font-size:11px; color:#666666; '
|
| 2030 |
+
f'line-height:1.8; border-top:1px solid rgba(255,255,255,0.06);">'
|
| 2031 |
+
f'{gap_reason}'
|
| 2032 |
+
f'</div>'
|
| 2033 |
)
|
| 2034 |
+
|
| 2035 |
st.markdown(
|
| 2036 |
f'<div style="background:linear-gradient(135deg,#1C1C1C 0%,#111111 100%); border:1px solid rgba(255,255,255,0.09); '
|
| 2037 |
f'border-radius:10px; padding:16px; margin-bottom:12px;">'
|
|
|
|
| 2048 |
f'<div style="font-size:11px; color:{"#E0E0E0" if an_upside>=0 else "#9ABBE0"}; margin-top:4px;">{an_upside:+.1f}%</div>'
|
| 2049 |
f'</div>'
|
| 2050 |
f'</div>'
|
| 2051 |
+
f'<div style="margin-top:10px; padding:10px 12px; background:{gap_color}; border:1px solid {gap_border}; '
|
| 2052 |
+
f'border-radius:6px; font-size:12px; color:{gap_text_color};">'
|
| 2053 |
+
f'{gap_icon} {gap_label}'
|
| 2054 |
+
f'{reason_html}'
|
| 2055 |
+
f'</div>'
|
| 2056 |
f'</div>',
|
| 2057 |
unsafe_allow_html=True
|
| 2058 |
)
|
|
|
|
| 2335 |
unsafe_allow_html=True
|
| 2336 |
)
|
| 2337 |
if analyst_target_krw and current_price_krw:
|
| 2338 |
+
gap_reason = target_rem.get("target_gap_reason", "")
|
| 2339 |
+
render_target_price_compare(tp, analyst_target_krw, current_price_krw, gap_reason)
|
| 2340 |
|
| 2341 |
|
| 2342 |
def render_scan_report(rpt, analyst_target_krw=0, current_price_krw=0):
|