Closed bakuku111 closed 4 years ago
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:
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")
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]
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.
I checked and it seems that on Windows Sockets
behave slightly differently and check_all()
indeed blocks.
I created #9 to track the issue.
Thank you! I will close this thread for now as you've addressed all of my questions. 👍
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