import pickle import csv import utils01 import utils02 import JSEutils import config import os os.chdir(config.APP_DIR) rsp = JSEutils.base_rq() if not rsp.ok: #--report error and quit print 'Response error %s' % rsp.status_code print 'Request %s: ' % rsp.url #!!!do some error handling and stop program #--build request header headers = JSEutils.request_header() cookies = JSEutils.cookies(rsp) instruments = pickle.load(open(config.PICKLE_DIR + '/' + config.INSTRUMENTS, 'rb')) index = utils02.findMasterID(instruments, 'SOL') print instruments[index] master_id = utils02.getMasterID(instruments[index]) """ dividends = list() for instrument in instruments: symbol = instrument.split('|')[0] print symbol
for instrument in instruments: if instrument['Status'].upper() == 'CURRENT': l.append('%s|%s|%s|%s|%s|%s|' % (instrument['AlphaCode'], instrument['Industry'], instrument['InstrumentType'], instrument['MasterID'], instrument['Sector'], instrument['ShortName'])) return l log = logger.logger(name = sys.argv[0]) os.chdir(config.APP_DIR) log.info('App started') rsp = JSEutils.base_rq() if not rsp.ok: #--report error and quit log.error('Response error %s' % rsp.status_code) log.error('Request %s: ' % rsp.url) log.error('App ended') quit() #--build request header headers = JSEutils.request_header() cookies = JSEutils.cookies(rsp) print 'Get all issuers' rsp = JSEutils.get_all_issuers(headers, cookies) if not rsp.ok: #--report error and quit
#--date already in file, do nothing fp.close() return False fp = open(filename, 'a') writer = csv.writer(fp) writer.writerow((date, '', float(d2['DailyHigh']), float(d2['DailyLow']), float(d1['ClosingPrice']), float(d1['Volume']), '')) fp.close() return True os.chdir(config.APP_DIR) log = logger.logger(name=sys.argv[0]) log.info('App started') rsp = JSEutils.base_rq() if not rsp.ok: #--report error and quit log.error('Response error %s' % rsp.status_code) log.error('Request %s: ' % rsp.url) log.error('App ended') quit() #--build request header headers = JSEutils.request_header() cookies = JSEutils.cookies(rsp) #--loads all equities from local store instruments = pickle.load( open(config.PICKLE_DIR + '/' + config.INSTRUMENTS, 'rb')) for instrument in instruments: rsp = JSEutils.get_pricing_information(
'', float(d2['DailyHigh']), float(d2['DailyLow']), float(d1['ClosingPrice']), float(d1['Volume']), '')) fp.close() return True os.chdir(config.APP_DIR) log = logger.logger(name = sys.argv[0]) log.info('App started') rsp = JSEutils.base_rq() if not rsp.ok: #--report error and quit log.error('Response error %s' % rsp.status_code) log.error('Request %s: ' % rsp.url) log.error('App ended') quit() #--build request header headers = JSEutils.request_header() cookies = JSEutils.cookies(rsp) #--loads all equities from local store instruments = pickle.load(open(config.PICKLE_DIR + '/' + config.INSTRUMENTS, 'rb')) for instrument in instruments: rsp = JSEutils.get_pricing_information(instrument.split('|')[3], headers, cookies) if not rsp.ok:
import pickle import csv import utils01 import utils02 import JSEutils import config import os os.chdir(config.APP_DIR) rsp = JSEutils.base_rq() if not rsp.ok: #--report error and quit print 'Response error %s' % rsp.status_code print 'Request %s: ' % rsp.url #!!!do some error handling and stop program #--build request header headers = JSEutils.request_header() cookies = JSEutils.cookies(rsp) instruments = pickle.load( open(config.PICKLE_DIR + '/' + config.INSTRUMENTS, 'rb')) index = utils02.findMasterID(instruments, 'SOL') print instruments[index] master_id = utils02.getMasterID(instruments[index]) """ dividends = list() for instrument in instruments: symbol = instrument.split('|')[0] print symbol master_id = instrument.split('|')[3]
l = list() instruments = d['GetAllInstrumentsForIssuerResult'] for instrument in instruments: if instrument['Status'].upper() == 'CURRENT': l.append('%s|%s|%s|%s|%s|%s|' % (instrument['AlphaCode'], instrument['Industry'], instrument['InstrumentType'], instrument['MasterID'], instrument['Sector'], instrument['ShortName'])) return l log = logger.logger(name=sys.argv[0]) os.chdir(config.APP_DIR) log.info('App started') rsp = JSEutils.base_rq() if not rsp.ok: #--report error and quit log.error('Response error %s' % rsp.status_code) log.error('Request %s: ' % rsp.url) log.error('App ended') quit() #--build request header headers = JSEutils.request_header() cookies = JSEutils.cookies(rsp) print 'Get all issuers' rsp = JSEutils.get_all_issuers(headers, cookies) if not rsp.ok: #--report error and quit
for day in d: date = utils01.jsonToYahooDate(day['Date'][1:-1]) if not dates.has_key(date): #--new date writer.writerow((date , '', '', float(day['Price']), '', '') ) fp.close() os.chdir(config.APP_DIR) log = logger.logger(name = sys.argv[0]) log.info('App started') rsp = JSEutils.base_rq() if not rsp.ok: #--report error and quit log.error('Response error %s' % rsp.status_code) log.error('Request %s: ' % rsp.url) log.error('App ended') quit() #--build request header headers = JSEutils.request_header() cookies = JSEutils.cookies(rsp) #--load instruments from pickle instruments = pickle.load(open(config.PICKLE_DIR + '/' + config.INSTRUMENTS, 'rb')) """