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
Re: twsapi: TWS API VB - GONE..
David
开云体育cheer up Andrew...
you have got the guts to say sorry...
That's a lot, at least in my eyes.
David
|
||
Re: twsapi: TWS_AP_VB -An addition to twsapi group
Richard Foulk
} Hello
} I just started new group based on great twsapi. } It is not any competition to existing group just extention for } VB programmers and newbies. } TWS_AP_VB will filter users and will focus on VB ONLY supporting } twsapi. } I am seting the TWS_AP_VB as membership only but everyone who } will POST a sample or partial code on twsapi for VB can join. } } I hope this will seperate ppl who want to share from all others } who just want to TAKE. } } Again.. THIS IS NOT A NEW GROUP.. if you just need help or advice } twsapi is the main group for all of us. } } any Q ?? contact me direct multicen2002@... } } That's just plain stupid! Don't be in such a hurry that you cause damage. There is not enough interest to support yet another group. And all the various languages supported by the API are similar enough that they should be discussed together for maximum benefit. So you're not much of a programmer and are trying to get others to do all your learning and work for you ... Well you're doing damage to the exchange of ideas. Back off! Relax. Richard |
||
twsapi: Re: VB Sample Project: How To Place An Order
marinindextrader
Your right...
Goes to show ya I really am coming up from the bottom on this... I think the premise is sound in terms of time I myself dont (wont) quibble to much on this. I just threw this out there... Probably a whole hell of a lot better to stick another dimension in an array and just time stamp the call Thanks for pointing out the obvious flaw. On the otherhand though, crafty order id assignment could be an advantage i suppose Scott FWIW: I didn't know an IF statment from Jack's Shinola 6 months ago...but I am trying like the dickens to learn fast...its the damn logic that beach slaps me down every time.... Thansk --- In twsapi@y..., "David" <kotomo@p...> wrote: Scott,after the other, TWS will complain about the duplicate order as they will be (the orderid i mean) separated by 1 to 2 seconds(numbers apart) another way is toDatePart("Y", Date) & IC and you cancel any orders that not filled through the gblOrderId() array. Of course, you would need to monitor it through the OrderStatus event. disturbing... when I helped you i did know that you had something to offer (AI).your bit on AI anyway. creation and value.time and date, convert it to a long value and then and use this as anid. value and reports can be printed on a time basis.2,147,483,647 the symbol...for instance all trades with cisco will be between X andY... of trade it was...Long or Short...arbitrary system is ridiculousService. |
||
Re: twsapi: Re: VB Sample Project: How To Place An Order
David
开云体育Scott,
the problem with your code is that if you put orders
through? one after the other, TWS will complain about the duplicate order
as they will be (the orderid i mean) separated by 1 to 2 seconds(numbers
apart)
another way is to
Public gblOrderId&()
DIM IC%
?
ReDim Preserve gblOrderId(IC)
IC = IC + 9 gblOrderId(IC) = DatePart("YYYY", Date) & DatePart("M", Date) & DatePart("Y", Date) & IC ?
This way you know the day of the year and all orders of that
day, and you cancel any orders that not filled through the gblOrderId() array.
Of course, you would need to monitor it through the OrderStatus
event.
?
Thanks
David
PS Andrew your comments about sharing and not sharing are
disturbing...
when I helped you i did know that you had something to offer
(AI).
Just go with the flow... you may enjoy it. I would not mind
seeing your bit on AI anyway.
?
|
||
order IDs
Robert Carey
开云体育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
? |
||
Re: VB Sample Project: How To Place An Order [Code]
marinindextrader
I wrote:
"Put a Text1 textbox on your form. Put a Command1 command button on your form Add a Simple BAS Module" And lamed out by not saying: Make sure you change the multiline property of your text box to True....The default is false Unless multi-line is selected you get these funney looking black box like charecters in your string and it just runs on.. Scott |
||
twsapi: Re: VB Sample Project: BEER TIME
marinindextrader
I am going to have a beer now.
Thanks to whoever brought up the whole order id question.... I needed to start working on this and his question forced my day to focus on and understand the order process... Scott <----------tossing back a Boddingtion Ale --- In twsapi@y..., "Bruce Hawkins" <hawkinsk001@h...> wrote: Thanks once again Scott,[Code] off for 1 Contract of September " & _in your array"As Long, _As String, _As String, _lmtPrice As Double, _value; 1, 5, 10 etcat it 'you will see that if the next available IB id is greater thanincrament If m_theirID < m_myID Thenorder ReDim Preserve m_arrOrders(12, UBound(m_arrOrders, 2) + 1)make the orderline OrderString = OrderString & "Trade: " & iTemp + 1& ", " & _end of theiTemp) & vbCrLfiTemp) & ", "Service. |
||
Re: VB Sample Project: How To Place An Order
marinindextrader
Here is the footnote I left off concerning order id's, thier creation
and value. Why choose an arbitrary value for an order id? I might suggest that your order id system be based on time. Using various functions one can extract a string from the system time and date, convert it to a long value and then and use this as an id. Why would one want to do this? If they were (in the future) to decide to capture all trades and store in a database, the id can be reconverted into its date value and reports can be printed on a time basis. Here is a crude example of creating an id based on date and time: Example Date: 6/20/02 10:24:17 AM Private Sub Command2_Click() Dim newString As String Dim newId As Long newString = newString & Month(Date) newString = newString & Day(Date) newString = newString & DatePart("h", Now) newString = newString & DatePart("m", Now) newString = newString & DatePart("s", Now) Text1 = newString 'displays 620102417; a unique number newId = CLng(newString) 'convert to long value 'this value is within the confines of Long type data: 2,147,483,647 End Sub There are other reasons to manipulate the order id... What if you want your id to be based on a conditional check of the symbol...for instance all trades with cisco will be between X and Y... Or...if you trade options you might want an order prefix that describes where in the money you are...or something like that.. I dont know much about options specifications Or...you may want use an ordering system that relates to the type of trade it was...Long or Short... The choices are endless, and to dismiss everything but an arbitrary system is ridiculous If your storing the number...put it to work Scott Owner TWS API Yahoo Discussion Forum "The other Yahoo Board" heheheheh |
||
Re: twsapi: Re: VB Sample Project: How To Place An Order [Code]
toggle quoted message
Show quoted text
|
||
Re: VB Sample Project: How To Place An Order [Code]
marinindextrader
Put a Text1 textbox on your form.
Put a Command1 command button on your form Add a Simple BAS Module Stick this in the Form: (and the rest in the Module) Private Sub Command1_Click() 'here I have just plugged in literal values for the example 'of course you could pull these in as variables or control properties 'such as a combo box text or what not... Call PlaceNewOrder("BUY", 1, "ES", "FUT", "200209", 0, "", "GLOBEX", "", "MKT", 0, 0) End Sub Private Sub Form_Load() 'connection call Tws1.Connect "", 7496 'initialize your module variables Call InitVarsNewOrderMod Text1 = "PLACE ORDER DEMO:" & vbCrLf & vbCrLf & _ "When you click Command1, a market order will fire off for 1 Contract of September " & _ "ES. Keep clicking it and it will keep buying one at market. Each time you click, " & _ "This box will fill with the order information stored in your array" End Sub 'and use this for when you log out and relog in 'you can conditionally test next valid id in the module Private Sub Tws1_nextValidId(ByVal id As Long) 'call a module level Sub that captures the IB id on log in Call CaptureID(id) End Sub 'now create a private sub that will handle the order routines 'the array captures the order info and stores it for you 'good idea IMHO to internally track this info and not rely 'on IB soley Private Sub PlaceNewOrder(ByVal action As String, ByVal quantity As Long, _ ByVal symbol As String, ByVal secType As String, ByVal expiry As String, _ ByVal strike As Double, ByVal right As String, ByVal exchange As String, _ ByVal curency As String, ByVal orderType As String, ByVal lmtPrice As Double, _ ByVal auxPrice As Double) Dim mirror(12) As Variant 'left this as zero based for clarity Dim newID As Long 'assign all of the arguements to the array 'not the conspicuous absence of id in the arguements mirror(1) = action: mirror(2) = quantity: mirror(3) = symbol mirror(4) = secType: mirror(5) = expiry: mirror(6) = strike: mirror(7) = right: mirror(8) = exchange: mirror(9) = curency: mirror(10) = orderType: mirror(11) = lmtPrice: mirror(12) = auxPrice 'pass the array out to the module newID = Get_Set_NewOrderID(mirror) 'place the order Call Tws1.placeOrder(newID, action, quantity, symbol, secType, expiry, strike, right, exchange, _ curency, orderType, price, auxPrice) End Sub 'MODULE CODE STARTS HERE Option Explicit Private m_arrOrders() As Variant 'master array Private m_myID As Long 'your starting point Private m_theirID As Long 'thier starting point Private m_nextID 'next id your going to use Private m_incrament As Integer 'a variable to incrament by any value; 1, 5, 10 etc ' 'call on form load Sub InitVarsNewOrderMod() m_myID = 3030 'set your starting level here ReDim m_arrOrders(12, 0) m_incrament = 10 'optional to incrament by other than 1 End Sub Sub CaptureID(ByVal theirID As Long) 'capture theirs at log on m_theirID = theirID End Sub 'store your order info and give an id back to the calling sub 'this is the workhorse Function Get_Set_NewOrderID(ByVal mirror As Variant) As Long Dim iTemp As Integer 'find the proper id; this looks a little convaluted but stare at it 'you will see that if the next available IB id is greater than your starting 'point, it will back up one then add your incrament 'otherwise it just keeps ripping out new id's per your incrament If m_theirID < m_myID Then m_nextID = m_myID m_myID = m_myID + m_incrament Else m_myID = m_theirID - 1 + m_incrament m_nextID = m_myID m_myID = m_myID + m_incrament End If 'assign the id to the first element of the array m_arrOrders(0, UBound(m_arrOrders, 2)) = m_nextID 'assign the mirror to the rest of the array For iTemp = 1 To UBound(m_arrOrders) m_arrOrders(iTemp, UBound(m_arrOrders, 2)) = mirror(iTemp) Next iTemp 'redim and preserve your array in preperation for the next order ReDim Preserve m_arrOrders(12, UBound(m_arrOrders, 2) + 1) 'display your array in the text box Call DisplayArray 'finally send the new id back to the calling sub to actually make the order Get_Set_NewOrderID = m_nextID End Function 'and a sub to display your array information Private Sub DisplayArray() Dim iTemp As Integer, iTemp2 As Integer Dim OrderString As String 'loop through the array and build a string to display For iTemp = 0 To UBound(m_arrOrders, 2) - 1 For iTemp2 = 0 To UBound(m_arrOrders) Select Case iTemp2 Case LBound(m_arrOrders) 'place the number of orders at the begining of each line OrderString = OrderString & "Trade: " & iTemp + 1 & ", " & _ "ID# " & m_arrOrders(iTemp2, iTemp) & ", " Case UBound(m_arrOrders) 'insert a line return character when you reach the end of the 'first trade OrderString = OrderString & m_arrOrders(iTemp2, iTemp) & vbCrLf Case Else OrderString = OrderString & m_arrOrders(iTemp2, iTemp) & ", " End Select Next iTemp2 Next iTemp 'display the string Form1.Text1 = OrderString End Sub |
||
VB Sample Project: How To Place An Order
marinindextrader
Andrew,
Go here and download this: 1_Project_PlaceOrder.zip To All: I havnt spent much time at all on the placeOrder routine...that is coming this week for me. However here is my take on the whole affair after some quick study of the methods. The next valid Id call is made right after startup. If it is the first time you have started IB for the day and have had no open orders, the next valid id will be 0. If you have made orders the last order id you placed will be incramented by 1... That having been said..If you are making your first trade you can assign anything you please as an order id...the key is to incrament it each time a trade is made. If and when you logged off to go to lunch for instance, then upon relogging, that is when the next valid id comes into play. Of course your system could save the information in the registry or whatnot and you more than likely could recall your own last id and go from their...the bottom line is that the order id's must ascend in relative value to one another...that is really the crux of it...relogging in will fetch the next valid id.. All that having been said, let me share some code with you on how I would handle incramenting the id and storing relevant order information.... Assume your first chosen id is 3030. More on choosing id#'s later; read footnote at bottom. Here is what happens. You place the order and it is sent upstream to IB and they record your chosen order id. If you relogged and captured the next valid id it would read 3031..but your not going to relog each time to fetch an id so you have to handle the incramenting your self. Now...you can incrament by whatever you choose...1, 5 10 etc...it is a Long type value so you will be limited to a ceiling of 2,147,483,647...LOL shouldn't be a problem with whatever creative method you choose to craft id's So on to te crux of the matter.... First off I would create a module that tracks your order id and all order information. Second I would create a Form level sub to handle the Tws1.place order call... I would post the code but its easier to just download the project: Scott Owner TWS API Yahoo Discussion Forum |
||
Re: twsapi: TWS_AP_VB -An addition to twsapi group
marinindextrader
Calm Down and wait two seconds...
My next post will have all you need brother Scott Owner Moderator TWS API Discussion Forum --- In twsapi@y..., multicen2002 <no_reply@y...> wrote: Thank you for commentcode. You can't force people to post code through exclusion.for post trying to assist you with your problem.advicecreate another group. twsapi is the main group for all of us.Service. |
||
Re: twsapi: TWS_AP_VB -An addition to twsapi group
multicen2002
Thank you for comment
I'll wait for more FOR and against.. and if neccecery i'll remove group extention.. what ever work for benefit of all of us. I am just saying that if ppl do not wish to share idea or code they do not need to join. But it is more than fair to exchange and not just take. Yes, twsapi is kickin.. but scott can not be the only one who share. I program for more than 5 years - database and adaptive apps. never did data feed.. as europian ..i am expecting cooperation.. I will post my ADAPTIVE AI program and its components as I go but please forgive me if i do not wish to share my hours of typing and testing with ppl who do not wish to share. I thing it is more than fair to work in a team on making better apps.. here we go.. Its to ME more like OPEN SOURCE just like FREEBSD again thanx for your comment Andrew --- In twsapi@y..., "Bruce Hawkins" <hawkinsk001@h...> wrote: I am not sure what you are trying to accomplish, I don't think weneed to splinter this topic. create stand alone programs, not complaining that nobody is posting code. There already have been some posts regarding requests for code. You can't force people to post code through exclusion. post trying to assist you with your problem. create another group. Service. |
||
Re: twsapi: TWS_AP_VB -An addition to twsapi group
开云体育I am not sure what you are trying to accomplish, I
don't think we need to splinter this topic.
?
If people want to post they will, lets keep the
focus of this to create stand alone programs, not complaining that nobody is
posting code. There already have been some posts regarding requests for code.
You can't force people to post code through exclusion.
?
As far as response is concerned, on 6/21 David
matched you post for post trying to assist you with your problem.
?
Needless to say Scott is the glue that holds this
board together.
?
If I haven't made my opinion clear I think it is a
mistake to create another group.
?
Sincerely,
?
Bruce Hawkins
?
?
|
||
TWS_AP_VB -An addition to twsapi group
multicen2002
Hello
I just started new group based on great twsapi. It is not any competition to existing group just extention for VB programmers and newbies. TWS_AP_VB will filter users and will focus on VB ONLY supporting twsapi. I am seting the TWS_AP_VB as membership only but everyone who will POST a sample or partial code on twsapi for VB can join. I hope this will seperate ppl who want to share from all others who just want to TAKE. Again.. THIS IS NOT A NEW GROUP.. if you just need help or advice twsapi is the main group for all of us. any Q ?? contact me direct multicen2002@... |
||
Re: twsapi: TWS API VB files for newbies - 1st POST
toggle quoted message
Show quoted text
|
||
Re: twsapi: Re: How do you?+ TWS API VB files for newbies - 1st POST
toggle quoted message
Show quoted text
|
||
Re: Working on polling any good ideas?
marinindextrader
GoldSilverMana,
Let me know if you find a polling thingy...I vaguely recall that when I first set the group up that Polling was an available option... However it also said that if I enabled it, our email address would have to be made public...so I opted against the idea... Now I have gone back into the maintenance section and can't find a refrence at all to a polling option.... I will delve a tad deeper into the Yahoo polling and see what I can find... I like the idea...just don't know how to go about it at this point Let us know what you come up with Scott --- In twsapi@y..., "goldensilvermana" <kybryan@c...> wrote: Are there any IT people that have access to a polling system we cancost solution.they want solved.are the major goals of IB's users that are real serious about a |
to navigate to use esc to dismiss