ginipick commited on
Commit
7fd7317
verified
1 Parent(s): 0e9d568

Create my_functions.py

Browse files
Files changed (1) hide show
  1. my_functions.py +23 -0
my_functions.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yfinance as yf
2
+
3
+ # 鞓堨嫓: 旮办〈 鞝滍拡 旃错儓搿滉犯
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['Close'].iloc[-1]
23
+ return float('nan')