softwarespartan / IB4m

Interactive Brokers API for Matlab
GNU General Public License v2.0
62 stars 21 forks source link

Getting list of symbols for primary exchange #68

Closed dakr001 closed 5 years ago

dakr001 commented 5 years ago

Apologies if this query doesn't belong here.

Is it possible to programmatically get a list of all symbols for an exchange using TWS API?

The example below suggests it is possible: https://interactivebrokers.github.io/tws-api/contract_details.html

However when I use the following contract specs I get an error contract.exchange('SMART'); contract.primaryExch('NYSE'); contract.currency('USD');

Error: 2 321 Error validating request:-'bQ' : cause - The symbol or the local-symbol or the security id must be entered

Despair2000 commented 5 years ago

I don't think this will work this way round. You can request the primary exchange of a specific symbol but not get a list of all symbols from a specific exchange.

softwarespartan commented 5 years ago

I think the issue here is that need to specify “STK” as the type id of the security

Sent from my iPhone

On Sep 24, 2019, at 4:30 AM, dakr001 notifications@github.com wrote:

Apologies if this query doesn't belong here.

Is it possible to programmatically get a list of symbols for an exchange using TWS API?

The example below suggests it is possible: https://interactivebrokers.github.io/tws-api/contract_details.html

However when I use the following contract specs I get an error contract.exchange('SMART'); contract.primaryExch('NYSE'); contract.currency('USD');

Error: 2 321 Error validating request:-'bQ' : cause - The symbol or the local-symbol or the security id must be entered

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dakr001 commented 5 years ago

Is there another source then to get list of symbols programmatically?

softwarespartan commented 5 years ago

Even if there was, it would not solve the error you posted.

All IB api functionality is described in the docs

http://interactivebrokers.github.io/tws-api/basic_contracts.html

On Sep 24, 2019, at 6:21 AM, dakr001 notifications@github.com wrote:

Is there another source then to get list of symbols programmatically?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dakr001 commented 5 years ago

I think the issue here is that need to specify “STK” as the type id of the security Sent from my iPhone On Sep 24, 2019, at 4:30 AM, dakr001 @.***> wrote: Apologies if this query doesn't belong here. Is it possible to programmatically get a list of symbols for an exchange using TWS API? The example below suggests it is possible: https://interactivebrokers.github.io/tws-api/contract_details.html However when I use the following contract specs I get an error contract.exchange('SMART'); contract.primaryExch('NYSE'); contract.currency('USD'); Error: 2 321 Error validating request:-'bQ' : cause - The symbol or the local-symbol or the security id must be entered — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Specified 'STK' but got the following error: 3 321 Error validating request:-'bQ' : cause - The symbol or the local-symbol or the security id must be entered

softwarespartan commented 5 years ago

As I said, You need to specify fully defined contract

Contract details works for individual contracts

Contract details has nothing to do with providing exchange security listings etc.

On Sep 24, 2019, at 7:16 AM, dakr001 notifications@github.com wrote:

I think the issue here is that need to specify “STK” as the type id of the security … Sent from my iPhone On Sep 24, 2019, at 4:30 AM, dakr001 @.***> wrote: Apologies if this query doesn't belong here. Is it possible to programmatically get a list of symbols for an exchange using TWS API? The example below suggests it is possible: https://interactivebrokers.github.io/tws-api/contract_details.html However when I use the following contract specs I get an error contract.exchange('SMART'); contract.primaryExch('NYSE'); contract.currency('USD'); Error: 2 321 Error validating request:-'bQ' : cause - The symbol or the local-symbol or the security id must be entered — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Specified 'STK' but got the following error: 3 321 Error validating request:-'bQ' : cause - The symbol or the local-symbol or the security id must be entered

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Despair2000 commented 5 years ago

Here you find a list of all stocks you can trade with IB sorted by exchange:

https://www.interactivebrokers.com/en/index.php?f=1563

Depending on how many stocks you need you can either parse all this information or just copy/paste to an excel spreadsheet and then read it into Matlab.

dakr001 commented 5 years ago

Here you find a list of all stocks you can trade with IB sorted by exchange:

https://www.interactivebrokers.com/en/index.php?f=1563

Depending on how many stocks you need you can either parse all this information or just copy/paste to an excel spreadsheet and then read it into Matlab.

Thanks, looks like this is the way to go. Wished there is a more elegant way.