SteamPunk_Devil

Untitled

Sep 28th, 2015
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. import yahoo_finance, time, pymysql.cursors
  2.  
  3. FTSE100=['^FTSE','AAL.L','ABF.L','ADM.L','ADN.L','AHT.L','ANTO.L','ARM.L','AV.L','AZN.L','BA.L','BAB.L','BARC.L','BATS.L','BDEV.L','BLND.L','BLT.L','BNZL.L','BP.L','BRBY.L','BT-A.L','CCH.L','CCL.L','CNA.L','CPG.L','CPI.L','CRH.L','DC.L','DGE.L','DLG.L','EXPN.L','EZJ.L','FRES.L','GFS.L','GKN.L','GLEN.L','HIK.L','HL.L','HMSO.L','HSBA.L','IAG.L','IHG.L','III.L','IMT.L','INTU.L','ISAT.L','ITRK.L','ITV.L','JMAT.L','KGF.L','LAND.L','LGEN.L','LLOY.L','LSE.L','MERL.L','MGGT.L','MKS.L','MNDI.L','MRW.L','NG.L','NXT.L','OML.L','PRU.L','PSN.L','PSON.L','RB.L','RBS.L','RDSA.L','RDSB.L','REL.L','RIO.L','RMG.L','RR.L','RRS.L','RSA.L','SAB.L','SBRY.L','SDR.L','SGE.L','SHP.L','SKY.L','SL.L','SMIN.L','SN.L','SPD.L','SSE.L','STAN.L','STJ.L','SVT.L','TRK.L','TSCO.L','TUI.L','TW.L','ULVR.L','UU.L','WEIR.L','WOS.L','WPP.L','WTB.L']
  4.  
  5. PW = 'HZAU8RAAvnQYrrCN'
  6. US = 'User'
  7. SQL = "INSERT INTO FTSE100Prices (StockTicker, Price, PriceIncrease, Time) VALUES (%s, %s, %s, %s)"
  8.  
  9. while True:
  10. connection = pymysql.connect(host='localhost',
  11. user=US,
  12. password=PW,
  13. charset='utf8mb4',
  14. db='Stocks',
  15. cursorclass=pymysql.cursors.DictCursor)
  16. for count in range(0, len(FTSE100)):
  17. print(count)
  18. Time = str(time.strftime("%D %H:%M:%S", time.gmtime()))
  19. print(Time)
  20. if count <= len(FTSE100):
  21. stock = yahoo_finance.Share(FTSE100[count])
  22. change = stock.get_change()
  23. price = stock.get_price()
  24. print("{}:{}:{}".format(FTSE100[count],price,change))
  25. with connection.cursor() as cursor:
  26. cursor.execute(SQL, (FTSE100[count], price, change, Time),)
  27. connection.commit()
  28.  
  29. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment