placeOrder: TWS Orders

.placeOrderR Documentation

TWS Orders

Description

Place or cancel an order to the TWS.

Usage

placeOrder(twsconn, Contract, Order)

cancelOrder(twsconn, orderId)

Arguments

twsconn

A twsConnection object.

Contract

A twsContract object.

Order

A twsOrder object.

orderId

A valid order id.

Details

As described by the official Interactive Brokers (tm) documentation. Caveat Emptor!!

Value

Called for its side effect of placing or cancelling an order on the TWS. This also returns the orderId used for placeOrder. An additional side-effect is that a variable .Last.orderId will be created or updated in the GlobalEnv as well.

Note

Orders via the API are quite complicated, or at least can be. It is strongly advised to only proceed with trading real money after one understands not only all the R code in this package, but the official API as well. If you are more comfortable clicking shiny buttons in a GUI, it is probably better that you keep clicking the buttons and not pretend to program.

Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.

Author(s)

Jeffrey A. Ryan

References

Official Place Order API: https://interactivebrokers.github.io/tws-api/classIBApi_1_1EClient.html#aa6ff6f6455c551bef9d66c34d1c8586c

See Also

twsContract twsOrder reqIds

Examples

## Not run: 
tws <- twsConnect()
id <- reqIds(tws)

placeOrder(tws, twsSTK("AAPL"), twsOrder(id))
cancelOrder(tws, id)

## End(Not run)

joshuaulrich/IBrokers documentation built on Feb. 4, 2024, 2:16 a.m.