ib_async icon indicating copy to clipboard operation
ib_async copied to clipboard

WSH filters not working

Open jakobovski-arb opened this issue 5 months ago • 0 comments

The following code (taken from the documentation) which is supposed to filters by event type is not filtering by event type and instead returning all event types.

Additionally the limit filter is not working.

import json
from ib_async import IB, WshEventData, util, Contract, Order, LimitOrder, TagValue, Stock
import pprint

WSH_CLIENT_ID = 1

ib = IB()
ib.connect('127.0.0.1', 7496, clientId=WSH_CLIENT_ID)

# Get the conId of an instrument (IBM in this case):
ibm = Stock('IBM', 'SMART', 'USD')
ib.qualifyContracts(ibm)
print(ibm.conId)  # is 8314

# Get the list of available filters and event types:
meta = ib.getWshMetaData()

# For IBM (with conId=8314) query the:
#   - Earnings Dates (wshe_ed)
data = WshEventData(
    filter = '''{
      "country": "All",
      "watchlist": ["8314"],
      "limit_region": 10,
      "limit": 1,
      "wshe_ed": "true",   
    }''')

events_str = ib.getWshEventData(data)
events = json.loads(events_str)

for event in events:
    print('========================')
    pprint.pprint(event)

jakobovski-arb avatar Jun 16 '25 15:06 jakobovski-arb