¿ªÔÆÌåÓý

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

Re: A couple of questions regarding the C++ Tws api client

 

It sounds like you are struggling with some of the concepts, Arthur. Such as how Orders may have Executions that become Trades and change the Account Position. If you have not done so yet, fire up TWS, do some manual trading and look at the various windows (orders, trades, account). Every major function in TWS has a corresponding set of requests and responses within TWS API.

TWS API is very flexible and you could envision a complex scenario where orders are placed by several clients and, unless you use IBGW for the connection with IBKR, manually through TWS. In order ro manage that correctly:
  • "API Orders" are those create automatically by one of your client apps via TWS API as opposed to orders created anually in TWS
  • If you have one client with clientId 0, it can see and manage orders that were placed manually in TWS
  • buddy pointed you to the Master Client, which can see all orders placed by other clients. You pick and configure the clientId within the API settings in TWS/IBGW
  • You can set the Master Client ID to "0" and give that client visibility to and manageability of orders placed by all clients and TWS

The and sections have more detail.

The C++ compile issue you are experiencing is going on for a while (since the introduction of the Decimal data type during the transition of V9 to V10) and you can find many posts about this in our forum.

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


On Fri, Jul 28, 2023 at 11:22 AM, <aSchwenk64@...> wrote:

I try my approach with a set Master Client ID. This sounds interesting.

Concerning the bug: If you try to compile the code under linux, you will get errors because the attached libbid.a and so are in Windows format . One need to replace it with the linux version.


Re: A couple of questions regarding the C++ Tws api client

 

Yes this is exactly what i encountered. I got the client build but i dont want to use any workarounds like this if my money is on the line, therefore i would like some reply from officials at IB that confirm that this is the way to go : )


Re: trying to get working version of TWS C++ API

 

i downloaded from ? the linux version. If you have windows go with windows because on linux you have to fix an error first get it build.

If the api client is good enough i cant say, because i am currently working on it my self. try to get it build first then try connect it to the trader work station


Re: A couple of questions regarding the C++ Tws api client

 

You can skip the first few messages of that thread actually and just start reading from the one numbered 51303.

-Good luck


Re: A couple of questions regarding the C++ Tws api client

 

On Fri, Jul 28, 2023 at 04:22 PM, aSchwenk64@... wrote:

If you try to compile the code under linux, you will get errors

That's been brought up before here.


Re: A couple of questions regarding the C++ Tws api client

 

I try my approach with a set Master Client ID. This sounds interesting.

Concerning the bug: If you try to compile the code under linux, you will get errors because the attached libbid.a and so are in Windows format . One need to replace it with the linux version.


Re: trying to get working version of TWS C++ API

 

I am happy with any OS where TWS C++ API works -- Windows or Linux.
Are you saying that what IB itself provides (no third party GitHub repo) is good enough?

I am looking for a few test cases to get market data and then submit and cancel a limit order with?configurable parameters
(instrument, limit price etc)?

On Fri, Jul 28, 2023 at 12:14?PM <aSchwenk64@...> wrote:
Hi,
do you have problems compiling it ? On which operating system ? Under Windows there should be a project file which you can open with visual studio.? If you compile the testclient it should know where the acutal library is (the source folder)


Re: trying to get working version of TWS C++ API

 

Hi,
do you have problems compiling it ? On which operating system ? Under Windows there should be a project file which you can open with visual studio.? If you compile the testclient it should know where the acutal library is (the source folder)


Re: A couple of questions regarding the C++ Tws api client

 

On Fri, Jul 28, 2023 at 03:18 PM, aSchwenk64@... wrote:

Thank you for clarifying this.

You're welcome.

The second question is, why there is such a thing like api orders ?

The short answer is: so that you can automate your trading and make or lose money in quantities and time-frames never imagined before :-) But, I suspect the crux of your question may be getting lost in translation. So, apologies in advance if my answer sounds flippant.

As i see it all the provided callbacks can't see sent orders that are listed in the api tab. if i set the transmit-flag to false in the order object the order is stored in the api tab but i cant "reach" them anymore (and i already looked in the documentation).

You've jammed quite a bit into this so I'll only address what stands out to me which is that you may have neglected to set and use a .

BTW. Are you a developer at IB ? I found an error in the linux version of the client and emailed it to feedback@... but didn't get any reply. I post the mail here if this is of any use.

No, but sometimes I wish I were so I could help them avoid some of their questionable design decisions and fix bugs they're "too busy for", lol. Seriously though... if you really think you've found a bug, emailing the feedback address is not be the best course of action.

I'd suggest that you first establish, beyond doubt, that it is a bug by bringing the issue up to their support team. More often than not they'll help address the misunderstanding and then triage the bug, internally, if it really exists. If you visit you'll find helpful resources along with an option, further down the page, to report problems and bugs.

-Good luck


trying to get working version of TWS C++ API

 

what is the best way/source to get "Template TWS C++ client" to compile?it and put? basic functionality with minor changes in the code? And then?build?on top of it


Re: A couple of questions regarding the C++ Tws api client

 

Thank you for clarifying this.

The second question is, why there is such a thing like api orders ?

As i see it all the provided callbacks can't see sent orders that are listed in the api tab. if i set the transmit-flag to false in the order object the order is stored in the api tab but i cant "reach" them anymore (and i already looked in the documentation).

BTW. Are you a developer at IB ? I found an error in the linux version of the client and emailed it to feedback@... but didn't get any reply. I post the mail here if this is of any use.


Re: A couple of questions regarding the C++ Tws api client

 

On Fri, Jul 28, 2023 at 03:10 PM, Malcolm Haylock wrote:

This is a problem with nomenclature

There's a lot of lingo to get used to, it's all part of the fun!

As Malcolm mentioned... you don't close an , you close a position. A is established once an order is filled.

-Good luck


Re: A couple of questions regarding the C++ Tws api client

 

¿ªÔÆÌåÓý

This is a problem with nomenclature. Your order is not open, but you have an open position.

You were correct in your first email. To close the position just do the opposite in a new order.

Malcolm


On 28 Jul 2023, at 17:08, aSchwenk64@... wrote:

Hi,

i place an order and i get the following:

ExecDetails. ReqId: -1 - EUR, CASH, USD - 000132b0.64c2e326.01.01, 9, 20000, 20000, 2
OrderStatus. Id: 9, Status: Filled, Filled: 20000, Remaining: 0, AvgFillPrice: 1.10343, PermId: 1476143489, LastFillPrice: 1.10343, ClientId: 0, WhyHeld: , MktCapPrice: 0

This states (i'm not mistaken) that the sent order was executed. If i check the tws server there is a position with -20.000 (as it was a sell order).

Then i try to close it by executing ->? m_pClient->cancelOrder(m_orderId, "");
It states: Error. Id: 9, Code: 10147, Msg: OrderId 9 that needs to be cancelled is not found.

As i see it, the order is still open. If i send a buy order with +20.000 in quantity i can close it.

Cancel implies for me, that if the order isn't executed i can cancel it but not to close an opened order

regards,





Re: A couple of questions regarding the C++ Tws api client

 

Hi,

i place an order and i get the following:

ExecDetails. ReqId: -1 - EUR, CASH, USD - 000132b0.64c2e326.01.01, 9, 20000, 20000, 2
OrderStatus. Id: 9, Status: Filled, Filled: 20000, Remaining: 0, AvgFillPrice: 1.10343, PermId: 1476143489, LastFillPrice: 1.10343, ClientId: 0, WhyHeld: , MktCapPrice: 0

This states (i'm not mistaken) that the sent order was executed. If i check the tws server there is a position with -20.000 (as it was a sell order).

Then i try to close it by executing ->? m_pClient->cancelOrder(m_orderId, "");
It states: Error. Id: 9, Code: 10147, Msg: OrderId 9 that needs to be cancelled is not found.

As i see it, the order is still open. If i send a buy order with +20.000 in quantity i can close it.

Cancel implies for me, that if the order isn't executed i can cancel it but not to close an opened order

regards,




Re: A couple of questions regarding the C++ Tws api client

 

¿ªÔÆÌåÓý

Hi Arthur

Maybe I¡¯m misunderstanding your question, but a filled order does not need to be closed. As far is IB are concerned, a filled order is history.

Malcolm


On 28 Jul 2023, at 16:38, aSchwenk64@... wrote:

Hello Malcolm,

as a matter of fact i work with the documentation and i'm well aware of the cancel_order function. If my order is filled i get an error that it's not possible to cancel an order that's already filled. Due to this, i suppose that canceling orders is when they are not active. And this is the confusing part. So again my question: What is the proper way of closing an order ? Shall i save the quantity, direction (Buy / Sell) and "construct" an order to "neutralize" the existing one or is there a simpler approach to this ?

regards,
Arthur


Re: A couple of questions regarding the C++ Tws api client

 

Hello Malcolm,

as a matter of fact i work with the documentation and i'm well aware of the cancel_order function. If my order is filled i get an error that it's not possible to cancel an order that's already filled. Due to this, i suppose that canceling orders is when they are not active. And this is the confusing part. So again my question: What is the proper way of closing an order ? Shall i save the quantity, direction (Buy / Sell) and "construct" an order to "neutralize" the existing one or is there a simpler approach to this ?

regards,
Arthur


Re: A couple of questions regarding the C++ Tws api client

 

¿ªÔÆÌåÓý

Sounds like you might not have found the documentation, which should be able to help with many things:


Malcolm

On 28 Jul 2023, at 11:54, aSchwenk64@... wrote:

Dear community,
i have been working with the tws api client (c++) for more than two weeks now. Even after carefully studying the code provided by Interactive Brokers i couldn't manage to find a suitable closing function for the opended Orders. So my first question is:
- How is that done properly ? Shall i create a new order to "neutralize" the old one ? For example "Long apple stock with? quantity 3" shall be neutralized with "Sell apple stock with quantity3" . IS this always matched correctly by TWS ?
The second one is, why are there "api orders", what is that and why it is different from active orders . This is confusing and i couldn't find an explanation in the documentation.
The third and last (for now) is, can it be guaranteed, that for every symbole there is a history of 1 minute candles that at least is, 2-3 weeks in duration ?

Thanks in advance,

Arthur


A couple of questions regarding the C++ Tws api client

 

Dear community,
i have been working with the tws api client (c++) for more than two weeks now. Even after carefully studying the code provided by Interactive Brokers i couldn't manage to find a suitable closing function for the opended Orders. So my first question is:
- How is that done properly ? Shall i create a new order to "neutralize" the old one ? For example "Long apple stock with? quantity 3" shall be neutralized with "Sell apple stock with quantity3" . IS this always matched correctly by TWS ?
The second one is, why are there "api orders", what is that and why it is different from active orders . This is confusing and i couldn't find an explanation in the documentation.
The third and last (for now) is, can it be guaranteed, that for every symbole there is a history of 1 minute candles that at least is, 2-3 weeks in duration ?

Thanks in advance,

Arthur


Re: Cancel order lag - sometimes when lag they can fill

 

well not 100% sure exactly why buti shut off the other instance of the same ticket symbol and just have one going. I watched the price move to the price level while order was cancelled and it was in cancelled state in TWS and it didnt filll.
After numerous cancels and resend new orders - everything seems to be well.

So interesting that is. thankfully also :)


Re: I have a hard time doing Paper Trading

 

Thank you once again !

On Wed, Jul 26, 2023 at 9:20?PM ´³¨¹°ù²µ±ð²Ô Reinold via <TwsApiOnGroupsIo=[email protected]> wrote:

Glad you were able to fix your issue locally.

When I referred to TWS logs, I was thinking about the encrypted logs you can access via the Help -> Troubleshooting -> Diagnostics -> TWSLogs menu. These are quite cryptic and more useful for IBKR, but when you search for "ERROR" they sometimes give you really good clues as to what is going on.

TWS launcher logs cover only the very early TWS startup phase and do not receive any updates, once TWS is past the login screen.

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