Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: twsapi: new here
I thought the TCP socket will take care of the reliability partYour are making the assumption here that they are on the same local host. Our target end environment has analysis and trading on separate computers, in separate locations. It's not so much as 'in the middle of a message', as 'is the connection to IB still alive'. We currently process thru other brokers, via different mechanisms, but, want IB in the loop. The order volume generated by our setup can be significant, many hundreds, and sometimes over a thousand, orders in a day. If the system has 25 orders open in the market, and connectivity to the broker dies, we need to know, so that manual procedures can be initiated. Since the actual trading computer is sitting in a cubicle on another site, where there is redundant net connection, redundant power, etc, we need to do all of this programatically, there is no human interaction at the computer actually executing trades in the market. Anyway, I am very interested in your investigations. And if enoughI think i broke the ice, and the c/c++ folks are speaking up now :) It looks to me like there's 2 main focus groups looking at the TWS api. The first, is what i would term the 'hobby folks', toying with automated trading for the first time, and learning VB in the process. The second group, developers that have been doing trading type stuff for a long time already, and the interface to IB is 'just another tool to go in the toolbox'. IB is an intriguing tool too. It will be interesting to see where it all ends up. |
|||
edemo error...
cyberbri_2000
Trying to use the demo system this weekend results in this error with
every market stock buy... "Could not value this contract at this time" .. anyone have an idea what's causing this? I wrote IB about the problem. Last weekend I was able to use the demo system for at least half the weekend. Brian |
|||
Re: twsapi: new here
Nick
weidong wrote:
I thought the TCP socket will take care of the reliability partThey don't have to be on the same machine although I agree they probably would be most of the time. Now regarding the internect connection with IB, do you actuallyI haven't seen this yet. In my approach I never block anyway - the request will simply time out. In my app I modified IB's code a bit - still using MFC though - butI have a generic "sockGets()" that reads lines from a socket and uses a large buffer to collect replies from the server. If there is an incomplete message the sockGets() will just time out. At that point the app can decide what to do but as far as I know a timeout is fatal. - Nick |
|||
Re: twsapi: Spin buttons? Read This Bruce
toggle quoted message
Show quoted text
|
|||
Re: twsapi: new here
I thought the TCP socket will take care of the reliability part
between TWS and your client. Besides they are on the same local host, so the only chance is buffer overflow, and that should be taken care of by the TCP protocal. Now regarding the internect connection with IB, do you actually experienced such disconnection causing the client blocked in the middle of a message? Would be very interested to learn the patterns of "always where" it is blocked. In my app I modified IB's code a bit - still using MFC though - but does it in the burst mode, so that it doesn't have to call those readInt or ReadFloat all the time. I also recongnize the possibility that the available data in the socket may not be null terminated. So by pulling them to a much larger buffer locally and having a macro parsing through the buffer for readInt and readFloat I greatly reduce the chance of blocking in the middle of a message. But I admit I don't have a mechanism in place to deal with when such an event actually happens, which could be caused by the internet problem for example. Anyway, I am very interested in your investigations. And if enough of us C++ users find this group too irrelevent to our project, then we should form our own group. -weidong --- In twsapi@y..., Nick <nickrbox@o...> wrote: TWS, there is no heartbeat as far as I can tell. I know if I don't sendanything to TWS the connection will be idle for over a minute. In essence TWSonly talks the client in response to client requests. If you don't askfor anything you won't receive anything from the server (TWS). Fornow you would have to do your own fake heartbeat by making a request forsomething harmless and looking for a reply.communication problems on the socket due to the way data is sent from theserver. They send a bunch of null-terminated strings for each logical record.If there are10 fields in a record then you read 10 "lines" from thesocket. There is no header info with the number of lines or total length of thebut then if any more data does arrive you don't know if it's the remainingpart of the previous packet or a new packet altogether. At this point atimeout is fatal and you would have to close the connection and try to re-connect. out so far. If you are interested I can keep you posted on what I findas I go along. I'm not sure I will stay subscribed to this group as thedominance of messages appear to be VB programming questions. |
|||
Re: twsapi: new here
Nick
I'm VERY interested in hearing your success/problem stories ofI plan on releasing my library and source code for non-commercial purposes. The first shot will be essentially a replacement for the IB C++ lib without any warts. It has platform-specific code separated out so ports to *nix are intended to be easy. The lib is primarily for my own use so it may not have features or functionality that others need, and it won't be a formal "supported product". I'm making it available as a service to the community. Email me privately if you want to be on the distribution list. - Nick |
|||
Re: twsapi: new here
I is also don't think it's possible to recover from anycommunication problems on the socket due to the way data is sent from theserver. They My expereince with communications problems is similar, any problem is fatal. The c++ wrapper tends to end up in a state that's unrecoverable, and to make it worse, if you call disconnect or delete the object to try restart things, you get an exception thrown from deep within windows somewhere, and it's a non recoverable event. edisconnect always seems to end up referenecing a null pointer within the windows kernel when called, and we have not found a solution to this yet. Creation of a new connect object doesn't help at all, once it's gone out to lunch, it's gone, and we have not figured out how to successfully re-initialize the connection once it throws an error. The only successful method we've got is really really ugly, but it does work. When we catch a windows exception, spawn a new copy of our application, and terminate the exception instance rudely. This will work thru a few iterations of the process, and ultimately, the windows 2000 TCP stack ends up confused eventually, and it's BSOD time. I'm not sure I will stay subscribed to this group as the dominanceThat's exactly why I piped up and asked if anybody is actually doing anything other than VB. Wondering if I've found the right place to discuss the issues of handling a windows exception thrown by the edisconnect() function of the TWS api, vs how to handle various various VB beginners issues that are totally unrelated to TWS. Most helpful, knowing a bit about what's happening under the covers kind of confirms my original take on the whole api. It's something kludged together very quickly by a junior programmer that doesn't understand real time, error recovery, or all of the 'little things' that differentiate serious business software from casually developed hobby stuff where no considerations are made for error identification and recovery. This is kinda proven by all the functions having 'void' return types, rather than some kind of value to at least let you know the function did something, is trying to do something, or failed completely. I have forwarded detailed commentary to IB about specific problem areas we have. I haven't had a response yet, but that's not my concern. I'm not here to whine about shortcomings, just to understand what it can/cant do, and how to work with it. I'm VERY interested in hearing your success/problem stories of rolling a new wrapper yourself. Our eventual goal here is to get all of this 'off windows' onto a reliable host that we can run remotely on a colo site. I dont dare consider running remotely until such time as we have a methodology that includes full recovery from all error situations. Like you, we'll probably have to roll our own for the whole thing before it's done, and abandon the wrapper code that IB has provided, just to get error handling into the system. |
|||
Re: twsapi: new here
Nick
I am curious if anybody has come up with ways of doing real timeI am developing a socket API to TWS in C as I don't like C++ or MFC. I'm using the source they provide to the C++ lib as a "reference". Despite Richard Foulk's urging to "make the world a better place" the raw socket protocol as it stands is not well thought out and probably needs to be completely re-done. The C++ lib they provide is a thin wrapper over the socket i/o. Providing feedback on a beta product is one thing. Providing free consulting to do a proper design is another. As for your specific situation of monitoring the connection to TWS, there is no heartbeat as far as I can tell. I know if I don't send anything to TWS the connection will be idle for over a minute. In essence TWS only talks the client in response to client requests. If you don't ask for anything you won't receive anything from the server (TWS). For now you would have to do your own fake heartbeat by making a request for something harmless and looking for a reply. I is also don't think it's possible to recover from any communication problems on the socket due to the way data is sent from the server. They send a bunch of null-terminated strings for each logical record. If there are10 fields in a record then you read 10 "lines" from the socket. There is no header info with the number of lines or total length of the packet. All you can do is time out if you don't get all 10 lines, but then if any more data does arrive you don't know if it's the remaining part of the previous packet or a new packet altogether. At this point a timeout is fatal and you would have to close the connection and try to re-connect. I'm just starting my investigation and this is what I have found out so far. If you are interested I can keep you posted on what I find as I go along. I'm not sure I will stay subscribed to this group as the dominance of messages appear to be VB programming questions. Anyway, I hope this little bit of info is helpful. - Nick |
|||
Re: twsapi: new here
Richard Foulk
} I'm new here, read the posts from back to the start to 'catch up'.
} I'm curious about one thing, is everybody here using VB, or are any } of you using anything more powerful for this application ? } } I started our first project utilizing the API a couple weeks ago, and } have delivered 'first prototype' to the customer already. Our } experience to date is 'if the api worked as documented' it would have } been a lot easier, and if the api didn't have serious concurrency } issues, it would have been almost trivial. We are working with this } api in C++ and integrating it as 'another platform' into a larger } system that's been in production with other brokers for years. Glad to hear others on the list are using C++. But please, the API is beta. Don't just fret about problems with the libraries, report them to IB so they can fix them. } } I am curious if anybody has come up with ways of doing real time } validation of the connection between TWS and IB. When using the } demo, our experience in this area was 'not good'. If I pull the plug } on the TWS connection at the firewall, it goes into a cycle of trying } to log back in, but never gives any kind of error indication to the } client application. I've kludged together a bit of an indication by } monitoring the bid/ask on the nq contract, basically we work on the } assumption that if there have been no updates for 30 seconds on the } nq, then it's likely the connection to IB is dead. The other option } we looked at, was a pinger thread, but that only verifies the network } connection, doesn't verify that TWS is indeed connected and live. } } Has anybody else been contemplating this problem ? } Please help make the world a better place ... report these problems and issues to IB. Work-arounds on beta software is kinda silly. Richard |
|||
Re: new here
m_c_a98
I know someone who chose to use the Patsystems API, which does give
all the error/verifaction of connection, etc... instead of IB. --- In twsapi@y..., "grozzie2" <grozzie2@y...> wrote: I'm new here, read the posts from back to the start to 'catch up'.and have delivered 'first prototype' to the customer already. Ourhave been a lot easier, and if the api didn't have serious concurrencythis api in C++ and integrating it as 'another platform' into a largerplug on the TWS connection at the firewall, it goes into a cycle oftrying to log back in, but never gives any kind of error indication to theby monitoring the bid/ask on the nq contract, basically we work on theoption we looked at, was a pinger thread, but that only verifies thenetwork connection, doesn't verify that TWS is indeed connected and live. |
|||
new here
I'm new here, read the posts from back to the start to 'catch up'.
I'm curious about one thing, is everybody here using VB, or are any of you using anything more powerful for this application ? I started our first project utilizing the API a couple weeks ago, and have delivered 'first prototype' to the customer already. Our experience to date is 'if the api worked as documented' it would have been a lot easier, and if the api didn't have serious concurrency issues, it would have been almost trivial. We are working with this api in C++ and integrating it as 'another platform' into a larger system that's been in production with other brokers for years. I am curious if anybody has come up with ways of doing real time validation of the connection between TWS and IB. When using the demo, our experience in this area was 'not good'. If I pull the plug on the TWS connection at the firewall, it goes into a cycle of trying to log back in, but never gives any kind of error indication to the client application. I've kludged together a bit of an indication by monitoring the bid/ask on the nq contract, basically we work on the assumption that if there have been no updates for 30 seconds on the nq, then it's likely the connection to IB is dead. The other option we looked at, was a pinger thread, but that only verifies the network connection, doesn't verify that TWS is indeed connected and live. Has anybody else been contemplating this problem ? |
|||
Re: twsapi: Spin buttons?
Scott
Bruce,?
|
|||
Re: twsapi: Spin buttons?
marinindextrader
At design time right click the control itself to invoke a special
properties dialogue..ala like a Tab Control.. Thats where the meat and potatos are cut.... --- In twsapi@y..., "Bruce Hawkins" <hawkinsk001@h...> wrote: Hi Scott,increase/decrease the value by 1 with a click of the up/down buttons in a text box called txtContracts.directory as part of Windows Common Controls 2 (SP 4) group. adjacent to another control, and you can mask the drop down button of a combo box, here is a neat trick. where as your original value is the middle of the range. You do this on the GotFocus event. After loading the list, you need to loop the list and compare the list items with the original value in the box, and when they match, set the .SelectedItem = the counter. This gives full focus on the combo, making it ready for a mouse roll event. tickStep) Step (-1 * tickStep) cmbPoints(Index).AddItem Format(dblTemp, "0.00")box, and he can also scroll the UpDown with his mouse wheel! be three labels. The left control is a Label. The middle control is a type 0 combo box. The right control is a type 1 combo box. The right hand combo masks the drop down button. You need a hvy weight control to mask another heavy weight control. Just need to get your Zorder right. the mouse wheel... Service. ---------- Do You Yahoo!? |
|||
Spin buttons? Read This Bruce
Scott
Bruce,
If You Need More Help Just Hollar. I have an UP DOWN sample project if you need it...
The UpDown ControlThe UpDown control offers a simple but effective way to create those spin buttons that many Windows applications display to the right of numeric fields and that let users increment or decrement a field's value using mouse clicks. While it's a trivial matter to create such spin buttons yourself?using a tiny VScrollBar control, for example, or using two smaller buttons with Style = 1-Graphical?the UpDown control offers many advantages and is far easier to set up and use than any other solution. The most intriguing characteristic of the UpDown control is that you can link it to another control?its buddy control?at design time, and you can even select which particular property of the buddy control is affected by the UpDown control. Add to this the ability to set the scrolling range and the increment, and you see that in most cases you don't even need to write code to make everything work as expected. Setting Design-Time PropertiesIn the General tab of an UpDown control, you typically set the Alignment property, which determines where the UpDown control has to align with respect to its buddy control. (The values are 0-cc2AlignmentLeft and 1-cc2AlignmentRight.) In this tab, you also set the Orientation property (0-cc2OrientationVertical or 1cc2OrientationHorizontal). The Orientation property can be set only at design time and is read-only at run time. You select the buddy control in the Buddy tab of the Property Pages dialog box. (See Figure 11-2.) You can either type the control's name in the first field or tick the AutoBuddy check box. In the latter case, the UpDown control automatically selects the previous control in the TabIndex sequence as its buddy control. After you've selected a buddy control, two other fields on the Property Pages dialog box become available. In the BuddyProperty combo box, you select which property of the buddy control is affected by the UpDown control. (If you don't select any, the buddy control's default property is used.) You can set the SyncBuddy property to True, which causes the UpDown control to automatically modify the selected property in its buddy control. You usually select a TextBox control as the buddy control of an UpDown control and Text as the buddy property. But nothing prevents you from connecting an UpDown control to other properties (for example, Left or Width) exposed by other types of controls. You can't use lightweight windowless controls as buddy controls, however. Figure 11-2. The Buddy tab of the Property Pages dialog box of an UpDown control lets you select the buddy control and the buddy property. Finally, in the Scrolling tab of the Property Pages dialog box, you select the UpDown control's Min and Max properties, which identify the valid range for the Value property. The Increment property is the value that's added to or subtracted from the Value property when the user clicks on the UpDown control's spin buttons. If the Wrap property is set to True, the Value property wraps when it reaches the Min or Max value. Run-Time OperationsIf the UpDown control's SyncBuddy property is set to True, you don't need to write any code to manually change the property in the buddy control. There are cases, however, when you can't rely on this simple mechanism. For example, the UpDown control might have no buddy controls or perhaps it's supposed to affect multiple controls or multiple properties of the same control. (For example, you might need to enlarge or shrink another control by affecting its Width and Height properties at the same time.) In such cases, all you have to do is write code inside the Change event procedure, as you would do for a scroll bar control. The UpDown control exposes two custom events that give you even more flexibility: The DownClick and UpClick events, which fire when the mouse is released (that is, after the Change event) on either one of the buttons that make up the UpDown control. These events fire even if the Value property has already reached its Min or Max, which makes DownClick and UpClick events useful when you don't want to enforce a limit to the range of valid values: ?
All the properties that you set at design time can also be modified at run time through code, with the exception of the Orientation property. For example, you can change the buddy control and the buddy property using this code: ?
The BuddyControl property can also be assigned the name of the buddy control, for example: ?
When you change the buddy control at run time, the UpDown control automatically moves to a position beside its buddy control, which shrinks to make room for the UpDown control. Do You Yahoo!? Yahoo! Autos - Get free new car price quotes |
|||
Re: twsapi: Spin buttons?
cyberbri_2000
Here's one example...
toggle quoted message
Show quoted text
Sub Form_Load() UpDown1.Increment = 1 UpDown1.Min = 1 UpDown1.Max = 10 End Sub Private Sub UpDown1_Change() txtContracts.Text = UpDown1.value End Sub Then, to put that value in your buy order, don't forget to convert it to a number... val(txtContracts.Text) For my own programs I would make it a label instead of a text box, which would only allow the UpDown buttons to change the value, instead of allowing a number to be typed in by the user. Then you could place code in the UpDown1_Change, like making sure the user has available capital for the number selected, etc. Brian Hi Scott, |
|||
Re: twsapi: Authomated Trading for TWS
Shukrainternationals
¿ªÔÆÌåÓýI have two questions about TradeGaurd. I have sent these
questions to the developer of the program also.
Here they are:
1. In what way this program is better than IB Dde.xls platform
where you can place orders also?
2. In Ib platform, you can at least send (write in to
appropriate cells) an order that is generated from other system such as
TradeStation 200i.
For a trader, and that to a scalper, there should be
supporting system that tells him when to buy and sell. While TraderGaurd is
good, it does not take orders from another system which develops trading signals
automatically in real time (or, does it?).
l
|
|||
Re: twsapi: Authomated Trading for TWS
m_c_a98
I gave Traderguard a test yesterday and what it does is allows you to
automate trailing stops at whatever point level you want. you can also change these realtime or reset to trail at the current price. It lets you buy/sell or reverse position as well. The programming inclined probably can easily create there own custom apps for this. I'm going to try my hand at my own program as well. --- In twsapi@y..., "Shukrainternationals" <shukrainternationals@c...> wrote: I tried your TradeGaurd but still unable to grasp the benefits ofit to traders except a bunch of flipping colorful arrows You can simply use IB's TWS Dde.xls or TWSActiveX.xls and place your orders as well! What additionals features and benefits your platform providescompared to IB's order-placing platforms? click to fill orders or reverse position.. no confirmation, noService. |
|||
Re: twsapi: Spin buttons? One last thing
marinindextrader
You read your combo box in the combo box click event. Each scroll
incrament fires the click event. So that is where you capture the value and update your variable if required. iSize = CInt(Combo1) Combo boxes have a default Text property value just like Text boxes. You don't need to explicitily refrence the .Text Property. Combo1 is equivalent to Combo1.Text Scott --- In twsapi@y..., "Bruce Hawkins" <hawkinsk001@h...> wrote: Awesome thanks so much Scottdirectory as part of Windows Common Controls 2 (SP 4) group. adjacent to another control, and you can mask the drop down button of a combo box, here is a neat trick. where as your original value is the middle of the range. You do this on the GotFocus event. After loading the list, you need to loop the list and compare the list items with the original value in the box, and when they match, set the .SelectedItem = the counter. This gives full focus on the combo, making it ready for a mouse roll event. tickStep) Step (-1 * tickStep) cmbPoints(Index).AddItem Format(dblTemp, "0.00")box, and he can also scroll the UpDown with his mouse wheel! be three labels. The left control is a Label. The middle control is a type 0 combo box. The right control is a type 1 combo box. The right hand combo masks the drop down button. You need a hvy weight control to mask another heavy weight control. Just need to get your Zorder right. the mouse wheel... Service. ---------- Do You Yahoo!? |
|||
Re: twsapi: Spin buttons?
marinindextrader
No problamatico, (I get a kick out of Gringo_Problamatico's handle)
Notice if you try my trick, that you need to populate the box in a bracket sense and then pin it in the middle. That way wheel roll up or wheel roll down works. The Exit For is there in case the user tries to roll into negative territory, or if he gives it focus when the value is 1. Dont need to populate the box with values less then 0. Notice too that in my case I decrament the list. Nothing says one cant incrament the list. It all depends on what direction you prefer your mouse roll event to have. If pulling back on the wheel feels like you should roll down, then decrament, and vice versa otherwise. Scott --- In twsapi@y..., "Bruce Hawkins" <hawkinsk001@h...> wrote: Awesome thanks so much Scottdirectory as part of Windows Common Controls 2 (SP 4) group. adjacent to another control, and you can mask the drop down button of a combo box, here is a neat trick. where as your original value is the middle of the range. You do this on the GotFocus event. After loading the list, you need to loop the list and compare the list items with the original value in the box, and when they match, set the .SelectedItem = the counter. This gives full focus on the combo, making it ready for a mouse roll event. tickStep) Step (-1 * tickStep) cmbPoints(Index).AddItem Format(dblTemp, "0.00")box, and he can also scroll the UpDown with his mouse wheel! be three labels. The left control is a Label. The middle control is a type 0 combo box. The right control is a type 1 combo box. The right hand combo masks the drop down button. You need a hvy weight control to mask another heavy weight control. Just need to get your Zorder right. the mouse wheel... Service. ---------- Do You Yahoo!? |