Spaces:
Running
Running
add finviz chart
Browse files- app.py +9 -5
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -2,22 +2,23 @@ import pandas as pd
|
|
| 2 |
import numpy as np
|
| 3 |
import os
|
| 4 |
from datetime import datetime
|
|
|
|
| 5 |
|
| 6 |
import hvplot as hv
|
| 7 |
import holoviews as hvs
|
| 8 |
import panel as pn
|
| 9 |
import hvplot.pandas
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
|
|
|
|
| 13 |
|
| 14 |
def _extract_raw_data(ticker):
|
| 15 |
-
import yfinance as yf
|
| 16 |
df = yf.Ticker(ticker)
|
| 17 |
return df.history(period="6mo", interval="1d").reset_index()
|
| 18 |
|
| 19 |
def _transform_data(raw_data: pd.DataFrame):
|
| 20 |
-
from datetime import timedelta
|
| 21 |
data = raw_data[["Date", "Open", "High", "Low", "Close", "Volume"]].copy(deep=True).rename(columns={
|
| 22 |
"Date": "time",
|
| 23 |
"Open": "open",
|
|
@@ -87,9 +88,12 @@ MarketCap = pn.widgets.FloatSlider(name='Market Capital (B$)', start=0, end=4000
|
|
| 87 |
|
| 88 |
def get_DF(DF,ticker,SmartScore,GFValuepercent, FinVizTargetpercent, Sector,MarketCap):
|
| 89 |
if ticker and ticker!="ALL":
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
chart1 = make_candle_stick(ticker)
|
| 92 |
-
return pn.Column(table1,chart1)
|
| 93 |
else:
|
| 94 |
return pn.widgets.Tabulator( DF.query("SmartScore>=@SmartScore[0] & SmartScore <= @SmartScore[1] & GFValuepercent>=@GFValuepercent & FinVizTargetpercent>@FinVizTargetpercent & Sector in @Sector & MarketCap>@MarketCap"), height=800, widths=200, show_index=False)
|
| 95 |
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import os
|
| 4 |
from datetime import datetime
|
| 5 |
+
from datetime import timedelta
|
| 6 |
|
| 7 |
import hvplot as hv
|
| 8 |
import holoviews as hvs
|
| 9 |
import panel as pn
|
| 10 |
import hvplot.pandas
|
| 11 |
|
| 12 |
+
import yfinance as yf
|
| 13 |
+
from finvizfinance.quote import finvizfinance
|
| 14 |
|
| 15 |
+
pn.extension('bokeh', template='bootstrap')
|
| 16 |
|
| 17 |
def _extract_raw_data(ticker):
|
|
|
|
| 18 |
df = yf.Ticker(ticker)
|
| 19 |
return df.history(period="6mo", interval="1d").reset_index()
|
| 20 |
|
| 21 |
def _transform_data(raw_data: pd.DataFrame):
|
|
|
|
| 22 |
data = raw_data[["Date", "Open", "High", "Low", "Close", "Volume"]].copy(deep=True).rename(columns={
|
| 23 |
"Date": "time",
|
| 24 |
"Open": "open",
|
|
|
|
| 88 |
|
| 89 |
def get_DF(DF,ticker,SmartScore,GFValuepercent, FinVizTargetpercent, Sector,MarketCap):
|
| 90 |
if ticker and ticker!="ALL":
|
| 91 |
+
stock = finvizfinance(ticker)
|
| 92 |
+
url_of_image = stock.ticker_charts()
|
| 93 |
+
image_panel = pn.panel(url_of_image) #, width=400, height=400)
|
| 94 |
+
table1 = pn.widgets.Tabulator(DF.query("Ticker == @ticker"), height=200, widths=200, show_index=False)
|
| 95 |
chart1 = make_candle_stick(ticker)
|
| 96 |
+
return pn.Column(table1,chart1,image_panel)
|
| 97 |
else:
|
| 98 |
return pn.widgets.Tabulator( DF.query("SmartScore>=@SmartScore[0] & SmartScore <= @SmartScore[1] & GFValuepercent>=@GFValuepercent & FinVizTargetpercent>@FinVizTargetpercent & Sector in @Sector & MarketCap>@MarketCap"), height=800, widths=200, show_index=False)
|
| 99 |
|
requirements.txt
CHANGED
|
@@ -2,4 +2,5 @@ panel
|
|
| 2 |
hvplot
|
| 3 |
holoviews
|
| 4 |
bokeh
|
| 5 |
-
yfinance
|
|
|
|
|
|
| 2 |
hvplot
|
| 3 |
holoviews
|
| 4 |
bokeh
|
| 5 |
+
yfinance
|
| 6 |
+
finvizfinance
|