RavenPack Sentiment Data Event Stream Example
In the public scripts under Sentiment you will find scripts for accessing the RavenPack sentiment data. Link1
RavenPack sentiment data is currently available from 2018-09-24 to the current date.
To receive the events "as they occur" in the backtest you need to take two steps.
1) Register to the event stream for the currently running backtest date..
@classmethod
def register_extra_data_sources(cls, md, service, account):
date=service.time_to_string(service.system_time,format="%Y-%m-%d")
return {('sentiment', 'ravenpack_sentiment_'+date+'.csv'): 'on_ravenpack_news'}
2) Receive callbacks throughout the day on the callback name you defined above...
def on_ravenpack_news(self, event, md, order, service, account):
sentiment_score=event.field['EVENT_SENTIMENT_SCORE']
print(sentiment_score)
print(event)
Over 40000 events during market hours on 9/24/2018
See RavenPack Event Fields for more information on the data.
Example of a complete RavenPack Event :
# event.timestamp
# event.symbol
# event.field['choose one below']
# 'RP_POSITION_ID': '',
# 'GROUP': '',
# 'ENTITY_NAME': 'Apple Inc.',
# 'ANL_CHG': 0,
# 'TIMESTAMP_UTC': '2018-09-24 09:30:00.053',
# 'BCA': 0,
# 'BEE': 0,
# 'EVENT_TEXT': '',
# 'EVENT_SIMILARITY_DAYS': '',
# 'RP_ENTITY_ID': 'D8442A',
# 'RP_STORY_EVENT_COUNT': 39,
# 'EVENT_RELEVANCE': '',
# 'BER': 0,
# 'BAM': 0,
# 'EARNINGS_TYPE': '',
# 'EVENT_START_DATE_UTC': '',
# 'FACT_LEVEL': '',
# 'RELATIONSHIP': '',
# 'REPORTING_END_DATE_UTC': '',
# 'ENTITY_TYPE': 'COMP',
# 'HEADLINE': 'U.S. Reliance on Obscure Imports From China Points to Strategic Vulnerability',
# 'MATURITY': '',
# 'BMQ': -1,
# 'COUNTRY_CODE': 'US',
# 'NEWS_TYPE': 'FULL-ARTICLE',
# 'REPORTING_START_DATE_UTC': '',
# 'EVENT_SIMILARITY_KEY': '',
# 'SOURCE_NAME': 'Dow Jones Newswires',
# 'RP_SOURCE_ID': 'B5569E',
# 'PEQ': 0,
# 'RELATED_ENTITY': '',
# 'RP_STORY_ID': '1CAE7F275F4BD6AFC6803D38FC30A8BE',
# 'RELEVANCE': 54,
# 'EVENT_SENTIMENT_SCORE': '',
# 'RP_STORY_EVENT_INDEX': 4,
# 'CSS': -0.06,
# 'CATEGORY': '',
# 'POSITION_NAME': '',
# 'EVALUATION_MTHOD': '',
# 'PROVIDER_ID': 'DJ',
# 'REPORTING_PERIOD': '',
# 'EVENT_END_DATE_UTC': '',
# 'PRODUCT_KEY': 'RPA',
# 'TOPIC': '',
# 'PROVIDER_STORY_ID': 'DN20180924002028',
# 'unique_id': '1CAE7F275F4BD6AFC6803D38FC30A8BE_D8442A_na_4',
# 'NIP': -0.5,
# 'PROPERTY': '',
# 'TYPE': '',
# 'SUB_TYPE': '',
# 'MCQ': 0