Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,975 Bytes
46a5be3 1954a4a 46a5be3 1954a4a 46a5be3 e43fe01 1954a4a e43fe01 1954a4a e43fe01 1954a4a e43fe01 1954a4a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import yfinance as yf
# ์ํ์ฉ Catalog
product_catalog = {
"807ZPKBL9V": "SuperWidget",
"1234567890": "MegaGadget"
}
def get_product_name_by_PID(PID: str) -> str:
"""
Finds the name of a product by its Product ID
"""
return product_catalog.get(PID, "Unknown product")
def get_stock_price(ticker: str) -> float:
"""
Retrieves the latest stock price for a given ticker using yfinance.
"""
stock = yf.Ticker(ticker)
data = stock.history(period="1d")
if not data.empty:
return data['Close'].iloc[-1]
return float('nan')
# ----------------------------------------------------
# MCO ์ํคํ
์ฒ ๋ถ์์ฉ ํจ์ (์์)
# ----------------------------------------------------
def analyze_mco_architecture(framework_version: str, detail_level: int = 3) -> str:
"""
MCO ์ํคํ
์ฒ(ํจ์ JSON + Python ๋ชจ๋) ๊ตฌ์กฐ๋ฅผ ๋ถ์ ๋ฐ ์์ฝํด์ฃผ๋ ํจ์.
"""
if detail_level < 1:
detail_level = 1
elif detail_level > 5:
detail_level = 5
analysis = (
f"MCO ์ํคํ
์ฒ(๋ฒ์ {framework_version}) ๋ถ์ ๊ฒฐ๊ณผ:\n"
f" - functions.json์ ์ ์๋ ํจ์ ๋ชฉ๋ก ํ์ธ\n"
f" - Python ๋ชจ๋({__file__})์์ ํจ์ ๊ตฌํ ์ ์ ์ฐ๊ฒฐ ํ์ธ\n"
f" - detail_level={detail_level} ๊ธฐ์ค์ผ๋ก ์์ฝ ๋ฆฌํฌํธ\n"
f"โป ์ค์ ๋ก๋ ํ์์ ๋ฐ๋ผ ๋ ๋ณต์กํ ๋ก์ง/ํ์ผ ๋ถ์ ๋ฑ ์ํ ๊ฐ๋ฅ."
)
return analysis
# ----------------------------------------------------
# [์ถ๊ฐ] functionName(...)
# - ๋ชจ๋ธ์ด functionName(string="AAPL")๋ผ๊ณ ์ฝํ๋ฉด ๋ด๋ถ์ ์ผ๋ก get_stock_price(ticker=string)์ ํธ์ถ.
# ----------------------------------------------------
def functionName(string: str) -> float:
"""
์์ ํธํ์ฉ ํจ์.
๋ชจ๋ธ์ด functionName(string="...")์ ํธ์ถํ๋ฉด, get_stock_price(ticker=...)๋ฅผ ๋์ ํธ์ถํ์ฌ ๋ฐํ.
"""
return get_stock_price(ticker=string)
|