stockpricecheck

stock price check

get company stock

http://dev.markitondemand.com/MODApis/Api/v2/Lookup/json?input=NFLX

Takes a CSV file of stock symbols and requests stock details - saving the results as json file.

The CSV file for symbols:

https://drive.google.com/file/d/0Bz6bXrUgcavndFhFTUhxMll3bE0/view?usp=sharing

http://eoddata.com/stocklist/NYSE/B.htm

In [47]:
import requests 
import bs4
import csv
#import tsv
import time
import getpass
In [48]:
myusr = getpass.getuser()
In [25]:
stksym = list()
In [26]:
with open('/home/pi/naradsplit.csv', 'r') as fedz:
    #fed = csv.reader(fedz)
    reader = csv.DictReader(fedz)
    for row in reader:
        #print(row)
        stksym.append(row['Symbol'])
    #print(fed.)
    
In [52]:
#stksym
In [53]:
#try:
#    for stk in stksym:
#        eqap = requests.get('http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol={}'.format(stk))
#        print(reqap.json())

#except ValueError:
#    pass
#    print('passed')
#print "Great, you successfully entered an integer!"
In [ ]:
#print(reqap.json())
In [51]:
for stk in stksym:
    #print(stk)
        #reqap = requests.get('http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol={}'.format(stk))
    quotesym = requests.get('http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=' + stk)
    qujs = (quotesym.json())
    if 'Name' in qujs:
        print(quotesym.json())
        with open('/home/{}/stockprice/{}.json'.format(myusr, qujs['Symbol']), 'w') as stprc:
            stprc.write(str(quotesym.json()))
            
    time.sleep(1)
        #elif ValueError:
        #    pass
A
{'Volume': 1136658, 'ChangePercentYTD': 7.24707007892849, 'Timestamp': 'Tue Dec 6 16:03:00 UTC-05:00 2016', 'Low': 44.2, 'ChangeYTD': 41.81, 'MarketCap': 14528160000, 'Name': 'Agilent Technologies Inc', 'High': 44.9, 'Open': 44.58, 'LastPrice': 44.84, 'Symbol': 'A', 'Change': 0.310000000000002, 'MSDate': 42710.66875, 'Status': 'SUCCESS', 'ChangePercent': 0.696159892207506}
AA
{'Volume': 4406535, 'ChangePercentYTD': -31.3745356298548, 'Timestamp': 'Tue Dec 6 16:01:00 UTC-05:00 2016', 'Low': 19.7, 'ChangeYTD': 29.61, 'MarketCap': 8909872960, 'Name': 'Arconic Inc', 'High': 20.34, 'Open': 19.89, 'LastPrice': 20.32, 'Symbol': 'ARNC', 'Change': 0.0599999999999987, 'MSDate': 42710.6673611111, 'Status': 'SUCCESS', 'ChangePercent': 0.296150049358335}
AAAP
AAC
{'Volume': 202300, 'ChangePercentYTD': -55.299055613851, 'Timestamp': 'Tue Dec 6 16:02:00 UTC-05:00 2016', 'Low': 8.36, 'ChangeYTD': 19.06, 'MarketCap': 201983640, 'Name': 'AAC Holdings Inc', 'High': 8.67, 'Open': 8.47, 'LastPrice': 8.52, 'Symbol': 'AAC', 'Change': -0.0500000000000007, 'MSDate': 42710.6680555556, 'Status': 'SUCCESS', 'ChangePercent': -0.583430571761969}
AADR
{'Volume': 0, 'ChangePercentYTD': 0, 'Timestamp': None, 'Low': 0, 'ChangeYTD': 0, 'MarketCap': 0, 'Name': 'AdvisorShares Dorsey Wright ADR ETF', 'High': 0, 'Open': 0, 'LastPrice': 0, 'Symbol': 'AADR', 'Change': 0, 'MSDate': 0, 'Status': 'Failure|APP_SPECIFIC_ERROR', 'ChangePercent': 0}
AAL
{'Volume': 5327768, 'ChangePercentYTD': 9.63400236127509, 'Timestamp': 'Tue Dec 6 00:00:00 UTC-05:00 2016', 'Low': 45.92, 'ChangeYTD': 42.35, 'MarketCap': 24056543750, 'Name': 'American Airlines Group Inc', 'High': 46.55, 'Open': 46.16, 'LastPrice': 46.43, 'Symbol': 'AAL', 'Change': 0.710000000000001, 'MSDate': 42710, 'Status': 'SUCCESS', 'ChangePercent': 1.55293088363955}
AAMC
{'Volume': 0, 'ChangePercentYTD': 0, 'Timestamp': None, 'Low': 0, 'ChangeYTD': 0, 'MarketCap': 0, 'Name': 'Altisource Asset Management Corp', 'High': 0, 'Open': 0, 'LastPrice': 0, 'Symbol': 'AAMC', 'Change': 0, 'MSDate': 0, 'Status': 'Failure|APP_SPECIFIC_ERROR', 'ChangePercent': 0}
AAME
AAN
{'Volume': 679548, 'ChangePercentYTD': 35.1496203662349, 'Timestamp': 'Tue Dec 6 16:02:00 UTC-05:00 2016', 'Low': 29.49, 'ChangeYTD': 22.39, 'MarketCap': 2161108680, 'Name': "Aaron's Inc", 'High': 30.29, 'Open': 29.71, 'LastPrice': 30.26, 'Symbol': 'AAN', 'Change': 0.400000000000002, 'MSDate': 42710.6680555556, 'Status': 'SUCCESS', 'ChangePercent': 1.3395847287341}
AAOI
AAON
{'Volume': 166238, 'ChangePercentYTD': 41.0422049956934, 'Timestamp': 'Tue Dec 6 00:00:00 UTC-05:00 2016', 'Low': 32.4, 'ChangeYTD': 23.22, 'MarketCap': 1727726250, 'Name': 'AAON Inc', 'High': 32.95, 'Open': 32.8, 'LastPrice': 32.75, 'Symbol': 'AAON', 'Change': -0.100000000000001, 'MSDate': 42710, 'Status': 'SUCCESS', 'ChangePercent': -0.304414003044144}
AAP
{'Volume': 753400, 'ChangePercentYTD': 15.1484951166036, 'Timestamp': 'Tue Dec 6 16:02:00 UTC-05:00 2016', 'Low': 169.85, 'ChangeYTD': 150.51, 'MarketCap': 12764974740, 'Name': 'Advance Auto Parts Inc', 'High': 173.76, 'Open': 170.18, 'LastPrice': 173.31, 'Symbol': 'AAP', 'Change': 2.78, 'MSDate': 42710.6680555556, 'Status': 'SUCCESS', 'ChangePercent': 1.63021169295725}
AAPC
{'Volume': 0, 'ChangePercentYTD': 0, 'Timestamp': None, 'Low': 0, 'ChangeYTD': 0, 'MarketCap': 0, 'Name': 'Atlantic Alliance Partnership Corp', 'High': 0, 'Open': 0, 'LastPrice': 0, 'Symbol': 'AAPC', 'Change': 0, 'MSDate': 0, 'Status': 'Failure|APP_SPECIFIC_ERROR', 'ChangePercent': 0}
AAPL
{'Volume': 26075932, 'ChangePercentYTD': 4.45563366901007, 'Timestamp': 'Tue Dec 6 00:00:00 UTC-05:00 2016', 'Low': 109.19, 'ChangeYTD': 105.26, 'MarketCap': 586287814350, 'Name': 'Apple Inc', 'High': 110.36, 'Open': 109.5, 'LastPrice': 109.95, 'Symbol': 'AAPL', 'Change': 0.840000000000003, 'MSDate': 42710, 'Status': 'SUCCESS', 'ChangePercent': 0.769865273577127}
AAT
{'Volume': 207488, 'ChangePercentYTD': 4.69361147327248, 'Timestamp': 'Tue Dec 6 16:02:00 UTC-05:00 2016', 'Low': 39.56, 'ChangeYTD': 38.35, 'MarketCap': 1832486150, 'Name': 'American Assets Trust Inc', 'High': 40.17, 'Open': 39.75, 'LastPrice': 40.15, 'Symbol': 'AAT', 'Change': 0.0899999999999963, 'MSDate': 42710.6680555556, 'Status': 'SUCCESS', 'ChangePercent': 0.224663005491753}
AAU
{'Volume': 0, 'ChangePercentYTD': 0, 'Timestamp': None, 'Low': 0, 'ChangeYTD': 0, 'MarketCap': 0, 'Name': 'Almaden Minerals Ltd', 'High': 0, 'Open': 0, 'LastPrice': 0, 'Symbol': 'AAU', 'Change': 0, 'MSDate': 0, 'Status': 'Failure|APP_SPECIFIC_ERROR', 'ChangePercent': 0}
AAV
{'Volume': 263397, 'ChangePercentYTD': 44.6850393700787, 'Timestamp': 'Tue Dec 6 16:02:00 UTC-05:00 2016', 'Low': 7.275, 'ChangeYTD': 5.08, 'MarketCap': 1357148100, 'Name': 'Advantage Oil & Gas Ltd', 'High': 7.425, 'Open': 7.3, 'LastPrice': 7.35, 'Symbol': 'AAV', 'Change': 0, 'MSDate': 42710.6680555556, 'Status': 'SUCCESS', 'ChangePercent': 0}
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-51-e80a20c1d1bd> in <module>()
      9             stprc.write(str(quotesym.json()))
     10 
---> 11     time.sleep(1)
     12         #elif ValueError:
     13         #    pass

KeyboardInterrupt: 
In [ ]:
#http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=AAPL

Comments

Comments powered by Disqus