¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 ¿ªÔÆÌåÓý

Re: API call: Error validating request.-'bF' : cause - Please enter a stop price

 

?
?
thanks
?
Can I use a 'stop limit' for my 2 SELL calls? (one for a stop above the current market and another for below the current market, whichever reaches first)
Here it says that a 'stop limit' can only be used for a stop at a price below?the current market, and to use 'Limit if Touched' for a SELL for a price above the current market
?
?

Limit if Touched

A??is an order to buy (or sell) a contract at a specified price or better, below (or above) the market. This order is held in the system until the trigger price is touched. An LIT order is similar to a stop limit order, except that an LIT sell order is placed above the current market price, and a stop limit sell order is placed below.

  • Products: BOND, CFD, CASH, FUT, FOP, OPT, STK, WAR
  • Order order = new Order();
    order.Action = action;
    order.OrderType = "LIT";
    order.TotalQuantity = quantity;
    order.LmtPrice = limitPrice;
    order.AuxPrice = triggerPrice;
    ?
    ?


Re: API call: Error validating request.-'bF' : cause - Please enter a stop price

 

¿ªÔÆÌåÓý

That message means exactly what it says.

?

The API log entries show that you have set the LmtPrice field to 34.71. But it¡¯s the AuxPrice field you need for the STOP price.

?


API call: Error validating request.-'bF' : cause - Please enter a stop price

 

Hello all,
?
I am sending 2 STP API calls (to sell at a specific increase and decrease from the current price, whichever reaches first), but I am getting an error message regarding "enter a stop price".
What am I doing wrong? (and what is "bF"?)
Thanks
?
From the API log:
?
SMCI-STK--0.0---SMART-Nasdaq-USD-----SELL-120-STP-34.71
SMCI-STK--0.0---SMART-Nasdaq-USD-----SELL-120-STP-31.2
?
getting:
?
Error validating request.-'bF' : cause - Please enter a stop price
?
Error validating request.-'bF' : cause - Please enter a stop price


Re: Documentation for OrderCancel? ...

 

In these situations, I always do the following:

1) I contact IB via support ticket. They will contact someone knowledgeable in the API team that will provide a detailed answer.

2) I read the relevant sections of the source code which is always the best and most updated documentation.

Often, I will have managed to find by myself how to proceed before IB replies to my support ticket confirming my findings.

Hope this helps.

--


using EWrapper::fundamentalData

 

Hello everybody,
is there anyone that use the EWrapper::fundamentalData function instead of the EClient::reqFundamentalData.
The 2nd is deprecated and I should need more fundamental data, so I'd like to use the 1st but I can't find any documentation or example (in any programming language).?

Thank you in advance


Re: Documentation for OrderCancel? ...

 

Recently, this mailing list was already the venue for an investigation into this apparent breaking change. You can search for the respective tread. As far as I can rely on my memory, the second argument is inconsequential for retail investors and it's OK to use both null and a default new instance.


§é§ä, 21 §ß§à§ñ§Ò. 2024 §Ô., 17:06 bdcoder via <bdaviduck=[email protected]>:

Using C# API Version 10.30.01.
?
Only a few weeks into using this API and have noticed the documentation is severely lacking in all areas (which seems to be the state of the programming world these days).? Regardless, I needed to use the cancelOrder method.
?
The shows an example of the cancelOrder method as:
client.cancelOrder(nextOrderId - 1, "");
?
The shows the same example as above.
?
However, the code (downloaded) from IB contains an EClient.cancelOrder method with the following arguments:
? ? ? ? public void cancelOrder(int orderId, OrderCancel orderCancel)
?
The code downloaded from IB shows the default constructor for an "OrderCancel" object as:

? ? ? ? public OrderCancel()
? ? ? ? {
? ? ? ? ? ? ManualOrderCancelTime = EMPTY_STR;
? ? ? ? ? ? ExtOperator = EMPTY_STR;
? ? ? ? ? ? ExternalUserId = EMPTY_STR;
? ? ? ? ? ? ManualOrderIndicator = int.MaxValue;
? ? ? ? }
?
I ended up calling the cancelOrder method as follows, which works ...
?
? ? ? ?cancelOrder( order_id, new IBApi.OrderCancel() );
?
But I am ASSUMING this is OK as I do not receive any errors.? If someone knows of a resource that fully describes the "OrderCancel" object, please post a link.
?
Also, any ideas as to how often the documentation is actually updated?
?
Thanks in advance.
?
?
?
?
?


--
Best,
DS


Documentation for OrderCancel? ...

bdcoder
 

Using C# API Version 10.30.01.
?
Only a few weeks into using this API and have noticed the documentation is severely lacking in all areas (which seems to be the state of the programming world these days).? Regardless, I needed to use the cancelOrder method.
?
The shows an example of the cancelOrder method as:
client.cancelOrder(nextOrderId - 1, "");
?
The shows the same example as above.
?
However, the code (downloaded) from IB contains an EClient.cancelOrder method with the following arguments:
? ? ? ? public void cancelOrder(int orderId, OrderCancel orderCancel)
?
The code downloaded from IB shows the default constructor for an "OrderCancel" object as:

? ? ? ? public OrderCancel()
? ? ? ? {
? ? ? ? ? ? ManualOrderCancelTime = EMPTY_STR;
? ? ? ? ? ? ExtOperator = EMPTY_STR;
? ? ? ? ? ? ExternalUserId = EMPTY_STR;
? ? ? ? ? ? ManualOrderIndicator = int.MaxValue;
? ? ? ? }
?
I ended up calling the cancelOrder method as follows, which works ...
?
? ? ? ?cancelOrder( order_id, new IBApi.OrderCancel() );
?
But I am ASSUMING this is OK as I do not receive any errors.? If someone knows of a resource that fully describes the "OrderCancel" object, please post a link.
?
Also, any ideas as to how often the documentation is actually updated?
?
Thanks in advance.
?
?
?
?
?


C# code needed to download earnings date data in a CSV

AJ
 

Hi

I'm new to IB API and my coding skills are quite limited. I need someone to help me with my request. I am willing to pay for it if needed. If you are looking for payment then please reply to me privately at below email address with your proposed fee:


I need a complete C# code that will contact the IB server, get the data I need, and perform error handling to handle issues. All I need to do is run the code.

The data I need is the following in a CSV format:

1. Symbol
2. Day of earning announcement (actual day not proposed or tentative)
3. Time of announcement of date from item 2?
4. Actual EPS
5. Forecasted EPS for the item 4
6. Next scheduled date for earning announcement

Note:
1. Limit results to US listed securities only.
2. Include time zone if possible.
3. If IB provides item 2 and 3 as one field then just report that. I can parse the field to get the day and time.
4. One CSV file is produced for each symbol so if there are 5000 symbols then there are 5000 CSV files.
5. Add a variable that let's me indicate the folder where the CSV files are to be stored on my local machine.
6. Be extremely generous in your code comments so every detail is explained.
7. I will not download libraries, DLLs, third party software etc for security purposes so provide your code in plain text format so I can review the code before running it. It is ok to use IB libraries and any libraries that come with C#.??
8. Retrieve all data for a given symbol. I'm not sure how far back IB data goes so go as far as back as possible.
9. If payment is involved, then payment is made after I have tested the code.

I can wait a few weeks for the deliverable after scope and any other details have been finalized.?

Any questions please ask.

Thank you


Re: timeout when connecting to TWS Gateway, but existing connection still works

 

That's a question for IBKR and it has been like this forever. There is a post in our group archive every few months such as this one from August: TWS not connecting throwing a timeout error as port is stuck in (CLOSE_WAIT) state .

The workaround is to avoid TCP/IP connections that get closed without sending the "API\0" message and firestorms of several connection requests simultaneously.

If you want to learn more about what happens (though you won't be able the change anything), enable verbose/debug logging in TWS, look at the logs, and follow how the port listener thread pool starts dedicated API threads for each connection. For some reason (race condition, missed socket-closed exception, singleton, ...) one of those threads can get locked up if it does not see the "API\0" message, or if the TCP/IP connection gets closed immediately after it has been established. Once that happens, TWS/IBGW can accept more (physical) TCP/IP connections, but it cannot start client conversations any longer until it restarts.

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

?

On Tue, Nov 19, 2024 at 11:29 AM, ?kos Mar¨®y wrote:

´³¨¹°ù²µ±ð²Ô,
?
What would be the reason for no new TWS API client connections, assuming the client is valid and follows the protocol? What is the limitation here?
?
?
?kos

On Tue 19 Nov 2024, 18:26 ´³¨¹°ù²µ±ð²Ô Reinold via , <TwsApiOnGroupsIo=[email protected]> wrote:
I can telnet to this port and it opens up, so the Gateway is listening on the port.

This is likely your problem. TCP/IP socket connections that do not start the TWS API session conversation with a properly formatted "API\0" message or that send some other data. As you describe, TWS/IBGW will still accept additional TCP/IP connections, but an API session cannot start any longer until restart. Not sure whether that is by design or a side effect of the implementation.

Avoid any such TCP/IP connection requests from port scanners or port monitoring tools, or at least send a proper "API\0" message.

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

?


Re: timeout when connecting to TWS Gateway, but existing connection still works

 

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

What would be the reason for no new TWS API client connections, assuming the client is valid and follows the protocol? What is the limitation here?


?kos

On Tue 19 Nov 2024, 18:26 ´³¨¹°ù²µ±ð²Ô Reinold via , <TwsApiOnGroupsIo=[email protected]> wrote:
I can telnet to this port and it opens up, so the Gateway is listening on the port.

This is likely your problem. TCP/IP socket connections that do not start the TWS API session conversation with a properly formatted "API\0" message or that send some other data. As you describe, TWS/IBGW will still accept additional TCP/IP connections, but an API session cannot start any longer until restart. Not sure whether that is by design or a side effect of the implementation.

Avoid any such TCP/IP connection requests from port scanners or port monitoring tools, or at least send a proper "API\0" message.

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

?

On Tue, Nov 19, 2024 at 10:57 AM, ?kos Mar¨®y wrote:
Hi,
?
I found this interesting phenomenon today when trying to connect with a second client to a running TWS Gateway, that I'm getting a timeout error. At the same time, the gateway has an active connection running by a client, that still is operational and works. Of course the new connection is using a different client id than the existing one.
?
In all cases the connection is made to 127.0.0.1, to the same port 4002. I can telnet to this port and it opens up, so the Gateway is listening on the port. But a new client can't connect and gets a timeout.
?
What could cause this issue?
?
?
?kos
?


Re: timeout when connecting to TWS Gateway, but existing connection still works

 

I can telnet to this port and it opens up, so the Gateway is listening on the port.

This is likely your problem. TCP/IP socket connections that do not start the TWS API session conversation with a properly formatted "API\0" message or that send some other data. As you describe, TWS/IBGW will still accept additional TCP/IP connections, but an API session cannot start any longer until restart. Not sure whether that is by design or a side effect of the implementation.

Avoid any such TCP/IP connection requests from port scanners or port monitoring tools, or at least send a proper "API\0" message.

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

?

On Tue, Nov 19, 2024 at 10:57 AM, ?kos Mar¨®y wrote:
Hi,
?
I found this interesting phenomenon today when trying to connect with a second client to a running TWS Gateway, that I'm getting a timeout error. At the same time, the gateway has an active connection running by a client, that still is operational and works. Of course the new connection is using a different client id than the existing one.
?
In all cases the connection is made to 127.0.0.1, to the same port 4002. I can telnet to this port and it opens up, so the Gateway is listening on the port. But a new client can't connect and gets a timeout.
?
What could cause this issue?
?
?
?kos
?


timeout when connecting to TWS Gateway, but existing connection still works

 

Hi,

I found this interesting phenomenon today when trying to connect with a second client to a running TWS Gateway, that I'm getting a timeout error. At the same time, the gateway has an active connection running by a client, that still is operational and works. Of course the new connection is using a different client id than the existing one.

In all cases the connection is made to 127.0.0.1, to the same port 4002. I can telnet to this port and it opens up, so the Gateway is listening on the port. But a new client can't connect and gets a timeout.

What could cause this issue?


?kos


Re: execDetails(...)+commissionReport(...) Callback different behaviour when not opening trade history

 

My apologies. I use a (pimped) version of the ApiController class that ships with the TWS API. It implements a "controller pattern" and hides a lot of unnecessary TWS API details from the client. But for some reason for the reqExecutions call, it renamed the execDetails() callback to tradeReport() and execDetailsEnd() to tradeReportEnd(). But their functions are identical.

You should reach out to IBKR if your execDetails callbacks indeed only arrive, when the Trade History window is open in TWS.

I still think that you need something more than Execution objects to properly implement your rules based trading. Keep in mind that a single order can be filled with multiple trades (causing multiple execDetails() callbacks and multiple Execution objects with different execIds) and that the total traded volume could be different from what your order asked for. Your rules logic needs to properly handle that. But you are correct that the position callbacks only provide you with aggregate quantities.

Maybe you need a thin layer that related the rule instructions to the various order and execution events and that avoids the erroneous rule execution tiggered by certain execDetails call backs. You could probably use the orderRef field to tag orders so that you know which rule event it belongs to. orderRef is a string in the Order class that you can define as you like when you place the order, it is returned with all order related callbacks as well as in Execution objects you receive from execDetails callbacks. If the rule, for example, says "sell 120" but that takes place in three trades of 100 + 10 + 10, your logic knows that those three execDetails() callbacks and Execution objects relate to that one rule event. And it also would know in case the actually traded volume is different from what the rule asked for.

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

?

On Tue, Nov 19, 2024 at 07:00 AM, <simon.meier1987@...> wrote:

I do not have the callback functions tradeReports(...) + tradeReportEnd(...) . When i make the request with reqExecutions(...), i receive the information through execDetails(...) and execDetailsEnd(...). How do i receive real-time reports ? Maybe i can use these functions in a java application? I program in c++ and i didn't find these in the documentation page. ?
?
The software behaves like i explained no matter what time. In my case it does not matter if the exchange is open or not.?
?
Exactly. A reliable working "position monitor" is what i need (for stocks and for futures). In my case for a symbol i have several trading rules and each of them manages a certain part of the aggregated position. Sometimes it happens that the statistic that a trading rule "contains" is not valid anymore and then it wants to close its part of the position. So i need the executions, because only then i can assign the closed order to the corresponding rule. As far as i know the position(...)-callback only delivers the aggregated position ( if so, -> not applicable). ?
?
With ---> "By using the position(..) + positionEnd(...) ? In my case it sends the close again and basically opens the symbol in the other direction" <--- I meant that if i do not receive the message that says "there was a execution of selling/buying 60 apple stocks" my system sends the request again, so that (sometimes) there will be another execution that either increments the postion to an unwanted amount (here 120 apple stock) or closes it again that this leads to selling short position. This is a critical error. ?
?
As a side note: i configured the tws in such a way to receive the 7 days of executions and i like to make use of that fact that there is always "enough time" (repeated sending) to complete the position monitor as the callback should send this information repeatedly. ?
But i will have a look at the position(...) and positionEnd(...) callback functions. Maybe they can solve at least a part of my problem
?
regards
Simon


Re: execDetails(...)+commissionReport(...) Callback different behaviour when not opening trade history

 

The Trade to Execution (Trade Report) relationship is definitely a "one to many". From the documentation:

Note if a correction to an execution is published it will be received as an additional IBApi.EWrapper.execDetails callback with all parameters identical except for the execID in the Execution object. The execID will differ only in the digits after the final period.

As far as I know, Trade to CommissionReport is a "1 to 1" relation. I don't think that there are corrections for those.

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

?

On Tue, Nov 19, 2024 at 06:16 AM, Brocksdorff wrote:

@´³¨¹°ù²µ±ð²Ô
?
I wonder if the 1:1 relation regarding Trade and CommisionReport is sufficient ...? 1:1 TradesReport and CommisionReport seems a better model. just my 2cents


Re: execDetails(...)+commissionReport(...) Callback different behaviour when not opening trade history

 

I do not have the callback functions tradeReports(...) + tradeReportEnd(...) . When i make the request with reqExecutions(...), i receive the information through execDetails(...) and execDetailsEnd(...). How do i receive real-time reports ? Maybe i can use these functions in a java application? I program in c++ and i didn't find these in the documentation page. ?
?
The software behaves like i explained no matter what time. In my case it does not matter if the exchange is open or not.?
?
Exactly. A reliable working "position monitor" is what i need (for stocks and for futures). In my case for a symbol i have several trading rules and each of them manages a certain part of the aggregated position. Sometimes it happens that the statistic that a trading rule "contains" is not valid anymore and then it wants to close its part of the position. So i need the executions, because only then i can assign the closed order to the corresponding rule. As far as i know the position(...)-callback only delivers the aggregated position ( if so, -> not applicable). ?
?
With ---> "By using the position(..) + positionEnd(...) ? In my case it sends the close again and basically opens the symbol in the other direction" <--- I meant that if i do not receive the message that says "there was a execution of selling/buying 60 apple stocks" my system sends the request again, so that (sometimes) there will be another execution that either increments the postion to an unwanted amount (here 120 apple stock) or closes it again that this leads to selling short position. This is a critical error. ?
?
As a side note: i configured the tws in such a way to receive the 7 days of executions and i like to make use of that fact that there is always "enough time" (repeated sending) to complete the position monitor as the callback should send this information repeatedly. ?
But i will have a look at the position(...) and positionEnd(...) callback functions. Maybe they can solve at least a part of my problem
?
regards
Simon


Re: execDetails(...)+commissionReport(...) Callback different behaviour when not opening trade history

 

@´³¨¹°ù²µ±ð²Ô
?
I wonder if the 1:1 relation regarding Trade and CommisionReport is sufficient ...? 1:1 TradesReport and CommisionReport seems a better model. just my 2cents


Re: execDetails(...)+commissionReport(...) Callback different behaviour when not opening trade history

 

Just to confirm that you are talking about historical tradeReports right after the call to reqExecutions and before the tradeReportEnd clall back. You are not talking about real-time reports right after order fills, right?

I can confirm this behavior for when the markets were closed over the weekend, and today at 16:30 US/Central during the CME/CBOT daily trading pause hour (my trade reports were for various futures). But just before 17:00 US/Central on Sunday and today and during trading hours, historical trade reports were delivered right after reqExecutions calls regardless of whether the Trade History window was open or not. This is probably a question for IBKR, but there are other request types with a disclaimer in the documentation that they only work when exchanges are open.

But coming back to your other questions. If I understand you correctly, you are trying to create a reliable "position" monitor within your client application. Both getting the an initial correct state when the client starts as well timely updates in real time when your orders fill.

For my taste, historical trade reports are not well suited to do that, considering that they generally are only available for the time since midnight (IBGW and TWS default) and only manual configuration of the TWS Trade History windows give you a longer historical view. Also, when you look at the (simplified) data model below, trade reports are pretty far removed from the notion of "Position" and subscriptions that get you updatePortcolio, position, pnl, and order status callbacks give you better data for position monitoring.

I did not understand your comment about position updates when you say "By using the position(..) + positionEnd(...) ? In my case it sends the close again and basically opens the symbol in the other direction". You would:

  • call to subscribe to position updates
  • for each first call back for an instrument you'd create an internal "Position" object
  • you can configure TWS/IBGW in the API configuration section whether they should send you "empty" positions (e.g. recent positions that now have a quantity of 0).
  • you know that you have seen all currently open positions when you receive the callback
  • and for each subsequent call back for that instrument, you'd update your internal "Position" object accordingly.

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

?

?

On Sun, Nov 17, 2024 at 09:07 AM, <simon.meier1987@...> wrote:

Update:
i checked the version of the tws and its 10.30.1q, and i dont receive the executions until i open the dialog


Re: keeping subscriptions

 

I second this and also have never seen periodical inactivity for an instrument cause real time market data subscriptions to stop working. Just to be sure:
  • Real time market data subscriptions include reqMktData, reqRealTimeBars, reqTickByTickData, and reqMktDepth
  • It does not include reqHistoricalData with keepUpToDate set to true. In my experience, those do not survive all data farm reconnects.

When I checked up on "holes in the data" for an instrument in the past it was always caused by a quiet period for that instrument (unless my recorder client had failed).

As a matter of practice I now subscribe to "5 second real time bars" for all instruments as a "second opinion" and data feed quality metric. For many instruments, those bars get sent for every 5 second period, even if no trades or ask/bid changes took place (16,560 or 17,280 bars per day). A 0 volume 0 count bar confirms quiet periods for the other feeds of that instrument. They also serve as data feed heart beat detectors.

But then, data for instruments I subscribe come from big exchanges and are generally quite active. Feeds from smaller exchanges or infrequently traded instruments may behave differently.

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

?
?
On Mon, Nov 18, 2024 at 12:00 PM, bespalex wrote:

I am not sure streaming data inactivity cease is connected to general API inactivity in any way, as in my case, I keep recCurrentTime requesting as a beacon every second, also difference in local/TWS time works for me as an API disconnect monitor sensor.
So my loss of some streams is of some other nature, but occurrence is stable in about 10% of maintained streams, different 10% each time.?
And no apparent connection to any of the events, looks like IB just "forgets" and drops some of the active subscriptions on ETH session start at 4am EST.


Re: fx about EUR.USD

 

IB never reported historical volume on Forex financial instruments. It was always reported as -1. This is by design.

If you want historical volume you need to request historical data for Forex futures/ETFs/options, etc...

The trading hours' information for any financial instrument is available in TWS (mouse right-click over the instrument row).

The exchange for EUR.USD is IDEALPRO (or IDEAL).

Hope this helps.

--


Re: fx about EUR.USD

 

I believe IDEALPRO is IB's own FX execution service. What volume you're looking for? There's no single exchange trading FX.