Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Julia version / enhancements #8

Closed
bakuku111 opened this issue Jul 21, 2020 · 6 comments
Closed

Compatibility with Julia version / enhancements #8

bakuku111 opened this issue Jul 21, 2020 · 6 comments

Comments

@bakuku111
Copy link

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

@lbilli
Copy link
Owner

lbilli commented Jul 21, 2020

Thanks for the feedback.
The package should work on Julia > 1.2, however it's only tested on linux.

  • check_all() shouldn't block. The case bytesavailable==0 and status==3 indicates that data are waiting to be read and in fact the execution proceeds and reads them. On the other hand, status==8 indicates that the queue is empty and an attempt to read would block.

  • Base.show() is purely a convenience to make it simple to inspect a struct by typing it in the terminal. It can be muted by terminating lines with semicolons or it can be redefined altogether.

In any case, it's hard to be more specific without minimal working examples that reproduce the issues.
Also infos about the operating system and whether this happens from within an IDE or a plain terminal session would be useful.

Regarding the enhancements:

  • EET looks like a nice addition and I'll add it in the next itaration.
  • The keyword arguments constructor is mostly for illustrative purposes. There are many different use cases and it's really straightforward to define customized ones.
  • Asynchronous messaging and the fact that requests can have zero, one, many and unlimited (in case of subscriptions) responses make it not a trivial task and it's beyond the scope of this package, which aims to be a mere implementation of the API and be the base for more complex applications.

@bakuku111
Copy link
Author

bakuku111 commented Jul 21, 2020

Thanks for quick response! Details on the system:
OS: Windows 10

julia> versioninfo()
Julia Version 1.4.2
Commit 44fa15b150* (2020-05-23 18:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_DEPOT_PATH = C:\Users\x\.juliapro\JuliaPro_v1.4.2-1;C:\Users\x\AppData\Local\JuliaPro-1.4.2-1\Julia-1.4.2\local\share\julia;C:\Users\x\AppData\Local\JuliaPro-1.4.2-1\Julia-1.4.2\share\julia
  JULIA_EDITOR = "C:\Users\x\AppData\Local\JuliaPro-1.4.2-1\app-1.47.0\atom.exe"  -a
  JULIA_NUM_THREADS = 2
  JULIA_PKG_SERVER = pkg.juliacomputing.com

Working example script for issues 1 and 2:

using Jib
ib = Jib.connect(7497, 1)
data, wrap = Jib.simple_wrap()
contract = Jib.Contract(conId=272093,
                        symbol="MSFT",
                        secType="STK",
                        exchange= "SMART",
                        currency="EUR")
# Base.show() returns in REPL contract details
println("do something")
# Base.show() returns in REPL contract details (again)
Jib.reqFundamentalData(ib, 1, contract, "ReportsFinStatements")
# Base.show() returns in REPL contract details (again)
Jib.check_all(ib,wrap)
# Base.show() returns in REPL contract details (again)
# Check_all processes messages but stucks on execution and block the whole program
println("do something again")

@lbilli
Copy link
Owner

lbilli commented Jul 21, 2020

Looks like you are using JuliaPro, with which I'm not familiar and I'll have to investigate farther.
show() is admittedly rather rough and might need improvement.

Maybe you could try plain Julia in a terminal and see if it behaves the same way.

Also, in the meantime, you could try something like this:

using Jib

# disable show()
function Base.show(io::IO, ::Union{Jib.Contract,Jib.ContractDetails,Jib.Order,Jib.OrderState,Jib.ScannerSubscription}) 
end

ib = Jib.connect(7497, 1);
data, wrap = Jib.simple_wrap();
# with this, you shouldn't use Jib.check_all() at all
Jib.start_reader(ib, wrap);

contract = Jib.Contract(symbol="MSFT", 
                        secType="STK", 
                        exchange="SMART", 
                        currency="USD");
# send requests
Jib.reqFundamentalData(ib, 1, contract, "ReportsFinStatements")
Jib.reqContractDetails(ib, 2, contract)

# check results
data[:cd]
data[:fundamental]

@bakuku111
Copy link
Author

bakuku111 commented Jul 22, 2020

Thanks for your suggestion and provided workaround. start_reader() works fine but does not provide as much control as check_all().
I have tested my previous example in pure Julia (command-line). Here are the results:

  1. check_all() is still blocking and requires manual interruption.
  2. Base.show() is not causing the same behavior as before. Looks that is only happening when working with IDE.

@lbilli
Copy link
Owner

lbilli commented Jul 22, 2020

I checked and it seems that on Windows Sockets behave slightly differently and check_all() indeed blocks.
I created #9 to track the issue.

@bakuku111
Copy link
Author

Thank you! I will close this thread for now as you've addressed all of my questions. 👍

lbilli added a commit that referenced this issue Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants