,

Real Time Stock Market Data Analysis Python Script

This simple python script will analyze real time stock data from the Alpha vantage API (https://www.alphavantage.co/)

🔑Register and get the free API key from https://www.alphavantage.co/support/#api-key

This script will showcase the percentage change for the daily close and send a text alert.

https://github.com/Persecure/Python-for-Finance-script-1-

#!/usr/bin/env python

import pandas as pd
from alpha_vantage.timeseries import TimeSeries
import time

api_key = '*YOUR API KEY' #https://www.alphavantage.co/support/#api-key

ts = TimeSeries(key=api_key, output_format='pandas')
data, meta_data = ts.get_daily(symbol='MSFT', outputsize = 'full') #enter your ticker of your choice symbol='TICKER'
close_data = data['4. close']
percentage_change = close_data.pct_change()
last_change = round((percentage_change[-1] * 100),2)

if abs(last_change) > 0.0004: #change volatality on your preference
    print('Alert: ' + str(last_change) + '%')

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Comments (

0

)

%d bloggers like this: