Data science is spread across our lives and we are surrounded by its applications. We unknowingly use the vast number of applications of data science and machine learning such as recommender systems, house price prediction, data monitoring and data analysis etc. We are in fact surrounded by data and probably have played around with it many a times (especially if you’re a math loving person). So here’s another web app in yet another vital application of data science.
This is a financial stock price web app. It shows the closing financial stock price values for S and P 500 companies. S and P 500 companies are 500 of the largest companies listed on stock exchanges in the US. The S and P 500 stock market index comprises of 505 common stocks issued by 500 large cap companies. The stocks of these companies trade either on the NYSE (New York Stock Exchange) or NASDAQ (National Association of Securities Dealers Automated Quotations). NYSE is an auction market whereas NASDAQ is a dealer’s market. Some of the S and P 500 companies included in the dataset are Alphabet, Apple, Amazon, Facebook, Microsoft etc.
This web app displays information about the respective user input company (from the list of S and P 500 companies) and provides its stock chart along with other company share statistics. It displays information of the company such as its GICS sector, GICS sub-industry, headquarters location, CIK, etc. Users can analyze data over the past multiple years of the respective company.
Simple moving averages have also been provided so that users can compare the present value with the average value of stocks in a particular range. This helps to determine whether an asset price will continue or if it will reverse a bull or bear trend. Historical company shares along with company share data statistics have also been provided.
Yahoo Finance and Yahoo Finance API was used to obtain the data. Users can also move their cursor over the stock charts to get the exact date and value of the stock price. Yahoo finance provides financial data, stock quotes, press releases etc. It alsooffers other tools for personal finance management.
Added feature: I added time series forecasting using fbprophet. Many people are unable to pip install that. This might be due to some reasons: fbprophet requires a C++ compiler, so if you’re operating on Windows, better use anaconda instead of VScode. Fbprophet also requires pystan so make sure that is working and check for the compatibility of those two versions. For any other build issues, contact us or drop a comment. You can also check out Stack Overflow for additional errors during installation of fbprophet: https://stackoverflow.com/questions/56701359/running-setup-py-install-for-fbprophet-error. Other solutions might also be available on Github.
Coming onto the update, yes I’ve finally added time series forecasting for the stocks and now the app can predict the opening and closing stock price values of companies over a period of 1 to 15 years. Time series data using rangeslider can also be seen to find out historical opening and closing stock values. The forecast plot and components have also been provided. Stock values and predictions can also be seen on a weekly basis apart from their yearly values and trends.
We have deployed the app using Streamlit. It is an open source framework that allows data science teams to deploy web apps fairly easily. It’s one of the best hosting services I’ve used and it’s great for quick and easy deployment of web apps. The app is majorly coded in python.
This web app helped me to improve my experience in Machine Learning and definitely helped in my future projects. Feel free to add onto this project and don’t hesitate to drop by any suggestions. Hope you enjoy the app!
Link of the app: https://share.streamlit.io/braxtonova/stockpred/main/app.py
Explanation of the Code and how you can make this yourself !
Here, I am going to go through the code in a very concise and simple manner so that people with even minimal experience in programming or data science can follow along and benefit it. This app has been coded in python and has been deployed on streamlit as mentioned before. I’ve also used the Random Forest Classifier Algorithm for this particular problem.
Alright so lets finally get started. First up I’ve imported the python packages / libraries that I’ve used for this app. More information for them is available on the project template of SkillTools.
import streamlit as st
from datetime import date
import yfinance as yf
from fbprophet import Prophet
from fbprophet.plot import plot_plotly
from plotly import graph_objs as go
from PIL import Image
import pandas as pd
After this, I’ve included an image of the usual perception of Finance in terms of mathematics (just to show you’ll something new). I’ve also included the description of the app early on. We also need to load the dataset (S and P 500 companies dataset in this case).
image = Image.open('stock.jpeg')
st.image(image, use_column_width=True)
st.markdown('''
# Fintech Stock Price App
This app shows the closing financial stock price values for S and P 500 companies along with the timeline.
- These are 500 of the largest companies listed on stock exchanges in the US.
- App built by Pranav Sawant and Anshuman Shukla of Team Skillocity.
- Dataset resource: Yahoo Finance
- Added feature: Time series forecasting with fbprophet that can predict the stock price values over 15 years.
- Note: User inputs for the company to be analysed are taken from the sidebar. It is located at the top left of the page (arrow symbol). Inputs for other features of data analysis can also be provided from the sidebar itself.
''')
st.write('---')
@st.cache
def load_data():
components = pd.read_html(
"https://en.wikipedia.org/wiki/List_of_S" "%26P_500_companies"
)[0]
return components.drop("SEC filings", axis=1).set_index("Symbol")
@st.cache(allow_output_mutation=True)
def load_quotes(asset):
return yf.download(asset)
The next block of a code is a slightly long one but I’ll try to explain it in a simple manner. Would have been much easier in person but in the pandemic we’re all at home aren’t we. I have defined certain components and have listed the features upon which we can perform EDA and find more information about the particular stocks. Some of these are year founded, security, simple moving average etc. I have provided checkboxes / sliders so that users can change their inputs. (They have an option to choose the particular company but they can’t manipulate stocks within the app). I’ve included stock charts and other features into the app.
def main():
components = load_data()
st.sidebar.title("Options")
if st.sidebar.checkbox("View companies list"):
st.dataframe(
components[["Security", "GICS Sector", "Date first added", "Founded"]]
)
title = st.empty()
def label(symbol):
a = components.loc[symbol]
return symbol + " - " + a.Security
st.sidebar.subheader("Select company")
asset = st.sidebar.selectbox(
"Click below to select a new company",
components.index.sort_values(),
index=3,
format_func=label,
)
title.title(components.loc[asset].Security)
if st.sidebar.checkbox("View company info", True):
st.table(components.loc[asset])
data0 = load_quotes(asset)
data = data0.copy().dropna()
data.index.name = None
section = st.sidebar.slider(
"Number of days for Data Analysis of stocks",
min_value=30,
max_value=min([5000, data.shape[0]]),
value=1000,
step=10,
)
data2 = data[-section:]["Adj Close"].to_frame("Adj Close")
sma = st.sidebar.checkbox("Simple Moving Average")
if sma:
period = st.sidebar.slider(
"Simple Moving Average period", min_value=5, max_value=500, value=20, step=1
)
data[f"SMA {period}"] = data["Adj Close"].rolling(period).mean()
data2[f"SMA {period}"] = data[f"SMA {period}"].reindex(data2.index)
sma2 = st.sidebar.checkbox("Simple Moving Average 2")
if sma2:
period2 = st.sidebar.slider(
"Simple Moving Average 2 period", min_value=5, max_value=500, value=100, step=1
)
data[f"SMA2 {period2}"] = data["Adj Close"].rolling(period2).mean()
data2[f"SMA2 {period2}"] = data[f"SMA2 {period2}"].reindex(data2.index)
st.subheader("Stock Chart")
st.line_chart(data2)
st.subheader("Company Statistics")
st.table(data2.describe())
if st.sidebar.checkbox("View Historical Company Shares"):
st.subheader(f"{asset} historical data")
st.write(data2)
main()
My original app contained just this much itself. But then someone also suggested me to run time series forecasting using fbprophet. I did have certain issues while installing but I’ve already mentioned it earlier in this article. There were however some slight disadvantages of doing this. The app became slower and the compatibility of fbprophet and rangslider is not the best with streamlit. But regardless of that, I’ve put it in and here’s how you can do it too.
To prevent the app from significantly lagging, I’ve only used a few stocks for demonstrating time series forecasting. We can predict the stocks upto a period of 35 years.
def pre_dict():
st.header('Stock prediction')
START = "2010-01-01"
TODAY = date.today().strftime("%Y-%m-%d")
stocks = ('AAPL', 'GOOG', 'MSFT', 'GME')
selected_stock = st.selectbox('Select company for prediction', stocks)
n_years = st.slider('Years of prediction:', 1, 15)
period = n_years * 365
Next, we need to load the data and plot it using a simple scatterplot.
@st.cache
def load_data(ticker):
data = yf.download(ticker, START, TODAY)
data.reset_index(inplace=True)
return data
#data_load_state = st.text('Loading data...')
data = load_data(selected_stock)
#data_load_state.text('Loading data... done!')
st.subheader('Raw data')
st.write(data.tail())
# Plot raw data
def runpls():
fig = go.Figure()
fig.add_trace(go.Scatter(x=data['Date'], y=data['Open'], name = "stock_open"))
fig.add_trace(go.Scatter(x=data['Date'], y=data['Close'], name = "stock_close"))
fig.layout.update(title_text='Time Series data with Rangeslider', xaxis_rangeslider_visible=True)
st.plotly_chart(fig)
runpls()
Now we simply need to predict the stock output, make necessary prediction data frames, and forecast the components.
df_train = data[['Date','Close']]
df_train = df_train.rename(columns={"Date": "ds", "Close": "y"})
m = Prophet()
m.fit(df_train)
future = m.make_future_dataframe(periods=period)
forecast = m.predict(future)
# Show and plot forecast
st.subheader('Forecast data')
st.write(forecast.tail())
st.write(f'Forecast plot for {n_years} years')
fig1 = plot_plotly(m, forecast)
st.plotly_chart(fig1)
st.write("Forecast components")
fig2 = m.plot_components(forecast)
st.write(fig2)
To finish up the code, I’ve added a stop button so that users can stop the forecasting as and when they like.
if st.button('Stock Prediction'):
if st.button('Stop Prediction'):
st.title("Prediction Stopped")
else:
pre_dict()
So that’s all from this web app and I’ll soon be back with another cool application of machine learning and data science. Hasta Pronto !
Clean and well displayed with good statistics. One suggestion : you can use time series forecasting using fbprophet package.
Hi, thanks. Yeah I'll definitely add that. I originally tried doing that but unfortunately I couldn't pip install fbprophet as it requires a C++ compiler. I'll try using Anaconda and see how that goes.
There you go, just uploaded it yesterday morning
Nice, thanks for the install tips. What version pystan did you use for this ?
Hi, I used pystan==2.19.1.1
👉 Anita He wants to talk frankly with you and show you something, you will like it. Click Here:👉 http://bit.do/fVzCM
A secret weapon for anyone who needs content. I dont need to tell you how important it is to optimize every step in your SEO pipeline. But unfortunately, its nearly impossible to cut out time or money when it comes to getting good content. At least thats what I thought until I came across Article Forge. Built by a team of AI researchers from Stanford, MIT, Carnegie Mellon, Harvard, Article Forge is an AI content writer that uses deep learning models to research, plan out, and write entire articles about any topic with the click of a button. Their team trained AI models on millions of articles to teach Article Forge how to draw connections between topics so that each article it writes is relevant, interesting and useful. All their hard work means you just enter a few keywords and Article Forge will write a complete article from scratch making sure every thought flows naturally into the next, resulting in readable, high quality, and unique content. Put simply, this is a secret weapon for anyone who needs content. I get how impossible that sounds so you need to see how Article Forge writes a complete article with the Click Here:👉 https://stanford.io/3FXszd0
Free. Sign up to receive $100, Trade to receive $5500. Click Here:👉 https://millionairego.page.link/free
order levofloxacin pill levaquin us
order avodart for sale purchase dutasteride ondansetron buy online
aldactone 25mg for sale spironolactone 25mg cheap fluconazole 100mg drug
acillin price buy cephalexin 500mg for sale order erythromycin generic
brand fildena generic robaxin order robaxin 500mg without prescription
purchase sildenafil sale sildenafil 150mg for sale order estradiol 1mg generic
order generic lamotrigine minipress usa buy retin cream without prescription
buy tadalafil 20mg avanafil 100mg over the counter diclofenac 100mg cheap
order isotretinoin without prescription isotretinoin uk azithromycin uk
indomethacin 50mg oral order indocin 75mg sale trimox 500mg oral
buy cialis 20mg sale buy cialis in us purchase sildenafil generic
anastrozole uk clarithromycin price order viagra
tadalafil prix sildenafil 200mg generique en pharmacie acheter 100mg du viagra
order prednisone online cheap viagra overnight delivery sildenafil over counter
cialis 10mg kaufen ohne rezept original cialis 5mg rezeptfrei sicher kaufen sildenafil generika
order isotretinoin 40mg order stromectol 3mg pill ivermectin price comparison
buy modafinil 200mg sale order diamox 250mg pills buy acetazolamide 250mg without prescription
doxycycline 100mg oral order vardenafil 10mg generic lasix 100mg price
altace 5mg over the counter temovate pills brand azelastine 10ml
clonidine 0.1 mg pills catapres 0.1 mg without prescription tiotropium bromide oral
brand buspar 10mg ditropan brand oxybutynin online order
hytrin pills buy hytrin 5mg pills azulfidine 500mg uk
buy alendronate generic fosamax 70mg price famotidine 40mg without prescription
benicar 10mg over the counter order diamox 250 mg online cheap diamox 250mg oral
prograf 1mg us buy ropinirole 2mg generic buy ursodiol 150mg generic
buy imdur for sale order digoxin 250 mg online purchase micardis online cheap
buy bupropion without prescription bupropion for sale online order seroquel 100mg for sale
buy molnupiravir 200 mg pills buy prevacid 15mg pills lansoprazole 30mg for sale
sertraline 100mg ca buy kamagra pill sildenafil 100mg price
buy salbutamol 100 mcg viagra 100mg england purchase sildenafil pills
бесплатный порно видео чат. Click Here:👉 http://rt.livepornosexchat.com/
cialis 10mg generic cialis canada buy sildenafil pills
cialis uk buy phenazopyridine pills buy symmetrel 100 mg without prescription
промокод в мелбет. Click Here:👉 http://lynks.ru/geshi/php/?melbet_promokod_pri_registracii_2020.html
revia order online revia uk buy abilify 20mg online
order dapsone 100 mg online cheap cheap avlosulfon 100 mg buy perindopril 8mg pills
промокод для мелбет. Click Here:👉 http://lynks.ru/geshi/php/?melbet_promokod_pri_registracii_2020.html
marimba remix ringtones https://downloadfreeringtoness.com/marimba-remix-ringtones
medroxyprogesterone ca order medroxyprogesterone generic cyproheptadine 4 mg oral
best ringtones https://ringtonessbase.com
online dinosaur games https://chromedinos.com
modafinil over the counter drug store ivermectin without a doctor prescription
brand luvox 100mg order cymbalta without prescription cost glucotrol 5mg
samsung ringtones https://downloadfreeringtoness.com/samsung-ringtones
car sounds https://sounddeffects.com/car-sounds
nokia 3315 old ringtone download https://ringtonessphone.com/nokia-3315-ringtone.html
order accutane 10mg sale order prednisone 10mg deltasone 20mg brand
piracetam 800mg sale sildenafil next day sildenafil 100mg cost
buy azithromycin 250mg generic purchase prednisolone online buy neurontin 800mg pills
order cialis 40mg online cheap order generic viagra 100mg sildenafil tablets
buy generic furosemide 100mg purchase furosemide online order plaquenil 400mg without prescription
buy discount levitra
order chloroquine 250mg sale buy cenforce 100mg online cheap buy baricitinib 2mg sale
buy sporanox 100 mg generic prometrium medication order tinidazole 300mg pill
Hmm it looks like your website ate my first comment (it was super long) so I guess I’ll just sum it up what I wrote and
say, I’m thoroughly enjoying your blog. I as well am
an aspiring blog blogger but I’m still new to everything.
Do you have any tips and hints for first-time blog writers?
I’d genuinely appreciate it. Life Experience Degrees
I read this paragraph fully concerning the resemblance of newest and preceding technologies, it’s awesome article. Life Experience Degree
order metformin 500mg without prescription atorvastatin 10mg oral order cialis 20mg generic
Great blog here! Also your site loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my website loaded up as fast as yours lol
I found your blog through google and I must say, this is probably one of the best well prepared articles I have come across in a long time. I have bookmarked your site for more posts.
Our family had similar issues, thanks.
buy zyprexa without prescription order diovan generic generic valsartan 160mg
order pharmacy online egypt
norvasc ca cheapest viagra tadalafil 5mg over the counter
clozaril for sale generic decadron buy generic decadron
sildenafil 100mg brand viagra 100mg over the counter order generic lisinopril 10mg
amoxicillin 1000 mg tablets
linezolid order free slot games no download free slots online
purchase omeprazole pill online casino usa real money slots games free
cymbalta coupon
Its wonderful as your other blog posts : D, regards for putting up.
Hello there, just became aware of your blog through Google, and found that it is truly informative. I am going to watch out for brussels. I will appreciate if you continue this in future. Lots of people will be benefited from your writing. Cheers!
Glad to be one of several visitors on this awful internet site : D.
I think this is among the so much vital info for me. And i’m happy reading your article. But wanna remark on few common issues, The site style is wonderful, the articles is really excellent : D. Just right job, cheers
lopressor 100mg generic vardenafil 20mg for sale buy levitra for sale
affordable term papers help with essay writing win real money online casino for free
purchase vardenafil without prescription buy pregabalin 150mg generic medrol 8 mg over counter
When we look at these issues, we know that they are the key ones for our time.
This has to be one of my favorite posts! And on top of thats its also very helpful topic for newbies. thank a lot for the information!
buy a essay online academia writing order sildenafil 100mg online
clomid 50mg ca betfair casino online real poker online
Could not disagree with the main ideas. Wonder how things will develop over the coming years.
tadalafil 10mg canada cost of cialis sildenafil pills 200mg
triamcinolone pills loratadine for sale desloratadine brand
Enjoyed reading through this, very good material. Thanks!
I like this weblog very much so much great info .
top 10 online pharmacy in india
cost dapoxetine 30mg order priligy for sale synthroid over the counter
tadalafil 40mg for sale viagra 100mg without prescription buy viagra
cost xenical 120mg diltiazem 180mg pills order generic zovirax
cialis in usa plavix usa clopidogrel 75mg generic
Well, I don’t know if that’s going to work for me, but definitely worked for you! 🙂 Excellent post!
I believe this web site has some really wonderful info for everyone : D.
Only a smiling visitor here to share the love (:, btw outstanding style and design .
I enjoy your blog posts, saved to my bookmarks!
allopurinol without prescription cost crestor 10mg buy generic zetia 10mg
I’ve read several good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to make such a magnificent informative site.
fluoxetine 40mg price
buy methotrexate 10mg sale brand metoclopramide 20mg buy metoclopramide 10mg
purchase domperidone without prescription purchase motilium buy flexeril 15mg pill
buy generic cozaar order topamax 200mg online cheap buy topiramate pills
I like what you have to offer. Keep up the good work!
Some genuinely choice content on this site, bookmarked .
I like what you have to offer. Keep up the good work!
When we look at these issues, we know that they are the key ones for our time.
buy ozobax without prescription cost toradol 10mg order toradol
sumatriptan sale avodart 0.5mg generic order dutasteride pills
order clindamycin
cost colchicine 0.5mg slots games real casino slot machine games
zantac 300mg brand order generic meloxicam celecoxib online buy
Public policy is key here, and our states need to develop some strategies – – soon.
play online blackjack gambling meaning where can i play poker online
Greetings… your blog is very interesting and beautifully written.
flomax pills zofran over the counter buy spironolactone 25mg without prescription
cialis 20mg us tadalafil ca oral cipro 500mg
I concur with your conclusions and will eagerly look forward to your future updates. The usefulness and significance is overwhelming and has been invaluable to me!
cost zocor order simvastatin 10mg generic order generic finasteride
order flagyl for sale order metronidazole 200mg pills trimethoprim sale
voltaren tablets 100mg
order fluconazole 200mg for sale diflucan 200mg pills buy sildenafil 50mg pills
order keflex 250mg generic purchase cephalexin buy erythromycin 250mg pills
order tadalafil 20mg pill tadalafil 20mg canada order viagra 100mg online
It is perfect time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I want to suggest you some interesting things or suggestions. Perhaps you can write next articles referring to this article. I wish to read more things about it!
sildenafil cheap tadalafil brand name cialis tadalafil 40mg
order cefuroxime 250mg without prescription buy ceftin online order generic robaxin 500mg
Simply wish to say the frankness in your article is surprising.
This has to be one of my favorite posts! And on top of thats its also very helpful topic for newbies. thank a lot for the information!
casino slot casino online roulette real money cialis black
Well, I don’t know if that’s going to work for me, but definitely worked for you! 🙂 Excellent post!
Thanks , I’ve recently been searching for info about this topic for ages and yours is the best I have discovered so far. But, what concerning the bottom line? Are you certain concerning the source?
This is valuable stuff.In my opinion, if all website owners and bloggers developed their content they way you have, the internet will be a lot more useful than ever before.
https://over-the-counter-drug.com/# over the counter ed medication
buy desyrel 100mg trazodone 100mg canada cheap sildenafil 50mg
buy essays for college cheap essay online buy oral stromectol
sildenafil india lamotrigine without prescription order lamictal 50mg online
https://stromectol.science/# cost of ivermectin 3mg tablets
order prednisone 10mg pill isotretinoin 10mg brand buy amoxil without prescription
buy viagra 100mg sale cialis without prescription cialis for daily use
arimidex tablet
ivermectin 0.08%
reputable online pharmacy
Regards for helping out, superb info.
I dont think Ive caught all the angles of this subject the way youve pointed them out. Youre a true star, a rock star man. Youve got so much to say and know so much about the subject that I think you should just teach a class about it
https://zithromax.science/# zithromax online usa no prescription
You have some helpful ideas! Maybe I should consider doing this by myself.
Can I just say what a relief to seek out someone who actually knows what theyre speaking about on the internet. You positively know find out how to bring a problem to mild and make it important. Extra individuals have to read this and perceive this side of the story. I cant believe youre not more in style because you positively have the gift.
Our local network of agencies has found your research so helpful.
where to buy sildalis
xenical india
buy atarax 25 mg
best online pharmacy reddit
5mg propecia daily
ivermectin 3
cost azithromycin 500mg cheap generic neurontin cost gabapentin 100mg
roulette online real money casino slot games tadalafil 40mg uk
medication lyrica 75 mg
malegra 200 mg for sale
225 mg lyrica
toradol cheap
buy generic dapoxetine uk
https://doxycycline.science/# generic doxycycline
metformin online purchase
where can i get cephalexin
orlistat online canada
erectafil canada
poker online free san manuel casino online modafinil 200mg cheap
colchicine from mexico
order arimidex online australia
buy ventolin over the counter with paypal
furosemide cheap order furosemide for sale plaquenil cheap
canadian family pharmacy
motilium drug
Keep it up!. I usually don’t post in Blogs but your blog forced me to, amazing work.. beautiful A rise in An increase in An increase in.
singulair tablet price
lasix tablets uk
medicine propranolol
cialis 2.5
online pharmacy 365 pills
What side effects can this medication cause? What side effects can this medication cause?
ivermectin 2mg
Cautions. Learn about the side effects, dosages, and interactions.
deltasone us deltasone ca buy generic vermox 100mg
albuterol tablets
earch our drug database. Actual trends of drug.
ivermectin 18mg
Get here. drug information and news for professionals and consumers.
order fildena 50mg generic purchase rhinocort online rhinocort online order
Cautions. Comprehensive side effect and adverse reaction information.
stromectol 3 mg dosage
Best and news about drug. All trends of medicament.
A cool post there mate ! Thank you for posting.
Hello, I think your blog might be having browser compatibility issues. When I look at your website in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other than that, awesome blog!