开云体育

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

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

----- Original Message -----
Sent: Monday, June 24, 2002 2:08 PM
Subject: twsapi: TWS API VB - GONE..

hi..

I have read your E-mails.. I was wrong..
We do not need another group..

I didn't mean to offend anyone...I'm sorry if I have...
I'm with you .. TWS API for VB is gone now..

Andrew





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



Your use of Yahoo! Groups is subject to the .


TWS API VB - GONE..

multicen2002
 

hi..

I have read your E-mails.. I was wrong..
We do not need another group..

I didn't mean to offend anyone...I'm sorry if I have...
I'm with you .. TWS API for VB is gone now..

Andrew


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,
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.

----- Original Message -----
From: marinindextrader
To: twsapi@y...
Sent: Monday, June 24, 2002 7:10 AM
Subject: twsapi: Re: VB Sample Project: How To Place An Order


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





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.


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.
?

----- Original Message -----
Sent: Monday, June 24, 2002 7:10 AM
Subject: twsapi: Re: VB Sample Project: How To Place An Order

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





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



Your use of Yahoo! Groups is subject to the .


Re: order IDs

marinindextrader
 

"I choose to use the Microsoft .mdb format and access it from VB with
DAO 3.6."

I am gonna put the screws to you when I get to this point...count on
it..

Excellent Tangent

Scott


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,

Bruce



----- Original Message -----
From: marinindextrader
To: twsapi@y...
Sent: Sunday, June 23, 2002 10:37 AM
Subject: twsapi: Re: VB Sample Project: How To Place An Order
[Code]


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







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.


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]

 

开云体育

Thanks once again Scott,
?
Bruce
?
?
?

----- Original Message -----
Sent: Sunday, June 23, 2002 10:37 AM
Subject: twsapi: Re: VB Sample Project: How To Place An Order [Code]

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







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



Your use of Yahoo! Groups is subject to the .


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 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 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


----- Original Message -----
From: multicen2002
To: twsapi@y...
Sent: Sunday, June 23, 2002 7:48 AM
Subject: twsapi: TWS_AP_VB -An addition to twsapi group


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@y...



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.


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 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


----- Original Message -----
From: multicen2002
To: twsapi@y...
Sent: Sunday, June 23, 2002 7:48 AM
Subject: twsapi: TWS_AP_VB -An addition to twsapi group


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@y...



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.


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
?
?

----- Original Message -----
Sent: Sunday, June 23, 2002 7:48 AM
Subject: twsapi: TWS_AP_VB -An addition to twsapi group

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@...



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



Your use of Yahoo! Groups is subject to the .


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

 

开云体育

Thank you very much Scott for taking the time and being so open.
?
Bruce

----- Original Message -----
Sent: Sunday, June 23, 2002 6:46 AM
Subject: Re: twsapi: TWS API VB files for newbies - 1st POST

Agreed,

I try and post code every week...
I put up bits and pieces and modules in the Files section
all the time...

As my program develops I will be shareing what ever it is I am
working on at the time

Check out the files section:



I am now just begining on the order handling routines and within a
week or two I will begin to post what I come up with

Any and all are certainly encouraged to share...

At the same time..those who don't are just as welcome to NOT post or
NOT respond...

Each of us will get or give differently...some alot and some none...

All is good

Scott
Yahoo TWS API



--- In twsapi@y..., multicen2002 wrote:
>
>
> POST your code, too
> and look under FILE AREA
> TWS API - Let's share VB code NR-1
>
> Somebody need to break an ace.
> just little somethink to play with..
>
> Andrew
>
>
>
>
> --- In twsapi@y..., "Bruce Hawkins" wrote:
> > Yes,? I agree any code examples that can be posted are greatly
> appreciated. Its frustrating when you
> >? know the info is out there but you can't get to it.
> >
> > I realize some people are trying to come up with a program to
> market to people who don't want to invest
> > the time to build there own.
> >
> > But I can't imagine all 200 plus members of this board are going
to
> do that, so what would it hurt to throw
> > out a few scraps of code? The people struggling with? creating
> there own programs are not the competition,
> > I could care less about marketing a standalone for TWS I just
want
> a program that I can tweak to my satisfaction.
> >
> > Thank you Scott for your effort and postings of files.
> >
> > Sincerely,
> >
> > Bruce
> >?? ----- Original Message -----
> >?? From: multicen2002
> >?? To: twsapi@y...
> >?? Sent: Saturday, June 22, 2002 4:01 PM
> >?? Subject: twsapi: TWS API VB files for newbies - 1st POST
> >
> >
> >?? Special thanx to users for trying to solve BUY/SALE/CANCEL
> >?? code lines for VB OCX.
> >?? Nothing works ....
> >
> >?? It look like nobody knows or want to share a sample VB PROJECT
in
> >?? files area showing PROPER USE of:
> >
> >?? Tws1.placeOrder
> >
> >?? Many of us are not experienced in programming but we can modify
> >?? a sample project.
> >
> >?? If there is a single person in this Group which can write a
sample
> >?? project with: Auto orderID numbering, BUY at ask , sale at BID
> >?? and cancel odrer buttons PLEASE RESPOND.
> >
> >?? We do not want to know how you trade. All we need is your
> technical
> >?? advice.
> >?? Is this not why this TWS API group exists ??
> >
> >?? Or maybe I am wrong??
> >
> >?? TO OTHER USERS : PLEASE SUPPORT MY REQUEST by posting SUPPORT
> message
> >?? Thanx everybody.
> >
> >?? Andrew
> >
> >
> >???????? 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.



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



Your use of Yahoo! Groups is subject to the .


Re: twsapi: Re: How do you?+ TWS API VB files for newbies - 1st POST

 

开云体育

All I can offer is this post from the IB board from Jaba,
?
?

Posted on Sunday, May 19, 2002 - 03:30 pm: ??

ok, since I see people are requesting this over, and over again... I put together a ridiculously simple VB Project. It will use ActiveX API to connect to the TWS, then request and display quotes for NQ contract. It's downloadable from Visual Basic Project directory, URL at the bottom of this message.

I hope this helps
Jaba


----
?
?
Bruce
?
?
?
?
?
?
?
?
----- Original Message -----
Sent: Sunday, June 23, 2002 5:57 AM
Subject: twsapi: Re: How do you?+ TWS API VB files for newbies - 1st POST

will you add a code line to your post ??
or sample to file area?? It will take you extra 2 more minutes.
Thanx


Andrew



--- In twsapi@y..., "qnolte" <q@n...> wrote:
> Use the "nextValidId" event to get a valid Id to use each time.
>
> --- In twsapi@y..., "Bruce Hawkins" <hawkinsk001@h...> wrote:
> > How do I get? Tws.ocx on to a new form?
> >
> > I tried the following on the Demo and it worked except I have to
> keep increasing the order ID to place more orders.
> >
> > Call Tws1.placeOrder(3030, "BUY", 1, "ES", "FUT", "200209", _
> > 0, "", "GLOBEX", "", "LMT", 1000.00, 0)
> >
> > How do you work around this?
> >
> > Any input appreciated,
> >
> > Bruce
> >
> > P.S. The form I am using now (which was a simple Demo I got from
> Jaba) I beleive has an earlier ver. of Tws.ocx



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



Your use of Yahoo! Groups is subject to the .


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 can
use (to enhance and push forward the development of a trading
interface)or have any ideas on anyone who does? Looking for low
cost
solution.

Idea: Team would send in ideas on polling questions that they would
like answered and then vote on the items that would be put into the
polls. They would have control of the questions asked and the
results would be a benifit to them rather that someone else.

IB has not volunteered yet to do this(specific) surveys.

Posted thread items:

(1) All interested parties need to make a list of what problems
they
want solved.

IB request( no response)

1. Sponsor specific surveys (trading interface) to find out what
are
the major goals of IB's users that are real serious about a
trading interface.