def parse_categories(self, response):
# unpack meta values
exchange = response.meta['exchange']
# get a dict with the json data
data = json.loads(response.body_as_unicode())
# for all instruments in the list
for instrument in data['aaData']:
ticker = instrument['Symbol']
name = instrument['Name']
paper_type = instrument['AssetType']
if ticker in self.requested_tickers:
self.logger.warning('Ticker "' + ticker + '" has already been requested. Skipping')
continue
# POST request for historical data for this ticker
self.logger.info('Sending POST request for ticker "' + ticker + '"')
yield FormRequest(url="https://indexes.nasdaqomx.com/Index/HistoryData",
formdata={
'id': ticker,
'startDate': '1950-09-03T00:00:00.000',
'endDate': '2050-09-03T00:00:00.000',
'timeOfDay': 'EOD'},
meta={'ticker': ticker,
'name': name,
'paper_type': paper_type,
'exchange': exchange},
callback=self.parse_historical_data)
# parse the POST response containing the ticker data
评论列表
文章目录