开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育
Date

Re: OCA order types and place in order queue

Ed
 

I actually haven't researched scenarios with multiple contracts or
more than 2 orders in the oca group. I use separate orders (and oca
groups) for 1 contract each which allows separate prices for each leg
and eliminates partial fill guessing games. I understand this would not
be efficient for large numbers of contracts but that is not an issue for
me - not quite up to trading 50 contracts at a time!

I send an empty field for the oca type and it has always canceled the
other side when one of the sides executes.

I'm not sure of your usage needs but normally you would want the other
side reduced proportionately rather than canceled. If you have a profit
and stop exit for 5 contracts and 3 of your profit exits fill, you
normally would want 2 contracts remaining on the stop. Otherwise you
have no stop exit and a position of 2 contracts.

Doesn't seem like I'm helping much but this is what I have experienced
with the oca's.

On 7/19/2013 12:48 PM, Davqe wrote:

The ocaType is in the C++ API documentation for the Order structure
(also in IOrder for ActiveX and I assume similar for other languages).
There are 2 blocking types, which guarantee that only 1 order will get
filled out of the group (eliminating possible overfill issue), and 1
type that does not block. I imagine because I am using the blocking
type, even native (LMT for example) orders get held on the server. But
there doesn't appear to be an option to cancel the other orders
without the blocking, only to reduce them.

Does your first fill order cancel all of the others, or does it just
reduce the others by the same amount of the fill?

--- In TWSAPI@... <mailto:TWSAPI%40yahoogroups.com>, Ed
<news1000@...> wrote:

Hmm. I use oca all the time and the limit orders are on the exchange.
I didn't know there were 'oca types' so maybe that changes how orders
are handled. If you use the default oca type do you still have the
issue?

I have been reading the TWS docs but haven't found a description of the
oca types.

On 7/19/2013 11:25 AM, Davqe wrote:

When I mouse over the profit exit, it says the order is being held
and
monitored just like the stop order. The row for the order on TWS
shows
the status column as dark blue, where if I place a single limit order
with no OCA, mousing over states that it is at the exchange and the
status color is green.

--- In TWSAPI@... <mailto:TWSAPI%40yahoogroups.com>
<mailto:TWSAPI%40yahoogroups.com>, Ed
<news1000@> wrote:

Limit orders are native to globex so your profit exit will be at the
exchange. This has nothing to do with oca.

The stop is not native so it must be simulated by ib.

If you mouse over the profit limit you should see a popup messsage
saying the order is at the exchange.




Re: OCA order types and place in order queue

Davqe
 

The ocaType is in the C++ API documentation for the Order structure (also in IOrder for ActiveX and I assume similar for other languages). There are 2 blocking types, which guarantee that only 1 order will get filled out of the group (eliminating possible overfill issue), and 1 type that does not block. I imagine because I am using the blocking type, even native (LMT for example) orders get held on the server. But there doesn't appear to be an option to cancel the other orders without the blocking, only to reduce them.

Does your first fill order cancel all of the others, or does it just reduce the others by the same amount of the fill?

--- In TWSAPI@..., Ed <news1000@...> wrote:

Hmm. I use oca all the time and the limit orders are on the exchange.
I didn't know there were 'oca types' so maybe that changes how orders
are handled. If you use the default oca type do you still have the issue?

I have been reading the TWS docs but haven't found a description of the
oca types.

On 7/19/2013 11:25 AM, Davqe wrote:

When I mouse over the profit exit, it says the order is being held and
monitored just like the stop order. The row for the order on TWS shows
the status column as dark blue, where if I place a single limit order
with no OCA, mousing over states that it is at the exchange and the
status color is green.

--- In TWSAPI@... <mailto:TWSAPI%40yahoogroups.com>, Ed
<news1000@> wrote:

Limit orders are native to globex so your profit exit will be at the
exchange. This has nothing to do with oca.

The stop is not native so it must be simulated by ib.

If you mouse over the profit limit you should see a popup messsage
saying the order is at the exchange.


[Non-text portions of this message have been removed]


Re: OCA order types and place in order queue

Ed
 

Hmm. I use oca all the time and the limit orders are on the exchange.
I didn't know there were 'oca types' so maybe that changes how orders
are handled. If you use the default oca type do you still have the issue?

I have been reading the TWS docs but haven't found a description of the
oca types.

On 7/19/2013 11:25 AM, Davqe wrote:

When I mouse over the profit exit, it says the order is being held and
monitored just like the stop order. The row for the order on TWS shows
the status column as dark blue, where if I place a single limit order
with no OCA, mousing over states that it is at the exchange and the
status color is green.

--- In TWSAPI@... <mailto:TWSAPI%40yahoogroups.com>, Ed
<news1000@...> wrote:

Limit orders are native to globex so your profit exit will be at the
exchange. This has nothing to do with oca.

The stop is not native so it must be simulated by ib.

If you mouse over the profit limit you should see a popup messsage
saying the order is at the exchange.


Re: OCA order types and place in order queue

Davqe
 

When I mouse over the profit exit, it says the order is being held and monitored just like the stop order. The row for the order on TWS shows the status column as dark blue, where if I place a single limit order with no OCA, mousing over states that it is at the exchange and the status color is green.

--- In TWSAPI@..., Ed <news1000@...> wrote:

Limit orders are native to globex so your profit exit will be at the
exchange. This has nothing to do with oca.

The stop is not native so it must be simulated by ib.

If you mouse over the profit limit you should see a popup messsage
saying the order is at the exchange.


Re: OCA order types and place in order queue

Ed
 

Limit orders are native to globex so your profit exit will be at the
exchange. This has nothing to do with oca.

The stop is not native so it must be simulated by ib.

If you mouse over the profit limit you should see a popup messsage
saying the order is at the exchange.

On 7/19/2013 11:05 AM, Davqe wrote:

I'm working on using OCA for my profit and loss orders. It appears
that once I set the orders up with an OCA group, they aren't actually
sitting at the exchange but rather are on an IB server waiting to be
triggered. I'm using ocaType of 1 (Cancel with Block). It is possible
to get the orders actually sitting in the queue at the exchange? For
futures contracts with a lot of market depth (S&P e-minis for
example), I want my profit limit order in the queue as early as
possible. If it waits until the price is touched, I'm at the back of
the queue at my limit price.

Am I misunderstanding the manner in which this works? Or is there
another way to specify the ocaType that will place the order at the
exchange and still handle the cancel once one is triggered.


OCA order types and place in order queue

Davqe
 

I'm working on using OCA for my profit and loss orders. It appears that once I set the orders up with an OCA group, they aren't actually sitting at the exchange but rather are on an IB server waiting to be triggered. I'm using ocaType of 1 (Cancel with Block). It is possible to get the orders actually sitting in the queue at the exchange? For futures contracts with a lot of market depth (S&P e-minis for example), I want my profit limit order in the queue as early as possible. If it waits until the price is touched, I'm at the back of the queue at my limit price.

Am I misunderstanding the manner in which this works? Or is there another way to specify the ocaType that will place the order at the exchange and still handle the cancel once one is triggered.


Re: TwsActivex.xls cannot "request account updates"??

jpgarciaa
 

This is the method you should call to request account updates
objTWSControl.m_TWSControl.reqAccountUpdates(True, accountName)

If you are managing more than one account, make sure to use the right one. Change to False if you want to cancel the updates.

JP

--- In TWSAPI@..., virusnme <no_reply@...> wrote:

I use TwsActiveX.xls excel sheet to connect to IB Gateway. The connection between IB Gateway and TwsActiveX.xls is fairly stable. However, on occasions when IB Gateway loses connection to IB Server, TwsActiveX.xls loses connection to IB Gateway. Eventually, IB Gateway reinstates a connection to IB server. And I will have to ensure that TwsActivex.xls reconnects to IB Gateway (via VBA).

I have figured out how to re-connect the TwsActivex.xls to IB Gateway but I am not able to "request account updates" via VBA! If anyone has figured out how to do it please do let me know.


Re: Connect to TWS in main not in Thread (Java)

 

I mainly suggested you choose wisely for your own needs.

If synchronization *is* a bitch and you are using 2 threads and one handles
incoming socket messages and the other is handling incoming GUI message,
then you may already have some issues on your hands if your have a user
interface that initiates socket events and displays results, if not for
other reasons. That's why for my preferences use 1 thread rather than 2,
knowing I can change this if it became a problem.

OTOH with Java's native threading support, if you know how to use it, maybe
it is no issue at all.

ASIDE: If btw... is a problem for Brian then "twsapi" could be a confusing
name for you to be using here (hint hint). It looks like you may both be
using yahoo for posting (with "twsapi" also having the no_reply feature), or
even as your email client. If you have an outside email client usually you
can just set your name for the From field and yahoo seems to honor it in
what it passes through. What you can do if you are fully inside yahoo, I
don't know, but no surprise if it is crippled to f'ing hell. If you can't
get a decent name through you can always name yourself in your signature. I
think "twsapi" is still fully anonymous at this point.

-Kurt

On 7/19/13 2:20 AM, "twsapi" <no_reply@...> wrote:

Hi Brian :), Kurt,

Thanks so much for your help! I will limit myself to just two threads and
actually based on also Kurt's comment synchronization can be a bitch so I
rather have two open connections in each thread than fumbling around with
thread concurrency :)

But guys, thanks so much you really helped me a lot!

Regards



Hi btw12342001,
Call me brian :). I have no idea how to change that login name.

thanks so much for the tip! That actually helps me a lot. I still did not
completely understood your earlier reply on how to handle returned data. In
which method is the returned data handled?
If you scroll down in Example1.java you will see the tickPrice method. This
is overriding the method of the same name in ExampleBase. All data from the
TWS socket gets sent to those methods in ExampleBase unless they are
overridden.

If you want more than one symbol you have to assign an separate id in the
request and then do something in tickPrice based on the returned tickerId.

I guess if the connection is not limited to just one thread you also run
into synchronization issues between the threads. But as far as I understood
you can initiate 6 or 8 connections but IB recommends to use as little as
possible, is that correct?
Yes, only use one connection. You don't even need the thread part, you could
delete the "extends thread" part in ExampleBase and then just call run,
however there's a thread.sleep in the run method and you would have to fix
the logic. I don't know what your purpose is so it's hard to tell you what
to do.

I wrote a very simple 1 file, console based program in the files section
under java.


6HUqFRn6EiCrYFcRz7u586_0orlX1Ezv82Y5JDJk9dcO5jxROw/Java%20Code/SimpleTWSconso
le.zip

Maybe that will be easier to understand, it's also a netbeans project.


Re: Connect to TWS in main not in Thread (Java)

twsapi
 

Hi Brian :), Kurt,

Thanks so much for your help! I will limit myself to just two threads and actually based on also Kurt's comment synchronization can be a bitch so I rather have two open connections in each thread than fumbling around with thread concurrency :)

But guys, thanks so much you really helped me a lot!

Regards


Hi btw12342001,
Call me brian :). I have no idea how to change that login name.

thanks so much for the tip! That actually helps me a lot. I still did not completely understood your earlier reply on how to handle returned data. In which method is the returned data handled?
If you scroll down in Example1.java you will see the tickPrice method. This is overriding the method of the same name in ExampleBase. All data from the TWS socket gets sent to those methods in ExampleBase unless they are overridden.

If you want more than one symbol you have to assign an separate id in the request and then do something in tickPrice based on the returned tickerId.

I guess if the connection is not limited to just one thread you also run into synchronization issues between the threads. But as far as I understood you can initiate 6 or 8 connections but IB recommends to use as little as possible, is that correct?
Yes, only use one connection. You don't even need the thread part, you could delete the "extends thread" part in ExampleBase and then just call run, however there's a thread.sleep in the run method and you would have to fix the logic. I don't know what your purpose is so it's hard to tell you what to do.

I wrote a very simple 1 file, console based program in the files section under java.



Maybe that will be easier to understand, it's also a netbeans project.


Re: VB6 TWS ActiveX Vs. IB Gateway

 

I don't know VB, but think it doesn't matter.

1. In all fundamental ways, Gateway works the same as TWS in terms of
connections. Since the Gateway has no purpose except to connect to API
clients, there is no need to make it an option.

2. TWS.Connect I don't know but yes you have to set the port appropriately.
The default port will be different in gateway than TWS, but if you've looked
in API - Settings you should have seen and had the opportunity to set the
port number and it should be no mystery. You can make the port number the
same as TWS if you like, and your setting will be remembered.

3. I don't use ActiveX but it is all the same socket. The Gateway is no
different from TWS in fundamental behavior. The system behavior is
different in various well-known ways, such as the fact that the gateway lets
you stay connected without your having to fight for it. There are probably
also subtle differences owing to the fact that they are different
executables and also are not necessarily released at the same time, so that
bugs may be different.

-Kurt

On 7/19/13 12:05 AM, "Edbar" <edbar@...> wrote:

I haven't used the gateway yet, but was wondering a few things:

1. Is any pre-configuration required to connect to the gateway from the VB6
program? For instance with TWS you had to go into tws and check "enable
activex and socket clients". But I notice that options isn't even there inte
gateway configuaration.

2. Do I have to change the TWS.Connect line to connect to the gateway vs
connecting to tws? My connect isn't working and I'm wondering if I have to
change the port. I've already got the gateway logged in and running but the
program doesn't connect to it.

3. Will all the tws activex methods and events work the same with the gateway
as they did with tws?

Thanks,

Ed


VB6 TWS ActiveX Vs. IB Gateway

Edbar
 

I haven't used the gateway yet, but was wondering a few things:

1. Is any pre-configuration required to connect to the gateway from the VB6 program? For instance with TWS you had to go into tws and check "enable activex and socket clients". But I notice that options isn't even there inte gateway configuaration.

2. Do I have to change the TWS.Connect line to connect to the gateway vs connecting to tws? My connect isn't working and I'm wondering if I have to change the port. I've already got the gateway logged in and running but the program doesn't connect to it.

3. Will all the tws activex methods and events work the same with the gateway as they did with tws?

Thanks,

Ed


Re: problem with contract details

 

It is 7/18, and I just noticed the recently slow contract details behavior
seems to have reverted back to what it was previously.

-Kurt

On 7/15/13 6:31 AM, "dairen62" <no_reply@...> wrote:

Good news... the problem will be fixed on 7/18. We just need to include the
full expiration in the format of YYYYMMDD when invoking the reqContractDeta
ils( ) method.

--- In TWSAPI@..., dairen62 <no_reply@...> wrote:

i received exactly the same answer... hope for a quick solution :)

--- In TWSAPI@..., clove2hitch <no_reply@> wrote:

just got an answer from IB API support.
1 minute issue should be solved in near future(when???)

Unfortunately IB imposes limitations on the amount of contracts
that can be returned when invoking the reqContractDetails( ) method.
In this particular case it would be best to include additional
contract parameters which will narrow your scope.
Example if you include m_expiration and m_right then you can
determine all the available strikes for that particular expiration.
Alternatively if you include m_strike and m_right you can determine
all the available expirations.
But please note there are currently an issue that development is
working on with respect to Option Contracts. It seems even though
you include the m_expiry there still is a 1 minute buffer for
additional requests. Once this has been resolved I will provide
you a follow-up comment on this ticket with additional details,

--- In TWSAPI@..., clove2hitch <no_reply@> wrote:

Hi, i experience same issues!
the first request answers quickly then a second after 1 minute
then nothing... :-(

I updated TWS and API to use latest stuff but even worse
with the <>clients.exe crash (previous API clients versions don't crash).

I'm going to log the issue to IB.
Regards
CH

--- In TWSAPI@..., dairen62 <no_reply@> wrote:

Yes, when i try to take the options chain every call to
reContractDetailsEx (with strike set to zero) lasts 1 minute instead the
normal 6 seconds. I also notice that the demo program of the API
(client3.exe) crash when you use "reqContractData". Can you try if you
have the same problem?

thanks

--- In TWSAPI@..., "rwk2095" <r@...> wrote:



Is this still a problem? I just ran a program at 8:25 EST on 11 JUL, and
everything appears normal on Globex (E6).

[rwk]



--- dairen62 <no_reply@> wrote:

hi everybody, i've a little program that that takes the chain of the
options using the method reqContractDetailsEx (ActiveX). It worked fine
till yesterday: every call to reqContractDetailsEx lasts 1 minute versus
the 6 seconds of before yesterday. In this way the program is
dramaticaly slow. Anyone experienced the same?


------------------------------------

Yahoo! Groups Links




Re: C# Option Contract Details

 

not sure of your problem but getting a full option chain for the underlying was never a problem for my code
the biggest problem was getting all the details and it timing out.
nick

On 7/18/2013 8:45 PM, andrewcmeier wrote:
Sorry, I've been away.
That looks fine, I'm happy that I've got what I need now to download data, havn't been able to retrieve an option chain but I've come up with a workaround that is quicker. Basically I'm downloading the option details from Yahoo in advance, storing the details in a file, then reading this file to download 100 option prices at a time, works out quicker because I can filter it ahead of time and be downloading 100 options at a time rather than 1 stock at a time. The programming to split the 100 options into their stocks is a bit of a pain though.

Thanks for your input.

--- In TWSAPI@..., "t0ksik" <seventhpoint@...> wrote:


I am not sure if anyone has answered your question to your satisfaction yet but I wanted to give you what I have figured out for options.

using request market data you would have something like this in c#

client.RequestMarketData(i, new Option("BAC", "BAC130720C00012000", "", RightType.Undefined, 0), some collection, false, false);

--- In TWSAPI@..., "andrewcmeier" <andrewcmeier@> wrote:
I've tried both dates, no luck.

--- In TWSAPI@..., Peter Gum <petergum@> wrote:

Should '20130719' be '20130720'? I.e. 19 -> 20 to match the tws market line. (Although IB will expire the option on the 19th. Confusing.)
Pete



On 07/14/13, andrewcmeier<andrewcmeier@> wrote:




Oops, Tester and A1 were meant to be the same variable in the options lines, change Tester to A1 and that is what I have.

--- In TWSAPI@..., "andrewcmeier" <andrewcmeier@> wrote:
Hi there,
I've started using the Krs.Ats.IBNet software () to develop TWS software in C#.

Setting up equities is easy enough:
Equity Google = new Equity("GOOG");
client.RequestMarketData(14, Google, null, true, false);

But when I try to adapt it to options, I can't get it to work. This is what I'm using:
Option A1 = new Option("AA", "AA", "20130719", RightType.Call, 8.0m);
client.RequestMarketData(15, Tester, null, false, false);

This is what it has in its class):
public Option(string equitySymbol, string optionSymbol, string expiry,
RightType right, decimal strike)

This is the error I get when I raise e.ErrorCode:
"No security definition has been found for the request"

Does anyone know what I'm entering wrong, or just how to set up an option in C#? I also then wan't to be able to leave fields out to do things such as return all the contracts in a month, does anyone have any examples how to do this?

I'm finding that C# should be a good way to download and analyse data but don't have any documentation, I've only worked out what to do from searching through lots of the code.

Thanks for your help.


------------------------------------

Yahoo! Groups Links




C# Option Contract Details

andrewcmeier
 

Sorry, I've been away.
That looks fine, I'm happy that I've got what I need now to download data, havn't been able to retrieve an option chain but I've come up with a workaround that is quicker. Basically I'm downloading the option details from Yahoo in advance, storing the details in a file, then reading this file to download 100 option prices at a time, works out quicker because I can filter it ahead of time and be downloading 100 options at a time rather than 1 stock at a time. The programming to split the 100 options into their stocks is a bit of a pain though.

Thanks for your input.

--- In TWSAPI@..., "t0ksik" <seventhpoint@...> wrote:



I am not sure if anyone has answered your question to your satisfaction yet but I wanted to give you what I have figured out for options.

using request market data you would have something like this in c#

client.RequestMarketData(i, new Option("BAC", "BAC130720C00012000", "", RightType.Undefined, 0), some collection, false, false);

--- In TWSAPI@..., "andrewcmeier" <andrewcmeier@> wrote:

I've tried both dates, no luck.

--- In TWSAPI@..., Peter Gum <petergum@> wrote:


Should '20130719' be '20130720'? I.e. 19 -> 20 to match the tws market line. (Although IB will expire the option on the 19th. Confusing.)
Pete



On 07/14/13, andrewcmeier<andrewcmeier@> wrote:




Oops, Tester and A1 were meant to be the same variable in the options lines, change Tester to A1 and that is what I have.

--- In TWSAPI@..., "andrewcmeier" <andrewcmeier@> wrote:

Hi there,
I've started using the Krs.Ats.IBNet software () to develop TWS software in C#.

Setting up equities is easy enough:
Equity Google = new Equity("GOOG");
client.RequestMarketData(14, Google, null, true, false);

But when I try to adapt it to options, I can't get it to work. This is what I'm using:
Option A1 = new Option("AA", "AA", "20130719", RightType.Call, 8.0m);
client.RequestMarketData(15, Tester, null, false, false);

This is what it has in its class):
public Option(string equitySymbol, string optionSymbol, string expiry,
RightType right, decimal strike)

This is the error I get when I raise e.ErrorCode:
"No security definition has been found for the request"

Does anyone know what I'm entering wrong, or just how to set up an option in C#? I also then wan't to be able to leave fields out to do things such as return all the contracts in a month, does anyone have any examples how to do this?

I'm finding that C# should be a good way to download and analyse data but don't have any documentation, I've only worked out what to do from searching through lots of the code.

Thanks for your help.


Re: problem with contract details

 

This has indeed been fixed for live and paper trading accounts, but not for edemo

--- In TWSAPI@..., dairen62 <no_reply@...> wrote:


Good news... the problem will be fixed on 7/18. We just need to include the full expiration in the format of YYYYMMDD when invoking the reqContractDeta ils( ) method.

--- In TWSAPI@..., dairen62 <no_reply@> wrote:

i received exactly the same answer... hope for a quick solution :)

--- In TWSAPI@..., clove2hitch <no_reply@> wrote:

just got an answer from IB API support.
1 minute issue should be solved in near future(when???)

Unfortunately IB imposes limitations on the amount of contracts
that can be returned when invoking the reqContractDetails( ) method.
In this particular case it would be best to include additional
contract parameters which will narrow your scope.
Example if you include m_expiration and m_right then you can
determine all the available strikes for that particular expiration.
Alternatively if you include m_strike and m_right you can determine
all the available expirations.
But please note there are currently an issue that development is
working on with respect to Option Contracts. It seems even though
you include the m_expiry there still is a 1 minute buffer for
additional requests. Once this has been resolved I will provide
you a follow-up comment on this ticket with additional details,

--- In TWSAPI@..., clove2hitch <no_reply@> wrote:

Hi, i experience same issues!
the first request answers quickly then a second after 1 minute
then nothing... :-(

I updated TWS and API to use latest stuff but even worse
with the <>clients.exe crash (previous API clients versions don't crash).

I'm going to log the issue to IB.
Regards
CH

--- In TWSAPI@..., dairen62 <no_reply@> wrote:

Yes, when i try to take the options chain every call to reContractDetailsEx (with strike set to zero) lasts 1 minute instead the normal 6 seconds. I also notice that the demo program of the API (client3.exe) crash when you use "reqContractData". Can you try if you have the same problem?

thanks

--- In TWSAPI@..., "rwk2095" <r@...> wrote:



Is this still a problem? I just ran a program at 8:25 EST on 11 JUL, and everything appears normal on Globex (E6).

[rwk]



--- dairen62 <no_reply@> wrote:

hi everybody, i've a little program that that takes the chain of the options using the method reqContractDetailsEx (ActiveX). It worked fine till yesterday: every call to reqContractDetailsEx lasts 1 minute versus the 6 seconds of before yesterday. In this way the program is dramaticaly slow. Anyone experienced the same?


TwsActivex.xls cannot "request account updates"??

virusnme
 

I use TwsActiveX.xls excel sheet to connect to IB Gateway. The connection between IB Gateway and TwsActiveX.xls is fairly stable. However, on occasions when IB Gateway loses connection to IB Server, TwsActiveX.xls loses connection to IB Gateway. Eventually, IB Gateway reinstates a connection to IB server. And I will have to ensure that TwsActivex.xls reconnects to IB Gateway (via VBA).

I have figured out how to re-connect the TwsActivex.xls to IB Gateway but I am not able to "request account updates" via VBA! If anyone has figured out how to do it please do let me know.


Re: Connect to TWS in main not in Thread (Java)

btw12342001
 

--- In TWSAPI@..., twsapi <no_reply@...> wrote:



Hi btw12342001,
Call me brian :). I have no idea how to change that login name.

thanks so much for the tip! That actually helps me a lot. I still did not completely understood your earlier reply on how to handle returned data. In which method is the returned data handled?
If you scroll down in Example1.java you will see the tickPrice method. This is overriding the method of the same name in ExampleBase. All data from the TWS socket gets sent to those methods in ExampleBase unless they are overridden.

If you want more than one symbol you have to assign an separate id in the request and then do something in tickPrice based on the returned tickerId.

I guess if the connection is not limited to just one thread you also run into synchronization issues between the threads. But as far as I understood you can initiate 6 or 8 connections but IB recommends to use as little as possible, is that correct?
Yes, only use one connection. You don't even need the thread part, you could delete the "extends thread" part in ExampleBase and then just call run, however there's a thread.sleep in the run method and you would have to fix the logic. I don't know what your purpose is so it's hard to tell you what to do.

I wrote a very simple 1 file, console based program in the files section under java.



Maybe that will be easier to understand, it's also a netbeans project.


Re: Connect to TWS in main not in Thread (Java)

 

Hi,

Breaking in, I have a vague memory there may be people who said they open
multiple connections in order to have a dedicated thread for each, but it is
highly unusual and probably not necessary.

Bottom line is if you do not have specific reason to make your life
complicated, don't make your threading model more complex than it needs to
be for your well-understood purposes. This certainly does not require
multiple connections and you can still spawn threads to handle computations
that can be factored in that way, if you like. I suggest you start with a
fewest-thread-possible approach. Personally I choose 1 thread and do not
use a separate reader thread. Sometimes the environment may present you
with a separate reader thread and you can write some code to funnel the
results from that back to the main thread. There have been endless
arguments here about the incredible importance or incredible unnecessity of
having additional threads for this or that. It is a big topic and has been
discussed for weeks on end numerous times. If you want to learn about it I
suggest your read the archives, but in the meantime stick with 1 thread, or
2 if that comes naturally in your context and you can manage it.

A common suggestion is to use a single thread to dispatch data *quickly* to
other threads so the main thread is close enough to always available to
handle the next incoming message. Anything processed quickly can be handled
on that thread and anything not can be put in a queue and handled elsewhere.
(Meanwhile just start coding without worrying about that until you need to.)

Regarding returned data the easy solution is to always override ALL callback
methods and log the results from every callback. Then you have no doubt
what data is returned through which callback, in case the documentation is
vague about it (or non-existent).

-Kurt

On 7/16/13 12:45 AM, "twsapi" <no_reply@...> wrote:

Hi btw12342001,

thanks so much for the tip! That actually helps me a lot. I still did not
completely understood your earlier reply on how to handle returned data. In
which method is the returned data handled? I guess if the connection is not
limited to just one thread you also run into synchronization issues between
the threads. But as far as I understood you can initiate 6 or 8 connections
but IB recommends to use as little as possible, is that correct?

Regards

--- In TWSAPI@..., "btw12342001" <newguy@...> wrote:


Not much of automation when I need to authorize it manually every time :)
To fix the authorizing part you just need to set trusted IP addresses in TWS.
Add 127.0.0.1 for the local machine.


Re: NKD data

jayfunandgames
 

Nice, that works. Thanks a lot for the tip.

--- In TWSAPI@..., Ed <news1000@...> wrote:

Try omitting local symbol and use expiration date of 201309 instead.

On 7/16/2013 10:06 PM, jayfunandgames wrote:

Trying to request NKD data, buy having a problem.

Using the following info
Symbol: NKD
Type: FUT
Exchange: GLOBEX
Local Symbol: NKD SEP 13

This is the format that I used when requesting YM futures, so I'm not
sure what I'm doing wrong.

Is there a good place that will show you the format needed for the
different types of requests?

Thanks,

Jay



[Non-text portions of this message have been removed]


Re: NKD data

Ed
 

Try omitting local symbol and use expiration date of 201309 instead.

On 7/16/2013 10:06 PM, jayfunandgames wrote:

Trying to request NKD data, buy having a problem.

Using the following info
Symbol: NKD
Type: FUT
Exchange: GLOBEX
Local Symbol: NKD SEP 13

This is the format that I used when requesting YM futures, so I'm not
sure what I'm doing wrong.

Is there a good place that will show you the format needed for the
different types of requests?

Thanks,

Jay