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