¿ªÔÆÌåÓý

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

Re: OTC

 

¿ªÔÆÌåÓý

That is not true. You don't need conid to place an order.

?

For example, to place an order for the ES E-mini future for March 21, all you need is:

?

LocalSymbol = "ESH1"

SecType = "FUT"

Exchange = "GLOBEX"

?

Try it yourself!

?

?

From: [email protected] <[email protected]> On Behalf Of hymagik via groups.io
Sent: 20 January 2021 18:03
To: [email protected]
Subject: Re: [TWS API] OTC

?

If you expect multiple answers or wonder what should be specify, use reqMatchingSymbols(211, "xxxxxxx") quick and efficient.

That deliver immediately nearly all you need to prepare future request.

If you are an adept of guessing, set Exchange = SMART and Primary empty or "ISLAND" for Nasdaq, NYSE for Nyse etc ...

But unless misinterpreting your intention you will need "conid" anyway to pass an order and this one you cannot guess it.

?


Re: Reuters Stock Report Plus

 

I use newsFeed sucessfully, but ... IB is not the way to get it.

I hypothesis that every thing you can see on TWS Station Headline news is available trough the API

For now nothing goes against this hypothesis. BUT be sure to subscribe to the feed in your account and familiarize yourself with the syntax for Ticker and Exhcange for news. IB recycle field in an rather odd way that require experiment

Things like

??? orqNews4.SetSymbol??? ("DJNL:DJNL_ALL");////BroadTape All News, DJN
?? ?orqNews4.SetType??? ("NEWS");
?? ?orqNews4.SetExchange("DJNL");

?

Comment:

IB news feed are generally cheaper than direct subscription to services, but they receive curated version (however fast enough)

If you intend to use "Behavioral trading" be ready to pay 100K/year, that the "ticket" to get 'Tweeter $Symbol API' , Bezinga WIM. Reuters direct etc ,,, that are pretty expensive. And don't be fooled, theses guys doesn't sale that much cheaper to IB so there is no secret weapons to get cheap instant feed. News wires know the price of news

Be aware that the faster you want the news the more you must pay.

Generally big brokerage firm get news 5 to 10 min before individuals. Don's forget Yahoo Finance that does a pretty good job for free.


Re: Starting with TWS APi using C++, looking for advice

 

about #1:

- I use latest 9.81 and I recommend using latest
a- Increment is marginal so few reason it failed and it secure your code, see also response to #2
b- It's more stable and better to get info about "shorting" capabilities (return amount instead of advice

?

about #2

Are you fluid un c++ ? If yes then go for native IB API, if no ... go for becoming fluid first. (or use IB REST API but NOT TWS)

- TwsApiCpp is build atop and one day or another you will need to dig in the IB APi anyway.

- The thing that you need to know in c++ is how to use ::mutex and ::thread. that's it.

?

But what mention as what you aim for, doesn't even need full real-time multithread. IB Api does answer reasonably quickly. (Way faster than REST in general and far better concept of "subscribe")

For "Balance and account" I suggest you consider the IB REST API instead of TWS API, but just for simple matter like that, Be careful that if you deal with orders your prone to enter a different world of complexity, as you will most probably need to get latest Bid/Ask etc ... and this is here lies the issues

?

?


Upgrading Java API version and EReaderSignal

 

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):?

final EClientSocket m_client = wrapper.getClient();
final EReaderSignal m_signal = wrapper.getSignal();

m_client.eConnect("127.0.0.1", 7497, 2);

final EReader reader = new EReader(m_client, m_signal);? ?
reader.start();
?
new Thread(() -> {
while (m_client.isConnected()) {
m_signal.waitForSignal();
try {
reader.processMsgs();
} catch (Exception e) {
System.out.println("Exception: "+e.getMessage());
}
}
}).start();

I get that the signal thread will now process queued messages but I'm confused why there's a second EReader created in EClientSocket.eConnect(Socket socket)?? That method is below...I'd very much appreciate any guidance on why a second instance of EReader is created...or more likely what I'm missing!

protected synchronized void eConnect(Socket socket) throws IOException {
? ?
? ? m_socketTransport = new ESocket(socket);
? ? m_dis = new DataInputStream(socket.getInputStream());
? ? m_defaultPort = socket.getPort();
? ? m_socket = socket;
?
? ? sendConnectRequest();
?
? ? // start reader thread
? ? EReader reader = new EReader(this, m_signal);
?
? ? if (!m_asyncEConnect) {
? ? reader.putMessageToQueue();
?
? ? while (m_serverVersion == 0) {
? ? m_signal.waitForSignal();
? ? reader.processMsgs();
? ? }? ? ? ?
? ? }
}


IB Amibroker auto order

 

Hi,
I need help for auto order code from Amibroker to IB (Interactive Broker TWS).

?

I have created my code in Amibroker based on my own strategy and tested in live for accurate results. The strategy is working well. I am trying to auto order (Buy/Stop loss/Exit) based on the strategy using the below code but not working. I have created the below code for placing orders but only Buy trade is executing and corresponding sell is not executing when the price hit target. I request you to help me.

_SECTION_BEGIN("Order");   

if(LastValue( Buy ))
{
  ibc = GetTradingInterface("IB");   // check if we are connected OK

  if( ibc.IsConnected() )
  {
     if( ibc.GetPositionSize( Name() ) == 0 )
     {     
		
		parentID = ibc.Placeorder(Name(), "Buy", 1, "MKT", 0, 0,  "Day", False);   
		ibc.Placeorder( Name(), "Sell", 1, "LMT", brd1, 0,  "Day", False, 1, "", parentID);   
		ibc.Placeorder( Name(), "Sell", 1, "STP", (bpd), (bpd), "Day", True, 1, "", parentID);

         }
	}
}

_SECTION_END();  

Thank you
Hanu


Re: OTC

 

If you expect multiple answers or wonder what should be specify, use reqMatchingSymbols(211, "xxxxxxx") quick and efficient.

That deliver immediately nearly all you need to prepare future request.

If you are an adept of guessing, set Exchange = SMART and Primary empty or "ISLAND" for Nasdaq, NYSE for Nyse etc ...

But unless misinterpreting your intention you will need "conid" anyway to pass an order and this one you cannot guess it.

?


Re: Using old versions of TWS

 

Hi Richard,

thanks for this information. However, I have another question:

Is it safe to run old API versions with new TWS versions? I think, it should be, because the API only makes a connection to the TWS of the same computer (or an computer in the private network). But I am not quite sure ...

Also I would be interested why it is critical to use old TWS versions. TWS connects only to the IB servers. Is this connection unsafe or the server itself?

Thanks in advance for your answer!

suebus


[Java] [reqMktData()] Need help figuring out why reqMktData() isn't working

mchaney2
 

Hi all, I have the following code:
?? ????
??????? public void tickPrice(int tickerId, int field, double price, TickAttrib attrib) {
?? ???????? System.out.println(price);
?? ???? }

?? ???? private EReaderSignal signal = new EJavaSignal();
?? ???? private EClientSocket client = new EClientSocket(this, signal);
?? ????
?? ???? client.eConnect("127.0.0.1", 7496, 2);
?? ???? Thread.sleep(3000);
?????? ?
?????? ?
?????? ?
??????? reader = new EReader(client, signal);? ?
??????? reader.start();
?????? ?
??????? new Thread(() -> {
??????????? while (client.isConnected()) {
??????????????? signal.waitForSignal();
??????????????? try {
??????????????????? reader.processMsgs();
??????????????? } catch (Exception e) {
??????????????????? System.out.println("Exception: "+e.getMessage());
??????????????? }
??????????? }
??????? }).start();
?????? ?
?????? ?
??????? Contract contract = new Contract();
??????? contract.symbol("IGC");
??????? contract.secType("STK");
?????? ?
??????? Vector<TagValue> mktDataOptions = new Vector<TagValue>();

??????? client.reqCurrentTime();
??????? client.reqMktData(nextOrderID, contract, null, false, false, mktDataOptions);
???????
??????? Thread.sleep(1000);
??????? client.eDisconnect();

I would like to know what's going wrong here. When I run the program it successfully gives me the current time but it does nothing regarding the call to reqMktData(). I believe that calling reqMktData() should automatically cause the tickPrice() method to print out the current price. Am I correct in believing that this is automatic upon calling reqMktData()? Or am I missing an extra step somewhere?

I am doing this outside of market hours but I don't believe that is my problem.

I have searched around this site and can't find anything suggesting that my code shouldn't work.

Thank you for any help.


Re: TwsActiveX.xls and Historical Bond Data

 

Steps:

Tried current date as end date and did get 6 M of historical in weeks and months.??


Re: model and model IV in options

 

Very useful pointers, thank you! I'm not trying to create my own option pricing model, just trying to understand what IB is computing.?


Re: Why is RTD data in Excel so buggy outside of market hours?

 

Anyone have any ideas? Surprised to get no replies...I can't be the only one experiencing this(?)


TwsActiveX.xls and Historical Bond Data

 

Greetings,

I've been a member and reader of the group for about a year, ...hello everyone!? I've been reading mostly, trying to figure an entry point in to
API programming for tws.??

I haven't dived in yet, but have been fiddling with the TwsActiveX.xls sample workbook.? Question? when attempting to receive historical bond
price data, the result is always one row, the most current.? Is this a limitation or is there a way to get historical bond data?


Re: Paper trading account value reset

 

Hello Stuart, thank you so much for your wonderful help.

I never would have figured that out on my own.

It works.

Thanks again,
Josef


Re: Bracket Order help

 

Python?


Bracket Order help

 

Hello everyone,

I am trying to mke a regular bracket order, however I would like the take profit price to be automatically placed a percentage, say 10% above the filled price of the parent order, and a percentage, say 5% automatically placed below the parent filled price..
Any help would be greatly appreciated.
Thank you
Adam


Re: Starting with TWS APi using C++, looking for advice

 

Regarding 2, I use TWS API. I can't remember why I didn't opt the second.

Cancelling/changing and tracking orders is a little bit more difficult. Modifying orders () necessitates you remembering all the order IDs. To modify order with id, say 300, you just submit another order using the same id: 300. Some fields you will be able to revise (e.g. price), others you won't.

If you're continuously revising passive limit orders, you'll need to keep all of these ids in some container, and then remove them when you get fill information back, taking care never to use any id more than once.

I remember a few things about it:

1.) revising orders seemed to be much quicker than cancelling and re-sending an order. This was my experience just by visually assessing performance on TWS GUI.

2.) I was always ending up with occasional errors, telling me that that order had already been filled or cancelled. I was always quite suspicious of the order info data feed. For instance, if IB doesn't trigger execDetails() fast enough to tell you about a fill, and you send off a revision, then you'll get a delayed error. I was being an idiot though, and trying to peg a limit buy at a tick below the best bid.

Conceivably you would have to deal with partial fills, too, but I personally was only trading a contract at a time for Eminis.?

3.) I was always ending up with "bad" fills, and had difficulty reconciling backtest behavior and live/paper trading behavior. I was always quite suspicious of the price/order data feed as well. For example, if your order data feed is delayed a little, and you're trying to peg orders to the best bid/ask, then you're probably not actually pegged. You tend to get filled faster for overly-ambitious orders, and not filled for too under-ambitious orders.

I gave up on this particular strategy, and moved to market orders, not keeping track of ids, and just incrementing the order id by 1 every time.


Re: OTC

 

Do a first to get it

Getting contract details is not an option! Forget about guessing, even is ISLAND = NASDAQ? you need to knwo whcih tape you listen to.

Avoid this mess do a reqConrtactDetails!

You will need it mandatory , not only do you need primary exchange but you will need the vital "conid"!

?


amex otc

Stuart Cracraft
 

Looks like the default out of the gate for new accounts is not to give universal trading access to amex and otc but okay for nasdaq and nyse.

Hopefully raising a ticket gets the
permissions granted.


Re: Bracket order - "good after time" fires immediately

 

You also need to set the TIF parameter to "GAT", otherwise the GAT value will be ignored (the default TIF is "GTC" = Good Till Cancelled)


Reuters Stock Report Plus

Jens Rohweder
 

Dear all,

is there a way to automatically download the latest Reuters Stock Report through the API?


Best regards
Jens