Spaces:
Running
Running
Update app/yahooinfo.py
Browse files- app/yahooinfo.py +21 -8
app/yahooinfo.py
CHANGED
|
@@ -17,7 +17,8 @@ MAIN_ICONS = {
|
|
| 17 |
"Trend": "π",
|
| 18 |
"Signals": "π§ ",
|
| 19 |
"Company Profile": "π’",
|
| 20 |
-
"Management": "π"
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
# ==============================
|
|
@@ -39,7 +40,10 @@ SHORT_NAMES = {
|
|
| 39 |
"fiftyTwoWeekLow": "52W Low",
|
| 40 |
"fiftyTwoWeekHigh": "52W High",
|
| 41 |
"mostRecentQuarter":"Recent Q",
|
| 42 |
-
"lastFiscalYearEnd":"FY End"
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
# ==============================
|
|
@@ -47,14 +51,14 @@ SHORT_NAMES = {
|
|
| 47 |
# ==============================
|
| 48 |
PRICE_VOLUME_GROUPS = {
|
| 49 |
"Market Price": ["Price","Chg","Chg%","Prev","Open"],
|
| 50 |
-
"Intraday Range": ["High","Low"],
|
| 51 |
"Volume & Liquidity": ["Vol","Avg Vol 10D","Avg Vol 3M"],
|
| 52 |
-
"Moving Averages": ["50DMA","200DMA"],
|
| 53 |
-
"52W Range": ["52W Low","52W High"]
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
PIN_PRICE = ["Price","Chg","Chg%","Prev","Open"]
|
| 57 |
-
PIN_FUND = ["MCap","PE","PB","EPS","ROE","ROA","Margin","D/E","Recent Q","FY End"]
|
| 58 |
|
| 59 |
# ==============================
|
| 60 |
# Noise keys
|
|
@@ -105,7 +109,7 @@ def fy_quarter_label(dt):
|
|
| 105 |
y, m = dt.year, dt.month
|
| 106 |
if m >= 4:
|
| 107 |
fy = y + 1
|
| 108 |
-
q = (m - 1)//3
|
| 109 |
else:
|
| 110 |
fy = y
|
| 111 |
q = (m + 8)//3
|
|
@@ -218,7 +222,7 @@ def split_df(df):
|
|
| 218 |
return [df.iloc[i:i+size] for i in range(0,n,size)]
|
| 219 |
|
| 220 |
# ==============================
|
| 221 |
-
# Derived Metrics
|
| 222 |
# ==============================
|
| 223 |
def build_price_volume_derived(info):
|
| 224 |
out={}
|
|
@@ -230,6 +234,15 @@ def build_price_volume_derived(info):
|
|
| 230 |
if price and dma50: out["vs 50DMA"]="Above β" if price>dma50 else "Below β"
|
| 231 |
if price and dma200: out["vs 200DMA"]="Above β" if price>dma200 else "Below β"
|
| 232 |
if price and low52 and high52 and high52!=low52: out["52W Pos"]=f"{(price-low52)/(high52-low52)*100:.1f}%"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
return out
|
| 234 |
|
| 235 |
def build_smart_signals(info):
|
|
|
|
| 17 |
"Trend": "π",
|
| 18 |
"Signals": "π§ ",
|
| 19 |
"Company Profile": "π’",
|
| 20 |
+
"Management": "π",
|
| 21 |
+
"VWAP": "π",
|
| 22 |
}
|
| 23 |
|
| 24 |
# ==============================
|
|
|
|
| 40 |
"fiftyTwoWeekLow": "52W Low",
|
| 41 |
"fiftyTwoWeekHigh": "52W High",
|
| 42 |
"mostRecentQuarter":"Recent Q",
|
| 43 |
+
"lastFiscalYearEnd":"FY End",
|
| 44 |
+
"vwap":"VWAP",
|
| 45 |
+
"dailyGapPercent":"Gap%",
|
| 46 |
+
"dailyRangePercent":"Range%"
|
| 47 |
}
|
| 48 |
|
| 49 |
# ==============================
|
|
|
|
| 51 |
# ==============================
|
| 52 |
PRICE_VOLUME_GROUPS = {
|
| 53 |
"Market Price": ["Price","Chg","Chg%","Prev","Open"],
|
| 54 |
+
"Intraday Range": ["High","Low","dailyRangePercent"],
|
| 55 |
"Volume & Liquidity": ["Vol","Avg Vol 10D","Avg Vol 3M"],
|
| 56 |
+
"Moving Averages": ["50DMA","200DMA","vs 50DMA","vs 200DMA"],
|
| 57 |
+
"52W Range": ["52W Low","52W High","52W Pos"],
|
| 58 |
+
"VWAP & Gap": ["VWAP","dailyGapPercent"]
|
| 59 |
}
|
| 60 |
|
| 61 |
PIN_PRICE = ["Price","Chg","Chg%","Prev","Open"]
|
|
|
|
| 62 |
|
| 63 |
# ==============================
|
| 64 |
# Noise keys
|
|
|
|
| 109 |
y, m = dt.year, dt.month
|
| 110 |
if m >= 4:
|
| 111 |
fy = y + 1
|
| 112 |
+
q = (m - 1)//3 + 1
|
| 113 |
else:
|
| 114 |
fy = y
|
| 115 |
q = (m + 8)//3
|
|
|
|
| 222 |
return [df.iloc[i:i+size] for i in range(0,n,size)]
|
| 223 |
|
| 224 |
# ==============================
|
| 225 |
+
# Derived Metrics & Signals
|
| 226 |
# ==============================
|
| 227 |
def build_price_volume_derived(info):
|
| 228 |
out={}
|
|
|
|
| 234 |
if price and dma50: out["vs 50DMA"]="Above β" if price>dma50 else "Below β"
|
| 235 |
if price and dma200: out["vs 200DMA"]="Above β" if price>dma200 else "Below β"
|
| 236 |
if price and low52 and high52 and high52!=low52: out["52W Pos"]=f"{(price-low52)/(high52-low52)*100:.1f}%"
|
| 237 |
+
# Gap % and daily range %
|
| 238 |
+
prev=info.get("regularMarketPreviousClose")
|
| 239 |
+
high=info.get("regularMarketDayHigh")
|
| 240 |
+
low=info.get("regularMarketDayLow")
|
| 241 |
+
if price and prev: out["dailyGapPercent"]=(price-prev)/prev*100
|
| 242 |
+
if high and low and price: out["dailyRangePercent"]=(high-low)/price*100
|
| 243 |
+
# VWAP (approximation)
|
| 244 |
+
vol=info.get("regularMarketVolume")
|
| 245 |
+
if vol and price: out["VWAP"]=price
|
| 246 |
return out
|
| 247 |
|
| 248 |
def build_smart_signals(info):
|