Skip to content

dshe/InterReact

Repository files navigation

InterReact   Version License Ukraine

Reactive C# API to Interactive Brokers Trader Workstation (TWS)

  • .NET 8.0 library
  • supports IB TWS API Stable 10.19 (Mar 25 2024 )
  • dependencies: RxSockets, Stringification, NodaTime
  • demo applications: Console, WPF
interface IInterReactClient : IAsyncDisposable
{
    IPEndPoint RemoteIpEndPoint { get; }
    Request Request { get; }
    IObservable<object> Response { get; }
    Service Service { get; }
}

Example

using System;
using System.Threading.Tasks;
using System.Reactive.Linq;
using InterReact;
// Create the InterReact client by connecting to TWS/Gateway on the local host.
IInterReactClient client = await InterReactClient.ConnectAsync();

// Create a contract object.
Contract contract = new()
{
   SecurityType = ContractSecurityType.Stock,
   Symbol       = "AMZN",
   Currency     = "USD",
   Exchange     = "SMART"
};

// Create and then subscribe to the observable which can observe ticks for the contract.
IDisposable subscription = client
    .Service
    .CreateMarketDataObservable(contract)
    .OfTickClass(selector => selector.PriceTick)
    .Where(tick => tick.TickType == TickType.LastPrice)
    .Subscribe(onNext: priceTick => Console.WriteLine($"Last Price = {priceTick.Price}"));

Console.WriteLine(Environment.NewLine + "press a key to exit...");
Console.ReadKey();
Console.Clear();

// Dispose the subscription to stop receiving ticks.
subscription.Dispose();

// Disconnect from TWS/Gateway.
await client.DisposeAsync();

Notes

Interactive Brokers Trader Workstation (TWS) or Gateway must be running with API access enabled. In TWS, navigate to Edit / Global Configuration / API / Settings. Ensure the option "Enable ActiveX and Socket Clients" is selected.

About

Reactive C# API to Interactive Brokers Trader Workstation.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy