Giter Site home page Giter Site logo

jib.jl's Introduction

Jib

A Julia implementation of Interactive Brokers API

Jib is a native Julia client that implements Interactive Brokers API to communicate with TWS or IBGateway.

It aims to be feature complete, however it does not support legacy versions. Currently, only API versions v176+ are supported.

The package design follows the official C++/Java IB API, which is based on an asynchronous communication model over TCP.

Installation

To install from GitHub:

] add https://github.com/lbilli/Jib.jl

Usage

The user interacts mainly with these two objects:

  • Connection: a handle holding a connection to the server
  • Wrapper: a container for the callbacks that are invoked when the server responses are processed.

Other data structures, such as Contract and Order, are implemented as Julia struct and mirror the respective classes in the official IB API.

A complete minimal working example is shown. For this code to work, an instance of IB TWS or IBGateway needs to be running on the local machine and listening on port 4002. Note: demo or paper account recommended!! 😏

using Jib

wrap = Jib.Wrapper(
         # Customized methods go here
         error= (id, errorCode, errorString, advancedOrderRejectJson) ->
                  println("Error: $(something(id, "NA")) $errorCode $errorString $advancedOrderRejectJson"),

         nextValidId= (orderId) -> println("Next OrderId: $orderId"),

         managedAccounts= (accountsList) -> println("Managed Accounts: $accountsList")

         # more method overrides can go here...
       );

# Connect to the server with clientId = 1
ib = Jib.connect(4002, 1);

# Start a background Task to process the server responses
Jib.start_reader(ib, wrap);

# Define contract
contract = Jib.Contract(symbol="GOOG",
                        secType="STK",
                        exchange="SMART",
                        currency="USD");

# Define order
order = Jib.Order();
order.action        = "BUY"
order.totalQuantity = 10
order.orderType     = "LMT"
order.lmtPrice      = 100

orderId = 1    # Should match whatever is returned by the server

# Send order
Jib.placeOrder(ib, orderId, contract, order)

# Disconnect
Jib.disconnect(ib)
Foreground vs. Background Processing

It is possible to process the server responses either within the main process or in a separate background Task:

  • foreground processing is triggered by invoking Jib.check_all(ib, wrap). It is the user's responsibility to call it on a regular basis, especially when data are streaming in.
  • background processing is started by Jib.start_reader(ib, wrap). A separate Task is started in the background, which monitors the connection and processes the responses as they arrive.

To avoid undesired effects, the two approaches should not be mixed together on the same connection.

Implementation Details

The package does not export any name, therefore any functions or types described here need to be prefixed by Jib.*.

As Julia is not an object-oriented language, the functionality of the IB EClient class is provided here by regular functions. In particular:

  • connect(port, clientId, connectOptions): establish a connection and return a Connection object.
  • disconnect(::Connection): terminate the connection.
  • check_all(::Connection, ::Wrapper): process available responses, not blocking. Return the number of messages processed. Needs to be called regularly!
  • start_reader(::Connection, ::Wrapper): start a Task for background processing.
  • methods that send specific requests to the server. Refer to the official IB EClient class documentation for further details and method signatures. The only caveat is to remember to pass a Connection as first argument: e.g. reqContractDetails(ib::Connection, reqId:Int, contract::Contract)

Like the official IB EWrapper class, this struct holds the callbacks that are dispatched when responses are processed. The user provides the callback definitions as keyword arguments in the constructor, as shown above, and/or by setting the property of an existing instance.

A more comprehensive example is provided by simple_wrap(), which is used like this:

using Jib: Jib, Contract, reqContractDetails, simple_wrap, start_reader

data, wrap = simple_wrap();

ib = Jib.connect(4002, 1);
start_reader(ib, wrap);

reqContractDetails(ib, 99, Contract(conId=208813720, exchange="SMART"))

# Wait for the response and then access the "ContractDetails" result:
data[:cd]

Thanks to closures, data (a Dict in this case) is accessible by all wrap methods as well as the main program. This is one way to propagate incoming data to different parts of the program.

For more details about callback definitions and signatures, refer to the official IB EWrapper class documentation. As reference, the exact signatures used in this package are found here.

Notes

Callbacks are generally invoked with arguments and types matching the signatures as described in the official documentation. However, there are few exceptions:

  • tickPrice() has an extra size::Float64 argument, which is meaningful only when TickType ∈ {BID, ASK, LAST}. In these cases, the official IB API fires an extra tickSize() event instead.
  • historicalData() is invoked only once per request, presenting all the historical data as a single DataFrame, whereas the official IB API invokes it row-by-row.
  • scannerData() is also invoked once per request and its arguments are in fact vectors rather than single values.

These modifications make it possible to establish the rule: one callback per server response.

Consequently, historicalDataEnd() and scannerDataEnd() are redundant and are not used in this package.

DataFrame are passed to several other callbacks, such as: mktDepthExchanges(), smartComponents(), newsProviders(), histogramData(), marketRule() and the historicalTicks*() family.

Missing Values

Occasionally, for numerical types, there is the need to represent the lack of a value.

IB API does not have a uniform solution across the board, but rather it adopts a variety of sentinel values. They can be either the plain 0 or the largest representable value of a given type such as 2147483647 and 9223372036854775807 for 32- and 64-bit integers respectively or 1.7976931348623157E308 for 64-bit floating point.

This package makes an effort to use Julia built-in Nothing in all circumstances.

Data Structures

Other classes that mainly hold data are also replicated. They are implemented as Julia struct or mutable struct with names, types and default values matching the IB API counterparts: e.g. Contract, Order, ComboLeg, ExecutionFilter, ScannerSubscription and Condition*.

TagValueList are implemented as Julia NamedTuple. Wherever a TagValue is needed, something like this can be used:

tagvaluelist = (tag1="value1", tag2="value2")
# or, in case of an empty list:
emptylist = (;)

Values don't need to be of type String. Int and Float64 are also allowed.

jib.jl's People

Contributors

lbilli avatar maccam912 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jib.jl's Issues

just started getting this IOError: write: broken pipe (EPIPE)

Just started happening since 12/16/22 did something change in Jib.jl or IB on or near 12/15/22 which is the last day the code ran.

β”Œ Warning: connection terminated
β”” @ Jib.Reader ~/.julia/packages/Jib/JOmEj/src/reader.jl:70
ERROR: [ Info: reader exiting
LoadError: IOError: write: broken pipe (EPIPE)
Stacktrace:
 [1] uv_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
   @ Base ./stream.jl:1064
 [2] unsafe_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
   @ Base ./stream.jl:1118
 [3] unsafe_write
   @ ./io.jl:683 [inlined]
 [4] write
   @ ./io.jl:706 [inlined]
 [5] write_one(socket::Sockets.TCPSocket, buf::IOBuffer)
   @ Jib.Client ~/.julia/packages/Jib/JOmEj/src/client.jl:28
 [6] sendmsg
   @ ~/.julia/packages/Jib/JOmEj/src/requests.jl:27 [inlined]
 [7] reqMktData(ib::Jib.Connection, tickerId::Int64, contract::Jib.Contract, genericTicks::String, snapshot::Bool, regulatorySnaphsot::Bool, mktDataOptions::NamedTuple{(), Tuple{}})
   @ Jib.Requests ~/.julia/packages/Jib/JOmEj/src/requests.jl:70
 [8] reqMktData
   @ ~/.julia/packages/Jib/JOmEj/src/requests.jl:47 [inlined]
 [9] top-level scope
   @ ~/tontine_2022/2022_live/9_6_22_LIVE_STK_IV_VOL_LAST.jl:171
in expression starting at /home/dave/tontine_2022/2022_live/9_6_22_LIVE_STK_IV_VOL_LAST.jl:160

running latest Jib.jl updated pkg and julia latest version.

@v1.8) pkg> up
    Updating registry at `~/.julia/registries/General.toml`
    Updating git-repo `https://github.com/lbilli/Jib.jl`
  No Changes to `~/.julia/environments/v1.8/Project.toml`
  No Changes to `~/.julia/environments/v1.8/Manifest.toml`

(@v1.8) pkg> up
    Updating registry at `~/.julia/registries/General.toml`
    Updating git-repo `https://github.com/lbilli/Jib.jl`
  No Changes to `~/.julia/environments/v1.8/Project.toml`
  No Changes to `~/.julia/environments/v1.8/Manifest.toml`

(@v1.8) pkg> st
Status `~/.julia/environments/v1.8/Project.toml`
  [c52e3926] Atom v0.12.38
  [336ed68f] CSV v0.10.8
  [1b08a953] Dash v1.1.2
βŒƒ [a93c6f00] DataFrames v1.3.6
  [1313f7d8] DataFramesMeta v0.12.0
  [31a5f54b] Debugger v0.7.6
βŒ… [c43c736e] Genie v4.18.1
βŒ… [cd3eb016] HTTP v0.9.17
  [f310f2d2] Jib v0.19.3 `https://github.com/lbilli/Jib.jl#master`
  [e5e0dc1b] Juno v0.8.4
  [f0f68f2c] PlotlyJS v0.18.10
βŒƒ [c3e4b0f8] Pluto v0.19.9
βŒ… [4acbeb90] Stipple v0.24.5
βŒƒ [ec984513] StipplePlotly v0.12.4
βŒƒ [a3c5d34a] StippleUI v0.19.4
  [9e3dc215] TimeSeries v0.23.1
  [c2297ded] ZMQ v1.2.2
  [ade2ca70] Dates
  [56ddb016] Logging
  [10745b16] Statistics
Info Packages marked with βŒƒ and βŒ… have new versions available, but those with βŒ… are restricted by compatibility constraints from upgrading. To see why use `status --outdated`

(@v1.8) pkg> 

dave@deepthought:~$ juliaup update
dave@deepthought:~$ juliaup status
 Default  Channel  Version                Update 
-------------------------------------------------
       *  release  1.8.3+0.x64.linux.gnu         
dave@deepthought:~$ juliaup update
dave@deepthought:~$ julia

this is the call that breaks

for (idx, s) in enumerate(eachrow(symbol_list))

    contract = Jib.Contract(symbol=s.Sym, secType="STK" , exchange=s.exchange , currency="USD")
    Jib.reqMktData(ib, idx, contract,"106", false) # https://interactivebrokers.github.io/tws-api/tick_types.html
end

BUT this one works properly. They both share the same ZMQ configuration code and worked fine up until 12/16/22.

for (idx, s) in enumerate(eachrow(symbol_list))
  sleep(5)
    contract = Jib.Contract(symbol=s.Sym, secType="STK" , exchange=s.exchange , currency="USD")
  try
       Jib.reqHistoricalData(ib, idx ,contract,"","1 Y","1 day","TRADES",true,1,false )
  
  catch e
           println("something went wrong with : " , s.Sym)
           stk_send_msg = "STK" *  "~" * s.Sy * "~" * "CLOSE" * "~" * string( 999 ) #show there was an error
           ZMQ.send( stk_socket, stk_send_msg )
           continue
  end
end

Jib.reqMktData throws e = TypeError: in typeassert, expected Float64, got a value of type Nothing

Hi there
remember I am a noob so please bear with me.I am trying not to bother you.

I added a 10 sec sleep and made the method override to see how it works but I got an error I don't know how to diagnose. I am running all of this in the repl and text editor.

ALSO I feel bad about raising these things as issues, do you have a julia discourse thread please?

using Jib
symbols = ["AAPL", "TSLA", "AMD", "INTC"]


ib = Jib.connect("192.168.1.219",1234, 21)

d, wrap = Jib.simple_wrap();

wrap.tickPrice = (tickerId, field, price, size, attrib) -> println("tickPrice2: $(symbols[tickerId]) $field $price $size $attrib")

Jib.start_reader(ib, wrap)

for (idx, s) in enumerate(symbols)
  contract = Jib.Contract(symbol=s, secType="STK", exchange="SMART", currency="USD")
  Jib.reqMktData(ib, idx, contract, "", false)
end

sleep(10)

for idx in 1:length(symbols)
  Jib.cancelMktData(ib, idx)
end

Jib.disconnect(ib)

and got this error

 Info: connected
β”‚   V = "165"
β””   T = "20220207 13:44:45 Central Standard Time"
error: -1 2104 Market data farm connection is OK:uscrypto 
error: -1 2104 Market data farm connection is OK:usfuture.nj 
error: -1 2104 Market data farm connection is OK:usfarm.nj 
error: -1 2104 Market data farm connection is OK:usfuture 
error: -1 2104 Market data farm connection is OK:cashfarm 
error: -1 2104 Market data farm connection is OK:usopt 
error: -1 2104 Market data farm connection is OK:usfarm 
error: -1 2106 HMDS data farm connection is OK:ushmds.nj 
error: -1 2106 HMDS data farm connection is OK:ushmds 
error: -1 2158 Sec-def data farm connection is OK:secdefil 
marketDataType: 1 REALTIME
tickReqParams: 1 0.01 9c0001 3
tickString: 1 LAST_TIMESTAMP 1644263088
tickString: 1 LAST_EXCH Q
tickPrice2: AAPL LAST 172.81 1.0 (canAutoExecute = false, pastLimit = false, preOpen = false)
tickSize: 1 LAST_SIZE 1.0
tickSize: 1 VOLUME 519927.0
tickPrice2: AAPL HIGH 173.95 0.0 (canAutoExecute = false, pastLimit = false, preOpen = false)
tickPrice2: AAPL LOW 171.53 0.0 (canAutoExecute = false, pastLimit = false, preOpen = false)
tickPrice2: AAPL CLOSE 172.39 0.0 (canAutoExecute = false, pastLimit = false, preOpen = false)
tickPrice2: AAPL OPEN 172.76 0.0 (canAutoExecute = false, pastLimit = false, preOpen = false)
tickPrice2: AAPL BID 172.8 23.0 (canAutoExecute = true, pastLimit = false, preOpen = false)
tickPrice2: AAPL ASK 172.81 33.0 (canAutoExecute = true, pastLimit = false, preOpen = false)
tickSize: 1 BID_SIZE 23.0
tickSize: 1 ASK_SIZE 33.0
tickString: 1 BID_EXCH KPQXZU
tickString: 1 ASK_EXCH KPQZNU
marketDataType: 2 REALTIME
tickReqParams: 2 0.01 9c0001 3
β”Œ Error: exception thrown
β”‚   e = TypeError: in typeassert, expected Float64, got a value of type Nothing
β”” @ Jib.Reader ~/.julia/packages/Jib/SeCxV/src/reader.jl:74
[ Info: reader exiting

Error message "UndefVarError: Execution not defined"

Hello,

When I try to run my_wrap() below with the execDetails function syntax from your source code I get an error message from Julia:
UndefVarError: Execution not defined
All other functions in the Jib.Wrapper( ) are fine.

Is there a way around this?
Thank you in advance for the help.

Regards,

function my_wrap( )
...
wrap = Jib.Wrapper(
... some functions (ok)
execDetails = function(reqId::Int, contract::Contract, execution::Execution)
                    d[:ex_con] = contract
                    d[:execution] = execution
                    println("ExecDetails: $reqId")
end,
... more functions (ok)
end # wrap
...
end # my_wrap()

Unable to connect thru IB Gateway ERROR: EOFError: read end of file

New to Julia, I'm using julia version 1.8.5 on macOS 13.2.1 and IB Gateway 10.21 on a paper account:

`julia> using Jib

julia> ib = Jib.connect(4002, 2)
ERROR: EOFError: read end of file
Stacktrace:
[1] (::Base.var"#wait_locked#680")(s::Sockets.TCPSocket, buf::IOBuffer, nb::Int64)
@ Base ./stream.jl:945
[2] unsafe_read(s::Sockets.TCPSocket, p::Ptr{UInt8}, nb::UInt64)
@ Base ./stream.jl:953
[3] unsafe_read
@ ./io.jl:759 [inlined]
[4] unsafe_read(s::Sockets.TCPSocket, p::Base.RefValue{UInt32}, n::Int64)
@ Base ./io.jl:758
[5] read!
@ ./io.jl:760 [inlined]
[6] read
@ ./io.jl:764 [inlined]
[7] read_one
@ ~/.julia/packages/Jib/pHjze/src/client.jl:34 [inlined]
[8] read_msg(socket::Sockets.TCPSocket)
@ Jib.Reader ~/.julia/packages/Jib/pHjze/src/reader.jl:11
[9] connect(host::Sockets.IPv6, port::Int64, clientId::Int64, connectOptions::String, optionalCapabilities::String)
@ Jib ~/.julia/packages/Jib/pHjze/src/Jib.jl:54
[10] connect(port::Int64, clientId::Int64, connectOptions::String, optionalCapabilities::String)
@ Jib ~/.julia/packages/Jib/pHjze/src/Jib.jl:74
[11] connect(port::Int64, clientId::Int64)
@ Jib ~/.julia/packages/Jib/pHjze/src/Jib.jl:72
[12] top-level scope
@ REPL[3]:1
`

Can connect to same environment with a python client.

Any hints?

Drop attempt to infer server time zone

Remove the functionality to infer the time zone that TWS is using, which is set at login time.
Let then the user be responsible of keeping track of it.

IB is also moving away from implicit time zones and this feature's cons might outweigh the pros.

How to respond to disconnection (e.g. Gateway restart)

Hi, first of all, thank you for this package! πŸ™‡β€β™‚οΈ

I'm trying to make my software more robust in its usage of Jib.jl around Gateway disconnections.
Currently, when IB Gateway (auto) restarts, my Julia client prints:

Warning: connection terminated
Info: reader exiting

I was wondering if / how the client could get notified in a way that allows it to take action in response to a disconnection from the Gateway?

For instance, when the Gateway (auto) restarts, it disconnects, and I would like to get notified of the disconnection (not just by a message print, but by a callback or maybe a variable I can repeatedly check) and take action.

The action I would take could be for example: trying connecting again repeatedly until Gateway is finished restarting and the connection succeeds, after which I would request data streams again (e.g. with reqMktData).

I went through the list of wrapper callbacks (in wrapper.jl) and did not see any that corresponds to what I need. However, there is this commented-out connectionClosed that sounded promising. Maybe it is planned for the future?
In the meantime, do you see any easy workaround?

Maybe it's even something that looks easy to contribute, if that's the case, let me know and I can try to make a PR with your guidance :-)

Versions tested:

  • Jib version v0.20.2
  • IB Gateway build 10.19.2d
  • julia 1.9.3

EOFError on connect

I'm having some trouble connecting to the API.

julia> ib = Jib.connect("172.20.176.1", 7496, 1)

ERROR: EOFError: read end of file
Stacktrace:
[1] (::Base.var"#wait_locked#715")(s::Sockets.TCPSocket, buf::IOBuffer, nb::Int64)
@ Base ./stream.jl:947
[2] unsafe_read(s::Sockets.TCPSocket, p::Ptr{UInt8}, nb::UInt64)
@ Base ./stream.jl:955
[3] unsafe_read
@ ./io.jl:761 [inlined]
[4] unsafe_read(s::Sockets.TCPSocket, p::Base.RefValue{UInt32}, n::Int64)
@ Base ./io.jl:760
[5] read!
@ ./io.jl:762 [inlined]
[6] read
@ ./io.jl:766 [inlined]
[7] read_one
@ ~/.julia/packages/Jib/51eDB/src/client.jl:34 [inlined]
[8] read_msg(socket::Sockets.TCPSocket)
@ Jib.Reader ~/.julia/packages/Jib/51eDB/src/reader.jl:11
[9] connect(host::String, port::Int64, clientId::Int64, connectOptions::String, optionalCapabilities::String)
@ Jib ~/.julia/packages/Jib/51eDB/src/Jib.jl:54
[10] connect(host::String, port::Int64, clientId::Int64)
@ Jib ~/.julia/packages/Jib/51eDB/src/Jib.jl:42
[11] top-level scope
@ REPL[3]:1

LoadError: [ Info: reader exiting IOError: stream is closed or unusable

Hi all
using ZMQ ( if relevant) code has been working excellently ( all hail ibilli ) but I am getting this message this am. I suck at error handling so anyone got any clues as to the cause? Thanks

ERROR: β”Œ Warning: connection terminated
β”” @ Jib.Reader ~/.julia/packages/Jib/12qUA/src/reader.jl:70
LoadError: [ Info: reader exiting
IOError: stream is closed or unusable
Stacktrace:
  [1] check_open
    @ ./stream.jl:388 [inlined]
  [2] uv_write_async(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
    @ Base ./stream.jl:1069
  [3] uv_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
    @ Base ./stream.jl:1032
  [4] unsafe_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
    @ Base ./stream.jl:1115
  [5] unsafe_write
    @ ./io.jl:683 [inlined]
  [6] write
    @ ./io.jl:706 [inlined]
  [7] write_one(socket::Sockets.TCPSocket, buf::IOBuffer)
    @ Jib.Client ~/.julia/packages/Jib/12qUA/src/client.jl:28
  [8] sendmsg
    @ ~/.julia/packages/Jib/12qUA/src/requests.jl:27 [inlined]
  [9] reqMktData(ib::Jib.Connection, tickerId::Int64, contract::Jib.Contract, genericTicks::String, snapshot::Bool, regulatorySnaphsot::Bool, mktDataOptions::NamedTuple{(), Tuple{}})
    @ Jib.Requests ~/.julia/packages/Jib/12qUA/src/requests.jl:70
 [10] reqMktData
    @ ~/.julia/packages/Jib/12qUA/src/requests.jl:47 [inlined]
 [11] top-level scope
    @ ~/tontine_2022/2022_live/9_6_22_LIVE_STK_IV_VOL_LAST.jl:171
in expression starting at /home/dave/tontine_2022/2022_live/9_6_22_LIVE_STK_IV_VOL_LAST.jl:160

here's the relevant "code" no giggling :-)

Jib.start_reader(ib, wrap)

context = Context()

stk_socket = Socket(context, PUSH)

ZMQ.connect(stk_socket, "tcp://localhost:5555")

for (idx, s) in enumerate(eachrow(symbol_list))

    contract = Jib.Contract(symbol=s.Sym, secType="STK" , exchange=s.exchange , currency="USD")
 
    Jib.reqMktData(ib, idx, contract,"106", false) # https://interactivebrokers.github.io/tws-api/tick_types.html

end

Decimal vs floating point data type for sizes

As of API v163, official IB implementations (except C++, see InteractiveBrokers/tws-api#1061) started reporting market data sizes and volumes as decimals instead of integers.

Here standard Float64 are used instead, which limits the precision to ~16 decimal digits.

Compatibility with Julia version / enhancements

What is the supported Julia version that is tested for the package?
I'm using Julia Version 1.4.2 and notices several issues, such as:
*) check_all function is blocking execution (I suppose not working properly?). It looks that the connection status is always open (=3) and the connection has 0 bytes available, even though there are messages that can be processed separately with check_msg function.
*) Base.show function goes in the loop when presenting data, the information from the type is repeatedly displayed after any other command is executed. Very annoying.

Regarding possible enhancements:

  1. would be good if another time zone can be added.
    elseif tz == "EET"
    tz"Europe/Riga"

  2. Would be helpful to add another attribute for Contract definition - "primaryExchange"

  3. Would be great to have a function that returns the relevant response for the specific response

check_all() blocks on Windows

Apparently on Windows TCPSocket status stays StatusOpen regardless whether there's data available to read.
Compare to linux where it changes to StatusPaused when data is available.

Therefore at the moment check_all() blocks on Windows and hence it's rather useless.

historicalData

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

Primary Exchange Error - Unsupported Keyword

The following is Apple Inc description from Interactive Brokers Trader Workstation TWS

_APPLEΒ INC

Underlying: AAPL
Security Type: STK Β 
Currency: USD
Exchange: SMART
Primary Exchange: NASDAQ
Symbol: AAPL
Sector: Technology
Industry: Computers
Category: Computers
Issuer Country: US
Stock type: COMMON_

This is the jib contract I am trying to create
JC = Jib.Contract(symbol = "AAPL", secType = "STK", currency = "USD", exchange = "SMART", primaryExchange="NASDAQ");

I get the following error
got unsupported keyword argument "primaryExchange"

But when I check the documentation (?Jib.Contract) it says the "primaryExchange" is a valid keyword.

Could you please emphasize how to state the primary exchange?

Thank you!

Unable to parse data. java.lang.NumberFormatException: For input string

I get this error from IB server after calling Jib.Requests.reqRealTimeBars(ib, 2, Jib.Contract(;conId=544894145756509053,exchange="SMART") , 5, "TRADES", true)

Error: 2 320 Erreur de lecture de la demande.Message id 2.  Unable to parse data. java.lang.NumberFormatException: For input string:  "544894145756509053" 

Versions :
IB gateway :
Build 981.2r, Feb 10, 2021 10:36:16 AM
Java Version: 1.8.0_152, OS: Linux (amd64, 5.4.101-1-MANJARO)

Jib
[f310f2d2] Jib v0.11.1 https://github.com/lbilli/Jib.jl#master

Integration with Rocket.jl

hi,

this looks like an excellent package, thanks for putting this together. for those of us who are new to Julia, from python, could you please illustrate an example of how to integrate this with Rocket.jl?

thanks

julia noob needs a little help with Jib asynch

Hi there
thanks SO MUCH for doing this, you've saved me a LOT of time. I'm coming to this from a python perspective and just learning julia. In python I get my IB data using a great framework called https://ib-insync.readthedocs.io/api.html and I use the asynch approach (see below for example) I don't really see how to achieve this using your framework and julia.

I can connect, run your examples in the REPL so I can see how to get contract information into a structure. So I know my system is set up to get information from IB but that's for a single data request, I need to stream data for a trading session.

It's just the asynch event loop I am having difficulty with.
how do I post reqMktdata requests as below
and
how do I consume the results?

I can code, in julia, how to set up the symbols to be requested and how to structure the contract parameters. Everything but the most important part, how to process the loop.

Can you give me some pointers please?

`
import asyncio

import ib_insync as ibi

class App:

async def run(self):
    self.ib = ibi.IB()
    with await self.ib.connectAsync():
        contracts = [
            ibi.Stock(symbol, 'SMART', 'USD')
            for symbol in ['AAPL', 'TSLA', 'AMD', 'INTC']]
        for contract in contracts:
            self.ib.reqMktData(contract)

        async for tickers in self.ib.pendingTickersEvent:
            for ticker in tickers:
                print(ticker)

def stop(self):
    self.ib.disconnect()

app = App()
try:
asyncio.run(app.run())
except (KeyboardInterrupt, SystemExit):
app.stop()

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.