开云体育

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

Re: twsapi: Trader Guard - ES NQ futures ready app.

Manuel Knospe
 

开云体育

I?m unable to download the prog anywhere...
?
Can you send it to me via eMail (i have enough space...)
Or can you give me the link to download it?
?
?
Thanks
?
Manuel
?

----- Original Message -----
Sent: Thursday, June 27, 2002 9:27 PM
Subject: twsapi: Trader Guard - ES NQ futures ready app.

Addition to your existing IB TWS platform. I designed it for scalpers
to profit from every single trend change with "adaptive Automation
Engine" monitoring market tick by tick and in real time.
You will love it.
It will automate your profit collection at the topmost
point and also auto-escape from bad point of entry. This is what i
like the most.
Download it from twsapi file area. I'll post it here within 3 days
(finishing GUI design only)
If you inpatient or file is not there for any reason e-mail request
to me. I'll be happy to send you a copy.


traderguard@...



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



Your use of Yahoo! Groups is subject to the .


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

 

--- In twsapi@y..., "rasears" <rasears@y...> wrote:
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.
Correct. When you connect using the API, a dialog box pops up on the
client asking whether you want to accept the connection.

Second, does anyone have experience using the Linux/UNIX client or
the Linux/UNIX APIs? Love to hear about any potential problems there.
TWS is a Java app, so it is pretty much the same on Linux as
elsewhere. I've had no problems that appeared to be specific to Linux.


Ken


Re: java api, maximum number of requests at a time ?

gu6526
 

As previous replies suggested, IB should not be misused as a
data feed. For several resons it's not suitable for that.

But in your example, you can drop the disconnect/connect and
assign use new Contract Objects with the same TickerIDs. This way
you can retrieve an arbitrary number of quotes sequentially.

Gernot

--- In twsapi@y..., usernew <no_reply@y...> wrote:
I am using the Java API. When I send more than 40 or so requests
for
ticker info, I get the following exception:

Error: Max number of tickers has been reached.

Then I tried to do the following:

connect;
for(i=0, i < 40; i++) send requests;
capture info using event handlers;
disconnect;
connect;
for(i=0; i < 40; i++) send requests;
capture info using event handlers;
disconnect;
etc.

But the problem is each time there is a connect() call, someone
needs
to manually click on the "Yes" button on the dialog that
asks "Accept
incoming connection attempt?"

I want to be able to download info on few hundred tickers at a
time,
what should I do ?

Thanks in advance.


Re: WG: twsapi: java api, maximum number of requests at a time ?

Richard Foulk
 

I agree. Especially since IB doesn't provide all of the available quotes.

} I think this is something the API is probably not meant for.
} I think that IB wants to help their clients to do lots of profitable
} trades, and that?s why they developed TWS and the API.
}
} If you want to get a few hundred tickers at a time, my opinion is that you
} should subscribe a datafeed somewhere else. eSignal and PCQuote have API?s
} that might be useful to you.
} They are specialised on providing real time data.
}
} Marcus
}
} -----Ursprungliche Nachricht-----
} Von: usernew [mailto:no_reply@...]
} Gesendet: Monday, July 01, 2002 11:37 AM
} An: twsapi@...
} Betreff: twsapi: java api, maximum number of requests at a time ?
}
}
} I am using the Java API. When I send more than 40 or so requests for
} ticker info, I get the following exception:
}
} Error: Max number of tickers has been reached.
}
} Then I tried to do the following:
}
} connect;
} for(i=0, i < 40; i++) send requests;
} capture info using event handlers;
} disconnect;
} connect;
} for(i=0; i < 40; i++) send requests;
} capture info using event handlers;
} disconnect;
} etc.
}
} But the problem is each time there is a connect() call, someone needs
} to manually click on the "Yes" button on the dialog that asks "Accept
} incoming connection attempt?"
}
} I want to be able to download info on few hundred tickers at a time,
} what should I do ?
}
} Thanks in advance.


WG: twsapi: java api, maximum number of requests at a time ?

 

I think this is something the API is probably not meant for.
I think that IB wants to help their clients to do lots of profitable
trades, and that?s why they developed TWS and the API.

If you want to get a few hundred tickers at a time, my opinion is that you
should subscribe a datafeed somewhere else. eSignal and PCQuote have API?s
that might be useful to you.
They are specialised on providing real time data.

Marcus

-----Ursprungliche Nachricht-----
Von: usernew [mailto:no_reply@...]
Gesendet: Monday, July 01, 2002 11:37 AM
An: twsapi@...
Betreff: twsapi: java api, maximum number of requests at a time ?


I am using the Java API. When I send more than 40 or so requests for
ticker info, I get the following exception:

Error: Max number of tickers has been reached.

Then I tried to do the following:

connect;
for(i=0, i < 40; i++) send requests;
capture info using event handlers;
disconnect;
connect;
for(i=0; i < 40; i++) send requests;
capture info using event handlers;
disconnect;
etc.

But the problem is each time there is a connect() call, someone needs
to manually click on the "Yes" button on the dialog that asks "Accept
incoming connection attempt?"

I want to be able to download info on few hundred tickers at a time,
what should I do ?

Thanks in advance.


Re: Trader Guard - ES NQ - 23MB program - get it from website.

marinindextrader
 

What is the compacted size when zipped down?

If its not to big just email it to me...

Is 23mb the compacted version or fully installed ready run version

Please clarify

Scott

--- In twsapi@y..., traderguard <no_reply@y...> wrote:
Trader Guard - ES NQ - 23MB program

Is Done !!! and working really GOOD.
Ready to be send to people who asked for it.. BUT..
Is to big to be POST here.. or to be send via E-mails.
I am going to setup today some free web site with this useful
interface for TWS.
And I'll POST link HERE ..download from there, please..
Protective mode work awesome.. I tested new version of TraderGuard
today on NQ.
It is better than older version.


If you like version 1.03.01 Try ver. 2.01.04. You want regret
it.

New features
- risk adjustable auto sell with wrong trend
- no transmit needed
- quick reverse with 1 click
- cover short or long with auto cancel pending one
- display profit of individual trade
- display risk monitoring limit
enjoy

I'll POST link here TOMMOROW.

traderguard@y...


VB New Sample Code: Auto Select Expiry For Index Products

marinindextrader
 

VB: This code automatically assigns the correct expiry string based
on the present date. Primarily for Index Futures products that roll
quarterly. Subscribes to the second Thursday rule.

Now in the files section:



Project requires:

Form1 form
Moudle1 module
Label1, Label2 Label3 labels
Command1 Command button

'Code Starts
'FormCode

Option Explicit

Private Sub Command1_Click()

Label1 = fxExpiry
Label3 = "This Contract Rolls On: " & fxRollOverDate _
& vbCrLf _
& fxDaysRemaining & " Days Left"

End Sub


Private Sub Form_Load()

Label2.Caption = _
"INDEX CONTRACT EXPIRY FINDER" & vbCrLf & vbCrLf & _
"This code will properley return the expiry based " & _
"on the present date." & vbCrLf & vbCrLf & _
"It confroms to the standard that contract trading" & _
" rolls over on the second thursday of the month of
expiration." & _
vbCrLf & vbCrLf & "Todays Date: " & Date
Label1 = fxExpiry
Label3 = "This Contract Rolls On: " & fxRollOverDate _
& vbCrLf _
& fxDaysRemaining & " Days Left"

End Sub



'Module Code

Option Explicit

Private m_qtr As Integer
Private m_ContractDate As Date

Function fxExpiry() As String

Dim firstVBday As Integer
Dim StartDate As Date

m_qtr = DatePart("q", Date)

Select Case m_qtr
Case 1
StartDate = "3/1/" & Year(Now)
firstVBday = Weekday(StartDate)
m_ContractDate = fxContractDate(StartDate, firstVBday)
Case 2
StartDate = "6/1/" & Year(Now)
firstVBday = Weekday(StartDate)
m_ContractDate = fxContractDate(StartDate, firstVBday)
Case 3
StartDate = "9/1/" & Year(Now)
firstVBday = Weekday(StartDate)
m_ContractDate = fxContractDate(StartDate, firstVBday)
Case 4
StartDate = "12/1/" & Year(Now)
firstVBday = Weekday(StartDate)
m_ContractDate = fxContractDate(StartDate, firstVBday)
End Select

fxExpiry = fxNewString()

End Function
Function fxRollOverDate() As String

Dim tempDate As Date
'Call fxExpiry

Select Case m_qtr
Case 4
If Date > m_ContractDate Then
tempDate = fxContractDate("3/1/" & Year(Now) + 1, _
Weekday("3/1/" & Year(Now) + 1))
fxRollOverDate = tempDate
Else
fxRollOverDate = m_ContractDate
End If
Case Else
fxRollOverDate = m_ContractDate
End Select

End Function
Function fxDaysRemaining()

Dim tempDate As Date
'Call fxExpiry

Select Case m_qtr
Case 4
If Date > m_ContractDate Then
tempDate = fxContractDate("3/1/" & Year(Now) + 1, _
Weekday("3/1/" & Year(Now) + 1))
fxDaysRemaining = tempDate - Date
Else
fxDaysRemaining = m_ContractDate - Date
End If
Case Else
fxDaysRemaining = m_ContractDate - Date
End Select

End Function
Private Function fxContractDate(ByVal dStart As Date, ByVal iDay As
Integer) As Date
If iDay = 5 Then
fxContractDate = dStart + 7
Else
Do
dStart = dStart + 1
Loop Until Weekday(dStart) = 5
fxContractDate = dStart + 7
End If
End Function

Private Function fxNewString() As String

Dim strYear As String
Dim strMonth As String

Dim arrMonth(1 To 4)
arrMonth(1) = "03": arrMonth(2) = "06"
arrMonth(3) = "09": arrMonth(4) = "12"

If Date < m_ContractDate Then
strMonth = arrMonth(m_qtr)
strYear = Year(Date)
Else
If Date = m_ContractDate Then
MsgBox "Contract Rolls Today!" _
& vbCrLf _
& " Liquidity At Issue" _
& vbCrLf _
& "Next Contract Selected"
End If

If m_qtr < 4 Then
strMonth = arrMonth(m_qtr + 1)
strYear = Year(Date)
Else
strMonth = arrMonth(1)
strYear = Year(Date) + 1
End If
End If

fxNewString = strYear & strMonth

End Function


Re: twsapi: Trader Guard - ES NQ - Does it need a specific IB Build ?

Eduardo J Motta
 

Do we need a specific IB Build ? Latest one ?

usually when they update their API some functions do not work properly,

could you please clarify?

eduardo

-----Original Message-----
From: traderguard [mailto:no_reply@...]
Sent: Monday, July 01, 2002 3:19 PM
To: twsapi@...
Subject: twsapi: Trader Guard - ES NQ - 23MB program - get it from
website.


Trader Guard - ES NQ - 23MB program

Is Done !!! and working really GOOD.
Ready to be send to people who asked for it.. BUT..
Is to big to be POST here.. or to be send via E-mails.
I am going to setup today some free web site with this useful
interface for TWS.
And I'll POST link HERE ..download from there, please..
Protective mode work awesome.. I tested new version of TraderGuard
today on NQ.
It is better than older version.


If you like version 1.03.01 Try ver. 2.01.04. You want regret
it.

New features
- risk adjustable auto sell with wrong trend
- no transmit needed
- quick reverse with 1 click
- cover short or long with auto cancel pending one
- display profit of individual trade
- display risk monitoring limit
enjoy

I'll POST link here TOMMOROW.

traderguard@...



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



Your use of Yahoo! Groups is subject to


Excel macro

ruffstuff123
 

I hope this is not off-topic....
Anyway I think it's a great link

General site:
Execl macro:


Trader Guard - ES NQ - 23MB program - get it from website.

traderguard
 

Trader Guard - ES NQ - 23MB program

Is Done !!! and working really GOOD.
Ready to be send to people who asked for it.. BUT..
Is to big to be POST here.. or to be send via E-mails.
I am going to setup today some free web site with this useful
interface for TWS.
And I'll POST link HERE ..download from there, please..
Protective mode work awesome.. I tested new version of TraderGuard
today on NQ.
It is better than older version.


If you like version 1.03.01 Try ver. 2.01.04. You want regret
it.

New features
- risk adjustable auto sell with wrong trend
- no transmit needed
- quick reverse with 1 click
- cover short or long with auto cancel pending one
- display profit of individual trade
- display risk monitoring limit
enjoy

I'll POST link here TOMMOROW.

traderguard@...


java api, maximum number of requests at a time ?

usernew
 

I am using the Java API. When I send more than 40 or so requests for
ticker info, I get the following exception:

Error: Max number of tickers has been reached.

Then I tried to do the following:

connect;
for(i=0, i < 40; i++) send requests;
capture info using event handlers;
disconnect;
connect;
for(i=0; i < 40; i++) send requests;
capture info using event handlers;
disconnect;
etc.

But the problem is each time there is a connect() call, someone needs
to manually click on the "Yes" button on the dialog that asks "Accept
incoming connection attempt?"

I want to be able to download info on few hundred tickers at a time,
what should I do ?

Thanks in advance.


Re: automated login

marinindextrader
 

You are among a large group of users who would like to be able to do
this, me being one of them...

I don't know how...

It really is anoying they don't give us a security server to pass
through. Seems so archaic to have to have a TWS open for each account
we log on to...

Scott


--- In twsapi@y..., "Michel" <migurull@t...> wrote:
Hi,

Does somebody know some way to run the TWS application unattended?
What I need is:
1- Avoid the login screen, passing parameters (UserName and
Password) from
my calling application.
2- Respond to the message window asking 'Accept incoming connection
attempt?' when I connect to the local server.

This is because I'm writting my own program (Visual Basic using TWS
ActiveX)
which allways runs in the background and want it to automatically
launch TWS
few minutes before markets open and perform some automated tasks
when I'm
not at home.

I've tried to launch TWS from my application with a call
to 'ShellExecute',
passing parameters as 'username' or 'user' without success. I
always get the
login screen blank because I ignore if TWS accepts such parameters
and how
they must be coded (I think this must be possible because in the
web demo,
the login screen appears whith such fields pre-filled with 'edemo'
and
'demouser'). Perhaps in some 'ini' file? (I've not found any
section related
to username and password).

Thanks for any help.

Michel.


First post and odd-lot question...

cyberbri_2000
 

This is a great group! I looked over the sample VB programs, opened
an account at IB and now my head is swimming with ideas. :)

I'm thinking of writing a utility that will monitor my open positions
during the day, then implement a trailing stop by updating a stop
order based on each stock's 14 day ATR X 3. I like this trailing
stop alot, and have been using it on a portfolio at Marketocracy.com
for 5 months now. It's up 8%... not too bad by only going long in a
bear market.

I program with VB6 and WebZinc (webzinc.net), a program that easily
grabs data off the web. It has a ton of uses and I highly recommend
it.

I know IB acccepts odd-lot stock orders for NYSE and Nasdaq stocks,
what about AMEX stocks? I wrote them a week ago and still no answer.

Thanx,
Brian


automated login

Michel
 

Hi,

Does somebody know some way to run the TWS application unattended?
What I need is:
1- Avoid the login screen, passing parameters (UserName and Password) from
my calling application.
2- Respond to the message window asking 'Accept incoming connection
attempt?' when I connect to the local server.

This is because I'm writting my own program (Visual Basic using TWS ActiveX)
which allways runs in the background and want it to automatically launch TWS
few minutes before markets open and perform some automated tasks when I'm
not at home.

I've tried to launch TWS from my application with a call to 'ShellExecute',
passing parameters as 'username' or 'user' without success. I always get the
login screen blank because I ignore if TWS accepts such parameters and how
they must be coded (I think this must be possible because in the web demo,
the login screen appears whith such fields pre-filled with 'edemo' and
'demouser'). Perhaps in some 'ini' file? (I've not found any section related
to username and password).

Thanks for any help.

Michel.


Re: twsapi: How to make the Java API work?

Michel
 

开云体育

I dont know of Java, but something looks strange: you connect to "gw4.ibllc.com:4000" which is the IB server on the Internet.
Dont have you to connect to the local server (as in VB): "127.0.0.1:7496"?
?
Michel.

[Michel]??-----Mensaje original-----
De: philipyeh [mailto:philipyeh@...]
Enviado el: lunes, 01 de julio de 2002 4:53
Para: twsapi@...
Asunto: twsapi: How to make the Java API work?

I am a new user of the TWS Java API.
I wrote a test program to test the reqMktData() method.
But I can not get any ticks data. What's problem in my
program? Could anybody help me?
Below is my test java program:

import com.ib.client.*;

public class ATMClient implements EWrapper
{
??? static final int BID_SIZE?? = 0;
??? static final int BID??????? = 1;
??? static final int ASK??????? = 2;
??? static final int ASK_SIZE?? = 3;
??? static final int LAST?????? = 4;
??? static final int LAST_SIZE? = 5;
??? EClientSocket m_client = new EClientSocket(this);
??? int m_id = 100000;
??? int o_id = 200000;


????? public static void main (String[] args)
????? {
????? ????? ATMClient myapp = new ATMClient();
????? ????? myapp.start("gw4.ibllc.com", "4000");
????? }

????? public void start(String host, String port)
????? {
??????? m_client.eConnect(host, Integer.parseInt(port));
System.out.println("connect ok!");
??????? Contract m_contract = new Contract();
??????? m_contract.symbol = "ESU2";
??????? m_contract.secType = "FUT";
??????? m_contract.expiry = "200209";
??????? m_contract.strike = 0.0;
??????? m_contract.right = "C";
??????? m_contract.exchange = "GLOBEX";
??????? m_contract.currency = "USD";
??????? m_client.reqMktData(m_id, m_contract);
????? }


??? public void tickPrice( int tickerId, int field, double price) {
??????? // received price tick
??????? System.out.println("id=" + tickerId + "? " + getField(field)
+ "=" + price);
??? }

??? public void tickSize( int tickerId, int field, int size) {
??????? // received size tick
??????? System.out.println("id=" + tickerId + "? " + getField(field)
+ "=" + size);
??? }

??? public void orderStatus(int orderId, String status, int filled,
int remaining, double price, int permId) {
??????? // received order status
??????? System.out.println("id=" + orderId + "? status=" + status
+ "? filled=" + filled + "? remaining=" + remaining + "? price=" +
price + "? permId=" + permId);
???????
??????? // make sure id for next order is at least orderId+1
??????? ++o_id;
??? }

??? public void openOrder( int orderId, Contract contract, Order
order) {
??????? // received open order
??????? System.out.println( "id=" + orderId + "? " + order.action
+ "? " + order.quantity + "? " + contract.symbol);
??? }
???
??? public void nextValidId(int orderId) {
??????? // received next valid order id
??????? o_id = orderId;
??? }
???
??? public void error(String str) {
??????? // received error
??????? System.out.println("*** Error: " + str);
??? }

??? public void connectionClosed() {
??????? System.out.println("Connection Closed");
??? }
???
??? private String getField(int tickType) {
??????? switch (tickType) {
??????????? case BID_SIZE:????? return "bidSize";
??????????? case BID:????? return "bidPrice";
??????????? case ASK:????? return "askPrice";
??????????? case ASK_SIZE:????? return "askSize";
??????????? case LAST:????? return "lastPrice";
??????????? case LAST_SIZE:????? return "lastSize";
??????????? default:????? return "unknown";
??????? }
??? }
???
??? public void updateAccountValue(String key,String value,String
currency) {
??????? System.out.println("key=" + key + ", value=" + value + ",
currency=" + currency);
??? }
???
??? public void updatePortfolio(Contract contract, int position,
double marketPrice, double marketValue) {
??????? System.out.println("position=" + position + ", marketPrice="
+ marketPrice + ", marketValue=" + marketValue);
??? }
???
??? public void updateAccountTime(String timeStamp) {
??????? System.out.println("timeStamp=" + timeStamp);
??? }???

}

Thanks.
Philip Yeh.




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



Your use of Yahoo! Groups is subject to the .


Re: How to make the Java API work?

marinindextrader
 

Not hip to Java, But It looks as if....
.....
.....

I dont code in Java but it seems as if you havnt made a regMktData
call...or am I missing something?

Further I have been unsuccesful passing anything other than variable
values through the reqMkt...

It appears as if your reqMkt object is expecting an object itself as
as an arguement>>> object m_contract...I have tried passing arrays as
arguements and get rejected...

And, the symbol appears incorrect:

ESU2 should be ES

You dont need anthing in the field .right

"C" should be ""

You dont need anything in the field currencey

"USD" should be ""


Here is a literal example of reqMkt call in VB if this helps:

symbol = "ES"
secType = "FUT"
expiry = "200209"
strike = 0
TWSright = ""
exchange = "GLOBEX"
curency = ""

Tws1.reqMktData id, symbol, secType, expiry, strike, TWSright,
exchange, curency

--- In twsapi@y..., "philipyeh" <philipyeh@y...> wrote:
I am a new user of the TWS Java API.
I wrote a test program to test the reqMktData() method.
But I can not get any ticks data. What's problem in my
program? Could anybody help me?
Below is my test java program:

import com.ib.client.*;

public class ATMClient implements EWrapper
{
static final int BID_SIZE = 0;
static final int BID = 1;
static final int ASK = 2;
static final int ASK_SIZE = 3;
static final int LAST = 4;
static final int LAST_SIZE = 5;
EClientSocket m_client = new EClientSocket(this);
int m_id = 100000;
int o_id = 200000;


public static void main (String[] args)
{
ATMClient myapp = new ATMClient();
myapp.start("gw4.ibllc.com", "4000");
}

public void start(String host, String port)
{
m_client.eConnect(host, Integer.parseInt(port));
System.out.println("connect ok!");
Contract m_contract = new Contract();
m_contract.symbol = "ESU2";
m_contract.secType = "FUT";
m_contract.expiry = "200209";
m_contract.strike = 0.0;
m_contract.right = "C";
m_contract.exchange = "GLOBEX";
m_contract.currency = "USD";
m_client.reqMktData(m_id, m_contract);
}


public void tickPrice( int tickerId, int field, double price) {
// received price tick
System.out.println("id=" + tickerId + " " + getField
(field)
+ "=" + price);
}

public void tickSize( int tickerId, int field, int size) {
// received size tick
System.out.println("id=" + tickerId + " " + getField
(field)
+ "=" + size);
}

public void orderStatus(int orderId, String status, int filled,
int remaining, double price, int permId) {
// received order status
System.out.println("id=" + orderId + " status=" + status
+ " filled=" + filled + " remaining=" + remaining + " price=" +
price + " permId=" + permId);

// make sure id for next order is at least orderId+1
++o_id;
}

public void openOrder( int orderId, Contract contract, Order
order) {
// received open order
System.out.println( "id=" + orderId + " " + order.action
+ " " + order.quantity + " " + contract.symbol);
}

public void nextValidId(int orderId) {
// received next valid order id
o_id = orderId;
}

public void error(String str) {
// received error
System.out.println("*** Error: " + str);
}

public void connectionClosed() {
System.out.println("Connection Closed");
}

private String getField(int tickType) {
switch (tickType) {
case BID_SIZE: return "bidSize";
case BID: return "bidPrice";
case ASK: return "askPrice";
case ASK_SIZE: return "askSize";
case LAST: return "lastPrice";
case LAST_SIZE: return "lastSize";
default: return "unknown";
}
}

public void updateAccountValue(String key,String value,String
currency) {
System.out.println("key=" + key + ", value=" + value + ",
currency=" + currency);
}

public void updatePortfolio(Contract contract, int position,
double marketPrice, double marketValue) {
System.out.println("position=" + position + ",
marketPrice="
+ marketPrice + ", marketValue=" + marketValue);
}

public void updateAccountTime(String timeStamp) {
System.out.println("timeStamp=" + timeStamp);
}

}

Thanks.
Philip Yeh.


Re: twsapi: Re: order IDs

Richard Foulk
 

Let's try to remember that the API is still beta. So if it doesn't
work propperly or reasonably or logically -- then please report it
to the IB folks so it can be fixed.

Don't just work around it in strange on crazy ways.

This is a great facility. Let's do our part to make it better.


Richard

} I think it should be possible to get the IDs from TWS.....
} When TWS logs in it produces a list with standing orders.
} Maybe also from a database...?
}
} Best would be if a ticker could be entered in a 3rd party program.
} That program checks if TWS already has that ticker active.
} If not then it creates a new id.
} If kinda afraid of what happens if you add/delete something directly
} from TWS and after that start the program.
} Big chance it resubmits the order.
} Or am I overlooking something?
}
}
}
} --- In twsapi@y..., "Marcus Jellinghaus" <Marcus_Jellinghaus@G...>
} wrote:
} > 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@p...]
} > Gesendet: Sunday, June 30, 2002 1:49 AM
} > An: twsapi@y...
} > 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


twsapi: Re: order IDs

ruffstuff123
 

I think it should be possible to get the IDs from TWS.....
When TWS logs in it produces a list with standing orders.
Maybe also from a database...?

Best would be if a ticker could be entered in a 3rd party program.
That program checks if TWS already has that ticker active.
If not then it creates a new id.
If kinda afraid of what happens if you add/delete something directly
from TWS and after that start the program.
Big chance it resubmits the order.
Or am I overlooking something?



--- In twsapi@y..., "Marcus Jellinghaus" <Marcus_Jellinghaus@G...>
wrote:
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@p...]
Gesendet: Sunday, June 30, 2002 1:49 AM
An: twsapi@y...
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@y...



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


How to make the Java API work?

philipyeh
 

I am a new user of the TWS Java API.
I wrote a test program to test the reqMktData() method.
But I can not get any ticks data. What's problem in my
program? Could anybody help me?
Below is my test java program:

import com.ib.client.*;

public class ATMClient implements EWrapper
{
static final int BID_SIZE = 0;
static final int BID = 1;
static final int ASK = 2;
static final int ASK_SIZE = 3;
static final int LAST = 4;
static final int LAST_SIZE = 5;
EClientSocket m_client = new EClientSocket(this);
int m_id = 100000;
int o_id = 200000;


public static void main (String[] args)
{
ATMClient myapp = new ATMClient();
myapp.start("gw4.ibllc.com", "4000");
}

public void start(String host, String port)
{
m_client.eConnect(host, Integer.parseInt(port));
System.out.println("connect ok!");
Contract m_contract = new Contract();
m_contract.symbol = "ESU2";
m_contract.secType = "FUT";
m_contract.expiry = "200209";
m_contract.strike = 0.0;
m_contract.right = "C";
m_contract.exchange = "GLOBEX";
m_contract.currency = "USD";
m_client.reqMktData(m_id, m_contract);
}


public void tickPrice( int tickerId, int field, double price) {
// received price tick
System.out.println("id=" + tickerId + " " + getField(field)
+ "=" + price);
}

public void tickSize( int tickerId, int field, int size) {
// received size tick
System.out.println("id=" + tickerId + " " + getField(field)
+ "=" + size);
}

public void orderStatus(int orderId, String status, int filled,
int remaining, double price, int permId) {
// received order status
System.out.println("id=" + orderId + " status=" + status
+ " filled=" + filled + " remaining=" + remaining + " price=" +
price + " permId=" + permId);

// make sure id for next order is at least orderId+1
++o_id;
}

public void openOrder( int orderId, Contract contract, Order
order) {
// received open order
System.out.println( "id=" + orderId + " " + order.action
+ " " + order.quantity + " " + contract.symbol);
}

public void nextValidId(int orderId) {
// received next valid order id
o_id = orderId;
}

public void error(String str) {
// received error
System.out.println("*** Error: " + str);
}

public void connectionClosed() {
System.out.println("Connection Closed");
}

private String getField(int tickType) {
switch (tickType) {
case BID_SIZE: return "bidSize";
case BID: return "bidPrice";
case ASK: return "askPrice";
case ASK_SIZE: return "askSize";
case LAST: return "lastPrice";
case LAST_SIZE: return "lastSize";
default: return "unknown";
}
}

public void updateAccountValue(String key,String value,String
currency) {
System.out.println("key=" + key + ", value=" + value + ",
currency=" + currency);
}

public void updatePortfolio(Contract contract, int position,
double marketPrice, double marketValue) {
System.out.println("position=" + position + ", marketPrice="
+ marketPrice + ", marketValue=" + marketValue);
}

public void updateAccountTime(String timeStamp) {
System.out.println("timeStamp=" + timeStamp);
}

}

Thanks.
Philip Yeh.


Re: Modifying an order & testing

marinindextrader
 

Excellent Commentary TriPack....