| Title: | R Client for the Interactive Brokers Client Portal API |
| Version: | 0.1.0 |
| Description: | Provides a lightweight R interface to the Interactive Brokers (IBKR) Client Portal REST API https://www.interactivebrokers.com/campus/ibkr-api-page/cpapi-v1/. Functions cover session management, account and portfolio queries, market data retrieval, and order placement and cancellation. Requires a locally running IBKR Client Portal Gateway. |
| License: | MIT + file LICENSE |
| Depends: | R (≥ 4.1.0) |
| Encoding: | UTF-8 |
| URL: | https://github.com/sactyr/ibkrcp |
| BugReports: | https://github.com/sactyr/ibkrcp/issues |
| Suggests: | httptest2, knitr, rmarkdown, spelling, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Imports: | httr2 |
| Config/roxygen2/version: | 8.0.0 |
| VignetteBuilder: | knitr |
| Language: | en-US |
| NeedsCompilation: | no |
| Packaged: | 2026-05-04 04:59:14 UTC; sactyr |
| Author: | Nagappan Karuppiah [aut, cre] |
| Maintainer: | Nagappan Karuppiah <sactyr@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-06 19:50:02 UTC |
Get the current session authentication status
Description
Get the current session authentication status
Usage
ibkr_auth_status()
Value
Named list with session status fields including authenticated,
connected, and competing
Cancel an open order
Description
Cancel an open order
Usage
ibkr_cancel_order(account_id, order_id)
Arguments
account_id |
IBKR account ID string |
order_id |
Order ID to cancel (as returned by |
Value
Invisibly returns the response list
Get all accounts associated with the authenticated user
Description
Get all accounts associated with the authenticated user
Usage
ibkr_get_accounts()
Value
Data frame with one row per account and columns: account_id,
type, currency, alias
Get all live and open orders
Description
Get all live and open orders
Usage
ibkr_get_orders()
Value
Data frame with one row per order and columns: order_id, conid,
symbol, side, order_type, quantity, status. Returns an empty
data frame if no open orders exist.
Get current positions for an account
Description
Get current positions for an account
Usage
ibkr_get_positions(account_id)
Arguments
account_id |
IBKR account ID string |
Value
Data frame with one row per position and columns: conid, symbol,
position, mkt_price, mkt_value, avg_cost, unrealised_pnl,
currency. Returns an empty data frame if no positions are open.
Get OHLCV price history for an instrument
Description
Fetches daily OHLCV bars from the IBKR Client Portal API. The t timestamp
field (Unix milliseconds) is converted to an Australia/Sydney date, which
correctly handles the UTC offset for ASX bar open times (~09:59 AEST =
23:59 UTC the prior day).
Usage
ibkr_get_price_history(conid, period = "1y")
Arguments
conid |
Integer conid of the instrument |
period |
History period string. Valid values: |
Value
Data frame with columns: date (Date), open, high, low,
close (numeric), volume (integer), sorted chronologically
Get portfolio summary for an account
Description
Returns cash balances and other high-level account metrics as a named list.
Each element corresponds to a summary field returned by the IBKR API (e.g.
totalcashvalue, netliquidation, availablefunds).
Usage
ibkr_get_summary(account_id)
Arguments
account_id |
IBKR account ID string (e.g. |
Value
Named list of summary fields. Each field is itself a list containing
amount, currency, and isNull
Get the trading schedule for an instrument
Description
Returns the IBKR trading schedule for the given symbol and exchange,
including trading and non-trading dates. Non-trading dates are those where
the sessions field is empty (public holidays). Weekend dates are not
included in the schedule.
Usage
ibkr_get_trading_schedule(
symbol = "VGS",
exchange = "ASX",
asset_class = "STK"
)
Arguments
symbol |
Ticker symbol (default: |
exchange |
Exchange code (default: |
asset_class |
Asset class (default: |
Value
Data frame with columns: date (Date), is_trading (logical),
sessions (character, semicolon-separated session open/close times or
NA for non-trading days). Template dates (year 2000) are excluded.
Place a market order
Description
Places a DAY market order for a single instrument. Confirmation prompts
returned by the API (e.g. price deviation warnings) are handled
automatically via ibkr_confirm_order_messages().
Usage
ibkr_place_order(account_id, conid, side, quantity)
Arguments
account_id |
IBKR account ID string (e.g. |
conid |
Integer conid of the instrument |
side |
|
quantity |
Number of shares (positive integer) |
Value
Invisibly returns the final order response list
Reauthenticate the session
Description
Call this if the session has timed out but the gateway is still running.
After calling this function, wait a few seconds then call ibkr_tickle()
to confirm the session is restored.
Usage
ibkr_reauthenticate()
Value
Invisibly returns the response list
Search for contracts by symbol
Description
Queries the IBKR contract search endpoint and returns all matching results.
Use this to look up conids (IBKR contract IDs) before placing orders or
fetching price history. To find ASX-listed contracts, filter the results
for rows where description or company_header contains "ASX".
Usage
ibkr_search_contracts(symbol, sec_type = "STK")
Arguments
symbol |
Ticker symbol to search for (e.g. |
sec_type |
Security type filter (default: |
Value
Data frame with one row per match and columns: conid, symbol,
company_name, description, company_header. Returns an empty data
frame if no matches are found.
Tickle the session to confirm it is alive
Description
Should be called at the start of each trading session to verify the Client Portal Gateway is running and the session is authenticated. Sessions time out after approximately 5 minutes without a request.
Usage
ibkr_tickle()
Value
Invisibly returns the response list. Stops with an error if the session is not authenticated.