def main(): idc = IressDataClient() idc.connect() announcements = idc.execute( DfsText.constants.dfsDataTextHeadline, dict( Code='BHP', StartDateTime='2008-01-01', EndDateTime='2009-01-01', )) # Only consider market sensitive announcemens. market_sensitive = [ x for x in announcements if x['MarketSensitive'] == 'Y' ] for index, headline in enumerate(market_sensitive): print '%d: %s' % (index, headline['Headline']) print headline['GMTDate'] bodytext = '\n'.join(headline['DataText'].execute()) # Write out body text stripping non-ascii unicode. Iress # returns text as unicode but the Windows prompt # doesn't seem to like UTF-8! print bodytext.encode('ascii', 'ignore') # Only print first 20 announcements beacuse we're hitting # Iress for every bodytext request. if index > 20: break
def main(): idc = IressDataClient() idc.connect() announcements = idc.execute(DfsText.constants.dfsDataTextHeadline, dict( Code='BHP', StartDateTime='2008-01-01', EndDateTime='2009-01-01', )) # Only consider market sensitive announcemens. market_sensitive = [x for x in announcements if x['MarketSensitive'] == 'Y'] for index, headline in enumerate(market_sensitive): print '%d: %s' % (index, headline['Headline']) print headline['GMTDate'] bodytext = '\n'.join(headline['DataText'].execute()) # Write out body text stripping non-ascii unicode. Iress # returns text as unicode but the Windows prompt # doesn't seem to like UTF-8! print bodytext.encode('ascii', 'ignore') # Only print first 20 announcements beacuse we're hitting # Iress for every bodytext request. if index > 20: break
""" Example usage of iress.IressDataClient to fetch weekly close prices of BHP. Outputs BHP's weekly close price for 2008 as CSV. """ import operator from iress import IressDataClient, DfsTimeSeries if __name__ == '__main__': idc = IressDataClient() idc.connect() # Fetch timeseries data for BHP during 2008. timeseries = idc.execute(DfsTimeSeries.constants.dfsDataTimeSeries, dict( Security='BHP', Exchange='ASX', Start='01/01/2008', End='31/12/2008', Frequency=DfsTimeSeries.constants.Weekly, Adjusted=True, )) # Output date and close price as csv. print 'Date,Close' for x in sorted(timeseries, key=operator.itemgetter('Date')): print '%s,%f' % (x['Date'].Format('%Y-%m-%d'), x['ClosePrice']/100.0)
""" Example usage of iress.IressDataClient that fetches all financials for BHP during 2008. """ import pprint from iress import IressDataClient, DfsSec if __name__ == '__main__': idc = IressDataClient() idc.connect() financials = idc.execute(DfsSec.constants.dfsDataFinancial, dict( Security='BHP', Exchange='ASX', StartDate='2008-01-01', EndDate='2009-01-01', ItemList=-1, AnnualReport=True, QuarterlyReport=True, InterimReport=True, PreliminaryReport=True, )) pprint.pprint(financials)