¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Date

Re: TWS API Linux - Segmentation fault - __bid64_to_string

 

I strongly recommend to use a containerized setup for tws/ib-gateway in wsl.
If you chose ubuntu as host for wsl, then lxd (sudo snap install lxd) should do it.

There is an automated setup for a trading-environment in a lxd-container:?
If needed, you can just copy the instance to a cloud-instance or a ?real? ubuntu-machine.

hartmut


Re: TWS API Linux - Segmentation fault - __bid64_to_string

 

Only reason really have windows installed on this machine is the wife and kids use it - however - running a few strategies on python / c++ - cpu usuage was about 8%. So using linux here on VM maybe wont slow too much BUT there is a whole GUI with ubuntu to the point i dont think my wife and kids would get lost for general browing of the internet. Dual boot maybe - lets see if i can get this whole thing up and running on linux.?


Re: How is auction price calculated?

 

¿ªÔÆÌåÓý

Just thought it worth adding that different exchanges will employ different methods for calculating the auction price given the state of the order book. If you want to know the exact method you will need to look it up for each exchange individually on the exchanges website. Usually they publish the method somewhere.?

Also, some exchanges don¡¯t publish the auction price, volume, imbalance, or some combination, for general retail users (as near as I can tell). If they do publish for retail users then Level 1 data for the exchange should give you access.


On 9 Jan 2023, at 3:33 am, cactus74@... wrote:

?IB does not calculate it, it is disseminated by the exchange. Yes, order imbalance will do it.
?


Re: TWS API Linux - Segmentation fault - __bid64_to_string

 

Thanks for looking into this with me.?
root@flare9x:~/IBJts/source/cppclient/client/lib# g++ -dumpmachine
x86_64-linux-gnu
?

I just recently installed WLS as per instruction from ubuntu - they have you download it from Microsoft store. I can check to make sure its as intended.?

When I installed everything inside the WSL, ubuntu?

sudo apt-get update
sudo apt-get install -y xterm or package here

Well I got TWS offline version installed?
installed javaFX and?xterm
installed and configured IBC?
TWS - current/latest version works OK when loaded?
TWS Offline works just fine running it via IBC?
using IDE?KDevelop
I can make a simple hello_world.cpp and run it with g++?

I installed?g++-multilib
root@flare9x:~/IBJts/source/cppclient/client/lib# dpkg -s gcc-multilib
Package: gcc-multilib
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 8
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@...>
Architecture: amd64


its amd64 architecture?

I mean I thought i'd give 32 bit a go since the same code was running OK on windows when i did that, it seemed like the libraries that came with the linux version are setup for 64bit vs 32bit which is fine.?

Ok leaning towards VM and ubuntu.

One last check of WSL install.?


Re: TWS API Linux - Segmentation fault - __bid64_to_string

 

Do you have the 64-bit versions of gcc and the standard libs installed via apt?? Also, I believe that there is something wrong with WSL somehow.? Possibly your specific setup (wrong libs installed?) or possibly some issue with how the libraries are getting loaded (maybe you need some sort of WSL specific thing).? No idea but I strongly suggest you stop trying to get WSL to work.? Unless you are professional C++ dev and are pretty good at it, it is going to be tough going for you.? Just download a Ubuntu VM and fire up VMWare or some other VM and run Ubuntu properly.? Or run it natively as a dual boot.? Or run Ubuntu inside of Docker.? Trying to make it work via WSL is just making your life difficult for no real good reason.

Hunter


On Sunday, January 8, 2023 at 02:49:18 PM PST, <bannerman1985@...> wrote:


Yeah - loading project file in Microsoft visual studio - it defaults to win32. On windows I couldn't get it to compile on 64bit.?
I tried both 32 and 64bit here - indeed running 32bit on this architecture - threw the lib error.

Context of the lib directory?
```
root@flare9x:~/IBJts/source/cppclient/client/lib# ls
eula.txt? libbid.a? libbid.so
```

When i run objdump -f libbid.a

```
root@flare9x:~/IBJts/source/cppclient/client/lib# objdump -f libbid.a
In archive libbid.a:
?
bid64_acos.o:? ? ?file format pe-x86-64
architecture: i386:x86-64, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x0000000000000000
?
?
bid64_acosh.o:? ? ?file format pe-x86-64
architecture: i386:x86-64, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x0000000000000000
```

When i run objdump -f libbid.so

```
root@flare9x:~/IBJts/source/cppclient/client/lib# objdump -f libbid.so
?
libbid.so:? ? ?file format pei-x86-64
architecture: i386:x86-64, flags 0x0000013b:
HAS_RELOC, EXEC_P, HAS_DEBUG, HAS_SYMS, HAS_LOCALS, D_PAGED
start address 0x0000000489e94a60
```



Re: TWS API Linux - Segmentation fault - __bid64_to_string

 

Yeah - loading project file in Microsoft visual studio - it defaults to win32. On windows I couldn't get it to compile on 64bit.?
I tried both 32 and 64bit here - indeed running 32bit on this architecture - threw the lib error.

Context of the lib directory?
```
root@flare9x:~/IBJts/source/cppclient/client/lib# ls
eula.txt? libbid.a? libbid.so
```

When i run objdump -f libbid.a

```
root@flare9x:~/IBJts/source/cppclient/client/lib# objdump -f libbid.a
In archive libbid.a:
?
bid64_acos.o:? ? ?file format pe-x86-64
architecture: i386:x86-64, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x0000000000000000
?
?
bid64_acosh.o:? ? ?file format pe-x86-64
architecture: i386:x86-64, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x0000000000000000
```

When i run objdump -f libbid.so

```
root@flare9x:~/IBJts/source/cppclient/client/lib# objdump -f libbid.so
?
libbid.so:? ? ?file format pei-x86-64
architecture: i386:x86-64, flags 0x0000013b:
HAS_RELOC, EXEC_P, HAS_DEBUG, HAS_SYMS, HAS_LOCALS, D_PAGED
start address 0x0000000489e94a60
```



Re: Standard deviation for strike

 

¿ªÔÆÌåÓý

I don't understand what you mean by "std deviation of strike". The underlying (i.e. stock price) has a std deviation, so the color coding just shows how far, in terms of std deviation, the underlying would need to move for the option to become in the money. I believe your formula is correct assuming you start from annual IV.
On Jan 8, 2023 at 7:32 AM -0800, leonid.dmitricenko via groups.io <leonid.dmitricenko@...>, wrote:

Hello! I want to ask how to calculate standard deviation for strike which is shown in option chains as popup on mouse cursor hover on strike:
<dummyfile.0.part>

I found that 1 standard deviation = stock price * volatility * square root of days to expiration/365. But in case of strike STD, stock price should be replaced with strike and what volatility should be used? IV?

Thanx


Re: TWS API Linux - Segmentation fault - __bid64_to_string

 

The static library to which you are linking is compiled for a different CPU architecture (specifically it is compiled for x86-64):
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid64_string.o)' is incompatible with i386 output

I suspect that on Windows you have versions of libbid.a compiled for 32-bit (why you are using 32-bit is confusing for me, I suggest you switch to 64-bit).? On Linux use
'objdump -f FILE_NAME' to print out the CPU architecture of a library.? You must make them match.? Also, that seg fault looks like a stack smash error which can be caused by a mismatch of assembler CPU targets between libraries.? Also, if you are using WSL, good luck, it isn't a very stable platform.? I suggest you just run a VM instead of using WSL or just using Ubuntu via dual boot.

Hunter


On Sunday, January 8, 2023 at 01:44:51 PM PST, bannerman1985@... <bannerman1985@...> wrote:


Running ubuntu.?

Running Cpp sample client out of the box.

I receive a segmentation fault.

0x00005555555efba6 in __bid64_to_string ()

Have sourced this function to client file to?Decimal.h

extern "C" void __bid64_to_string(char*, Decimal, unsigned int*);

This may have something to do with the floating point library that the API documentation mentions: Intel? Decimal Floating-Point Math Library

I have checked if this is installed on my ubuntu version, using WSL Ubuntu 20.04.05

libintelrdfpmath-dev/now 2.0u2-4 amd64 [installed,local]

Looking at the makefile:

CXXFLAGS=-pthread -Wall -Wno-switch -Wpedantic -Wno-unused-function -std=c++11
ROOT_DIR=../../../source/cppclient
BASE_SRC_DIR=${ROOT_DIR}/client
INCLUDES=-I${BASE_SRC_DIR} -I${ROOT_DIR}
SHARED_LIB_DIRS=${BASE_SRC_DIR}
SHARD_LIBS=libTwsSocketClient.so
TARGET=TestCppClient

$(TARGET)Static:
    $(CXX) $(CXXFLAGS) $(INCLUDES) $(BASE_SRC_DIR)/*.cpp ./*.cpp $(BASE_SRC_DIR)/lib/libbid.a -o$(TARGET)Static

$(TARGET):
    $(CXX) $(CXXFLAGS) $(INCLUDES) ./*.cpp $(BASE_SRC_DIR)/lib/libbid.so $(SHARED_LIB_DIRS)/$(SHARD_LIBS) -o$(TARGET)

clean:
    rm -f $(TARGET) $(TARGET)Static *.o

The interesting part - I can compile the exact same code on Windows, VScode in win32.

I have tried to enforce 32bit with gcc. adding -m32.

When doing this compiler shows numerous complaints:

 1974 |  printf("Soft dollar tiers (%lu):", tiers.size());
      |                             ~~^     ~~~~~~~~~~~~
      |                               |               |
      |                               |               std::vector<SoftDollarTier>::size_type {aka unsigned int}
      |                               long unsigned int
      |                             %u

I commented out these functions which include %lu as do not need them in main application.

Compile again, this time we have errors with the librarys that are packaged with the TWS API - the Intel decimal floating point math library, these libs come with the original TWS installation and locate:

/source/cppclient/client/lib/libbid.a
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid64_string.o)' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid128_2_str_tables.o)' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid_decimal_data.o)' is incompatible with i386 output

win32 runs this just fine vscode.

running with ```gcc -m64``

Obtain seg fault again:

Thread 1 "TestCppClientSt" received signal SIGSEGV, Segmentation fault.
0x00005555555efba6 in __bid64_to_string ()
(gdb) bt
#0  0x00005555555efba6 in __bid64_to_string ()
#1  0x00007fffffffd940 in ?? ()
#2  0x00007fffffffd940 in ?? ()
#3  0x00007fffffffd940 in ?? ()
#4  0x00007fffffffd941 in ?? ()
#5  0x00007fffffffd940 in ?? ()
#6  0x00007fffffffd820 in ?? ()
#7  0x000055555555d5ff in std::iterator_traits<char*>::difference_type std::distance<char*>(char*, char*) ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Not sure what it could be at this point - WSL and running ubuntu on windows - that process manages memory? is ubuntu clashing with windows.

At this point - what else can I check / troubleshoot?

Thanks


TWS API Linux - Segmentation fault - __bid64_to_string

 

Running ubuntu.?

Running Cpp sample client out of the box.

I receive a segmentation fault.

0x00005555555efba6 in __bid64_to_string ()

Have sourced this function to client file to?Decimal.h

extern "C" void __bid64_to_string(char*, Decimal, unsigned int*);

This may have something to do with the floating point library that the API documentation mentions: Intel? Decimal Floating-Point Math Library

I have checked if this is installed on my ubuntu version, using WSL Ubuntu 20.04.05

libintelrdfpmath-dev/now 2.0u2-4 amd64 [installed,local]

Looking at the makefile:

CXXFLAGS=-pthread -Wall -Wno-switch -Wpedantic -Wno-unused-function -std=c++11
ROOT_DIR=../../../source/cppclient
BASE_SRC_DIR=${ROOT_DIR}/client
INCLUDES=-I${BASE_SRC_DIR} -I${ROOT_DIR}
SHARED_LIB_DIRS=${BASE_SRC_DIR}
SHARD_LIBS=libTwsSocketClient.so
TARGET=TestCppClient

$(TARGET)Static:
    $(CXX) $(CXXFLAGS) $(INCLUDES) $(BASE_SRC_DIR)/*.cpp ./*.cpp $(BASE_SRC_DIR)/lib/libbid.a -o$(TARGET)Static

$(TARGET):
    $(CXX) $(CXXFLAGS) $(INCLUDES) ./*.cpp $(BASE_SRC_DIR)/lib/libbid.so $(SHARED_LIB_DIRS)/$(SHARD_LIBS) -o$(TARGET)

clean:
    rm -f $(TARGET) $(TARGET)Static *.o

The interesting part - I can compile the exact same code on Windows, VScode in win32.

I have tried to enforce 32bit with gcc. adding -m32.

When doing this compiler shows numerous complaints:

 1974 |  printf("Soft dollar tiers (%lu):", tiers.size());
      |                             ~~^     ~~~~~~~~~~~~
      |                               |               |
      |                               |               std::vector<SoftDollarTier>::size_type {aka unsigned int}
      |                               long unsigned int
      |                             %u

I commented out these functions which include %lu as do not need them in main application.

Compile again, this time we have errors with the librarys that are packaged with the TWS API - the Intel decimal floating point math library, these libs come with the original TWS installation and locate:

/source/cppclient/client/lib/libbid.a
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid64_string.o)' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid128_2_str_tables.o)' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `../../../source/cppclient/client/lib/libbid.a(bid_decimal_data.o)' is incompatible with i386 output

win32 runs this just fine vscode.

running with ```gcc -m64``

Obtain seg fault again:

Thread 1 "TestCppClientSt" received signal SIGSEGV, Segmentation fault.
0x00005555555efba6 in __bid64_to_string ()
(gdb) bt
#0  0x00005555555efba6 in __bid64_to_string ()
#1  0x00007fffffffd940 in ?? ()
#2  0x00007fffffffd940 in ?? ()
#3  0x00007fffffffd940 in ?? ()
#4  0x00007fffffffd941 in ?? ()
#5  0x00007fffffffd940 in ?? ()
#6  0x00007fffffffd820 in ?? ()
#7  0x000055555555d5ff in std::iterator_traits<char*>::difference_type std::distance<char*>(char*, char*) ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Not sure what it could be at this point - WSL and running ubuntu on windows - that process manages memory? is ubuntu clashing with windows.

At this point - what else can I check / troubleshoot?

Thanks


Re: trouble linking twsapi

 

Ok I am having some seg fault issues as well running on ubuntu.?

I can compile the exact same code on windows, vscode,win32. The library there is different though.?

Did you ever find a resolution??


Re: trouble linking twsapi

 

Is there a direct place to file bugs with IBKR - checked github didnt see issues section open there.


Re: How is auction price calculated?

 

IB does not calculate it, it is disseminated by the exchange. Yes, order imbalance will do it.
?


Standard deviation for strike

 

Hello! I want to ask how to calculate standard deviation for strike which is shown in option chains as popup on mouse cursor hover on strike:

I found that 1 standard deviation = stock price * volatility * square root of days to expiration/365. But in case of strike STD, stock price should be replaced with strike and what volatility should be used? IV?

Thanx

?


Reading API Logfile

 

Is there any utility available for reading API logfile? Or any pointer on how to read these files?

Thanks


Re: Request Historical Data with Keep up to date set to true

 

Thanks again. Yes, that was the problem.


Re: Request Historical Data with Keep up to date set to true

 

I think you have led me to a solution. I am using an older version of the ewrapper from an older version of the API. I have been working in VS2015 just because it is what I had installed. I can't open the newer samples with it, so I am downloading a new version of Visual Studio. I have a slow internet connection, so it may be a while? before I can look and see for sure. Thanks for your help.


Re: IBKR API: ERROR -1 1100 Connectivity between IB and Trader Workstation has been lost.

 

They will definitely occur in case your internet connection is flaky. But We get them every night during the scheduled reset period (see )

Wednesday night we received
  • Message code 1100 at 23:17:37.220, 23:17:44.290, 23:17:49.284, 23:17:54.284, 23:18:00.200, 23:18:04.290, and 23:18:09.986
  • Message code 1102 at 23:18:19.154

All times are US/Central.

´³¨¹°ù²µ±ð²Ô


Re: IBKR API: ERROR -1 1100 Connectivity between IB and Trader Workstation has been lost.

 

Thank you ´³¨¹°ù²µ±ð²Ô
It occured during wednesday's night not during the weekend.
After investigation i think it was my internet connection at home during that night.
oto


Re: IBKR API: ERROR -1 1100 Connectivity between IB and Trader Workstation has been lost.

 

When do you experience the 1100 errors, oho? During the IBKR maintenance windows and on weekends?

Take a look at the section of the TWS API Reference Guide. At the top of that section you'll find a little more detail about connection errors.

When we receive 1100 errors, we shortly after that receive code 1102 "Connectivity between IB and TWS has been restored- data maintained." so that nothing really needs to be done. The connection between our clients and TWS./IBGW is never impacted so that the clients do not have to restart.

We have never seen code 1101 "Connectivity between IB and TWS has been restored- data lost.". In case your client gets this message code, simply resubmit the market data requests your client had active before error 1100.

´³¨¹°ù²µ±ð²Ô

On Thu, Jan 5, 2023 at 11:34 AM, <autotest890@...> wrote:

Hi,
i am testing the bracket order with ibkr api, it works fine but
during the test there was a connection problem then it cancels all orders.
I have to restart my python code manually.
How can we restart connection when an error 1100 occurs?
Thank you
oto


Re: Main app in new process vs new thread (Python)

 

On Thu, Jan 5, 2023 at 11:30 PM, GreenGreen wrote:

* * Good point about OS resources, but my knowledge of OS are so limited that it looks like Python path is a bit easier.

Yeah, well... give it time and that stuff will become obvious. I was just taking an educated guess but if you're really curious you can actually read through the Python code for multiprocessing . Look inside process.py and subsequently context.py to get the final word on exactly what's happening "under the hood". Have fun :-)