Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
- Twsapi
- Messages
Search
Re: downlod historical SH data, Proshares Short S&P 500, before the split
开云体育I tried it with both dates and received data.? I didn't use the time, but not sure that should cause any issue.? When I ran it for the 6th, it shows up to and including 2024-11-05 close = 44.616 With the 7th it adds 2024-11-06 close = 10.639 Do you need to specify the time? I also noticed that I was using rth=0, so Inswitched that and I now get close = 42.564 for the 6th. Odd now I don't see the $10 price... If I switch RTH = 0 then I see the $10 price but only on the 6th. Why if there was a 1:4 split is it showing $42 prices again after? -------- Original message -------- From: "supis31 via groups.io" <supis31@...> Date: 2024-11-12 10:23 a.m. (GMT-08:00) Subject: [TWS API] downlod historical SH data, Proshares Short S&P 500, before the split Hi,
?
When I'm trying to download the close prices with endDate 2024-11-07 everything is fine:
?
? ? ticker = "SH"
? ? contract = Stock(ticker, 'SMART', 'USD', primaryExchange = 'ARCA')
? ? bars = ib.reqHistoricalData(contract, endDateTime='20241107 15:59:00 US/Eastern', durationStr='3 Y', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? barSizeSetting='1 day', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? whatToShow='TRADES', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? useRTH=True) ?
But when I change the date to 2024-11-06 i get this:
Error 162, reqId 24: Historical Market Data Service error message:Unknown contract, contract: Stock(symbol='SH', exchange='SMART', primaryExchange='ARCA', currency='USD') ?
It must have something to do with the recent reverse split ?
|
downlod historical SH data, Proshares Short S&P 500, before the split
Hi,
?
When I'm trying to download the close prices with endDate 2024-11-07 everything is fine:
?
? ? ticker = "SH"
? ? contract = Stock(ticker, 'SMART', 'USD', primaryExchange = 'ARCA')
? ? bars = ib.reqHistoricalData(contract, endDateTime='20241107 15:59:00 US/Eastern', durationStr='3 Y', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? barSizeSetting='1 day', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? whatToShow='TRADES', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? useRTH=True) ?
But when I change the date to 2024-11-06 i get this:
Error 162, reqId 24: Historical Market Data Service error message:Unknown contract, contract: Stock(symbol='SH', exchange='SMART', primaryExchange='ARCA', currency='USD') ?
It must have something to do with the recent reverse split ? |
Re: How are built the Continuous future data retrieved with secType = CONTFUT ?
After a loto of time, IB added an explanation on this topic on the online guide, the link is:
?
?
Read the section:
?
Generate Normalized Historical Data Series for Continuous Futures?
But this explanation has been added following my question to the assitance
?
I hope it will be useful to many.
|
Re: 10326 - OCA group revision is not allowed
I believe this is a bug that occurs in TWS 10.30+
I see this message when trying to modify the limit or stop price of an OCA order in TWS 10.30+; same code works fine in TWS 10.19.
TWS log shows that there is no OCA group revision.
There is also a related error ("OCA handling method mismatch") which (I think) occurs when submitting dependent OCA orders (again, only TWS 10.30+)
OCA orders are really messed up in 10.30+, and I have an IB ticket that TWS API support is investigating (ticket #804191, if you would like to contribute). |
Trail price movement callbacks?
I dont think this exists but wanted to check with the group before giving up.?
?
I'm trying to record movements of the stop price on a trailing order, so I can chart the movement of the floor price and understand how close the price is to the floor at any given time.?
?
I dont see any relevant events in the order status events, does this info exist?
?
thank you. |
IB_apps github project
I created a GitHub project for my python code that works with the ibapi.
?
To give an insight to whether it may be useful to you I made an accompanying youtube video that can be found here:
?
It is still very much a work in progress and I am still working on fixing bugs improving stability, usage is at one's own risk (if you understand this and want to save some time, the introduction of its functionality starts at 3:25). But now that most things are somewhat up and running I figured I might as well share it to see if I can find others that are interested in it. Especially because I realized I need some motivation to work on making it more stable and adding some automated testing to ensure stability of future versions.
?
The project itself can be found here.
?
If you have questions, remarks or want to discuss something, feel free to message me at: vriesdephilip@... |
Re: C++ - TWS API - Connection Closed Handling
I had a side discussion with Eitan but I think it is useful to explain the change made on the C++ API that fixes the bug reported in this thread: ? /g/twsapi/message/51775
?
The error that Eitan talks about is caused by the client trying to read or write from/to a closed socket. The socket can be closed by a call to eDisconnect() or it could be by an unexpected TWS shutdown.
?
Without going into all the details explained in the linked thread, the basic problem in the old API versions is that the EReader thread never shut down due to bad thread management. The thread just hung in a never ending loop. The only way to shut it down was to delete the EReader. Also the consequence of this is that the EWrapper callback function "closedConnection()" was never called.
?
The thread management has been fixed a while back and his been in the "LATEST" releases for some time. This new revision will call "closedConnection()" when a socket is closed (either by user or due to TWS shutdown, etc.) so that the client can handle the shutdown gracefully.?
?
This means that the proposed solution by Vadim below is not the correct one as what you are basically doing is trying to write and read from a closed socket which results in the said error. The correct way is to handle the EWrapperImpl callback.
?
Note that this fix is only applicable to the C++ code. I cannot say if there is a similar bug in the Java, Python, etc. APIs. However, the description from IB at the bottom of this documentation page would indicate that this code may be broken in other languages too. ?
?
Note: I did ask for the documentation to be updated to reflect this fix but it has not been done. |
Re: Visual Studio 2022 and C++ TWS API 10.32
OKAY I FIXED IT.
?
?WHO EVER READS THIS AND WANTS TO COMPILE WITH VS 2022 AND 10.32
?
HERE ARE THE STEPS I USED TO GET IT TO WORK
?
1. Try compiling the "TestCppClient\Debug\TestCppClientStatic.exe "? first. I think all libs are embedded in the .EXE. Bigger file but who cares.
?
2. YOU MUST USE ONLY THE VISUAL STUDIO COMMAND
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
?
TO COMPILE THE (libbid.lib) :
nmake -fmakefile.mak CC=cl CALL_BY_REF=0 GLOBAL_RND=0 GLOBAL_FLAGS=0 UNCHANGED_BINARY_FLAGS=0
del *.obj ?
Only then it will compile. I tried using older versions from 2019 of NMAKE and it failed!! I tried different toolsets. All failed to compile the floating point library from intel
?
3. YOU MUST SWITCH CONFIGURATION MANAGER TO (PLATFORM WIND32) ITS SET TO X64 BY default AND IT WILL NOT COMPILE. YOU WILL BE MISSING SOME METHODS for Floating.obj
?
?
?
THANK YOU
?
?
?
?
?
? |
Re: Visual Studio 2022 and C++ TWS API 10.32
Okay I followed the TEXT document (NOT FOUND IN THE BETA DONWLOAD) .
?
I was able to use NMAKE and compile the floating point library called (libbid.lib)
?
I then placed the libbid.lib in my TestCppClientStatic folder and hit rebuild.
?
Now the error message is different:
?
?
Build started at 10:19 PM...
1>------ Build started: Project: TestCppClientStatic, Configuration: Debug x64 ------ 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __bid64_add referenced in function "public: static unsigned __int64 __cdecl DecimalFunctions::add(unsigned __int64,unsigned __int64)" (?add@DecimalFunctions@@SA_K_K0@Z) 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __bid64_sub referenced in function "public: static unsigned __int64 __cdecl DecimalFunctions::sub(unsigned __int64,unsigned __int64)" (?sub@DecimalFunctions@@SA_K_K0@Z) 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __bid64_mul referenced in function "public: static unsigned __int64 __cdecl DecimalFunctions::mul(unsigned __int64,unsigned __int64)" (?mul@DecimalFunctions@@SA_K_K0@Z) 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __bid64_div referenced in function "public: static unsigned __int64 __cdecl DecimalFunctions::div(unsigned __int64,unsigned __int64)" (?div@DecimalFunctions@@SA_K_K0@Z) 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __bid64_from_string referenced in function "public: static unsigned __int64 __cdecl DecimalFunctions::stringToDecimal(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?stringToDecimal@DecimalFunctions@@SA_KV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __bid64_to_string referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl DecimalFunctions::decimalToString(unsigned __int64)" (?decimalToString@DecimalFunctions@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z) 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __bid64_to_binary64 referenced in function "public: static double __cdecl DecimalFunctions::decimalToDouble(unsigned __int64)" (?decimalToDouble@DecimalFunctions@@SAN_K@Z) 1>TwsSocketClientStatic.lib(Decimal.obj) : error LNK2019: unresolved external symbol __binary64_to_bid64 referenced in function "public: static unsigned __int64 __cdecl DecimalFunctions::doubleToDecimal(double)" (?doubleToDecimal@DecimalFunctions@@SA_KN@Z) 1>libbid.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64' 1>E:\Creation\TWS_API\samples\Cpp\TestCppClient\x64\Debug\TestCppClientStatic.exe : fatal error LNK1120: 8 unresolved externals 1>Done building project "TestCppClientStatic.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ========== ========== Build completed at 10:19 PM and took 00.673 seconds ========== ?
?
?
?
The compiler finds the library but a few methods are missing from the library
?
Where did I go wrong?
?
? |
Re: C++ - TWS API - Connection Closed Handling
I tried to reach out to you individually to send me your code as I cannot replicate the test you are doing with TestCppClient example. The example code connects and disconnects rapidly 50 times in a loop so how did you modify the code to stay connected and make your "disconnect" manually from TWS?
?
Code related to the EReader & EClientSocket was changed a few revisions ago to fix a bug with the hanging of a thread when an unexpected disconnect occurred. This error had been there since the beginning of the API so it is possible that some workarounds had been built into the source of the examples which are no longer needed or actually cause problems.
?
Anyway, if you could share how you did your disconnect test I will try to replicate it and check it.
?
If you want to send a? source file I suggest you send it directly to me rather than posting it. |
Re: ValueError: could not convert string to float: b'\xe2\x88\x9e'
I'd try to figure out, where those bytes come from. This feels like some memory corruption inside the client and it is unlikely that they came from TWS/IBGW through the socket connection (though not impossible). The message processing is in the middle of reading the "open" bar field from the historical data bar message. At that point, there should only be 7bit ASCII string values in the message such as the digit characters and other number related characters such as [0-9.+=E] (plus the byte value 0 to indicate the end of each field). There should definitely be no Unicode characters and specifically the "unlimited" sign would be out of place. A couple things come to mind:
闯ü谤驳别苍 ? ?
On Thu, Nov 7, 2024 at 07:38 AM, bespalex wrote:
|
Re: ValueError: could not convert string to float: b'\xe2\x88\x9e'
you can catch exceptions in threads without modifying the ibapi source code by using Python's threading.excepthook function
?
On Thu, Nov 7, 2024 at 01:02 AM, Cash wrote:
|
ValueError: could not convert string to float: b'\xe2\x88\x9e'
Using Python api -
?
From time to time i am getting following error and it stops the api thread completely. I can't catch this exception in Main thread. This happens with HistoricalData callback. It is somehow receiving inifinity character as i understand.
Is there a way to catch this exception without updating API source code?
?
? File "xxx/ibapi-10.30.1-py3.9.egg/ibapiibapi/client.py", line 398, in run
? File "xxx/ibapi-10.30.1-py3.9.egg/ibapi/decoder.py", line 1506, in interpret ? File "xxx/ibapi-10.30.1-py3.9.egg/ibapi/decoder.py", line 616, in processHistoricalDataUpdateMsg ? File "xxx/ibapi-10.30.1-py3.9.egg/ibapi/utils.py", line 135, in decode ValueError: could not convert string to float: b'\xe2\x88\x9e'
?
?
thanks, |
Re: Undocumented error codes: 10089 and 10091 ...
bdcoder
Thanks again 闯ü谤驳别苍 for your help and support, it is greatly appreciated.
?
I will get my client to check their market data subscriptions again.? We have also put the question out directly to IB support (several days ago), but have not had any responses.
?
Too bad TWS is not open source, we could probably find answers to a great many questions by just following the code that produces these (sometimes undocumented) errors.
?
Thanks again! |
to navigate to use esc to dismiss