• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Wall Street Horizon Corporate Event filters

The IBApi.EClient.reqWshMetaData function now offers greatly expanded filtering of the Wall Street Horizon Event calendar data via six new fields added to the IBApi.EWrapper.wshEventData class: WshEventData.fillWatchlist, WshEventData.fillPortfolio, WshEventData.fillCompetitors, WshEventData.startDate, WshEventData.endDate and WshEventData.filter.

Given a IBApi.EWrapper.wshEventData object:

wsheFilters = WshEventData()

WshEventData.startDate establishes the lower bound on the returned calendar data's date range. It receives a string in the form "YYYYMMDD" as in:

wsheFilters.startDate = "2022401"

WshEventData.endDate establishes the upper bound on the returned calendar data's date range. It receives a string in the form "YYYYMMDD" as in:

wsheFilters.endDate = "2020501"

WshEventData.fillWatchlist, WshEventData.fillPortfolio and WshEventData.fillCompetitors requests conIds of the instruments present in watchlists, portfolios and competitors.
These booleans are not required to be present in request and may be set to False.

wsheFilters.fillWatchlist = True
wsheFilters.fillPortfolio = True
wsheFilters.fillCompetitors = True

WshEventData.filters accepts a string in the form of a single JSON object, with key-value pairs corresponding to available filters and/or event types, as returned by the IBApi.EWrapper.wshMetaData callback following a call to IBApi.EClient.reqWshMetaData.

NB: Available filters and event types are subject to change. As a result, IBApi.EClient.reqWshMetaData must be successfully called once per day after server restart, prior to making any calls to IBApi.EClient.reqWshEventData, in order to refresh the list of filters and event types retained by TWS/IB Gateway.

The JSON payload delivered in wshMetaData.dataJson contains two arrays, event_types and filters, whose elements together comprise all of the available filtering options. Filters within the "filters" array can be used with various values, such as lists (arrays) of conIds or strings (to filter by symbol). For example, you can specify:

"country": "All",
"watchlist": ["8314"],

This requests events for conId 8314 (IBM) in all countries.

On the other hand, the "event_types" array offers filtering based on inclusion/exclusion of certain event types, as defined in the WSH Event Calendar. These event_type filters are employed simply by including the desired event_type code as another key with value "true". Please note that these event_type filters require values of the JSON string data type, and thus "true" must be enclosed in double quotes. For example:

"wsh_ed": "true",
"wshe_bod": "true",

This limits the returned events to only those two event types: Earnings Dates ("wsh_ed") and Board of Directors meetings ("wshe_bod"). If no event_type filters are included, then events of all types will be delivered. The inclusion of a single event_type filter will exclude all others. Multiple event_type filters are joined via logical OR, as the WSH Event Calendar does not assign multiple event types to a single event record.

A complete JSON filter object would thus be:

{
    "country": "All",
      "watchlist": ["8314"],
      "limit_region": 10,
      "limit": 10,
      "wsh_ed": "true",
      "wshe_bod": "true"
}

This JSON object must be must be assigned as a string, as in:

wsheFilters.filter = '{"country": "All","watchlist": ["8314"],"limit_region": 10,"limit": 10,"wsh_ed": "true","wshe_bod": "true"}'

NB: The existing WshEventData.conId field cannot be used in conjunction with a WshEventData.filter JSON-formatted string. Only one of the two fields can be set in a given IBApi.EWrapper.wshEventData object in order to make a successful IBApi.EClient.reqWshEventData request.