lbilli / Jib.jl

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

Error message "UndefVarError: Execution not defined" #3

Closed jpuser2 closed 4 years ago

jpuser2 commented 4 years ago

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()
lbilli commented 4 years ago

In general, this package doesn't export any name. In order to use any function or type defined therein you can either:

So in your case you can either use Jib.Execution or add using Jib: Execution somewhere earlier in the file.

lbilli commented 4 years ago

There's also a third option: in fact in Julia there's really no benefit in using type annotations in function definitions. This is equally fine:

 execDetails = function(reqId, contract, execution)
                 d[:ex_con] = contract
                 d[:execution] = execution
                 println("ExecDetails: $reqId")
               end
jpuser2 commented 4 years ago

I used the third option mentioned above. Works very well indeed. My issue is solved. Thank you very much.