Closed ihiasi closed 4 years ago
Here's a quick example to retrieve EUR historical 5min bars:
using Jib
ib = Jib.connect(4002, 1); # Connect on port 4002
d, w = Jib.simple_wrap();
Jib.start_reader(ib, w);
# Define contract
eur = Jib.Contract(symbol="EUR", secType="CASH", exchange="IDEALPRO", currency="USD");
# Send request
Jib.reqHistoricalData(ib, 1234, eur, "20200603 16:00:00 EDT", "2 D", "5 mins", "MIDPOINT", true, 1, false)
# Display result
d[:history]
Refer to IB API documentation for more details and the meaning of the arguments.
The function historicalData()
is a member of Wrapper
and is provided by the user. It is implicitly invoked when data are received. The one used in this example is defined here.
Note. In this case there's a slight deviation from the official IB API implementations: IB calls historicalData()
multiple times, row by row (Bar
), whereas Jib
calls it only once for the whole table (DataFrame
).
THANK YOU, I appreciate the pointers and the example.
This example is valuable and informative. I suggest if you could put it on the library home page.
Thanks for the feedback.
@lbilli Thanks for your time and effort!
What would be an example use of this API ? Thank you.