开云体育

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

twsapi: Re: order IDs

kxlin99
 

Hi Marcus -

Have you ever tried reqopenorders and openorder1/openorder2? It seems
to me they behave strangely.

1. openorder1/openorder2 only fire once after reconnect
2. only one open order id is returned no matter how many open orders
you have
3. open order id changed upon reqopenorders called

Do you know what the permID for ? Thanks


Re: stockwatchpro

ruffstuff123
 

--- In twsapi@y..., "gugute01" <gugute01@y...> wrote:
Found this on silicon investor IB board. I tried stockwatchpro
along
with IB today, works pretty good. I wish IB removed BEST routing
restriction on its API.

Is it possible to make a trailing stop systm with that formula
language???



---------------------------------------------------------
Stock Watch Pro 2.3 with IB TWS integration just got released.
Orders
can be initiated from Stock Watch Pro as follows:
- QuoteSheets (double-clicking on bid or ask)
- Level II or Island book (double-clicking on a market maker)
- Charts (from the right-click menu)
- From alerts when they trigger. SWP formula language allows you to
define any condition and associate an order with it.

Stock Watch Pro website:
For integration details see


AW: twsapi: Re: order IDs

 

开云体育

Hi David,
?
I use? a access database and MS-Access, which is included with MS-Office Pro. I program in Access-VisualBasic for applications.
?
Normally, I get any change to the orderstatus immidiatly and store it immidiatly in the database.
?
The situation descriped below is just for the rare case that one application crashes or the API connection breaks.
?
Marcus

-----Ursprüngliche Nachricht-----
Von: David [mailto:kotomo@...]
Gesendet: Sunday, June 30, 2002 5:36 AM
An: twsapi@...
Betreff: Re: twsapi: Re: order IDs
Wichtigkeit: Niedrig

I do not use that many orders but your idea, Marcus, is a fanatastic way to have a good, even though delayed, control of your orders.
Do you use any special db or just free dbjet engine?
well done.
David
----- Original Message -----
Sent: Sunday, June 30, 2002 5:05 PM
Subject: AW: twsapi: Re: order IDs

I store everything in a database, including the order details and the order
id.
When you have a Limit order which doesn?t get executed, and you disconnect,
close TWS, open TWS, and reconnect through the API to TWS, then TWS forget?s
the API order ID.

So I decided that I cancel all open orders manually in TWS and then send all
open orders again from my programm to TWS.

Marcus

-----Ursprungliche Nachricht-----
Von: kxlin99 [mailto:klin@...]
Gesendet: Sunday, June 30, 2002 1:49 AM
An: twsapi@...
Betreff: twsapi: Re: order IDs


Hi there -

I would like to know how you manage order ids from session to
session. I meant you place an order and store the order id in your
table, what if the TWS/Windows crashed, and you need reboot the
machine, how do you change/cancel your open orders? Thanks

--- In twsapi@y..., Robert Carey wrote:
> You have to keep track of your trading over time. You have to keep
track of what you or your Automated Trading System is doing. You need
to store what was done, when, and why.
> Besides, the IRS is coming on 4/15/2003 for sure, if not sooner.
> That means storage of your trading events on a hard drive and with
backup.
> I choose to use the Microsoft .mdb format and access it from VB
with DAO 3.6.
> There is a table of trades. It has an entry order number and an
exit order number in each record. There are lots of other fields to
keep track of when, where, and why.
> A recordset RS.TradesEnter is created indexed on the
openOrderNumber.
> A recordset RS.TradesExit is created indexed on the exitOrderNumber.
> They both point to the same table.
>
> Creating a unique entry order number is as follows.
> RS.TradesEnter.MoveLast
> thisEntryOrderNumber = RS.TradesEnter![openOrderNumber] + 2
> thisExitOrderNumber = thisEntryOrderNumber + 1
> Now create a new trade record.
> RS.TradesEnter.AddNew
>???? RS.TradesEnter![openOrderNumber] = thisEntryOrderNumber
>???? RS.TradesEnter![closeOrderNumber] = thisExitOrderNumber
> RS.TradesEnter.Update
>
> When a fill arrives, whether partial of full, RS.TradesEnter
updates the when,where,why fields.
> When you or your ATS decides to close a position,
RS.TradesExit "seeks" this ExitOrderNumber and updates the when,
where, why fields.
> That should keep you and the IRS happy.
> Comments?
> RCarey


Yahoo! Groups Sponsor
ADVERTISEMENT



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the .


To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the .


Re: twsapi: Re: order IDs

David
 

开云体育

I do not use that many orders but your idea, Marcus, is a fanatastic way to have a good, even though delayed, control of your orders.
Do you use any special db or just free dbjet engine?
well done.
David

----- Original Message -----
Sent: Sunday, June 30, 2002 5:05 PM
Subject: AW: twsapi: Re: order IDs

I store everything in a database, including the order details and the order
id.
When you have a Limit order which doesn?t get executed, and you disconnect,
close TWS, open TWS, and reconnect through the API to TWS, then TWS forget?s
the API order ID.

So I decided that I cancel all open orders manually in TWS and then send all
open orders again from my programm to TWS.

Marcus

-----Ursprungliche Nachricht-----
Von: kxlin99 [mailto:klin@...]
Gesendet: Sunday, June 30, 2002 1:49 AM
An: twsapi@...
Betreff: twsapi: Re: order IDs


Hi there -

I would like to know how you manage order ids from session to
session. I meant you place an order and store the order id in your
table, what if the TWS/Windows crashed, and you need reboot the
machine, how do you change/cancel your open orders? Thanks

--- In twsapi@y..., Robert Carey wrote:
> You have to keep track of your trading over time. You have to keep
track of what you or your Automated Trading System is doing. You need
to store what was done, when, and why.
> Besides, the IRS is coming on 4/15/2003 for sure, if not sooner.
> That means storage of your trading events on a hard drive and with
backup.
> I choose to use the Microsoft .mdb format and access it from VB
with DAO 3.6.
> There is a table of trades. It has an entry order number and an
exit order number in each record. There are lots of other fields to
keep track of when, where, and why.
> A recordset RS.TradesEnter is created indexed on the
openOrderNumber.
> A recordset RS.TradesExit is created indexed on the exitOrderNumber.
> They both point to the same table.
>
> Creating a unique entry order number is as follows.
> RS.TradesEnter.MoveLast
> thisEntryOrderNumber = RS.TradesEnter![openOrderNumber] + 2
> thisExitOrderNumber = thisEntryOrderNumber + 1
> Now create a new trade record.
> RS.TradesEnter.AddNew
>???? RS.TradesEnter![openOrderNumber] = thisEntryOrderNumber
>???? RS.TradesEnter![closeOrderNumber] = thisExitOrderNumber
> RS.TradesEnter.Update
>
> When a fill arrives, whether partial of full, RS.TradesEnter
updates the when,where,why fields.
> When you or your ATS decides to close a position,
RS.TradesExit "seeks" this ExitOrderNumber and updates the when,
where, why fields.
> That should keep you and the IRS happy.
> Comments?
> RCarey


Yahoo! Groups Sponsor
ADVERTISEMENT



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the .


Re: twsapi: Modifying an order & testing

ruffstuff123
 

--- In twsapi@y..., "marinindextrader" <marinindextrader@y...> wrote:
There is nothing in the files section that specifically deals with
trailing stops...though I can asure you that someday not to long
from
now it will
Wow!
Can't hardly wait :)





As to your trailing stop question:

It is my understanding that this can be handled in a few different
ways:
(whole explanation is about long postions)
IMO serverbased orders are always best (method B/C)because:
- Method A can be dangerous when loosing a connection. (client/ISP
down or internet overload with 11 sept like events)

- Serverbased orders have an other advantage IMO
Say there are 2 traders with a stop on MSFT.
TraderA=client based
TraderB=server based
TraderB is better of because:
a] The server 'knows' first about a stop being hit
b] The server order is older then the the order that TraderA submits
just after the stop is hit. And assuming the orders have the same
stop the server will execute the one that is the oldest first.
This can be an advantage when there is low volume or sudden
declines.


Stop system.....
I use an 'advanced' stop system (manually)
I use a adaptive stop system. Lemme explain.
a] I enter the market with a 5% stop
b] Calculate the expect price target (usually a res line)
c] The stop at the resline is 2%
So the stop gets gradually smaller as the stock rises.

Market vs limit orders.
I only use market orders as a last resort.
In most cases a stock just pull back. No critical situation of any
kind. Say from $100 to $98
Sell at $97.50 would be a 'fair' trade.
But what if the next bid is absurtly low? You know the $0.06 kinda
orders you see now and then....
If I get hit by such an trade I rather didn't use my stop.
You won't have that problem with high volume stocks like MSFT that
has 1000's of traders at each price. But with lower volume stocks
before/after markets hours this can be a real danger.
So we need to place a sell at the next bid (minus a few cents)
If the next bid isn't realistic just place an higher sell order.





Method A:

Have no server sided order and have an order on your client side
that
is ready to execute. You track the security price on your side,
then
if and when certain price events occur, you do one of two things:
modify the ready order, or go ahead and send it

Method B:

Have a standing order on the server, and if and when price events
occur one of two things happens. You do nothing and the standing
order is executed on the server side (you got stopped out), Or, You
resubmit the order with modifications using the identical id # (not
positive about this one), and the server sided order is modified
(an
event occured that triggered your modified order to send).

Method C:

Have a standing order on the server side, and when events occur
either one of two things happen. The order triggers (you were
stopped
out), or you cancel the order and resubmit a new order with your
new
parameters based on a price action event.


another java dev here, UNIX/Linux questions...

 

Hello everyone, I'm another professional Java developer more than
willing to lend a hand if anyone needs it. I also have more than 5
years of Java dev experience, on all levels but mostly involving UI
development, and especially swing...and data vis. :)

Also have a good bit of C++ experience.

I'm curious about two things as I get started on my own Java
project involving IB and their API. First, I think I'm understanding
that you have to have TWS running locally and that the socket client
checkbox must be checked in order to use the API. Is this correct? It
seems it must be true because the API does not offer any login
support.

Second, does anyone have experience using the Linux/UNIX client or
the Linux/UNIX APIs? Love to hear about any potential problems there.

Thanks!
Randy


AW: twsapi: Re: order IDs

 

I store everything in a database, including the order details and the order
id.
When you have a Limit order which doesn?t get executed, and you disconnect,
close TWS, open TWS, and reconnect through the API to TWS, then TWS forget?s
the API order ID.

So I decided that I cancel all open orders manually in TWS and then send all
open orders again from my programm to TWS.

Marcus

-----Ursprungliche Nachricht-----
Von: kxlin99 [mailto:klin@...]
Gesendet: Sunday, June 30, 2002 1:49 AM
An: twsapi@...
Betreff: twsapi: Re: order IDs


Hi there -

I would like to know how you manage order ids from session to
session. I meant you place an order and store the order id in your
table, what if the TWS/Windows crashed, and you need reboot the
machine, how do you change/cancel your open orders? Thanks

--- In twsapi@y..., Robert Carey <rcarey1@o...> wrote:
You have to keep track of your trading over time. You have to keep
track of what you or your Automated Trading System is doing. You need
to store what was done, when, and why.
Besides, the IRS is coming on 4/15/2003 for sure, if not sooner.
That means storage of your trading events on a hard drive and with
backup.
I choose to use the Microsoft .mdb format and access it from VB
with DAO 3.6.
There is a table of trades. It has an entry order number and an
exit order number in each record. There are lots of other fields to
keep track of when, where, and why.
A recordset RS.TradesEnter is created indexed on the
openOrderNumber.
A recordset RS.TradesExit is created indexed on the exitOrderNumber.
They both point to the same table.

Creating a unique entry order number is as follows.
RS.TradesEnter.MoveLast
thisEntryOrderNumber = RS.TradesEnter![openOrderNumber] + 2
thisExitOrderNumber = thisEntryOrderNumber + 1
Now create a new trade record.
RS.TradesEnter.AddNew
RS.TradesEnter![openOrderNumber] = thisEntryOrderNumber
RS.TradesEnter![closeOrderNumber] = thisExitOrderNumber
RS.TradesEnter.Update

When a fill arrives, whether partial of full, RS.TradesEnter
updates the when,where,why fields.
When you or your ATS decides to close a position,
RS.TradesExit "seeks" this ExitOrderNumber and updates the when,
where, why fields.
That should keep you and the IRS happy.
Comments?
RCarey

Yahoo! Groups Sponsor
ADVERTISEMENT



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


Re: order IDs

kxlin99
 

Hi there -

I would like to know how you manage order ids from session to
session. I meant you place an order and store the order id in your
table, what if the TWS/Windows crashed, and you need reboot the
machine, how do you change/cancel your open orders? Thanks

--- In twsapi@y..., Robert Carey <rcarey1@o...> wrote:
You have to keep track of your trading over time. You have to keep
track of what you or your Automated Trading System is doing. You need
to store what was done, when, and why.
Besides, the IRS is coming on 4/15/2003 for sure, if not sooner.
That means storage of your trading events on a hard drive and with
backup.
I choose to use the Microsoft .mdb format and access it from VB
with DAO 3.6.
There is a table of trades. It has an entry order number and an
exit order number in each record. There are lots of other fields to
keep track of when, where, and why.
A recordset RS.TradesEnter is created indexed on the
openOrderNumber.
A recordset RS.TradesExit is created indexed on the exitOrderNumber.
They both point to the same table.

Creating a unique entry order number is as follows.
RS.TradesEnter.MoveLast
thisEntryOrderNumber = RS.TradesEnter![openOrderNumber] + 2
thisExitOrderNumber = thisEntryOrderNumber + 1
Now create a new trade record.
RS.TradesEnter.AddNew
RS.TradesEnter![openOrderNumber] = thisEntryOrderNumber
RS.TradesEnter![closeOrderNumber] = thisExitOrderNumber
RS.TradesEnter.Update

When a fill arrives, whether partial of full, RS.TradesEnter
updates the when,where,why fields.
When you or your ATS decides to close a position,
RS.TradesExit "seeks" this ExitOrderNumber and updates the when,
where, why fields.
That should keep you and the IRS happy.
Comments?
RCarey


Tickers & 40 More Tickers....Someone Try This....See If It Works

marinindextrader
 

I wonder....wanting of more Ticker's....
[in regards to the 40 ticker limit to API users]

If one logged on through multiple instance of the API moduel via an
array or segragate naming could they pull more than 40 or multiples
of 40?

I will bet ya dozen Krispy Kreme your good to go....

Dim iTemp As Integer

For iTemp = 0 To UBound(TWS1)

TWS1(iTemp).connect "", 7496 + iTemp

Next iTemp

If id <= 39 Then

TWS1(0).reqMktData(yada yada)

Else If id > 39 And id <= 79 Then

TWS1(1).reqMktData(yada yada)

End If

makes one wonder doesn't it?

If anyone has time to burn give this a rip and see if it works...I
will get around to it eventually but I am focused elswhere...

Scott
Yhoo TWSAPI


Re: twsapi: Modifying an order & testing

marinindextrader
 

There is nothing in the files section that specifically deals with
trailing stops...though I can asure you that someday not to long from
now it will

As TonkaDad said there is a demo server

To log in:

Username for equities demo: edemo

Username for commodities demo: cdemo

And in both of the above cases the password is:

demouser


As to your trailing stop question:

It is my understanding that this can be handled in a few different
ways:

Method A:

Have no server sided order and have an order on your client side that
is ready to execute. You track the security price on your side, then
if and when certain price events occur, you do one of two things:
modify the ready order, or go ahead and send it

Method B:

Have a standing order on the server, and if and when price events
occur one of two things happens. You do nothing and the standing
order is executed on the server side (you got stopped out), Or, You
resubmit the order with modifications using the identical id # (not
positive about this one), and the server sided order is modified (an
event occured that triggered your modified order to send).

Method C:

Have a standing order on the server side, and when events occur
either one of two things happen. The order triggers (you were stopped
out), or you cancel the order and resubmit a new order with your new
parameters based on a price action event.

I havn't explored the nuts and bolts of it yet...but that is how I
believe it is played out. Which method one chooses is a matter of
prefrence and the liquidity of the market you trade.

Scott





--- In twsapi@y..., "Bruce Hawkins" <hawkinsk001@h...> wrote:
I to would like to know how to place trailing stops.

If you go to on the left
about half way down
it should say "Files" there is some code there. Also Jaba put
together a simple project that you can download look at post 189.

As far as testing before you go live IB has a demo that you can
connect to.

Good luck,

Tonkadad
----- Original Message -----
From: ruffstuff123
To: twsapi@y...
Sent: Saturday, June 29, 2002 10:05 AM
Subject: twsapi: Modifying an order & testing


Hi,

First post in this forum. I hope this question han't been posted
before.......

The only thing that I'm really missing is a trailing stop.
Anyone managed to code something like that?
If so please mail me the code or point me to an example.
It would save me huge amounts of time.
Finally away from the screen for a few hours :-)

I can code a bit in VB6. Level... erm... advanced 'Hello world' ;)
But if anyone would be so kind to share a few lines of code that
modifies an order I have enough to build on.

Is their a way to test without placing real trades?
Needless to say a little bug can cost 1000's........

Looking forward to the replies.
And to the founder(s) of this group: Great initiative!

Kind regards.



Yahoo! Groups Sponsor
ADVERTISEMENT



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@y...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.


Re: twsapi: Modifying an order & testing

 

开云体育

I to would like to know how to place trailing stops.
?
If you go to on the left about half way down
it should say "Files" there is some code there. Also Jaba put together a simple project that you can download look at post 189.
?
As far as testing before you go live IB has a demo that you can connect to.
?
Good luck,
?
Tonkadad

----- Original Message -----
Sent: Saturday, June 29, 2002 10:05 AM
Subject: twsapi: Modifying an order & testing

Hi,

First post in this forum. I hope this question han't been posted
before.......

The only thing that I'm really missing is a trailing stop.
Anyone managed to code something like that?
If so please mail me the code or point me to an example.
It would save me huge amounts of time.
Finally away from the screen for a few hours :-)

I can code a bit in VB6. Level... erm... advanced 'Hello world' ;)
But if anyone would be so kind to share a few lines of code that
modifies an order I have enough to build on.

Is their a way to test without placing real trades?
Needless to say a little bug can cost 1000's........

Looking forward to the replies.
And to the founder(s) of this group: Great initiative!

Kind regards.




To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the .


Modifying an order & testing

ruffstuff123
 

Hi,

First post in this forum. I hope this question han't been posted
before.......

The only thing that I'm really missing is a trailing stop.
Anyone managed to code something like that?
If so please mail me the code or point me to an example.
It would save me huge amounts of time.
Finally away from the screen for a few hours :-)

I can code a bit in VB6. Level... erm... advanced 'Hello world' ;)
But if anyone would be so kind to share a few lines of code that
modifies an order I have enough to build on.

Is their a way to test without placing real trades?
Needless to say a little bug can cost 1000's........

Looking forward to the replies.
And to the founder(s) of this group: Great initiative!

Kind regards.


Autostoptrailing

 

Hi,
i tried to run autostoptrailing using dde interface and the example
from tws manuel. It didn't work properly. Any idea's ?

Thx for help


IB TWS API Thread at WL.

techguy1313
 

Hi, I'm Techguy:

I started an IB Automation thread at Wealth Lab, under the Automation
Category. Click here to read it. It may have some value to you, and
will certainly expose my limited programming ability - but there may
be some good information there for you as well.



Some of you may know me from elsewhere - other forums - same guy. If
you are in the Seattle or Portland area, we have a group of Trader
Programmers that meet regularly: Here is the contact info:

The PDX and Seatac Wealth Lab User Groups are now centralized at the
Yahoo Groups area. Members can post, view the calendar, upload files,
chat, and generally keep themselves informed of the PDX WLUG
happenings.

Membership is by moderator acceptance. Content is un-moderated.

All Backtesting / Trading suite Users / Programmers / Developers are
invited to attend (Tradestation, AMI, SmartQuant, Wealth Lab, C++
Users, etc. . . are invited to attend and participate in the
meetings - if for nothing else comradiere)

This User Group strives to meet monthly, and address topics of
interest to Trader Programmers. Emphasis is on the use of Wealth Lab
for Trading strategy testing and as use of a decision engine for
Trading automation.

For a brief synopsis of the groups and more about what we are all
about go here:



A link to Wealth Lab is located on the page above.

For the sister SeaTac group membership request go here:



For the Portland Oregon Wealth Lab User Group (PDX_WLUG) go here:


Re: twsapi: Market Making App

fanjacks
 

Odd lots do not have to be represented in the NBBO. They do have
to
trade if given the opportunity though.
So does this mean that I can put a buy and a sell order inside the
spread, and if the orders are odd lots, they are effectively
invisible, at least on the level 1? I'm thinking there must be a
huge disadvantage to this, like full lots are given execution
priority (at that level), or it would be too advantagous.

FYI, I know IB forbids you from making markets in options. I
wouldn't be surprised to see something similiar in stocks. I know
back in the old days it was not legal for complete automation, even
on a fully certed OTC dealer desk.
I tried it out on my account it indeed, it does work for stocks.
There's a specific regulation in the options market that forbids
opening two opposit positions on the same option (something to that
effect). I dont' think it exists for stocks, unless someone knows
better.

I have seen similar programs in the forex market (where the market
makers are real A**holes, more so than any equity MM can ever be).
I'm surprised that they aren't more prevasive in the equity market,
or at least, I know they exist but they are never advertised. Does
anyone know the reason?

Cheers,

JS


Re: twsapi: Market Making App

 

Odd lots do not have to be represented in the NBBO. They do have to
trade if given the opportunity though.

FYI, I know IB forbids you from making markets in options. I
wouldn't be surprised to see something similiar in stocks. I know
back in the old days it was not legal for complete automation, even
on a fully certed OTC dealer desk.

Good luck.



Aaron Schindler


----- Original Message -----
From: fanjacks
To: twsapi@y...
Sent: Thursday, June 27, 2002 9:29 AM
Subject: twsapi: Market Making App


Hello. I'm a seasoned vb programmer and I've been trading with
IB
for a long while. I'm thinking about writing a fully automated
Market Making application that posts bids/asks automatically. I
have
to admit, although I would have no problem writing the software
(which I don't mind sharing with everyone), I don't think I know
enough about market making. In general, when I try to post a
test 10-
share sell/buy on a NASDAQ stock inside the bid/ask spread, it
doesn't seem to show up on the Bid/Ask. Is this because I'm not
posting lots? or is there some other restriction. I would love
to
hear from people with similar interest, and get a move on this
project if it is feasible.

Cheers,

JS


Yahoo! Groups Sponsor
ADVERTISEMENT



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@y...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.


Re: How to get - Account Number

marinindextrader
 

That was an excellent question

--- In twsapi@y..., bee_jay_61 <no_reply@y...> wrote:
--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:
I have 2 accounts.
Anyone know how to get account number >>?
An example vb code line will do just fine.

ThanX
I am not sure, but isn?t the account number display in the window
caption of the "Account"-Window?

If so, than I would read the Window Caption.


Re: How to get - Account Number

marinindextrader
 

Anyone know how to get account number >>?

I think you need to control this yourself and keep a cross refrence
with which instance you are calling the connect from.

In this case you need to either capture the port and compare it when
you call it, or better yet keep an array that mirrors your API object
array interms of indecies

Such as a Long, 2 dimensional array that has as many lead indecie as
you have API objects and as many columns as you feel fit to
include...2 in this case...that would look something like this


Dim arrAccount()
ReDim arrAccount(UBound(TWS1), 1)

arrAccount(0,0) = 7496
arrAccount(0,1) = 'some account number
arrAccount(UBound(arrAccount),0) = 7497
arrAccount(UBound(arrAccount),1) = 'some other account number

Then when you call any TWS you can refrence the array as well and
return the account number easily based on the index API object.

You could add a third element to the array and make the array variant
and put a string value in the third slot such as "Stocks"
or "Futures" to further expand its utility.

Hope this helps as well

Scott

PS I will be exploring this subject in depth some time in the coming
couple of weeks and will be posting example code...

Unless of course you beat me to it



--- In twsapi@y..., "marinindextrader" <marinindextrader@y...> wrote:
This is an interesting question, and one I was intending at some
point to explore.

Based on a cursory review of the methods and calls, there is no way
to retrieve an account number.

But on a little deeper look I believe I have a solution for you.

Apparentley the TWS platform remembers the socket port you called
with the account you called.

In other words you must log onto to each account from a different
socket port with seperate instance of TWS, and then from within
your
program you can call the connection from a seperate instance of the
Active X componenet for each account.

An array of controls would do the job...

TWS1(0).Connect "", 7496
TWS1(1).Connect "", 7497

or perhaps just renaming the controls

TWS1.Connect "", 7496
TWS2.Connect "", 7497

I am an array kind of guy so I would go the array route...

Lastley, perhaps you dont even need the second instance and can
call
direct..

TWS1.Connect "", 7496
TWS1.Connect "", 7497

But this looks like your asking for trouble and corupted data...IMHO

Either Way....

From there, you can then refrence your calls and segregate returns
based on the source of the call

TWS1(0).reqMktData(da dee da)
TWS1(1).reqMktData(da dee da)

Thats how I see it.

Again, I havn't explored this in detail and perhaps I am wrong.

Give that a shot and then report back here what you find so we can
all benefit from your experience.

Scott
Owner TWSAPI






--- In twsapi@y..., bee_jay_61 <no_reply@y...> wrote:
--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:
I have 2 accounts.
Anyone know how to get account number >>?
An example vb code line will do just fine.

ThanX
I am not sure, but isn?t the account number display in the window
caption of the "Account"-Window?

If so, than I would read the Window Caption.


Re: How to get - Account Number

marinindextrader
 

This is an interesting question, and one I was intending at some
point to explore.

Based on a cursory review of the methods and calls, there is no way
to retrieve an account number.

But on a little deeper look I believe I have a solution for you.

Apparentley the TWS platform remembers the socket port you called
with the account you called.

In other words you must log onto to each account from a different
socket port with seperate instance of TWS, and then from within your
program you can call the connection from a seperate instance of the
Active X componenet for each account.

An array of controls would do the job...

TWS1(0).Connect "", 7496
TWS1(1).Connect "", 7497

or perhaps just renaming the controls

TWS1.Connect "", 7496
TWS2.Connect "", 7497

I am an array kind of guy so I would go the array route...

Lastley, perhaps you dont even need the second instance and can call
direct..

TWS1.Connect "", 7496
TWS1.Connect "", 7497

But this looks like your asking for trouble and corupted data...IMHO

Either Way....

From there, you can then refrence your calls and segregate returns
based on the source of the call

TWS1(0).reqMktData(da dee da)
TWS1(1).reqMktData(da dee da)

Thats how I see it.

Again, I havn't explored this in detail and perhaps I am wrong.

Give that a shot and then report back here what you find so we can
all benefit from your experience.

Scott
Owner TWSAPI

--- In twsapi@y..., bee_jay_61 <no_reply@y...> wrote:
--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:
I have 2 accounts.
Anyone know how to get account number >>?
An example vb code line will do just fine.

ThanX
I am not sure, but isn?t the account number display in the window
caption of the "Account"-Window?

If so, than I would read the Window Caption.


Re: How to get - Account Number

bee_jay_61
 

--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:
I have 2 accounts.
Anyone know how to get account number >>?
An example vb code line will do just fine.

ThanX
I am not sure, but isn?t the account number display in the window
caption of the "Account"-Window?

If so, than I would read the Window Caption.