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
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 stockwatchproalong with IB today, works pretty good. I wish IB removed BEST routing Is it possible to make a trailing stop systm with that formula language??? Orders can be initiated from Stock Watch Pro as follows: |
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
|
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
|
Re: twsapi: Modifying an order & testing
ruffstuff123
--- In twsapi@y..., "marinindextrader" <marinindextrader@y...> wrote:
There is nothing in the files section that specifically deals withfrom now it willWow! Can't hardly wait :) As to your trailing stop question:(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. 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:(an event occured that triggered your modified order to send).stopped out), or you cancel the order and resubmit a new order with yournew 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 keeptrack 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.backup. I choose to use the Microsoft .mdb format and access it from VBwith DAO 3.6. There is a table of trades. It has an entry order number and anexit 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 theopenOrderNumber. A recordset RS.TradesExit is created indexed on the exitOrderNumber.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. 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 keeptrack 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.backup. I choose to use the Microsoft .mdb format and access it from VBwith DAO 3.6. There is a table of trades. It has an entry order number and anexit 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 theopenOrderNumber. A recordset RS.TradesExit is created indexed on the exitOrderNumber.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. |
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.about half way down it should say "Files" there is some code there. Also Jaba puttogether a simple project that you can download look at post 189. connect to. 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
|
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. |
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 haveto 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. II 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 SchindlerIB for a long while. I'm thinking about writing a fully automatedhave to admit, although I would have no problem writing the softwaretest 10- share sell/buy on a NASDAQ stock inside the bid/ask spread, itto hear from people with similar interest, and get a move on thisService. |
Re: How to get - Account Number
marinindextrader
That was an excellent question
toggle quoted message
Show quoted text
--- In twsapi@y..., bee_jay_61 <no_reply@y...> wrote:
--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:I have 2 accounts.I am not sure, but isn?t the account number display in the window |
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 someyour program you can call the connection from a seperate instance of thecall direct.. |
Re: How to get - Account Number
marinindextrader
This is an interesting question, and one I was intending at some
toggle quoted message
Show quoted text
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.I am not sure, but isn?t the account number display in the window |
Re: How to get - Account Number
bee_jay_61
--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:
I have 2 accounts.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. |
to navigate to use esc to dismiss