import threading, select
import shinybroker as sb
= sb.create_ibkr_socket_conn()
ib_socket, API_VERSION, CONNECTION_TIME
= threading.Thread(
ib_msg_reader_thread =sb.ib_msg_reader_run_loop,
target={'ib_sock': ib_socket, 'verbose': True}
kwargs
)
ib_msg_reader_thread.start()
= select.select([], [ib_socket], [])
(rd, wt, er) 0].send(
wt[
sb.req_historical_data(=1,
reqId=sb.Contract({
contract'symbol': "AAPL",
'secType': "STK",
'exchange': "SMART",
'currency': "USD"
}),="1 W",
durationStr=0
keepUpToDate
)
)
= select.select([], [ib_socket], [])
(rd, wt, er) 0].send(
wt[
sb.req_sec_def_opt_params(=1,
reqId="AAPL",
underlyingSymbol="STK",
underlyingSecType=265598
underlyingConId
) )
"Headless Mode" for In-App Scripting and Development
“Somewhat Interactive” Development Mode
As you’re developing apps, it’s sometimes useful to just create a scratch file containing a bit of code that grabs some input. You can watch the information get printed by the async reader loop as it becomes available off the socket, and maybe copy-paste it from the terminal printout do perform some of your exploratory development work.