¿ªÔÆÌåÓý

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

How to get market data, specifying exchange=NASDAQ, when ssh to a server that the TWS application is running on


 

If I run TWS app and TWA API from my local machine, I could request market data when setting exchange=NASDAQ?

But when I ssh to a server where the TWS application is running, I get the error "200 No security definition has been found for the request". This happen if I?set exchange=NASDAQ and it is fixed if I set exchange=SMART.?

My purpose is to request market data from NASDAQ exchange. I would appreciate if anyone could help me with this.


 

IB doesn't differentiate where you run the client, so the reason for your issue is somewhere else.


 

I agree with @misantroop. I can't imagine anything reasons related to SSH or telco. However I idea popup in my mind:

I read somewhere that IB is in the process of removing temptation to use ISLAND and expect user to label it NASDAQ.
every IB Data Farms may not be all updated, and dungtrand0127 may implicitly and unknowingly trying to access another old farm that still expect ISLAND and does not yet support NASDAQ. (Ok I agree farfetch)

@dungtran0127@...
- try with ISLAND (Old way to access NASDAQ and probably still available for a couple of years)
- on your local machine and on the target machine try reqMatchingSymbols on your symbol
and in the call backs data; look and compare what are primary exchange and what are the official name of supported exchanges.


 

¿ªÔÆÌåÓý

As far as I¡¯m aware ¡°NASDAQ¡± doesn¡¯t appear in the list of valid exchanges in the contactDetails() callback for any security. The list for MSFT is typical:

?

validExchanges = SMART,AMEX,NYSE,CBOE,PHLX,ISE,CHX,ARCA,ISLAND,DRCTEDGE,BEX,BATS,EDGEA,JEFFALGO,BYX,IEX, EDGX,FOXRIVER,PEARL,NYSENAT,LTSE,MEMX,TPLUS1,IBEOS,OVERNIGHT,PSX

?

Market data requests must specify an item in this list.

?

However ¡°NASDAQ¡± does appear as the primaryExchange attribute (whereas for IBM the primaryExchange is listed as ¡°NYSE¡±).

?

Primary exchange has always been a very unclear concept in the API and isn¡¯t really defined properly anywhere. Originally there was a statement somewhere that its purpose was to disambiguate the meaning of ¡°SMART¡± ¨C because there are separate SMART routing infrastructures in different regions, eg US, Canada, EU, LSE. So if nothing else indicated which SMART routing infrastructure was to be used for an undirected order, primaryExchange would do it. Normally currency would do the job, but not in every case, though I don¡¯t remember any specific examples. This is all still true, but it may be that primaryExchange has some additional use now that I¡¯m not aware of.

?

So primaryExchange is hardly ever necessary, but in my platform I always use the primaryExchange returned in the contractDetails().

?


 

What caught my attention were:

1- This issue is mentioned on Update 20.05.2022 (and the one before too)
2- NASDAQ seems already working in many calls, executing call as they should if set with ISLAND.

And more specifically

This article deal with a settings in TWS 10.16+ which is needed to keep compatibility with ISLAND, (unclear what is the default on new install)
This could explain the issue raised in this thread if dungtran0127@... used 2 different TWS settings, as he seems able to use NASDAQ successfully for data call, on at least one of his platform.

My take is that without IB specific notice, as long as I will see contractDetails() returning ISLAND and not NASDAQ I can keep using ISLAND, but I felt compelled to also implement such a switch.


 

¿ªÔÆÌåÓý

So where is this ¡°Compatibility Mode: Send ISLAND for US Stocks trading on NASDAQ" setting? I can¡¯t find it anywhere (on 10.19 or 10.25).

?

From: [email protected] <[email protected]> On Behalf Of Gordon Eldest via groups.io
Sent: Tuesday, November 14, 2023 9:33 PM
To: [email protected]
Subject: Re: [TWS API] How to get market data, specifying exchange=NASDAQ, when ssh to a server that the TWS application is running on

?

What caught my attention were:

1- This issue is mentioned on Update 20.05.2022 (and the one before too)
2- NASDAQ seems already working in many calls, executing call as they should if set with ISLAND.

And more specifically

This article deal with a settings in TWS 10.16+ which is needed to keep compatibility with ISLAND, (unclear what is the default on new install)
This could explain the issue raised in this thread if dungtran0127@... used 2 different TWS settings, as he seems able to use NASDAQ successfully for data call, on at least one of his platform.

My take is that without IB specific notice, as long as I will see contractDetails() returning ISLAND and not NASDAQ I can keep using ISLAND, but I felt compelled to also implement such a switch.


 

I don't know. Not seen on TWS.
The logical place should be under Configuration->API but nothing visible about that
Whoever get a clue please share it, I am Interested to not be the last one to know it.

Only place I saw a trace about that is with Gateway ->File->Gateway Layout/Settings, Then grab the XML
in <ApiSettings, look for "sendIslandForUsStocksTradingOnNasdaq"? but this seems more like a provision or unused rubric. It is set with "false" on my machines.

The only 'flags' still raised in my mind is to be careful that an install of latest code on a clean new machine may behave differently than latest code but as an update of a years old installed.


 

As I understand, primary exchange is the native exchange for the instrument, regardless where it could be trading. IBM is trading in USD on LSE, so a contract request for (symbol: IBM, currency: USD) would be ambiguous. IBM/SMART would cause even more issues as there are many IBMs listed. The only way to get NYSE listed IBM without fail is to specify NYSE as primaryExchange.
One silly foolproof option is to keep a static list of primaryExchanges, so every rejection for ambiguity will be retried with the next primaryExchange in the list until a match is made. Alternative for US equity markets is to use the ftp.nasdaqtrader.com symbol files and make a query there.


 

Hi all. Thanks for helping me out. I tested with exchange=ISLAND and it worked on my server. I'm about using exchange=SMART and?primaryExch=NASDAQ but now I understand it is wrong setting.

My TWS version on MacOS is 10.26.2023, while the server version is 10.25.2023.?


 

On Wed, Nov 15, 2023 at 06:29 AM, <dungtran0127@...> wrote:

Hi all. Thanks for helping me out. I tested with exchange=ISLAND and it worked on my server. I'm about using exchange=SMART and?primaryExch=NASDAQ but now I understand it is wrong setting.

My TWS version on MacOS is 10.26.2023, while the server version is 10.25.2023.?

Be careful that one day IB may ask you to switch to NASDAQ instead of ISLAND (I guess your good for 1 or 2 years)

Also: SMART is Ok to fetch market data unless you look for very specific exchange volumes (as opposed to prices which seems nearly always same across exchanges when looking historical)
BUT if you use SMART for placeOrder that is a different story, as SMART allow variation on the theme (preference to speed/preference to lower commission/better price/ etc...)
see TWS->File->Global Configuration->Orders->Smart Routing . In general SMART default is the safest choice, especially for low liquidity instrument. Just be aware of what is SMART doing.


 

On Wed, Nov 15, 2023 at 04:54 AM, misantroop wrote:
As I understand, primary exchange is the native exchange for the instrument, regardless where it could be trading. IBM is trading in USD on LSE, so a contract request for (symbol: IBM, currency: USD) would be ambiguous. IBM/SMART would cause even more issues as there are many IBMs listed. The only way to get NYSE listed IBM without fail is to specify NYSE as primaryExchange.
One silly foolproof option is to keep a static list of primaryExchanges, so every rejection for ambiguity will be retried with the next primaryExchange in the list until a match is made. Alternative for US equity markets is to use the ftp.nasdaqtrader.com symbol files and make a query there.

Very Good point, I hit that one too.
Note:
BTW was on IBM too!
I wonder why IB isn't adding LSE to resolution under SMART as what LSE does trade as IBM have same ISIN as the NYSE one. (different Trading hours ?)