Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions ag_grid_finance/ag_grid_finance/ag_grid_finance.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import reflex as rx
from reflex_ag_grid import ag_grid
import yfinance as yf
from datetime import datetime, timedelta

import pandas as pd
import yfinance as yf

import reflex as rx
import reflex_enterprise as rxe
from reflex_enterprise import ag_grid


companies = ["AAPL", "MSFT", "GOOGL", "AMZN", "META"]


class State(rx.State):
# The selected rows in the AG Grid
selected_rows: list[dict] = None
selected_rows: list[dict] | None = None
# The currently selected company in AG Grid
company: str
# The data fetched from Yahoo Finance
data: pd.DataFrame
# The data to be displayed in the AG Grid
dict_data: list[dict] = [{}]
# The data to be displayed in the line graph
dff_ticker_hist: list[dict] = None
dff_ticker_hist: list[dict] = []
# The datetime of the current fetched data
datetime_now: datetime = datetime.now()
# The theme of the AG Grid
Expand All @@ -33,7 +36,7 @@ def fetch_stock_data(self):

# Fetch data for all tickers in a single download
self.data = yf.download(
companies, start=start_date, end=self.datetime_now, group_by="ticker"
companies, start=start_date, end=self.datetime_now, group_by="ticker",
)
rows = []
for ticker in companies:
Expand Down Expand Up @@ -73,7 +76,7 @@ def update_line_graph(self):
if self.selected_rows:
ticker = self.selected_rows[0]["ticker"]
else:
self.dff_ticker_hist = None
self.dff_ticker_hist = []
return
self.company = ticker

Expand Down Expand Up @@ -185,5 +188,5 @@ def index():


# Add state and page to the app.
app = rx.App()
app = rxe.App()
app.add_page(index)
6 changes: 3 additions & 3 deletions ag_grid_finance/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
reflex>=0.5.10
reflex-ag-grid>=0.0.5
yfinance==0.2.43
reflex>=0.7.2a2
reflex-enterprise>=0.0.2
yfinance==0.2.54
Loading