I use Amibroker to automatically and correctly place Buy and Sell orders daily into IB TWS on the ASX and US markets.
I'm trying to start the same process on the LSE. The problem that I'm finding is that there are many stocks where the IB Underlying symbol doesn't match the (exchange) Symbol. For example, Aptitude Software Group has the symbol "APTD" with the exchange and my data provider, and IB show APTD as the symbol, but the underlying is "MCGN".
When I enter the stock on a TWS watchlist, it references it as MCGN
So my problem is that my data provider (and I've checked several and they're all the same) use APTD but I can't use this to enter my orders. When I place an order with APTD-LSE-STK-GBP through Amibroker I get an error that the stock can't be found.
If I use MCGN-LSE-STK_GBP I can get an order to market correctly. See the first order line from IB Controller 1.3.8 below
The problem is that if I enter an order manually using the MCGN watchlist symbol then in IBController the symbol is shown as APTD. See the second order line from IB Controller below.
(the status error is simply because this account doesn't have sufficient funds yet while I wait for IB to change the base currency).
I've spoken with the IB API support team in both the US and Hong Kong and they both say that I need to get Amibroker to reference the "Local Symbol" used by the exchange, which is what I thought I was doing by defining the exchange as LSE rather than SMART? They can't help further than that they say.
Can anyone please suggest how to get my order to market using the APTD symbol code. I don't want to be keeping manual lists to convert codes from exchange/data provider codes to IB codes. I also looked at using the "Alias" reference in the stock description but this would also need to be maintained manually.
Any help much appreciated.
One possible solution is to use IBDictionary.txt to translate
IBDictionary.txt text file descriobes how symbols are translated before plugin talks to TWS API. It allows to use shorter name for symbols and addresses situations when IB starts trading given symbol on
multiple exchanges and SMART-STK-USD default becomes not enough to uniquely specify US symbol.
The format of this file is CSV (comma separated values): InputSymbol,OutputSymbol, comment (optional)
As to what is IBController and plugin doing with the symbol, it works as follows:
- if security type (
STK then contract.Symbol is set to
SYMBOL and contract.localSymbol is empty
- if security type (
TYPE) is NOT
STK then contract.Symbol is empty and contract.localSymbol is set to
Then contract.PrimaryExchange is set to
PRIMARYEXCHANGE (if defined) or empty if not defined.
This is the only way found by experimentation to force IB API to work with stocks and all other security types, without need to specify TWO different symbols at once (which is absurd IMHO).
Thank you for your reply. So is there any way of setting the contract.localSymbol for a STK in Amibroker? I can see that a decision was made back in version 1.3.5 to set the contractSymbol and localSymbol for stocks and futures - is there any code to override this decision?
Could you please explain this passage from the IBController 1.3.8 Beta Read Me. It seems to indicate the IBController can get information from TWS to setup the Symbol needed to place orders? Could you please tell me if this is relevant here? Thanks
CHANGES FOR VERSION 1.3.6
- IBController now uses more reliable way to translate from local symbol to TWS symbol/expiry pair based on information sent back by TWS. (It is not as simple as one may think because sometimes local symbol does not contain TWS symbol, so one can not derive TWS symbol from local symbol in general case, for example FESX SEP 10 local symbol translates to ESTX50,20100917, therefore IBController needs to get info from TWS)
This release note description applies to FUTURES and the way how symbols are treated for display (for portfolio pages, position and pending pages).
Thanks Tomasz for the help - I have opted to go with the lookup file to translate the symbols from the data provider to the IB trading symbol. Hopefully it won't be to much work to maintain