"""Render the stock prices page."""
def __init__(
- self, name_to_timeout_dict: Dict[str, int], symbols: List[str]
+ self,
+ name_to_timeout_dict: Dict[str, int],
+ symbols: List[str],
+ display_subs: Dict[str, str] = None,
) -> None:
super(stock_quote_renderer, self).__init__(name_to_timeout_dict, False)
self.symbols = symbols
+ self.display_subs = display_subs
def debug_prefix(self) -> str:
return "stock"
f.write("<TABLE WIDTH=99%>")
symbols_finished = 0
for symbol in self.symbols:
- # print(f"--- Symbol: {symbol} ---")
ticker = yf.Ticker(symbol)
print(type(ticker))
# print(ticker.get_info())
f.write("</TR>")
f.write("<TR>")
symbols_finished += 1
+ if self.display_subs is not None and symbol in self.display_subs:
+ symbol = self.display_subs[symbol]
f.write(
f"""
<TD WIDTH=20% HEIGHT=150 BGCOLOR="{cell_color}">
<!-- Container -->
<DIV style="position:relative;
height:150px;">
- <!-- Symbol -->
+ <!-- Symbol {symbol} -->
<DIV style="position:absolute;
bottom:50;
right:-20;
f.write("</TR></TABLE>")
return True
-
# Test
-# x = stock_quote_renderer({}, ["MSFT", "GOOG", "GBTC", "OPTAX", "VNQ"])
-# x.periodic_render(None)
+#x = stock_quote_renderer({}, ["MSFT", "GOOG", "BTC-USD", "OPTAX", "GC=F", "VNQ"], { "BTC-USD": "BTC", "GC=F": "GOLD" })
+#x.periodic_render(None)