Mariner Backtesting - news

News Overview:

The most recent data for each symbol. This data is no older than the beginning of the previous trading day.

Attributes:

Sample - Access data attribute

 md.news.headline
Name Type Special Information
headline string "" News headline.
hyperlink string "" Web URL to the news story.
provider_name string "" Name of the news story provider.
source_instructions string "" Source instructions of news story.
story_codes string "" Unique identifier for the news story.
symbols list None List of symbols related to the news story.
synopsis string "" Summary of the news story.
timestamp muts 0 Timestamp of the last news event
wire_description string "" Human-readable version of the provider_name field.
Remarks:
  • Date ranges?
  • There is a chance that the 'timestamp' field may not fall on a trading day: for example, if the previous calendar day of the simulation was not a trading day (e.g. on Mondays, or the day after market-holidays, etc) the simulator may prime the simulation with news events that happened during non-trading days simply because they happened more recently than the previous trading day. If two NewsEvent objects concerning the same symbol also have the same timestamps, they will occur in the order that the news data vendor provided them to gr8py.
Working Example:
 from cloudquant.interfaces import Strategy


class NewsExample(Strategy):

    @classmethod
    def on_strategy_start(cls, md, service, account):
        print service.time_to_string(service.system_time, '%Y-%m-%d')

    @classmethod
    def is_symbol_qualified(cls, symbol, md, service, account):
        return symbol == 'SPY'

    def on_start(self, md, order, service, account):
        print self.symbol

    def on_news(self, event, md, order, service, account):
        print '\nin on_news\n\t%s\n' % service.time_to_string(service.system_time, '%H:%M:%S.%f')

        print '\n\nmd.news\n'

        print ' md.news.headline    -   ', md.news.headline
        print ' md.news.hyperlink   -   ', md.news.hyperlink
        print ' md.news.provider_name   -   ', md.news.provider_name
        print ' md.news.source_instructions -   ', md.news.source_instructions
        print ' md.news.story_codes -   ', md.news.story_codes
        print ' md.news.symbols -   ', md.news.symbols
        print ' md.news.synopsis    -   ', md.news.synopsis
        print ' md.news.timestamp   -   ', md.news.timestamp
        print ' md.news.wire_description    -   ', md.news.wire_description

        service.terminate()

Console

2015-03-31
XLF

in on_news()
    10:36:46.403000


md.news

    md.news.headline    -   Financial Select Sector: Pivot points
    md.news.hyperlink   -
    md.news.provider_name   -   FLYWALL_
    md.news.source_instructions -
    md.news.story_codes -   IC/mveh.retl;IC/mveh;NI/Automotive;XC/NYSEArca;XC/any.US;XC/any.company;XC/any.public;MC/HOT;MC/HOT;NT/NEC;PS/p.FLYWALL_;PS/s.USEQUITY;PC/t.150330084507374;PS/Live_News_Feed;PS/src.4001.2;PS/.Live_News_Feed;SU/Technical_Analys;
    md.news.symbols -   []
    md.news.synopsis    -   The following are the pivot points for XLF. Pivot High: $23.960, Pivot Low: $23.810. These were calculated using the DeMark method.
    md.news.timestamp   -   1427733907783000
    md.news.wire_description    -   TheFlyOnTheWall

The image below shows AAPL's news from the start of the news data April 2013 until May 2018.

It shows the number of on_news calls and breaks them down by md.news.provider_name

 

AAPL News