Spaces:
Runtime error

ditgun commited on
Commit
03181da
ยท
verified ยท
1 Parent(s): 4cc4752

Update src/app.py

Browse files
Files changed (1) hide show
  1. 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
- warn_html = (
2014
- f'<div style="background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.14); '
2015
- f'border-radius:6px; padding:8px 12px; margin-top:10px; font-size:12px; color:#D8D8D8;">'
2016
- f'โš ๏ธ AI ๋ชฉํ‘œ๊ฐ€์™€ ์‹ค์ œ ์• ๋„๋ฆฌ์ŠคํŠธ ๋ชฉํ‘œ๊ฐ€๊ฐ€ <b>{diff_pct:.0f}%</b> ์ฐจ์ด๋‚ฉ๋‹ˆ๋‹ค.</div>'
2017
- )
2018
  else:
2019
- warn_html = (
2020
- f'<div style="background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.10); '
2021
- f'border-radius:6px; padding:8px 12px; margin-top:10px; font-size:12px; color:#AAAAAA;">'
2022
- f'โœ… AI ๋ชฉํ‘œ๊ฐ€์™€ ์‹ค์ œ ์• ๋„๋ฆฌ์ŠคํŠธ ๋ชฉํ‘œ๊ฐ€๊ฐ€ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค (์ฐจ์ด {diff_pct:.0f}%).</div>'
 
 
 
 
 
 
 
 
 
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'{warn_html}'
 
 
 
 
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
- render_target_price_compare(tp, analyst_target_krw, current_price_krw)
 
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):