dtype='str', delimiter=',', comments='#', skiprows=0)) symbols.append("IBM") #symbols.append("BLAH") # uncomment this line to see what happens # Set the directories from which we will read data QSDATA = os.environ.get('QSDATA') listOfPaths = list() listOfPaths.append(QSDATA + "/Processed/Norgate/Equities/US_NASDAQ/") listOfPaths.append(QSDATA + "/Processed/Norgate/Equities/US_NYSE/") listOfPaths.append(QSDATA + "/Processed/Norgate/Equities/US_NYSE Arca/") # Set start and end boundary times. They must be specified in Unix Epoch start_bound = tu.ymd2epoch(2008, 1, 1) end_bound = tu.ymd2epoch(2010, 1, 1) # Create the data object. Once the dates are set, this object can not give you # data from outside this range even though it might be present in the hdf file data = da.DataAccess(True, listOfPaths, "/StrategyData", "StrategyData", False, symbols, start_bound, end_bound) # Find the actual first and last timestamps timestamps = data.getTimestampArray() start_time = timestamps[0] end_time = timestamps[-1] print("first timestamp:" + str(tu.epoch2date(start_bound)) + " mapped to " + str(tu.epoch2date(start_time))) print("last timestamp:" + str(tu.epoch2date(end_bound)) + " mapped to " +
from QSTK.qstkutil import timeutil as tu from QSTK.qstkutil import timeseries as ts # Set the list of stocks for us to look at symbols = list() symbols = list( np.loadtxt('example-syms.csv', dtype='str', delimiter=',', comments='#', skiprows=0)) symbols.append("IBM") #symbols.append("BLAH") # uncomment this line to see what happens # Set start and end boundary times. They must be specified in Unix Epoch tsstart = tu.ymd2epoch(2008, 1, 1) tsend = tu.ymd2epoch(2010, 1, 1) # Get the data from the data store storename = "Norgate" # get data from our daily prices source fieldname = "adj_close" # adj_open, adj_close, adj_high, adj_low, close, volume adjcloses = ts.getTSFromData(storename, fieldname, symbols, tsstart, tsend) # Print out a bit of the data print("The prices are: ") print(symbols) print(adjcloses.values) # Convert the timestamps to dates for the plot dates = [] for ts in adjcloses.timestamps:
# Set the list of stocks for us to look at symbols= list() symbols = list(np.loadtxt('example-syms.csv',dtype='str',delimiter=',', comments='#',skiprows=0)) symbols.append("IBM") #symbols.append("BLAH") # uncomment this line to see what happens # Set the directories from which we will read data QSDATA = os.environ.get('QSDATA') listOfPaths=list() listOfPaths.append(QSDATA + "/Processed/Norgate/Equities/US_NASDAQ/") listOfPaths.append(QSDATA + "/Processed/Norgate/Equities/US_NYSE/") listOfPaths.append(QSDATA + "/Processed/Norgate/Equities/US_NYSE Arca/") # Set start and end boundary times. They must be specified in Unix Epoch start_bound = tu.ymd2epoch(2008,1,1) end_bound = tu.ymd2epoch(2010,1,1) # Create the data object. Once the dates are set, this object can not give you # data from outside this range even though it might be present in the hdf file data= da.DataAccess(True, listOfPaths, "/StrategyData", "StrategyData", False, symbols, start_bound, end_bound) # Find the actual first and last timestamps timestamps = data.getTimestampArray() start_time = timestamps[0] end_time = timestamps[-1] print "first timestamp:" + str(tu.epoch2date(start_bound)) + " mapped to " + str(tu.epoch2date(start_time)) print "last timestamp:" + str(tu.epoch2date(end_bound)) + " mapped to " + str(tu.epoch2date(end_time))
# imports import matplotlib.pyplot as plt from pylab import * from QSTK.qstkutil import DataAccess as da from QSTK.qstkutil import timeutil as tu from QSTK.qstkutil import timeseries as ts # Set the list of stocks for us to look at symbols= list() symbols = list(np.loadtxt('example-syms.csv',dtype='str',delimiter=',', comments='#',skiprows=0)) symbols.append("IBM") #symbols.append("BLAH") # uncomment this line to see what happens # Set start and end boundary times. They must be specified in Unix Epoch tsstart = tu.ymd2epoch(2008,1,1) tsend = tu.ymd2epoch(2010,1,1) # Get the data from the data store storename = "Norgate" # get data from our daily prices source fieldname = "adj_close" # adj_open, adj_close, adj_high, adj_low, close, volume adjcloses = ts.getTSFromData(storename,fieldname,symbols,tsstart,tsend) # Print out a bit of the data print("The prices are: ") print(symbols) print(adjcloses.values) # Convert the timestamps to dates for the plot dates = [] for ts in adjcloses.timestamps: