Skip to content

Commit 67ccacb

Browse files
committed
some more changes
1 parent 627f49f commit 67ccacb

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

stock_graph_app/stock_graph_app/components/stock_chart_display.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def stock_header_component() -> rx.Component:
115115
" ",
116116
rx.el.span(
117117
StockState.after_hours_change_display_val,
118-
class_name=StockState.after_hours_change_color
119-
+ " font-semibold",
118+
class_name="text-neutral-500 font-semibold",
120119
),
121120
rx.el.span(
122121
StockState.company_info.get("currency", ""),

stock_graph_app/stock_graph_app/states/stock_state.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
from typing import List, TypedDict
2+
13
import reflex as rx
24
import yfinance as yf
35

46

7+
class HistoricalDataPoint(TypedDict):
8+
name: str
9+
price: float
10+
11+
512
def format_market_cap(cap):
613
if cap is None:
714
return "N/A"
@@ -19,7 +26,7 @@ class StockState(rx.State):
1926

2027
search_ticker_input: str = "AAPL"
2128
company_info: dict = {}
22-
historical_data: list[dict] = []
29+
historical_data: List[HistoricalDataPoint] = []
2330

2431
is_loading: bool = False
2532
error_message: str = ""
@@ -208,19 +215,6 @@ def show_after_hours_section(self) -> bool:
208215
price, change, _ = self._after_hours_data
209216
return price is not None and change is not None
210217

211-
@rx.var
212-
def after_hours_change_color(self) -> str:
213-
_, change, _ = self._after_hours_data
214-
if change is None:
215-
return "text-neutral-500"
216-
return (
217-
"text-green-500"
218-
if change > 0
219-
else "text-red-500"
220-
if change < 0
221-
else "text-neutral-500"
222-
)
223-
224218
@rx.var
225219
def currency_code(self) -> str:
226220
"""Returns the upper-cased currency code, defaulting to USD."""
@@ -239,7 +233,7 @@ def y_axis_label_config(self) -> dict:
239233
}
240234

241235
@rx.var
242-
def current_stock_data_for_chart(self) -> list[dict]:
236+
def current_stock_data_for_chart(self) -> List[HistoricalDataPoint]:
243237
if not self.historical_data:
244238
return [{"name": "N/A", "price": 0}]
245239
return self.historical_data

0 commit comments

Comments
 (0)