instruction stringlengths 0 1k | input stringlengths 1 1k | output stringlengths 10 6.51k |
|---|---|---|
"interval": "5m"},
"5D": {"period": "5d", "interval": "30m"},
"1M": {"period": "1mo", "interval": "1d"},
"6M": {"period": "6mo", "interval": "1d"},
"1Y": {"period": "1y", "interval": "1d"},
"5Y": {"period": "5y", "interval": "1wk"},
"MAX": {"period": "max", "interval": "1mo"},
}
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"}
@rx.event
async def on_load_fetch(self):
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
|
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
p | self.error_message = "" |
{"period": "5d", "interval": "30m"},
"1M": {"period": "1mo", "interval": "1d"},
"6M": {"period": "6mo", "interval": "1d"},
"1Y": {"period": "1y", "interval": "1d"},
"5Y": {"period": "5y", "interval": "1wk"},
"MAX": {"period": "max", "interval": "1mo"},
}
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"}
@rx.event
async def on_load_fetch(self):
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
|
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params[ | if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return |
"1M": {"period": "1mo", "interval": "1d"},
"6M": {"period": "6mo", "interval": "1d"},
"1Y": {"period": "1y", "interval": "1d"},
"5Y": {"period": "5y", "interval": "1wk"},
"MAX": {"period": "max", "interval": "1mo"},
}
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"}
@rx.event
async def on_load_fetch(self):
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
|
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
| self.error_message = "Ticker symbol cannot be empty." |
od": "6mo", "interval": "1d"},
"1Y": {"period": "1y", "interval": "1d"},
"5Y": {"period": "5y", "interval": "1wk"},
"MAX": {"period": "max", "interval": "1mo"},
}
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"}
@rx.event
async def on_load_fetch(self):
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
|
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period" | self.is_loading = False |
al": "1d"},
"5Y": {"period": "5y", "interval": "1wk"},
"MAX": {"period": "max", "interval": "1mo"},
}
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"}
@rx.event
async def on_load_fetch(self):
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
|
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
| ticker = yf.Ticker(ticker_symbol_to_fetch) |
1wk"},
"MAX": {"period": "max", "interval": "1mo"},
}
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"}
@rx.event
async def on_load_fetch(self):
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
|
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[[" | if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch |
async def on_load_fetch(self):
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
|
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
h | info = ticker.info |
"""Fetch initial data when the page loads."""
if not self.company_info:
await self.fetch_stock_data()
def _determine_period_interval(self, time_range: str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
|
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
| if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return |
str) -> dict:
"""Determines yfinance period and interval from UI time_range."""
return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
|
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
| self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker." |
get(time_range, self._DEFAULT_PERIOD_INTERVAL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
|
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Dat | self.company_info = {} |
AL)
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
|
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
| self.historical_data = [] |
self, ticker_symbol_to_fetch: str):
"""Internal logic to fetch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
|
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if | self.is_loading = False |
tch company data and historical prices."""
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
|
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Clos | self.company_info = info |
"
self.is_loading = True
self.error_message = ""
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
|
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[[" | self.search_ticker_input = ticker_symbol_to_fetch |
"
if not ticker_symbol_to_fetch:
self.error_message = "Ticker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
|
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
se | params = self._determine_period_interval(self.selected_time_range) |
ker symbol cannot be empty."
self.is_loading = False
return
try:
ticker = yf.Ticker(ticker_symbol_to_fetch)
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
|
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from | hist_df = ticker.history(
period=params["period"], interval=params["interval"]
) |
if (
not self.company_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
|
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
| self.historical_data = [] |
mpany_info
or self.company_info.get("symbol") != ticker_symbol_to_fetch
):
info = ticker.info
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
|
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
| self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range." |
o
if (
not info
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
|
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_sym | hist_df = hist_df.reset_index() |
nfo
or info.get("quoteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
|
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.hist | date_col_found = False |
oteType") == "NONE"
or info.get("longName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
|
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data an | if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True |
ongName") is None
):
self.error_message = f"Could not retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
|
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M") |
t retrieve data for {ticker_symbol_to_fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
|
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company d | date_col_found = True |
fetch}. It might be an invalid ticker."
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
|
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data an | elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True |
self.company_info = {}
self.historical_data = []
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
|
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if fo | hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y") |
self.is_loading = False
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
|
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data an | date_col_found = True |
lse
return
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
|
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_da | if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
) |
self.company_info = info
self.search_ticker_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
|
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
| hist_df["price"] = hist_df["Close"].round(2) |
er_input = ticker_symbol_to_fetch
params = self._determine_period_interval(self.selected_time_range)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
|
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
sel | self.historical_data = hist_df[["name", "price"]].to_dict("records") |
e)
hist_df = ticker.history(
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
|
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.i | self.historical_data = [] |
period=params["period"], interval=params["interval"]
)
if hist_df.empty:
self.historical_data = []
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
|
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_da | self.error_message = (
"Date information missing from historical data."
) |
self.error_message = f"No historical data found for {ticker_symbol_to_fetch} for the selected range."
else:
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
|
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_ | self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
) |
hist_df = hist_df.reset_index()
date_col_found = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
|
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
| if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = [] |
d = False
if "Datetime" in hist_df.columns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
|
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
| self.historical_data = [] |
mns:
hist_df["name"] = hist_df["Datetime"].dt.strftime("%b %d %Y %H:%M")
date_col_found = True
elif "Date" in hist_df.columns:
hist_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
|
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time | self.is_loading = False |
t_df["name"] = hist_df["Date"].dt.strftime("%b %d %Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
|
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_ | ticker_to_use = self.search_ticker_input |
%Y")
date_col_found = True
if date_col_found:
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
|
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return | if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use |
hist_df["price"] = hist_df["Close"].round(2)
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
|
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
| ticker_to_use = form_data["ticker_input"].upper() |
self.historical_data = hist_df[["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
|
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return | self.search_ticker_input = ticker_to_use |
["name", "price"]].to_dict("records")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
|
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.compan | if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return |
s")
else:
self.historical_data = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
|
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
de | self.error_message = "Please enter a ticker symbol." |
a = []
self.error_message = (
"Date information missing from historical data."
)
except Exception as e:
self.error_message = (
f"Error fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
|
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
| self.is_loading = False |
ror fetching data for {ticker_symbol_to_fetch}: {e!s}"
)
if self.company_info.get("symbol") == ticker_symbol_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
|
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
| if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh." |
l_to_fetch:
self.historical_data = []
finally:
self.is_loading = False
@rx.event
async def fetch_stock_data(self, form_data: dict | None = None):
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
|
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
| self.error_message = "No ticker symbol to refresh." |
"""Fetch company data and historical prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
|
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
| self.selected_time_range = time_range |
prices using yfinance, triggered by form."""
ticker_to_use = self.search_ticker_input
if form_data and "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
|
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice | if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data() |
d "ticker_input" in form_data and form_data["ticker_input"]:
ticker_to_use = form_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
|
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_acti | def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return "" |
orm_data["ticker_input"].upper()
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
|
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_displ | ticker = self.stock_ticker |
self.search_ticker_input = ticker_to_use
if not ticker_to_use:
self.error_message = "Please enter a ticker symbol."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
|
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_mar | if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}" |
."
self.is_loading = False
return
await self._internal_fetch_stock_data(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
|
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regul | def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A") |
ta(ticker_to_use)
@rx.event
async def refresh_data(self):
"""Refreshes the data for the current search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
|
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active st | def company_name(self) -> str:
return self.company_info.get("longName", "Company Name") |
search_ticker_input."""
if self.search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
|
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
| def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
|
search_ticker_input:
await self._internal_fetch_stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
|
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", " | exchange = self.company_info.get("exchange", "N/A") |
stock_data(self.search_ticker_input)
else:
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
|
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_ | currency = self.company_info.get("currency", "") |
self.error_message = "No ticker symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
|
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_ | display_parts = [exchange] |
er symbol to refresh."
@rx.event
async def set_time_range(self, time_range: str):
"""Set the time range and refetch historical data."""
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
|
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company | if currency:
display_parts.append(f"Currency: {currency.upper()}") |
"
self.selected_time_range = time_range
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
|
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["P | def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A" |
if self.company_info and self.company_info.get("symbol"):
await self.fetch_stock_data()
@rx.var
def logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
|
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None | price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
) |
f logo_url(self) -> str:
"""Constructs the URL for the company logo."""
ticker = self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
|
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
eli | if price is not None:
return f"{price:.2f}" |
= self.stock_ticker
if ticker and ticker != "N/A":
return f"https://assets.parqet.com/logos/symbol/{ticker.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
|
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
| def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap")) |
.upper()}"
return ""
@rx.var
def stock_ticker(self) -> str:
return self.company_info.get("symbol", "N/A")
@rx.var
def company_name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
|
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_ | def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states |
name(self) -> str:
return self.company_info.get("longName", "Company Name")
@rx.var
def exchange_info(self) -> str:
exchange = self.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
|
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_ho | market_state = self.company_info.get("marketState", "").upper() |
.company_info.get("exchange", "N/A")
currency = self.company_info.get("currency", "")
display_parts = [exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
|
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self | active_states = ["REGULAR", "PRE", "POST", "POSTPOST"] |
[exchange]
if currency:
display_parts.append(f"Currency: {currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
|
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration | def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, "" |
currency.upper()}")
return " · ".join(filter(None, display_parts))
@rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
|
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change | info = self.company_info |
rx.var
def current_price_display_val(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
|
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
| if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours" |
al(self) -> str:
price = self.company_info.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
|
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
| price = info.get("preMarketPrice") |
nfo.get("currentPrice") or self.company_info.get(
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
|
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_ho | change = info.get("preMarketChange") |
"regularMarketPrice"
)
if price is not None:
return f"{price:.2f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
|
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not Non | if price is not None and change is not None:
return price, change, "Pre-Market" |
f}"
return "N/A"
@rx.var
def market_cap_display_val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
|
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
| elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours" |
val(self) -> str:
return format_market_cap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
|
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased | price = info.get("postMarketPrice") |
ap(self.company_info.get("marketCap"))
@rx.var
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
|
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
retur | change = info.get("postMarketChange") |
r
def is_market_currently_active(self) -> bool:
"""Determines if the market is currently in an active trading session (regular, pre, or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
|
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
| if price is not None and change is not None:
return price, change, "After Hours" |
or post)."""
market_state = self.company_info.get("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
|
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": | def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return "" |
t("marketState", "").upper()
# Active states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
|
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle | price, _, _ = self._after_hours_data |
states include regular market, pre-market, and post-market trading
active_states = ["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
|
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style | if price is not None:
return f"{price:.2f}" |
["REGULAR", "PRE", "POST", "POSTPOST"]
return market_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
|
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "pr | def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return "" |
rket_state in active_states
@rx.var
def _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
|
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def curren | _, change, _ = self._after_hours_data |
ef _after_hours_data(self) -> tuple[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
|
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{ | if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}" |
[float | None, float | None, str]:
info = self.company_info
market_state = info.get("marketState")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
|
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not se | sign = "+" if change > 0 else "" |
ate")
if market_state == "PRE":
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
|
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if | def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label |
price = info.get("preMarketPrice")
change = info.get("preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
|
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[flo | _, _, label = self._after_hours_data |
preMarketChange")
if price is not None and change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
|
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not pri | def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None |
nd change is not None:
return price, change, "Pre-Market"
elif market_state in ["POST", "POSTPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
|
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.histo | price, change, _ = self._after_hours_data |
STPOST", "CLOSED"]:
price = info.get("postMarketPrice")
change = info.get("postMarketChange")
if price is not None and change is not None:
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
|
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price | def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper() |
return price, change, "After Hours"
return None, None, ""
@rx.var
def after_hours_price_display_val(self) -> str:
price, _, _ = self._after_hours_data
if price is not None:
return f"{price:.2f}"
return ""
@rx.var
def after_hours_change_display_val(self) -> str:
_, change, _ = self._after_hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
|
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
} |
hours_data
if change is not None:
sign = "+" if change > 0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
|
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data |
0 else ""
return f"{sign}{change:.2f}"
return ""
@rx.var
def after_hours_label(self) -> str:
_, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
|
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| if not self.historical_data:
return [{"name": "N/A", "price": 0}] |
, _, label = self._after_hours_data
return label
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
|
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)] |
el
@rx.var
def show_after_hours_section(self) -> bool:
price, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
|
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| if not self.historical_data:
return ["auto", "auto"] |
rice, change, _ = self._after_hours_data
return price is not None and change is not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
|
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| prices = [d["price"] for d in self.historical_data if d["price"] is not None] |
s not None
@rx.var
def currency_code(self) -> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
|
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| if not prices:
return [0, 100] |
-> str:
"""Returns the upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
|
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| min_price = min(prices) |
upper-cased currency code, defaulting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
|
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| max_price = max(prices) |
lting to USD."""
return self.company_info.get("currency", "USD").upper()
@rx.var
def y_axis_label_config(self) -> dict:
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
|
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
)
| padding = (max_price - min_price) * 0.05 |
"""Provides configuration for the Y-axis label (title)."""
return {
"value": self.currency_code,
"angle": -90,
"position": "insideLeft",
"style": {"textAnchor": "middle", "fill": "#d4d4d4"},
"dy": 70,
"dx": -15,
}
@rx.var
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
if not self.historical_data:
return [{"name": "N/A", "price": 0}]
return self.historical_data
@rx.var
def y_axis_domain(self) -> list[float | str]:
if not self.historical_data:
return ["auto", "auto"]
prices = [d["price"] for d in self.historical_data if d["price"] is not None]
if not prices:
return [0, 100]
min_price = min(prices)
max_price = max(prices)
padding = (max_price - min_price) * 0.05
return [round(max(0, min_price - padding)), round(max_price + padding)]
@rx.var
| def has_data_to_display(self) -> bool:
return bool(
self.company_info
and self.company_info.get("symbol")
and self.historical_data
) | |
from stock_market_dashboard.components.line_chart import trading_line_chart
from stock_market_dashboard.components.main_header import main_header
from stock_market_dashboard.components.options_table import options_table
from stock_market_dashboard.components.orders_table import orders_table
from stock_market_dashboard.components.positions_table import positions_table
from stock_market_dashboard.states.trading_state import TradingState
def index() -> rx.Component:
"""The main page component for the trading dashboard."""
return rx.el.div(
main_header(),
rx.el.main(
trading_line_chart(),
options_table(),
orders_table(),
positions_table(),
class_name="grid grid-cols-1 lg:grid-cols-3 gap-4 p-4",
),
class_name="min-h-screen bg-gray-900 text-gray-300 font-sans",
on_mount=TradingState.start_simulation,
)
app = rx.App(
theme=rx.theme(appearance="light"),
stylesheets=["/s | import reflex as rx | |
import reflex as rx
|
from stock_market_dashboard.components.main_header import main_header
from stock_market_dashboard.components.options_table import options_table
from stock_market_dashboard.components.orders_table import orders_table
from stock_market_dashboard.components.positions_table import positions_table
from stock_market_dashboard.states.trading_state import TradingState
def index() -> rx.Component:
"""The main page component for the trading dashboard."""
return rx.el.div(
main_header(),
rx.el.main(
trading_line_chart(),
options_table(),
orders_table(),
positions_table(),
class_name="grid grid-cols-1 lg:grid-cols-3 gap-4 p-4",
),
class_name="min-h-screen bg-gray-900 text-gray-300 font-sans",
on_mount=TradingState.start_simulation,
)
app = rx.App(
theme=rx.theme(appearance="light"),
stylesheets=["/styles.css"],
)
app.add_page(index, route="/")
| from stock_market_dashboard.components.line_chart import trading_line_chart |
import reflex as rx
from stock_market_dashboard.components.line_chart import trading_line_chart
|
from stock_market_dashboard.components.options_table import options_table
from stock_market_dashboard.components.orders_table import orders_table
from stock_market_dashboard.components.positions_table import positions_table
from stock_market_dashboard.states.trading_state import TradingState
def index() -> rx.Component:
"""The main page component for the trading dashboard."""
return rx.el.div(
main_header(),
rx.el.main(
trading_line_chart(),
options_table(),
orders_table(),
positions_table(),
class_name="grid grid-cols-1 lg:grid-cols-3 gap-4 p-4",
),
class_name="min-h-screen bg-gray-900 text-gray-300 font-sans",
on_mount=TradingState.start_simulation,
)
app = rx.App(
theme=rx.theme(appearance="light"),
stylesheets=["/styles.css"],
)
app.add_page(index, route="/")
| from stock_market_dashboard.components.main_header import main_header |
import reflex as rx
from stock_market_dashboard.components.line_chart import trading_line_chart
from stock_market_dashboard.components.main_header import main_header
|
from stock_market_dashboard.components.orders_table import orders_table
from stock_market_dashboard.components.positions_table import positions_table
from stock_market_dashboard.states.trading_state import TradingState
def index() -> rx.Component:
"""The main page component for the trading dashboard."""
return rx.el.div(
main_header(),
rx.el.main(
trading_line_chart(),
options_table(),
orders_table(),
positions_table(),
class_name="grid grid-cols-1 lg:grid-cols-3 gap-4 p-4",
),
class_name="min-h-screen bg-gray-900 text-gray-300 font-sans",
on_mount=TradingState.start_simulation,
)
app = rx.App(
theme=rx.theme(appearance="light"),
stylesheets=["/styles.css"],
)
app.add_page(index, route="/")
| from stock_market_dashboard.components.options_table import options_table |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.