Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: How do I find out the margin requirements for a US stock through the TWS API?
Well, it sounds very anti-intuitive that one cannot determine if a trade will go through by using data available at the time of entering a trade - but has to 'reverse engineer' by issuing 'what if' trades and seeing their result. Is this really the case? On Sat, Nov 2, 2024 at 6:35?PM ´³¨¹°ù²µ±ð²Ô Reinold via <TwsApiOnGroupsIo=[email protected]> wrote:
|
Re: using EWrapper::fundamentalData
You use reqFundamentalData to request certain data. The requested data is then sent to you via fundamentalData. However, as you already mention, is the request reqFundamentalData deprecated. Meaning that if you can't request data, then implicitly no data can be sent to you.
If you search in this group you will find multiple topics, all related to the fact that fundamental data has been deprecated. |
Best practice for cancelmktdata
Hello I am currently have this in a foreach loop using
?
?
My question is should i add sleep between each canceltickerid, I am batching about 300 canceltickerids at once and the tick call backs for each canceltickerids keeps firing,? On the log for example I could call canclemktdata for a specific tickerid and for up to 2 minutes I may still get tick call backs for that partciular tickerid, Will adding sleep allow for faster processing or should i do smaller batches? |
Re: API call: Error validating request.-'bF' : cause - Please enter a stop price
The TWS documentation on orders is most useful when you want to determine, which order object fields need to be initialized. But that documentation does not give you any details on exactly what the different order types (or algos) do, what thez are intended for, or what their major limitations are. Richard gave you an overview of the STP, STLMT, and "IF TOCUHED" orders, but I recommended that, if you have not done so yet, you spend some time with this IBKR "" explorer. Here the . ´³¨¹°ù²µ±ð²Ô ? ?
On Fri, Nov 22, 2024 at 12:01 PM, Danny wrote:
.. |
Re: API call: Error validating request.-'bF' : cause - Please enter a stop price
¿ªÔÆÌåÓýFor a sell order, you only use stop or stoplimit when the market is above the trigger price (ie the AuxPrice). When the price drops to the trigger price, either a market or a limit order is then entered into the exchange. So you can use this to exit from a long position (this is typically a stop-loss, but it can alternatively be a profit taker if the position is currently in profit). ? You can use a buy stop or stoplimit to enter a new position, in which case market price must be below the trigger price. ? Be careful not to confuse a stop or stoplimit ?order with a ¡®stop-loss¡¯ order: stop and stoplimit orders are specific types of order, whereas a stop-loss order is really a mode of operating that protects a position against excessive loss, and can be of several different types. ? Note also that a market- or limit--if-touched order can also be used either to enter or exit a position, but you wouldn¡¯t use it as a stop-loss. I¡¯ll leave you to think about why that is. You need to make sure you have a clear understanding of these different order types. ? But here¡¯s an example: suppose the market is trading in a range, and you want to catch a breakout from that range in either direction: you could use a sell stop with trigger 1-tick below the bottom of the range, and a buy stop with trigger 1-tick above the high of the range. And you would put both orders in an OCA group so if one order fills, the other is cancelled. ? ? ? ? From: [email protected] <[email protected]> On Behalf Of Danny via groups.io
Sent: 22 November 2024 18:01 To: [email protected] Subject: Re: [TWS API] 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 TouchedA??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.
¡¤?????????????????????? 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
?
?
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 TouchedA??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.
|
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]>:
--
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:
|
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:
|
Re: timeout when connecting to TWS Gateway, but existing connection still works
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:
|
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:
|
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:
|