Skip to main content

ibevent

A library for simplifying event listening for Interactive Brokers (IBKR).

Installation

pip install ibevent

Quick Start

To get started with ibevent, follow these steps:

  1. Connect to Interactive Brokers.
  2. Create a contract for the asset you want to trade.
  3. Register event handlers to listen for market data updates.

Example

from ib_async import IB
from ibevent.events import IBEventType
from ib_async.contract import Forex

# Create IB connection
ib = IB()
ib.connect('127.0.0.1', 7497, clientId=1)

# Create USD/JPY contract
usd_jpy = Forex('USDJPY')

# Register bar update handler
@ib.events.register(
    IBEventType.BAR_UPDATE,
    bind_to=ib.reqRealTimeBars(
        usd_jpy,
        barSize=5,
        whatToShow='MIDPOINT',
        useRTH=True
    )
)
def handle_bar(ib, bars, has_new_bar):
    if has_new_bar:
        print(bars[-1])

# Run until interrupted
ib.run()

Features

  • Event-driven framework for handling IB API events.
  • Support for asynchronous event handling.
  • Priority-based event handlers for multiple data streams.

IBEventType Enumeration

The IBEventType enumeration defines all supported IB API event types. Each event type corresponds to a specific event in the IB API that can be subscribed to and handled.

Attributes:

  • BAR_UPDATE: Real-time bar data update event.
  • ERROR: Error event from IB API.
  • CONNECTED: Connection established event.
  • DISCONNECTED: Connection lost event.
  • (Other attributes as needed)

Example Usage:

from ibevent.events import IBEventType

# Example of using IBEventType
event_type = IBEventType.BAR_UPDATE
print(event_type)

API Reference

For detailed API documentation, please refer to the MkDocs documentation.

Metadata

Release files for ibevent 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ibevent 0.2.0
File Size Uploaded
ibevent-0.2.0.tar.gz 46.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ibevent 0.2.0
File Interpreter ABI Platform
ibevent-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.1 kB

Release files / ibevent-0.2.0.tar.gz

Download URL ibevent-0.2.0.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
785256575dd527391717e0f83491ddc4188639d5ab03621afa4fd29211d25be6
BLAKE2b-256 checksum
How to use checksums
58f88c67d8837de85d6dec685b85f3c5a7f530c6ea3f52c0032351506f5691cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release files / ibevent-0.2.0-py3-none-any.whl

Download URL ibevent-0.2.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5e99323da4a16d6bba736f67ddbc14d49403a38e8f52de136dd75177c02127d
BLAKE2b-256 checksum
How to use checksums
1f7d367c9cf182b12047e0acd1232933e812754a717f0d1a265cd6f46793b2bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page