Upload 4 files
Browse files- Dockerfile +16 -0
- app.py +46 -0
- requirements.txt +0 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9
|
| 2 |
+
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
|
| 5 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 6 |
+
RUN python3 -m pip install --no-cache-dir --upgrade pip
|
| 7 |
+
RUN python3 -m pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 8 |
+
|
| 9 |
+
COPY . .
|
| 10 |
+
|
| 11 |
+
CMD ["panel", "serve", "/code/app.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
|
| 12 |
+
|
| 13 |
+
RUN mkdir /.cache
|
| 14 |
+
RUN chmod 777 /.cache
|
| 15 |
+
RUN mkdir .chroma
|
| 16 |
+
RUN chmod 777 .chroma
|
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import panel as pn
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
from datetime import date
|
| 5 |
+
pn.extension('bokeh', template='bootstrap')
|
| 6 |
+
import hvplot.pandas
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@pn.cache
|
| 10 |
+
def get_df(todaydate):
|
| 11 |
+
|
| 12 |
+
from datetime import datetime
|
| 13 |
+
todaydate = datetime.today().strftime("%Y-%m-%d")
|
| 14 |
+
# URL of the CSV file
|
| 15 |
+
url = f"https://raw.githubusercontent.com/alirezax2/GurusFocusCrawl/main/gurufocus/GuruFocus_merged_{todaydate}.csv"
|
| 16 |
+
|
| 17 |
+
# Read the CSV file into a DataFrame
|
| 18 |
+
df = pd.read_csv(url)
|
| 19 |
+
|
| 20 |
+
return df
|
| 21 |
+
|
| 22 |
+
selectedcol = pn.widgets.Select(name='Select Ratio', value = 'PEG Ratio', options=list(df.columns))
|
| 23 |
+
selecteditem = pn.widgets.Select(name='Select Item', options=['Industry' , 'Sector'])
|
| 24 |
+
|
| 25 |
+
selectedhover = 'Ticker'
|
| 26 |
+
hv.extension('bokeh')
|
| 27 |
+
|
| 28 |
+
def create_plot(selectedcol,selecteditem,todaydate):
|
| 29 |
+
df = get_df(todaydate)
|
| 30 |
+
|
| 31 |
+
group_means = df.groupby(selecteditem)[selectedcol].mean()
|
| 32 |
+
df2 = df.merge(group_means, left_on=selecteditem, right_index=True, suffixes=('', f'_{selecteditem}_mean'))
|
| 33 |
+
|
| 34 |
+
return df2.hvplot.bar(x=selecteditem, y=f'{selectedcol}_{selecteditem}_mean', hover_cols=selectedhover, height=600, width=1600).opts(xrotation=90, fontsize={'xticks': 10})
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
todaydate = pn.widgets.DatePicker(
|
| 38 |
+
name ="End Date",# value=datetime(2000, 1, 1),
|
| 39 |
+
description='Select a Date',
|
| 40 |
+
end= date.today() #date(2023, 9, 1)
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
bound_plot = pn.bind(create_plot, selectedcol=selectedcol , selecteditem=selecteditem, todaydate=todaydate)
|
| 45 |
+
pn.Column(selectedcol, selecteditem, todaydate, bound_plot)
|
| 46 |
+
|
requirements.txt
ADDED
|
File without changes
|