开云体育

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Date

Re: twsapi: Trader Guard - ES NQ futures ready app.

marinindextrader
 

"Download it from twsapi file area. I'll post it here within 3 days"

He hasnt uploaded it yet...but when he does you can get there from
here by clicking on the Files link on the left sidebar


<-----------------------------------Over There, see where it says
FILES

Or you can click this link:


Scott





--- In twsapi@y..., "Shukrainternationals"
<shukrainternationals@c...> wrote:
How to go to TWSAPI file area?

----- Original Message -----
From: traderguard
To: twsapi@y...
Sent: Thursday, June 27, 2002 3:27 PM
Subject: twsapi: Trader Guard - ES NQ futures ready app.


Addition to your existing IB TWS platform. I designed it for
scalpers
to profit from every single trend change with "adaptive
Automation
Engine" monitoring market tick by tick and in real time.
You will love it.
It will automate your profit collection at the topmost
point and also auto-escape from bad point of entry. This is what
i
like the most.
Download it from twsapi file area. I'll post it here within 3 days
(finishing GUI design only)
If you inpatient or file is not there for any reason e-mail
request
to me. I'll be happy to send you a copy.


traderguard@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: Trader Guard - ES NQ futures ready app.

Shukrainternationals
 

开云体育

How to go to TWSAPI file area?
?

----- Original Message -----
Sent: Thursday, June 27, 2002 3:27 PM
Subject: twsapi: Trader Guard - ES NQ futures ready app.

Addition to your existing IB TWS platform. I designed it for scalpers
to profit from every single trend change with "adaptive Automation
Engine" monitoring market tick by tick and in real time.
You will love it.
It will automate your profit collection at the topmost
point and also auto-escape from bad point of entry. This is what i
like the most.
Download it from twsapi file area. I'll post it here within 3 days
(finishing GUI design only)
If you inpatient or file is not there for any reason e-mail request
to me. I'll be happy to send you a copy.


traderguard@...



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



Your use of Yahoo! Groups is subject to the .


Trader Guard - ES NQ futures ready app.

traderguard
 

Addition to your existing IB TWS platform. I designed it for scalpers
to profit from every single trend change with "adaptive Automation
Engine" monitoring market tick by tick and in real time.
You will love it.
It will automate your profit collection at the topmost
point and also auto-escape from bad point of entry. This is what i
like the most.
Download it from twsapi file area. I'll post it here within 3 days
(finishing GUI design only)
If you inpatient or file is not there for any reason e-mail request
to me. I'll be happy to send you a copy.


traderguard@...


Re: twsapi: Market Making App

Richard Foulk
 

} Hello. I'm a seasoned vb programmer and I've been trading with IB
} for a long while. I'm thinking about writing a fully automated
} Market Making application that posts bids/asks automatically. I have
} to admit, although I would have no problem writing the software
} (which I don't mind sharing with everyone), I don't think I know
} enough about market making. In general, when I try to post a test 10-
} share sell/buy on a NASDAQ stock inside the bid/ask spread, it
} doesn't seem to show up on the Bid/Ask. Is this because I'm not
} posting lots? or is there some other restriction. I would love to
} hear from people with similar interest, and get a move on this
} project if it is feasible.
}
} Cheers,
}
} JS

Glad to hear you consider yourself to be `seasoned'. :-)

NASDAQ doesn't show orders less than 100 shares. Try Island and the Island
book if you want to play with tiny trades.


Richard


Market Making App

fanjacks
 

Hello. I'm a seasoned vb programmer and I've been trading with IB
for a long while. I'm thinking about writing a fully automated
Market Making application that posts bids/asks automatically. I have
to admit, although I would have no problem writing the software
(which I don't mind sharing with everyone), I don't think I know
enough about market making. In general, when I try to post a test 10-
share sell/buy on a NASDAQ stock inside the bid/ask spread, it
doesn't seem to show up on the Bid/Ask. Is this because I'm not
posting lots? or is there some other restriction. I would love to
hear from people with similar interest, and get a move on this
project if it is feasible.

Cheers,

JS


Don't change the board

Todd Hanson
 

Please do not confuse everyone with posting another
board or splitting it off. Take care.

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup


Good job Scott

multicen2002
 

ThanX

Andrew..


twsapi: Re: VB Sample Project: How To Place An Order

marinindextrader
 

He was talking about different code Andrew...the footnote
discussion....

The proggie that demos orders is fine...its even customized for your
3030 start point...just download it and check it out


Scott

--- In twsapi@y..., multicen2002 <no_reply@y...> wrote:
could you modify scott example and post it in file area??
i like to test drive it too.

Thanks
Andrew


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


twsapi: Re: VB Sample Project: How To Place An Order

multicen2002
 

could you modify scott example and post it in file area??
i like to test drive it too.

Thanks
Andrew


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