AlirezaX2 commited on
Commit
d959664
·
1 Parent(s): 890b5c6

first commit

Browse files
Files changed (3) hide show
  1. app.py +67 -0
  2. dockerfile +16 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import os
4
+
5
+ import hvplot as hv
6
+ import holoviews as hvs
7
+ import panel as pn
8
+ import hvplot.pandas
9
+
10
+ pn.extension('bokeh', template='bootstrap')
11
+
12
+
13
+ #Need to update github action to merge gurufocus daily with weekly tiprank
14
+
15
+ current_datetime = datetime.now().strftime("%Y-%m-%d")
16
+ daily_gurufocus_csvfile = f"https://raw.githubusercontent.com/alirezax2/GurusFocusCrawl/main/gurufocus/GuruFocus_merged_{current_datetime}.csv"
17
+
18
+ daily_gurufocus_DF = pd.read_csv(daily_gurufocus_csvfile)
19
+
20
+
21
+ monthly_tiprank_csvfile = f"https://raw.githubusercontent.com/alirezax2/GurusFocusCrawl/main/tipranks/tipranks_2024-02-28.csv"
22
+
23
+ monthly_tiprank_DF = pd.read_csv(monthly_tiprank_csvfile)
24
+
25
+ #Merging with Gurufocus
26
+ DFgurufocus = daily_gurufocus_DF[['Ticker' , 'GFValue']] # , 'GFValuediff']]
27
+ DFmerge_tipranks_gurufocus = DFgurufocus.merge(monthly_tiprank_DF)
28
+
29
+ if 'Price' in DFmerge_tipranks_gurufocus.columns and 'GFValue' in DFmerge_tipranks_gurufocus.columns:
30
+ DFmerge_tipranks_gurufocus['GFValuepercent'] = 100* ( DFmerge_tipranks_gurufocus['GFValue'] - DFmerge_tipranks_gurufocus['Price']) / DFmerge_tipranks_gurufocus['Price']
31
+
32
+
33
+ ticker = pn.widgets.AutocompleteInput(name='Ticker', options=list(DFmerge_tipranks_gurufocus.Ticker) , placeholder='Write Ticker here همین جا')
34
+ # ticker.value = "AAPL"
35
+
36
+ SmartScore = pn.widgets.EditableRangeSlider(name='SmartScore', start=0, end=10, value=(9, 10), step=1)
37
+
38
+ Industry = pn.widgets.CheckBoxGroup( name='Select Industry', value=list(set(DFmerge_tipranks_gurufocus.Industry)), options=list(set(DFmerge_tipranks_gurufocus.Industry)), inline=True)
39
+ Sector = pn.widgets.CheckBoxGroup( name='Select Sector', value=list(set(DFmerge_tipranks_gurufocus.Sector)), options=list(set(DFmerge_tipranks_gurufocus.Sector)), inline=False)
40
+ GFValuepercent = pn.widgets.FloatSlider(name='GFValuepercent', start=-100, end=1000, step=1, value=30.0)
41
+ alert = pn.pane.Alert(f'{DFmerge_tipranks_gurufocus.shape} ', alert_type="success")
42
+ # SmartScore = pn.widgets.IntSlider(name='SmartScore', start=0, end=10, step=1, value=9)
43
+ # Sector = pn.widgets.Select(name='Sector', value='Mean', options=list(DFmerge_tipranks_gurufocus.Sector))
44
+ # Industry = pn.widgets.Select(name='Sector', value='Mean', options=list(DFmerge_tipranks_gurufocus.Sector))
45
+
46
+
47
+ def get_DF(DF,ticker,SmartScore,GFValuepercent ,Sector):
48
+ if ticker:
49
+ DF = DF.query("Ticker == @ticker")
50
+ # DF = DF.query("SmartScore>=@SmartScore[0] & SmartScore <= @SmartScore[1]")
51
+ # DF = DF.query('GFValuepercent>=@GFValuepercent')
52
+ # DF = DF.query('Sector in @ Sector')
53
+ return pn.widgets.Tabulator( DF.query("SmartScore>=@SmartScore[0] & SmartScore <= @SmartScore[1] & GFValuepercent>=@GFValuepercent & Sector in @ Sector" ), name='DataFrame' , height=500, widths=200 ,)
54
+
55
+ def get_alert(DF,ticker,SmartScore,GFValuepercent ,Sector):
56
+ if ticker:
57
+ DF2 = DF.query("Ticker == @ticker")
58
+ else:
59
+ DF2 = DF
60
+ DF = DF.query("SmartScore>=@SmartScore[0] & SmartScore <= @SmartScore[1]")
61
+ return pn.pane.Alert(f'{DF.shape} ', alert_type="success")
62
+
63
+
64
+ pn.extension('tabulator')
65
+ bound_plot = pn.bind(get_DF, DF=DFmerge_tipranks_gurufocus,ticker=ticker,SmartScore=SmartScore,GFValuepercent=GFValuepercent ,Sector=Sector)
66
+
67
+ pn.Column(pn.Row(pn.Column(ticker,SmartScore,GFValuepercent ,Sector),bound_plot)).servable(title="Fair Value Ranking - Gurufocus & Tiprank")
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
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ panel
2
+ hvplot
3
+ holoviews
4
+ bokeh