开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: Trail price movement callbacks?

 

Since no one replied to your question, I will provide my (possibly outdated) contribution.

Several years ago, I was also interested in monitoring the updated price of trailing (stop) orders.

I confirmed that the "orderStatus" callback was called periodically for these order types but unfortunately no price updates were being issued.

I contacted IB which provided the usual response: "it is like this by design".

So I gave up.

I cannot confirm if this unfortunate limitation is still in place.

Hope this helps.

--


Re: 10326 - OCA group revision is not allowed

 

开云体育

After upgrading, the api and tws I ran into similar problems, but they all are fixable. Here's my original post:

/g/twsapi/topic/java_tws_api_972_03_too_old/109159281

In the old situation, I always updated an oca child order with the same parameters, including the parentId . That no longers works. And the error message is actually helpful ;-) Leave parentId out when updating a child oca order when the parent has already been triggered. Worked for me.

Good luck, regards,
Raoul



On 13-11-2024 17:19, Andrew Flis via groups.io wrote:

I would like to confirm that IBKR has some serious problems with software releases. 10.30.1o released Oct 24 is garbage. I tried to create a simple bracket order (through API) and once the parent order was filled I tried to modify the stop order and later the target order. Both attempts failed with error 135: parent order not found. I created a ticket. Two days later IBKR released 10.30,1p with the same results. I downloaded 10.23, which works and sent logs from both 10.30.1p and 10.23 repeating the same bracket order test . I was advised not to use 10.30.1p. On Nov 12 10.30.1q was released. I managed to to modify stop order in the bracket order once. Any other attempt after that failed with the same error.. It shows how little care and virtually no testing takes place at IBKR (bracket order is so basic one) . How long they are going to be in business !?
One lesson to be learned: keep the working version in a separate directory, test new software release in paper account before using it in your live account.Here is the link to 10.23 which is not going to be overwritten by automatic software update.
?
?
?
[Moderator Addition]
Please not that TWS 10,23 is available for download only not IBKR.


Re: 10326 - OCA group revision is not allowed

 

I would like to confirm that IBKR has some serious problems with software releases. 10.30.1o released Oct 24 is garbage. I tried to create a simple bracket order (through API) and once the parent order was filled I tried to modify the stop order and later the target order. Both attempts failed with error 135: parent order not found. I created a ticket. Two days later IBKR released 10.30,1p with the same results. I downloaded 10.23, which works and sent logs from both 10.30.1p and 10.23 repeating the same bracket order test . I was advised not to use 10.30.1p. On Nov 12 10.30.1q was released. I managed to to modify stop order in the bracket order once. Any other attempt after that failed with the same error.. It shows how little care and virtually no testing takes place at IBKR (bracket order is so basic one) . How long they are going to be in business !?
One lesson to be learned: keep the working version in a separate directory, test new software release in paper account before using it in your live account.Here is the link to 10.23 which is not going to be overwritten by automatic software update.
?
?
?
[Moderator Addition]
Please not that TWS 10,23 is available for download only not IBKR.


Re: How are built the Continuous future data retrieved with secType = CONTFUT ?

 

A watchout with ratio adjustments (RA):
- useful when calculating % returns, roll yields or other multiplicative measures
- resulting in different signals when running the same ATS on it again (backtesting results will differ)
?
For completeness, one can calculate rollover also like this:
- by date no adjustment
- by volume (front < back) no adjustment
- by date backadjusted BA (front settlement - back settlement)
- by volume backadjusted BA (front settlement - back settlement)
?
The BA data (not available on TWS) is suitable for additive measures (net profit, draw down) and remains stable for backtesting (up to a constant offset). The ratio data is suitable only for multiplicative measures (returns, standard deviation of returns, TWRR/CAGR, etc.) - you cannot add profit from trade A in $ with profit from trade B a few months ago. Also, obviously one cannot have a buy on one side of an RA and the corresponding sale on the other side (this is true for BA also).


Re: downlod historical SH data, Proshares Short S&P 500, before the split

 

Yes, a time is required. What worked best for me is this:
  • On the command line for my Historical Data Downloader, dates are specified as YYYYMMDD and interpreted in the instrument's time zone
  • The tool uses reqContractDetails() to get the most current contract for the instrument and extracts the instrument's time zone from that contract
  • It them advances end time to the next midnight (in the instruments timezone). For example, an end date of 20241112 becomes "20241113 00:00:00 US/Eastern" for stocks or NYC trades instruments, while it (automatically) becomes "20241113 00:00:00 US/Central" for any Chicago traded contract (and so on)
  • IBKR often uses 23:59:59 the day of (e.g. one second before the next midnight) but actual midnight feels "cleaner", was less code, and has worked for me perfectly for years.
闯ü谤驳别苍
?
On Tue, Nov 12, 2024 at 03:37 PM, <supis31@...> wrote:

I think I have to provide a time, otherwise I get an error:
Error 10314, reqId 13: End Date/Time: The date, time, or time-zone entered is invalid. The correct format is yyyymmdd hh:mm:ss xx/xxxx where yyyymmdd and xx/xxxx are optional. E.g.: 20031126 15:59:00 US/Eastern ?Note that there is a space between the date and time, and between the time and time-zone. ?If?
no date is specified, current date is assumed. If no time-zone is specified, local time-zone is assumed(deprecated). ?You can also provide yyyymmddd-hh:mm:ss time is in UTC. Note that there is a dash between the date and time in UTC notation., contract: Stock(symbol='SPY', exchange='SMART', primaryExchange='ARCA', currency='USD')


Re: downlod historical SH data, Proshares Short S&P 500, before the split

 

SH before and after the reverse split are two different instruments. ProShares, for example, indicates the SH CUSIPs as 74347B425 (before) and 74349Y753 (after) and, consequently, IBKR changed the conid for the SH contracts as well:
  • from 236687911 for 20241106 and before
  • to now 738523410 for 20241107 and after

I am not sure what exactly your "Stock()" function does, but if it returns a contract with conid 236687911, that contract will now be rejected even for data requests for time frames when it was the correct contract. At this point (20241107 and after) only contracts for SH with conid 738523410 will work.

But those new contracts describe an instrument with 1/4th of the shares than before the reverse split. I guess that is why that contract reports prices from before 201107 at 4x the actual price for that day. And the volume is probably be reported at 1/4 of the actual volume.

闯ü谤驳别苍

?
reqHistoricalData:SH:20241113 00:00:00 US/Eastern:3:YEAR:_1_day:TRADES:true:false
?
On Tue, Nov 12, 2024 at 12:23 PM, <supis31@...> wrote:

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: downlod historical SH data, Proshares Short S&P 500, before the split

 

I think I have to provide a time, otherwise I get an error:
Error 10314, reqId 13: End Date/Time: The date, time, or time-zone entered is invalid. The correct format is yyyymmdd hh:mm:ss xx/xxxx where yyyymmdd and xx/xxxx are optional. E.g.: 20031126 15:59:00 US/Eastern ?Note that there is a space between the date and time, and between the time and time-zone. ?If?
no date is specified, current date is assumed. If no time-zone is specified, local time-zone is assumed(deprecated). ?You can also provide yyyymmddd-hh:mm:ss time is in UTC. Note that there is a dash between the date and time in UTC notation., contract: Stock(symbol='SPY', exchange='SMART', primaryExchange='ARCA', currency='USD')


  • Historical data is obtained from the the TWS via the??function. Every request needs:

    • tickerId, A unique identifier which will serve to identify the incoming data.
    • contract, The??you are interested in.
    • endDateTime, The request's end date and time (the empty string indicates current present moment).
    • durationString, The amount of time (or?) to go back from the request's given end date and time.
    • barSizeSetting, The data's granularity or?
    • whatToShow, The type of data to retrieve. See?
    • useRTH, Whether (1) or not (0) to retrieve data generated only within Regular Trading Hours (RTH)
    • formatDate, The format in which the incoming bars' date should be presented. Note that for day bars, only yyyyMMdd format is available.
    • keepUpToDate, Whether a subscription is made to return updates of unfinished real time bars as they are available (True), or all data is returned on a one-time basis (False).?Available starting with API v973.03+ and TWS v965+. If?True, and endDateTime cannot be specified.


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.


Re: 10326 - OCA group revision is not allowed

 

you ever figure out if this is possible?


Re: IB_apps github project

 

*at gmail com.


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

 

On Thu, Nov 7, 2024 at 07:26 PM, Marluv wrote:

check your architecture this might be an x64 vs x86 issue. Don't remember much about C++ but this might be a libbid.lib architecture issue.


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.