Categorygithub.com/scmhub/ibapi
modulepackage
0.0.1
Repository: https://github.com/scmhub/ibapi.git
Documentation: pkg.go.dev

# README

Go Report Card Go Reference License: MIT

Unofficial Golang Interactive Brokers API (Beta)

This package provides an unofficial Golang implementation of the Interactive Brokers API. It is designed to mirror the official Python or C++ tws-api provided by Interactive Brokers. We will do our best to keep it in sync with the official API releases to ensure compatibility and feature parity, but users should be aware that this is a community-driven project and may lag behind the official versions at times.

Note: This package is in the beta phase. While functional, it may still have bugs or incomplete features. Please test extensively in non-production environments.

Getting Started

Prerequisites

  • Go version 1.23 or higher (recommended)
  • An Interactive Brokers account with TWS or IB Gateway installed and running

Installation

Install the package via go get:

go get -u github.com/scmhub/ibapi

Usage

Here’s a basic example to connect and place an order using this package:

package main

import (
	"math/rand"
	"time"

	"github.com/scmhub/ibapi"
)

const (
	IB_HOST = "127.0.0.1"
	IB_PORT = 7497
)

func main() {
	// We set logger for pretty logs to console
	log := ibapi.Logger()
	ibapi.SetConsoleWriter()

	// New IB CLient
	ib := ibapi.NewEClient(nil)
    // Connect client
	if err := ib.Connect(IB_HOST, IB_PORT, rand.Int63n(999999)); err != nil {
		log.Error().Err(err)
		return
	}

    // Create and place order
	id := ib.NextID()
	eurusd := &ibapi.Contract{Symbol: "EUR", SecType: "CASH", Currency: "USD", Exchange: "IDEALPRO"}
	limitOrder := ibapi.LimitOrder("BUY", ibapi.StringToDecimal("20000"), 1.08)
	ib.PlaceOrder(id, eurusd, limitOrder)

	time.Sleep(1 * time.Second)

	err := ib.Disconnect()
	if err != nil {
		log.Error().Err(err).Msg("Disconnect")
	}
}

For more information on how to use this package, please refer to the GoDoc documentation.

Acknowledgments

  • Some portions of the code were adapted from hadrianl. Thanks to them for their valuable work!
  • Decimals are implemented with the fixed package

Notice of Non-Affiliation and Disclaimer

Beta Release: This project is in the beta phase and is still undergoing testing and development. Users are advised to thoroughly test the software in non-production environments before relying on it for live trading. Features may be incomplete, and bugs may exist. Use at your own risk.

This project is not affiliated with Interactive Brokers Group, Inc. All references to Interactive Brokers, including trademarks, logos, and brand names, belong to their respective owners. The use of these names is purely for informational purposes and does not imply endorsement by Interactive Brokers.

The authors of this package make no guarantees regarding the software's reliability, accuracy, or suitability for any particular purpose, including trading or financial decisions. No liability will be accepted for any financial losses, damages, or misinterpretations arising from the use of this software.

License

Distributed under the MIT License. See LICENSE for more information.

# Packages

No description provided by the author

# Functions

AtAuction .
AttachAdjustableToStop .
AttachAdjustableToStopLimit .
AttachAdjustableToTrail .
AuctionLimit .
AuctionPeggedToStock .
AuctionRelative.
Block .
Bond .
BondWithCusip .
BoxTop .
BracketOrder .
BTbroadtapeNewsFeed .
ByConId .
ByFIGI .
ByISIN .
ByIssuerId .
BZbroadtapeNewsFeed .
CancelOrderEmpty .
CancelOrderWithManualTime .
CashCFD .
CFD .
ComboLimitOrder .
ComboMarketOrder .
Commodity.
ComplexOrdersAndTrades .
ContAndExpiringFut .
ContFut .
No description provided by the author
CryptoContract .
CSFBContract .
No description provided by the author
Discretionary .
DutchWarrant .
EReader starts the scan and decode goroutines.
ETF .
EurGbpFx .
EuropeanStock .
EuropeanStockCFD .
FAUpdatedGroup returns a list of groups xml sample.
FillAccumulateDistributeParams .
FillAdaptiveParams .
FillArrivalPriceParams .
FillBalanceImpactRiskParams .
FillClosePriceParams .
FillCSFBInlineParams .
FillDarkIceParams .
FillJefferiesVWAPParams .
FillMinImpactParams .
FillPctVolParams .
FillPriceVariantPctVolParams .
FillSizeVariantPctVolParams .
FillTimeVariantPctVolParams .
FillTwapParams .
FillVwapParams .
FLYbroadtapeNewsFeed .
Fund .
FutureComboContract .
FuturesOnOptions .
FutureWithLocalSymbol .
FutureWithMultiplier .
No description provided by the author
HighOptVolumePCRatioUSIndexes .
HKStk.
HotUSStkByVolume .
IBKRATSContract .
IBKRStk .
IBMBond .
IBMUSStockAtSmart .
Index .
InterCmdtyFuturesContract .
No description provided by the author
JefferiesContract .
LimitIBKRATS .
LimitIfTouched .
LimitOnClose .
LimitOnOpen .
LimitOrder .
LimitOrderForComboWithLegPrices .
LimitOrderWithCashQty .
LimitOrderWithCustomerAccount .
No description provided by the author
LimitOrderWithManualOrderTime .
Logger returns the logger.
MarketFHedge .
MarketIfTouched .
MarketOnClose creates A Market-on-Close (MOC) order is a market order that is submitted to execute as close to the closing price as possible.
MarketOnOpen .
MarketOrder .
MarketToLimit .
MarketWithProtection .
MidpointMatch .
Midprice .
MostActiveFutEurex .
MutualFund .
No description provided by the author
NewComboLeg creates a default ComboLeg.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewEClient returns a new Eclient.
No description provided by the author
NewExecutionCondition .
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewMarginCondition .
NewMsgBuffer create a new MsgBuffer.
No description provided by the author
NewOrder creates a default Order.
No description provided by the author
NewOrder creates a default OrderComboLeg.
No description provided by the author
NewPercentageChangeCondition .
NewPriceCondition .
No description provided by the author
No description provided by the author
NewScannerSubscription creates a default ScannerSubscription.
NewsFeedForQuery .
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewTimeCondition .
VolumeConditionOrder .
No description provided by the author
One-Cancels All (OCA) order type allows an investor to place multiple and possibly unrelated orders assigned to a group.
OptionAtBox.
OptionAtIse .
OptionComboContract .
OptionForQuery .
OptionWithLocalSymbol .
OptionWithTradingClass .
PassiveRelative .
PegBestOrder .
PegBestUpToMidOrder .
PeggedToBenchmark .
PeggedToMarket .eurusd := &ibapi.Contract{Symbol: "EUR", SecType: "CASH", Currency: "USD", Exchange: "IDEALPRO"} A pegged-to-market order is designed to maintain a purchase price relative to the national best offer (NBO) or a sale price relative to the national best bid (NBB).
PeggedToMidpoint .
PeggedToStock .
PegMidOrder .
RelativeLimitCombo .
RelativeMarketCombo .
RelativePeggedToPrimary .
SetConsoleWriter will send pretty log to the console.
SetLogLevel sets the loggging level.
SimpleFuture .
SmartFutureComboContract .
StockComboContract .
StockWithIPOPrice .
Stop .
StopLimit .
StopWithProtection .
No description provided by the author
No description provided by the author
SweepToFill .
No description provided by the author
TopPercentGainersIbis .
TrailingStop .
TrailingStopLimit .
USOptionContract .
USStock .
USStockAtSmart .
USStockCFD .
USStockWithPrimaryExch .
Volatility .
Warrants .
WhatIfLimitOrder .
WrongContract .

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Trigger Methods.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Trigger Methods.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Trigger Methods.
Trigger Methods.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Trigger Methods.
Trigger Methods.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
16Mb - 1byte.
Trigger Methods.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MIN_SERVER_VER_POST_TO_ATS
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MIN_SERVER_VER_REAL_TIME_BARS Version = 34 MIN_SERVER_VER_SCALE_ORDERS Version = 35 MIN_SERVER_VER_SNAPSHOT_MKT_DATA Version = 35 MIN_SERVER_VER_SSHORT_COMBO_LEGS Version = 35 MIN_SERVER_VER_WHAT_IF_ORDERS Version = 36 MIN_SERVER_VER_CONTRACT_CONID Version = 37.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MIN_SERVER_VER_REQ_NEWS_ARTICLE
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NEWS_ARTICLE
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
REQ_NEWS_ARTICLE
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Account .
Bar .
CodeMsgPair is IB internal errors.
ComboLeg .
CommissionReport .
Connection is a TCPConn wrapper.
Contract describes an instrument's definition.
No description provided by the author
ContractDescription includes contract and DerivativeSecTypes.
ContractDetails .
DeltaNeutralContract .
DepthMktDataDescription .
EClient is the main struct to use from API user's point of view.
EDecoder transforms a message's payload into higher level IB message.
Execution is the information of an order`s execution.
No description provided by the author
ExecutionFilter .
FamilyCode .
Group .
HistogramData .
HistoricalSession .
HistoricalTick is the historical tick's description.
HistoricalTickBidAsk is the historical tick's description.
HistoricalTickLast is the historical last tick's description.
IneligibilityReason is a simple struct for ineligibility reason.
ListOfAccounts .
ListOf Groups .
No description provided by the author
MsgBuffer is the buffer that contains a whole msg.
NewsProvider .
No description provided by the author
Order .
OrderCancel .
OrderComboLeg .
OrderDecoder .
OrderState .
No description provided by the author
No description provided by the author
PriceIncrement .
RealTimeBar .
ScanData .
ScannerSubscription .
SmartComponent .
SoftDollarTier stores the Soft Dollar Tier information.
TagValue maps a tag to a value.
TickAttrib .
TickAttribBidAsk .
TickAttribLast .
No description provided by the author
No description provided by the author
Wrapper is the default implementation of the EWrapper interface.
WshEventData .

# Interfaces

EWrapper contains the function to handle incoming messages from TWS or Gateway.
No description provided by the author

# Type aliases

AccountSummaryTags .
No description provided by the author
No description provided by the author
Decimal implements Fixed from "github.com/robaho/fixed".
No description provided by the author
No description provided by the author
No description provided by the author
IN is the incoming msg id's.
LegOpenClose .
No description provided by the author
No description provided by the author
No description provided by the author
OUT is the outgoing msg id's.
No description provided by the author
TickType is the type of ticks.
Version is the server version.