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) + '%')

Create a website or blog at WordPress.com