Determine the Event Volume Indicator Using RavenPack News Analytics

This example shows how to determine the Event Volume Indicator (EVI) from RavenPack® News Analytics historical and intraday data. The example also shows how to retrieve real-time data to update the EVI.

The EVI counts the number of RavenPack News Analytics news events based on the event sentiment score (ESS). Find the EVI on day t using


The variables are:

  • post is the count of positive events on day t.

  • negt is the count of negative events on day t.

  • n is the number of days for which you are calculating the EVI.

ESS is the Event Sentiment Score that measures positive or negative news sentiment. Define positive events by ESS > 50 and negative events by ESS < 50. For details about ESS, see the RavenPack News Analytics User Guide and Service Overview in the RavenPack Developer Zone Overview. For details about this calculation, see [1].

To analyze the news activity about a company or other entity, use the EVI.

To access the code for this example, see RavenPackWorkflowExample.m.

Connect to RavenPack News Analytics

Create a RavenPack News Analytics connection c using the user name username and password pwd.

c = ravenpack('username','pwd');

Retrieve Historical and Intraday RavenPack News Data

Retrieve RavenPack News Analytics Data Gateway entitlements using the RavenPack News Analytics connection c.

e = entitlements(c);

e is a table that contains the entitlement data.

Retrieve the RavenPack News Analytics symbol for equities data.

symbol = e.NAME{1};

Create a historical equities data file 2014-11-equities.csv using the RavenPack Data Feed Tool. Load the data into the MATLAB® variable histData.

histData = rploader('2014-11-equities.csv');

Request the last two and a half hours of intraday data recentData for all valid fields using the RavenPack News Analytics connection c. symbol is the entitled symbol for equity data. Create the time interval using now-.1 and now.

recentData = timeseries(c,symbol,{now-.1,now});

To retrieve the last minute of intraday data for the RavenPack News Analytics fields ENTITY_NAME, GROUP, and ESS, use this code. Create the time interval for the last minute using now-.001 and now.

essData = timeseries(c,symbol,{now-.001,now},...

Combine the historical and intraday data into the MATLAB variable allData. Remove the time component from the timestamp using dateshift.

allData = [histData; recentData];
allData.TIMESTAMP_UTC = dateshift(allData.TIMESTAMP_UTC,'start','day');

Retrieve Twitter News Data

Isolate the Twitter® news event data using strcmp. Assign the Twitter news event data to the MATLAB variable companyData.

iCompany = strcmp('Twitter Inc.',allData.ENTITY_NAME);
companyData = allData(iCompany,:);

Filter out the insider trading and order imbalance events from the Twitter news event data. To find these events, use the RavenPack News Analytics field GROUP. For details about this field, see RavenPack Developer Zone Overview. For details about this filter, see [1].

iIT = strcmp('insider-trading',companyData.GROUP);
companyData(iIT,:) = [];
iIT = strcmp('order-imbalances',companyData.GROUP);
companyData(iIT,:) = [];

Determine EVI for Twitter News Data

This code loops through the Twitter company data companyData. The logic filters out empty ESS scores and ESS scores equal to 50. The code adds a record for the first event of the day using the timestamp essTimestamp. Then, the code increments the EVI count eviData.

EVI = 0;
eviData(1,1) = EVI;
essTimestamp = companyData.TIMESTAMP_UTC(1);
iEVI = 1;
for j = 1:length(companyData.ESS)
  % Discard neutral and empty scores
  if ~isempty(companyData.ESS{j}) && ~strcmp(companyData.ESS{j},'50')
    % Add new record for new day's event, otherwise increment existing count
    if essTimestamp(iEVI) ~= companyData.TIMESTAMP_UTC(j)
      essTimestamp(end+1,1) = companyData.TIMESTAMP_UTC(j); 
      iEVI = length(essTimestamp);
      EVI = 0;
      essTimestamp = companyData.TIMESTAMP_UTC(j);
    EVI = EVI + 1;
    eviData(iEVI,1) = EVI;  

Populate a table twitter with a timestamp essTimestamp and the Twitter EVI data eviData.

twitter = table(essTimestamp,eviData,...

Clear temporary MATLAB variables.

clear essTimestamp EVI eviData

Retrieve Real-Time Twitter News Data

Populate real-time Twitter EVI data into the MATLAB variable twitter in the Workspace browser using realtime. Run realtime using the RavenPack News Analytics connection c and symbol. The sample listener rpExampleListener listens for news event data from any company or entity. When realtime is run as part of this example, realtime provides real-time updates for the Twitter EVI. Here, this listener is monitoring for news related to these RavenPack News Analytics fields: ENTITY_NAME, GROUP, and ESS. To add other functionality, you can modify this listener function or create your own.

[status,lhandle] = realtime(c,symbol, ...
    @(~,evt)rpExampleListener(evt,{'ENTITY_NAME', ...

Close RavenPack News Analytics Connection



[1] Hafez, Peter, and Junqiang Xie. “Enhancing Short Term Reversal Strategies with News Analytics.” RavenPack Quantitative Research The News Analytics Specialist. September 5, 2013, p. 3.

See Also

| | | | |

Related Topics

External Websites