-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathStockDisplay.py
27 lines (27 loc) · 925 Bytes
/
StockDisplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from urllib2 import Request, urlopen
from urllib import urlencode
def techrequest(symbol, stat):
#Defining Function that fetches Yahoo Finance CSV
url='http://finance.yahoo.com/d/quotes.csv?s=%s&f=%s' % (symbol, stat)
req = Request(url)
resp = urlopen(req)
#Fetching Required Variables
content = resp.read().decode().strip()
return content
y = raw_input('Enter stock name')
# Script by Techite Solutions (Shashi Prakash Agarwal & Kanak Sharma)
#symbol= raw_input('Enter Symbol') - Tried testing by accepting manual input
#print techrequest(y,symbol) - Tried testing output from manual input of fetched variable
o = float(techrequest(y,'o'))
#Setting open
print ('Open:',o)
h = float(techrequest(y,'h'))
#Setting high
print ('high:',h)
l = float(techrequest(y,'g'))
#Setting last closed value
print ('low:',l)
c = float(techrequest(y,'p'))
#Setting low,
print ('close:',c)
#Setting Close.