Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
- Twsapi
- Messages
Search
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?
toggle quoted message
Show quoted text
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 |
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 ?
toggle quoted message
Show quoted text
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 |
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,Password) from my calling application.ActiveX) which allways runs in the background and want it to automaticallylaunch TWS few minutes before markets open and perform some automated taskswhen I'm not at home.to 'ShellExecute', passing parameters as 'username' or 'user' without success. Ialways get the login screen blank because I ignore if TWS accepts such parametersand how they must be coded (I think this must be possible because in theweb demo, the login screen appears whith such fields pre-filled with 'edemo'and 'demouser'). Perhaps in some 'ini' file? (I've not found anysection related to username and password). |
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. |
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.(field) + "=" + price);(field) + "=" + size);marketPrice=" + marketPrice + ", marketValue=" + marketValue); |
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 andthe order id.disconnect, close TWS, open TWS, and reconnect through the API to TWS, then TWSforget?s the API order ID.send all open orders again from my programm to TWS.need to store what was done, when, and why.exitOrderNumber.Besides, the IRS is coming on 4/15/2003 for sure, if not sooner.backup. They both point to the same table.updates the when,where,why fields. |
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
tripack44
--- In twsapi@y..., ruffstuff123 <no_reply@y...> wrote:
The only thing that I'm really missing is a trailing stop.To modify an order, just reenter the order with the new price and contracts via the .placeorder method using the same TWS order id # (argument 1 in the "placeorder" method). Trailing stops take a bit of proper organization to work out correctly. You need to keep track of entry price, whether it is a buy or sell, MaxPnL for the open position and the Trail Stop amount. You use live data to figure the MaxPnL. For a long position the Trail stop price = Entry Price - MaxPnL. Those are the basics of setting up a trailing stop. Whether you choose to hold that stop on your machine or to transmit each new stop price to IB is a personal choice. You can cancel untransmitted stops easier than transmitted ones and know that you aren't going to be filled. Globex held stops will probably fill at a better price than local system held stops. Some of the complexities involved with trailing stops include: Multiple entries at different times with multiple entry prices. Partial exits and reentries. Formating your stop orders so that they are within the minimum tick range expected by the exchange you trade on. This is particularly important when you consider partial fills at different prices that may create an average price that is outside the minimum tick of your exchange. Doing a trailing stop for multiple symbols pretty much requires you to code so that multiple instances of the code can be created for each symbol you trade (class module). I'm not ambitious enough to create sample code for this, but hopefully this short discussion of the issues will help some who are trying to figure it out. |
Re: How to get - Account Number
tripack44
--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:
I have 2 accounts.This issue may be more complex than just parsing the acct # from the title bar because you don't know which socket # is associated with which account #. But if you want to find all the windows title bars that contain the words "Interactive Brokers Trader Workstation" then the following VB source code from Karl Peterson will get you started. Web Site: Sample code: |
Re: twsapi: Trader Guard - ES NQ futures ready app.
tripack44
The twsapi web site on yahoo groups is:
I read all my mail from yahoo groups online. That way I can skip reading for a couple of weeks and then browse at my leisure. You can change your group settings to read your mail online. --- In twsapi@y..., "Shukrainternationals" <shukrainternationals@c...> wrote: Can anybody tell me what is the web site address of twsapi group?(NOT the email address). Thanks. |
AW: twsapi: Re: order IDs
开云体育That
is the reason why I do not use reqOpenOrders or
reqExecutions.
?
I just
request the portfolio/account data and check if "my accounting" gives the same
numbers as the values that I get from TWS.
I
found a problem with reqAccountData: If you request it several times, it doesn?t
work anymore.
?
I did
not use the permID, I have near to no problems with the OrderID that?I
provide when I post an order since I use the NextValidID that I get when I
connect to TWS. I store that ID and increase it every time I place an
order.
|
to navigate to use esc to dismiss