登录

TIABSocket component & API v10.11 for Delphi Full Source

2024-12-18 23:03:45
TIABSocket component & API v10.11 for Delphi Full Source

This component set is designed to seamlessly integrate with the Interactive Brokers TradeWorkStation API and the IBGateway API. It's also compatible with re-branded platforms like Memex and ProRealtime.

With the introduction of API version 10. x, full support for Bitcoin trading has been added, including a dedicated BigDecimals code library to handle the fractional shares commonly used in digital coins.

Our API empowers developers using Delphi, RAD Studio, BCB, FPC, and Lazarus to construct applications that can directly transmit orders to TWS/Gateway. The TIABSocket component establishes a direct connection to the socket for efficient communication with TWS without any reliance on DLLs, ActiveX, .Net, or DDE files. This direct socket connection ensures rapid and dependable interaction and response times. The component set also manages all interactions with TWS and includes sub-components to oversee order processing, portfolio management, and account details. The code is structured similarly to standard Delphi components, making it easy to work. Comprehensive source code, a demo application, and a help file are all provided.

You receive access to all source codes and a versatile component set that streamlines TWS activities and nuances, surpassing other connection methods in speed and efficiency.

Furthermore, our API can be utilized in console applications without needing VCL or other visual components.

The latest addition to this offering is a stored history manager component, enabling users to save, reload, merge, search, edit, and construct a local history database. Currently, it supports all GetHistorical... data, with tick history support planned for the future.

This API has been rigorously tested and is compatible with all Delphi versions starting from Delphi 6 onwards, including XE, all 10. x versions, and the latest Delphi 11. It's also compatible with C++Builder (BCB), RAD Studio, and the FPC/Lazarus programming environments. It can be compiled for 32-bit and 64-bit architectures and fully supports Unicode. However, if you intend to use the BigDecimals code library for Bitcoin trading, a minimum compiler version of XE2 is required. (For BCB, you'll compile a Pascal unit into the VCL and link that code into your application.)

Please note that the TWS and the API are version-controlled, ensuring compatibility between recent API versions and TWS versions. They are designed to communicate with each other seamlessly.

TIABSocket component & API for Delphi Getting started

  1. Install the TIABSocket component into the library. In Delphi XE, 10 and 11 era IDE's; Menu select Components -> Select IABSocketAPI.pas, IABSocketAPI_const.pas, IABSocketAPI_tcpclient.pas, and the .dcr files, select existing (dclextras) or new bpl file, Build, Install, save, and close. It will appear on the Samples page by default. Amend the IDE's Library and Browing paths to include the above location (Tools -> Options -> Environment -> Delphi -> Library).In older Delphi 7 era IDEs; Menu select Components -> Install component into dclextras, or other new bpl file, then add the IABSocketAPI.pas, IABSocketAPI_const.pas, IABSocketAPI_tcpclient.pas, and the .dcr file, then Build, Install, save, and close. It will appear on the Samples page by default. For Updating: Replace the IABSocketAPI.pas, IABSocketAPI_const.pas, IABSocketAPI_tcpclient.pas files, open the .dpk package built above, and Build / Install it again. If bitcoin trading is needed, enable USE_BIGDECIMAL (see the Bigdecimal.txt for procedures.)
  2. Start a project, and drop the component on the form.
  3. Set the various properties, including the Default Order settings.
  4. Set the events for (as required):
    • OnAccountTime - latest account update.
    • OnAccountValue - changes in any account value.
    • OnConnectionState - monitors the connection to TWS, waits for a Ready state before sending the order.
    • OnOrderStatus - changes, fills, partials, cancels to orders.
    • OnPortfolioUpdate - changes in the portfolio.
    • OnTickPrice & OnTickSize, or OnTickSizeAndSize - for market data.
  5. Set the connected property to true to start a connection to the TWS.
  6. Call these Methods to (example):
    • PlaceOrder - enter new order.
    • CancelOrder - cancels an open order.
    • ModifyOrder - changes an existing order (cancel and replace).
    • GetMarketData - starts the flow of market data.
    • GetAccountUpdates - starts the flow of changes.
    • GetExecutions - for execution details.
    • GetOpenOrders - any open orders on logon.
  7. Check the various properties for values such as:
    • Filled, remaining, partial fill quantity.
    • Fill price, partial fill prices.
    • Account data
    • Portfolio data
    • State, fill, of any order
  8. See the "Code-notes.txt" file in the demo project folder for further details on program structure.