lbilli / Jib.jl

A Julia implementation of Interactive Brokers API
MIT License
62 stars 14 forks source link

historicalData #4

Closed ihiasi closed 4 years ago

ihiasi commented 4 years ago

What would be an example use of this API ? Thank you.

lbilli commented 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).

ihiasi commented 4 years ago

THANK YOU, I appreciate the pointers and the example.

Sinansi commented 4 years ago

This example is valuable and informative. I suggest if you could put it on the library home page.

lbilli commented 4 years ago

Thanks for the feedback.

Sinansi commented 4 years ago

@lbilli Thanks for your time and effort!