Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Rate Futures - No security definition has been found of rthe request
Hi all, I'm trying to get historical data for the rate contract below. It works perfectly for ES and NQ but for some reason I can't get it to work for ZF or F1U. The data is in Workstation. What am I missing here? Thanks.
??????? ibcontract1 = IBcontract() ??????? ibcontract1.secType = "FUT" ??????? ibcontract1.symbol='ZF' ??????? ibcontract1.exchange="SMART" ??????? ibcontract1.primaryExchange="GLOBEX" ??????? ibcontract1.currency="USD" ??????? ibcontract1.localSymbol = "ZF MAR 21" |
Re: [Java] [reqMktData()] Need help figuring out why reqMktData() isn't working
On Thu, Jan 21, 2021 at 08:35 PM, mchaney2 wrote:
With respect to number 4 and canceling my market data subscriptions... How do I do this? I've looked around the pages on the Github intro and don't see any way to do this with code.See here:? http://interactivebrokers.github.io/tws-api/md_cancel.html |
Re: [Java] [reqMktData()] Need help figuring out why reqMktData() isn't working
1. reqMktData() requires you to specify a sequence number. You apparently decided to use parameter nextOrderID for this. But your code did not show whether that parameter was initialized somewhere. Which is why I asked. What number you select is not relevant (although I usually refrain from using zero as sequence number).
2. reqContractDetails() returns information in method contractDetails(). You could indeed pick up the returned contract and use that in the remainder of the code. Or simply print it to screen to verify that your contract definition was both sufficient and unique, resulting in precisely one returned contract. 3. method tickPrice() only gets updated if a price changes to what it was previously. This means that if there is no trading going on (and the best bid/ask prices don't change) you won't receive any data. If, during trading, multiple trades get executed at the same price you only receive a price update at the first trade, but not at the successive trades, because the price is not changing. 4. look for method cancelMktData(). In your case it would be cancelMktData(nextOrderID). |
Re: Adding delta information to positions in ApiDemo (java)
Adding FishTailContractData to the existing PositionRow will not do the trick. Replace PositionRow by??FishTailContractData in the callback for positionMulti. It could look like this : ?row?=?new?FishTailContractData(m_model,?contract); ?m_map.put(key,?row); ?m_list.add(row); ApiDemo.INSTANCE.controller().reqContractDetails(contract,??list?-> { ?????contract.exchange(list.get(0).contract().exchange()); ?????row.subscribeMarketData(); }); ? You may need m_model in?FishTailContractData?to fire data changes is you want to use the table model.
?
Best,
Herman. |
Re: additional messages besides in messages.py to facilitate reading of tws api log
Adding FishTailContractData to the existing PositionRow will not do the trick. Replace PositionRow by ?FishTailContractData in the callback for positionMulti. It could look like this : ?row = new FishTailContractData(m_model, contract); ?m_map.put(key, row); ?m_list.add(row); ApiDemo.INSTANCE.controller().reqContractDetails(contract,? list -> { ???? contract.exchange(list.get(0).contract().exchange()); ???? row.subscribeMarketData(); }); ? You may need
m_model in FishTailContractData?to fire data changes is you want to use the table model. Best, Herman. |
Re: TWS ERROR, 200, The contract description specified for ABNB is ambiguous.
¿ªÔÆÌåÓýApologies, I need to clarify and correct my previous reply. Using SMART for exchange and leaving primaryExchange blank returns a unique contract 459530964 via reqContractDetails(), provided the currency is specified as USD. ? However for reqMktData() and other requests this gives an error 'contract description specified for ABNB is ambiguous'. ? If you reqContractDetails() without including the currency, you get two contracts returned as JR pointed out earlier. It is slightly bizarre that adding the currency removes the EBS-hosted contract, since both contracts have the same currency (I think that indicates that the IBS contract is not set up properly on the IB contracts database) ? So I was incorrect to say that you don't need to supply the primary exchange: you do need it for reqMktData() etc. However the fact remains that the following does work, in spite of what you say: ? contract.symbol = 'ABNB' contract.localSymbol = 'ABNB' contract.secType = 'STK' contract.exchange = 'SMART' contract.currency = 'USD' contract.PrimaryExch = 'ISLAND' ? When investigating contract issues, I find it invaluable to have a tool that lets me poke around in contract definitions without having to write code. So I wrote the ContractInspector program, which is free for anyone that wants to use it (but currently limited to Windows). You can get it here: ? ? I've attached a screenshot. ? Richard ? ? ? ? From: [email protected] <[email protected]> On Behalf Of deerff@...
Sent: 21 January 2021 01:36 To: [email protected] Subject: Re: [TWS API] TWS ERROR, 200, The contract description specified for ABNB is ambiguous. ? What are you subscribing to? For me it is?reqMktData. Using v9.76 of API with IB gateway |
Re: TWS ERROR, 200, The contract description specified for ABNB is ambiguous.
Asking for ABNB of type STOCK in currency USD on ISLAND is ambiguous. There are two such ABNBs out there:
Description/Name ??? AIRBNB INC-CLASS A Conid??? 459530964 Symbol ??? ABNB Exchange ??? NASDAQ, CHX, IEX, MEMX, MIAX, NMS, NYSE Contract Type ??? Stock Country/Region ??? US - United States Closing Price ??? 173.69 Currency ??? U.S. Dollar (USD) Description/Name ??? 21SHARES BINANCE COIN ETP Conid ??? 387250452 Symbol ??? ABNB Exchange ??? EBS Contract Type ??? Stock Country/Region ??? CH - Switzerland Closing Price ??? 47.44 Currency ??? U.S. Dollar (USD) So I guess the correct thing to do, if you want to lookup by symbol name, is to specify symbol "ABNB" and exchange "NASDAQ". Or go by the CONID as Richerd suggested. |
Re: [Java] [reqMktData()] Need help figuring out why reqMktData() isn't working
mchaney2
Thank you for your reply!
Here are my responses to your questions: 1. Have you specified nextOrderID - ??????????? Yes, I defined it as zero elsewhere... Is there a programatic way to ensure it's always an appropriate number? I never intend to send any actual orders so I'm not sure if this matters. 2. ...Run reqContractDetails() before reqMktData() to ensure contract specified - ???????????? Ok thanks for the tip. Question : Does running reqContractDetails() auto fill the values into the parameters of the Contract object? So that I can then act on it as though the Contract object is "full"? 3. The disconnect could occur before you receive any market data, depending on how actively this stock ticker is being traded. ??????????? Ok so the reqMktData() function only will return data if any trades happen? i.e. will return nothing on zero volume day? I'm guessing to get the current "last traded price" we would go the historical data route? Or maybe set snapshot to true? 4.? before calling eDisconnect() you need to cancel your market data subscriptions. ????????? I will look into how to do this and add it to my code, thank you. I'm working at the moment but I'll be digging in deeper later. Thanks for your help, sorry if any questions are asinine. |
Different exchange rates for different accounts from reqAccountSummary() call
I'm calling?reqAccountSummary() from different accounts (one paper, 2 live) and I'm getting different?ExchangeRate values being returned from each account.? This is from USD to CAD.
Values I'm getting are: ExchangeRate, Value: 1.27078, Currency: USD (registered account) ExchangeRate, Value: 1.26207, Currency: USD (margin account) ExchangeRate, Value: 1.2707849, Currency: USD? (paper account) Have other people noticed this?? I'm making the calls after markets are closed, around 10pm EST. And it looks like the account summary in TWS is using a different exchange rate, as the base currency total is different from the value I'm calculating via the API.? It looks like the TWS account summary is using the real time rate, while the reqAccountSummary() call is giving me a delayed rate - delayed by as much as 1 day even.? Except the paper account in TWS account summary does agree with me, which seems to imply it is also delayed by 1 day? Why the discrepancy and how to get the current exchange rate? From the look of things, the price of 1.27 was around yesterday's closing price and the current price is about 1.2616. Thanks in advance. |
Re: [Java] [reqMktData()] Need help figuring out why reqMktData() isn't working
I have a few suggestions:
(1) have you specified nextOrderID? (2) you could run reqContractDetails() before reqMktData() to ensure that your contract is sufficiently specified. (3) After submitting reqMktData() you wait for only 1 second and then disconnect from IB. The disconnect could occur before you receive any market data, depending on how actively this stock ticker is being traded. (4) before calling eDisconnect() you need to cancel your market data subscriptions. Otherwise you might have issues if you try to run the same program once more immediately afterwards. |
Re: Bracket Order help
The child orders of the bracket are submitted at the same time as the parent (i.e. opening) order. This means that at the time the orders are submitted is the fill price of the parent order not yet known. So you can't specify a price relative to the fill price of the parent order.
I think that there are two ways how you can circumvent this: (1) submit a regular bracket order and specify a very wide stop price and take profit price. This to ensure that these orders are not hit immediately after the parent order gets filled. Wait until the parent order gets filled and calculate the correct values for the stop price and take profit price. Then modify the child orders to the desired price. (2) submit the opening order and wait until it gets filled (thus not a bracket order). From the fill price calculate the desired stop price and take profit price. Now submit a pair of OCA orders, using these calculated prices. |
Re: TWS ERROR, 200, The contract description specified for ABNB is ambiguous.
What are you subscribing to? For me it is?reqMktData. Using v9.76 of API with IB gateway
I only included contract.PrimaryExch and contract.localSymbol because elsewhere I saw suggestions that these fields could help disambiguate Below is my original code, does not work with ABNB for me. Was working fine for?many dozens of symbols until I ran into ABNB contract.symbol = <symb> contract.secType = 'STK' contract.exchange = 'SMART' contract.currency = 'USD' |
Re: TWS ERROR, 200, The contract description specified for ABNB is ambiguous.
¿ªÔÆÌåÓýI find that both the examples you give work fine. Also you can JUST use SMART for exchange and leave primaryExchange blank. You can also leave either symbol or local symbol blank. ? The contract returned by all of these has conid = 459530964. ? So I think you need to look at this again. ? From: [email protected] <[email protected]> On Behalf Of deerff@...
Sent: 20 January 2021 19:35 To: [email protected] Subject: [TWS API] TWS ERROR, 200, The contract description specified for ABNB is ambiguous. ? I have followed previous discussions on this topic where similar issues were had with MSFT and CSCO. So I'm aware of issues around smart order routing and ambiguities |
HOT_BY_OPT_VOLUME scanner vs relative volume
Hi, I am trying to build a scanner that can generate information on relative volume spikes on specific option chains, similar to unusual options scanner. I have tried building a scanner using these parameters
But I am finding some of the tickers/options are not showing up as expected, specifically larger cap stocks.
I can find some of the larger names by using I can't find any documentation on how Is there a way I can calculate relative volume vs the average volume for a specific price? I think this could help me significantly even if I have to do it manually. Thanks, Eric |
Re: Upgrading Java API version and EReaderSignal
Take a look at the conditions in each `while` loop. The second EReader you spotted goes out of scope after the version is received, it isn't run in a new thread.? On Wed, Jan 20, 2021 at 10:08 AM B Talladell via <bs2167=[email protected]> wrote: I'm a bit overdue on upgrading to an api version >= 9.72, so I've installed 9.76 and am working through updating my code. I see the addition of the EReaderSignal thread and how it is to be implemented as follows (taken from Testbed sample):? |
TWS ERROR, 200, The contract description specified for ABNB is ambiguous.
I have followed previous discussions on this topic where similar issues were had with MSFT and CSCO. So I'm aware of issues around smart order routing and ambiguities
I'm using ibapi Python client and I have only been able to work with ABNB if I stop using 'SMART' for contract.exchange and instead use 'ISLAND'. E.g. below contract.symbol = 'ABNB' contract.localSymbol = 'ABNB' contract.secType = 'STK' contract.exchange = 'ISLAND' contract.currency = 'USD' Note, below does Not work: contract.symbol = 'ABNB' contract.localSymbol = 'ABNB' contract.secType = 'STK' contract.exchange = 'SMART' contract.currency = 'USD' contract.PrimaryExch = 'ISLAND' Thing is, my code calls?reqContractDetails() and when I do that I see below for validExchange: SMART,AMEX,NYSE,CBOE,PHLX,ISE,CHX,ARCA,ISLAND,DRCTEDGE,BEX,BATS,EDGEA,CSFBALGO,JEFFALGO,BYX,IEX,EDGX,FOXRIVER,PEARL,NYSENAT,LTSE,MEMX,PSX I don't have this same issue with other stocks e.g. CSCO I put a check in my code, if it sees ABNB it will not use 'SMART' and instead use 'ISLAND', but what about others that have similar behavior? E.g. CSCO returns below from reqContractDetails() for validExchange. CSCO doesn't have this problem, but how would I know to otherwise distinguish ABNB ? SMART,AMEX,NYSE,CBOE,PHLX,ISE,CHX,ARCA,ISLAND,DRCTEDGE,BEX,BATS,EDGEA,CSFBALGO,JEFFALGO,BYX,IEX,EDGX,FOXRIVER,PEARL,TPLUS1,NYSENAT,LTSE,MEMX,PSX Maybe there is some aspect of this I'm missing. My solution works for now, but would be nicer if I could more programmatically adapt to any other stocks that share this behavior |
Re: Using old versions of TWS
¿ªÔÆÌåÓýsuebus ? Compared with TWS, the API is a very simple piece of code. There's relatively little logic in it, and I imagine most bugs are found pretty quickly and reported by API users. So the chance of being exposed to unfixed API bugs is much less than with TWS/Gateway, which are massively more complicated and very heavily multi-threaded. ? So someone who is still using API 9.71, say, is probably not going to have any issues (and that API version still works fine with current TWS/Gateway versions). But you can bet your life that if an obscure bug were found in that version and reported to IB, or even in a more recent version but that was also relevant to 9.71, IB wouldn't fix it in 9.71. So if you are using an old API version (ie prior to the current 'stable' version), you do run a small risk, but I imagine it's negligible. ? When you ask 'why it is critical to use old TWS versions' (and I presume you actually meant 'NOT to use'), I didn't say it was critical, just unwise. And I thought I explained that. Suppose while developing the latest beta version of TWS, the IB developers come across some strange combination of circumstances that results in a an order being placed incorrectly: they will of course fix it, and of course they'll examine the stable and latest version to see if the same bug occurs there, and fix it if it does. But they aren't going to trawl back through every prior version to see whether it might occur there too. I don't know this for a fact, but I can't imagine they would. That's the whole point of having the three current versions: ? STABLE ¨C no new features are added, any bug discovered in that or later versions are fixed. ? LATEST ¨C contains new features that aren't in the STABLE version. IB may need to be increment the version number of the LATEST versions if, for example, a new feature requires a new TWS version. Bugs discovered and reported are fixed in the current LATEST version and in the STABLE version (if relevant there). Versions between the STABLE and current LATEST versions, I suspect, are not bug-fixed because there's no way for users to access a version from IB once it's no longer LATEST. ? BETA ¨C contains new features that may not yet be fully tested. So you get early access to new features, but you use them at your own risk. Again, any bugs discovered that are relevant to the LATEST and/or STABLE versions would be fixed in them. ? I don't know what you're getting at when you say 'TWS connects only to the IB servers. Is this connection unsafe or the server itself?'. I've only been talking about TWS/Gateway ¨C nothing to do with the connection or the IB servers. ? Richard ? ? From: [email protected] <[email protected]> On Behalf Of suebusbavaricus
Sent: 20 January 2021 11:34 To: [email protected] Subject: Re: [TWS API] Using old versions of TWS ? Hi Richard, |