|
All TWS ActiveX: Partial Orders!
Author Message
TriPack
Unregistered guest
Posted on Friday, June 07, 2002 - 11:16 am:
----------------------------------------------------------------------
----------
I agree alanm, and am glad you spoke out in favor of the transaction
history. I would like to see it too. It personally makes more sense
to me to provide a actual fills prices rather than an average price
history. It takes the rounding problems out of mix.
alanm
Unregistered guest
Posted on Thursday, June 06, 2002 - 11:40 pm:
----------------------------------------------------------------------
----------
Why not report the actual fill prices instead, since these will be
exactly correct, instead of having to extrapolate it from the
average?
TriPack
Unregistered guest
Posted on Thursday, June 06, 2002 - 10:45 am:
----------------------------------------------------------------------
----------
It appears that this request takes the form of a request for a bug
fix. We need the precision improved for the average prices reported
via the orderstatus event (and other events that report average fill
prices). Regardless of whether a full transaction history is
provided, the average price precision needs to be improved from two
rounded decimal places so that we can calculate fill prices
accurately.
Bart Gelens
Unregistered guest
Posted on Wednesday, June 05, 2002 - 12:56 pm:
----------------------------------------------------------------------
----------
Problem: Twice a "filled order" confirmation with different average
prices?
I am using the TWS stand alone version (build 765) (ActiveX API).
Sometimes, when I place an order like Id=10382 NQM2 BUY 1 4818.50
LIMIT
I get 2 OrderStatus events:
OnOrderStatus: Id=10382 Status=Filled Filled=1 Remain=0 price=4818.50
OnOrderStatus: Id=10382 Status=Filled Filled=1 Remain=0 price=9635.00
The first (average) price is exactly the same as the requested price.
The second price is multiplied by (almost) 2!
This only happens while using the official account. If I log in as
cdemo user, it seems to be working fine. Did anyone have a similar
experience?
Regards,
Bart.
TriPack
Unregistered guest
Posted on Wednesday, June 05, 2002 - 10:41 am:
----------------------------------------------------------------------
----------
"The API is always reporting the average price. "
Marcus, thanks for the clarification in your post. Well that is good
to know. I can make up a formula to account for the averages. My
original impression was that only the last fill reported was an
average. I should be able to solve for rounding (at least in my case
with the EMINIs) because they have a set .25 or .5 tick price for ES
and NQ. Stocks will be more difficult because of the one cent and sub-
one cent prices (in some cases).
Yes, giving us an unrounded average would make it easier. Giving us
full transaction history would also do the trick.
Marcus Jellinghaus
Unregistered guest
Posted on Wednesday, June 05, 2002 - 09:58 am:
----------------------------------------------------------------------
----------
The API is always reporting the average price. The advantage of that
is, that we do not have to calculate the average price, the
disadvantage is, that we have to calculate the part fills. Of course,
the API could return the values the other way round or both.
I think since we program anyway, the calculation of the part filles
shouldn´t be a big problem.
From my calculations, the price of the second part fill should be
((20*1043.44)-(15*1043.5))/5 = 10.26.
You are right with the rounding errors. But the API users can
calculate exactly, the problem is that the API gives rounded numbers
which leads to wrong prices:
Yesterday I bought 600 stocks in 3 part-fills:
100 x 5.9200 Average Price: 5.92
286 x 5.9160 Average Price: 5.917036
214 x 5.9200 Average Price: 5.918141
I have the first 2 numbers from the account statement and calculated
from that the average price. The API always returned 5.92 as average
price, which is rounded. If the API would give the correct number, we
could calculate correct partfills.
So the partfill prices may be wrong in the area smaller a cent.
The fill prices are also sometimes different because IB rounds the
turnover to full cents and so charges other prices than the tick was
at the exchange. But I guess the reason is that most exchanges also
round the turnover to full cents.
TriPack
Unregistered guest
Posted on Tuesday, June 04, 2002 - 03:40 pm:
----------------------------------------------------------------------
----------
Let me use an acutal example from my debug window. I place a limit
order to sell 20 ES @ 1043.25 Limit and the following is my initial
feedback.
Tws1_orderStatus 224 PendingSubmit 15 5 1043.5
Tws1_orderStatus 224 Submitted 15 5 1043.5
Tws1_orderStatus 224 Filled 20 0 1043.44
So from this I *infer* (are fills reported on "PendingSubmit"
and "Submit" events reliable?) that the first lot of 15 was filled at
1043.5 but we have to deduce that the 2nd lot of 5 was filled at
1043.25. Is it just me or is it strange that we have to either
mathematically figure or use some other method to get the last fill
price when you have a partial fill? In this case you can infer that
it was filled at 1043.25 on the last 5 cars because of the limit
price. In other cases it isn't so clear cut. When mathematically
figuring, we have to deal with the rounding errors.
I request executions, and after a delay of about 20 seconds I get the
following information:
Tws1_openOrder1 225 ES FUT 200206 0 ? GLOBEX USD
Tws1_openOrder2 225 SELL 15 LMT 1043.25 0 DAY F92 O 2
Tws1_orderStatus 225 Filled 15 0 1043.5
Tws1_openOrder1 226 ES FUT 200206 0 ? GLOBEX USD
Tws1_openOrder2 226 SELL 5 LMT 1043.25 0 DAY F92 O 2
Tws1_orderStatus 226 Filled 5 0 1043.44
Why isn't the price on the 5 contract fill reported as 1043.25
instead of reporting the average price for the whole lot? This seems
like a bug to me. If it was intentionally programmed this way then
perhaps it needs to be rethought because it makes it unnecessarily
difficult to compare the fills listed in the TWS vs the ones reported
via the TWS API. Also, why does it take so long for the execution
report to come out? I'm not really asking for new features, just
wondering why the current reporting mechanism makes no sense. Why
don't they just give us our transaction history? It seems to me that
people who are using this successfully now must have done something
to compensate for the fact that the API is giving average price
instead of just reporting each fill.
Marcus Jellinghaus
Unregistered guest
Posted on Tuesday, June 04, 2002 - 01:54 pm:
----------------------------------------------------------------------
----------
I do not really get your point. To take your example, I first get an
orderstatus event where 30 are filled and 70 are remaining. So it is
easy to see that it is just part fill. I also know the filled price.
After that I get a second orderstatus event which says 100 filled, 0
remaining. So I know that the order is filled, I know average price,
from that and the first part fill I know the data of the second part
fill etc.
I would prefer it if IB would solve the existing problems with the
API rather than adding new functionality, which is not really
necessary.
Best regards,
Marcus
TriPack
Unregistered guest
Posted on Tuesday, June 04, 2002 - 11:15 am:
----------------------------------------------------------------------
----------
I like the TWS API a lot. It works well for all but partial fills,
which become a pain to manage. It would be nice to push a PartialFill
status update through the "orderstatus" event. I'm using the TWS Ax
OCX.
Probably the best way to implement this would be to have the
PartialFill status in the orderstatus event fire off whenever there
is either a partial or full fill. For example if you put in an order
for 100 shares and are filled on 30 then 70, you would receive two
orderstatus events with the PartialFill for 30 filled with 70
remaining and then 70 filled with 0 remaining. This would leave the
Filled status unchanged - it would continue to just report when the
full position has filled. If you put in an order for 100 shares and
it was filled all at once, you would receive both the PartialFill
event for 100 shares filled 0 outstanding and the same event for
Filled shares (so as not to mess up legacy systems that other
programmers have implemented).
|
build?
2
So what's the trick to getting the IB test mess to build with C++ 6.0?
Thanks
Richard
|
XLS DDE, C++, Delphi: Can Someone Post A Sample Project Please?
Build it and they will come....
We need someone who is fluent in the use of TWS-OCX to build a single
sheet project in the above languages
It need do nothing more than log in, and retrieve a single user
symbols data set and print the price to a cell or label.
There are many many people who are begging for demonstration projects
like this.
I posted one in VB in the files section of this board. We need the
other languages done....
We need one for XLS-VBA DDE, C++ OCX, and Delphi too.
When the inevitable clamour begins, we can simply point them at these
files as a resource...
Consider it a contribution to humanity..
I will be posting a second VB project that uses MSHFlexGrid and
demonstrates in cell editing, and the display of the full data set in
a row...
Scott
|
XLS DDE, C++, Delphi: What are you doing with the API?
2
I
would like to know what you are using the API for. Why did you decide to make
something on your own instead of using some existing solution? What should be
the pro´s of your solution versus the exiting solutions?
-Are
you retrieving the market data? (As you could do it with eSignal, for
example)
-Are
you retrieving the market data and make some rather complex calculations with
it?
(as you could probably do it with
tradestation or wealth-lab)
-Are
you developing a different or better order entry tool?
Did you look into other order entry tools, like Jerry
Medved´s Quotetracker, CyberX2, Cybertrader Pro, Datek´s Tools, Realtick,
..?
-Are
you developing an automated trading solution?
I couldn´t find an existing stock trading solution for
several stocks.
Marcus
|
Message Board: Email to IB mangement .
IB management
Please view the following site.
http://groups.yahoo.com/group/twsapi/
I would like to get the all clear from you guys on this Yahoo message
board. The board merely expands on the API discussion on the present
IB board. Using the Yahoo forum we can exchange files, post
graphics, and search threads by keyword.
Please send this up to the proper management level.
I would yank the banner but I think it looks good, and you guys get
free advertising.
There are two links to the IB site.
One to the home page and a second to the users guide.
Scott
Owner TWS API Yahoo board
|
Welcome: 80 members in a day
80 Members in less than 24 hours....
I had no idea.
I think this goes to show that there are many interested in IB's API,
and that the present sources of information exchange are lacking a
bit.
I hope this is succesful board. All members are encouraged to ask and
answer questions. Feel free to post source code examples to simple
problems for beginners in the files section
This board is completely unmoderated. Act responsiblely.
The race is on to produce killer app's and ats for IB API.
I wouldn't at all be surprised to see third party plugins popping up
like sand fleas within 6-9 months
This can only be good for the consumer. Competition is great.
Scott
Owner TWSAPI
|
VB TWS: New Sample Project For Newbies In The File Section
I have posted a sample project that uses MicroSoft Hierarchical Flex
Grid, an in cell editing routine and a better start for someone just
getting going.
Still a very basic example...but it will help those who are just
getting started. Great foundation to start a program with and begin
exploring TWS API
[CODE]
Option Explicit
Private Sub Command1_Click()
'call for the connection
'your TWS must be up and running in order to connect
Tws1.Connect "", 7496
End Sub
Private Sub Form_Load()
Dim iTemp As Integer
Dim iTemp2 As Integer
Dim Cancel As Boolean
'grid formating stuff
With hFlexGrid
.Col = 0
.Row = 0
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.FillStyle = flexFillRepeat
.CellFontBold = True
.CellAlignment = flexAlignCenterCenter
.TextMatrix(0, 1) = "Symbol"
.TextMatrix(0, 2) = "B-Size"
.TextMatrix(0, 3) = "Bid"
.TextMatrix(0, 4) = "Ask"
.TextMatrix(0, 5) = "A-Size"
.TextMatrix(0, 6) = "Last"
.TextMatrix(0, 7) = "L-Size"
.Col = 1
.Row = 1
.ColWidth(0) = .RowHeight(0) + 50
'number the first column and alternate the row colors
For iTemp = 1 To .Rows - 1
.TextMatrix(iTemp, 0) = iTemp
If Not Cancel Then
For iTemp2 = 1 To .Cols - 1
.Row = iTemp
.Col = iTemp2
.CellBackColor = &HE0E0E0
Cancel = True
Next iTemp2
Else
Cancel = False
End If
Next iTemp
'adds a couple of items to the combo box
Combo1.AddItem "Stocks, Instinet"
Combo1.AddItem "Futures, Globex, 200206"
End With
End Sub
Private Sub hFlexGrid_DblClick()
'calls the grid editor when you double click a cell
Call GridEdit(Asc(" "))
End Sub
Private Sub hFlexGrid_GotFocus()
Dim strTemp As String
If txtCellEditor.Visible Then
hFlexGrid = UCase$(txtCellEditor)
'calls the req market data text box loses focus, restricts
symbols to row 1
If txtCellEditor <> "" And hFlexGrid.Col = 1 Then
strTemp = UCase$(txtCellEditor)
Call reqMarketData(strTemp, hFlexGrid.Row)
ElseIf txtCellEditor = "" Then
'cancels market data if you leave the cell empty
Call cancelMktData(hFlexGrid.Row)
End If
txtCellEditor.Visible = False
End If
End Sub
Private Sub hFlexGrid_KeyDown(KeyCode As Integer, Shift As Integer)
'cancels the market data if you use the delete key remove a symbol
If KeyCode = vbKeyDelete And hFlexGrid.Col = 1 Then
Call cancelMktData(hFlexGrid.Row)
Else
'just in case....not really necessary
hFlexGrid.TextMatrix(hFlexGrid.Row, hFlexGrid.Col) = ""
End If
End Sub
Private Sub hFlexGrid_KeyPress(KeyAscii As Integer)
'calls the grid editor when you start typeing
Call GridEdit(KeyAscii)
End Sub
Private Sub hFlexGrid_LeaveCell()
Dim strTemp As String
If txtCellEditor.Visible Then
hFlexGrid = UCase$(txtCellEditor)
'calls the req market data when you leave a cell, restricts
symbols to row 1
If txtCellEditor <> "" And hFlexGrid.Col = 1 Then
strTemp = UCase$(txtCellEditor)
Call reqMarketData(strTemp, hFlexGrid.Row)
'calls cancel market data if you go in and leave it empty
ElseIf txtCellEditor = "" Then
Call cancelMktData(hFlexGrid.Row)
End If
txtCellEditor.Visible = False
End If
End Sub
Sub GridEdit(KeyAscii As Integer)
With txtCellEditor
'use correct font
.FontName = hFlexGrid.FontName
.FontSize = hFlexGrid.FontSize
Select Case KeyAscii
Case 0 To Asc(" ")
.Text = hFlexGrid
.SelStart = 1000
Case Else
.Text = Chr(KeyAscii)
.SelStart = 1
End Select
'position the edit box
.Left = hFlexGrid.CellLeft + hFlexGrid.Left
.Top = hFlexGrid.CellTop + hFlexGrid.Top - 10
.Width = hFlexGrid.CellWidth - 8
.Height = hFlexGrid.CellHeight - 15
.Visible = True
.SetFocus
End With
End Sub
Private Sub Tws1_tickPrice(ByVal id As Long, ByVal tickType As Long,
ByVal price As Single)
'populates the grid with the price information
hFlexGrid.TextMatrix(id, 2 + tickType) = Format(price, "0.00")
End Sub
Private Sub Tws1_tickSize(ByVal id As Long, ByVal tickType As Long,
ByVal size As Long)
'populates the grid with the size information
hFlexGrid.TextMatrix(id, 2 + tickType) = size
End Sub
Private Sub txtCellEditor_KeyDown(KeyCode As Integer, Shift As
Integer)
'handles the little text box editor for certain keystrokes
Select Case KeyCode
Case vbKeyEscape
txtCellEditor.Visible = False
hFlexGrid.SetFocus
Case vbKeyReturn
hFlexGrid.SetFocus
Case vbKeyDown
hFlexGrid.SetFocus
DoEvents
If hFlexGrid.Row < hFlexGrid.Rows - 1 Then
hFlexGrid.Row = hFlexGrid.Row + 1
End If
Case vbKeyUp
hFlexGrid.SetFocus
DoEvents
If hFlexGrid.Row > hFlexGrid.FixedRows Then
hFlexGrid.Row = hFlexGrid.Row - 1
End If
End Select
End Sub
Private Sub txtCellEditor_KeyPress(KeyAscii As Integer)
'noise suppression
'If KeyAscii = vbKeyReturn Then KeyAscii = 0
End Sub
Public Sub reqMarketData(TWSsymbol As String, trow As Long)
'issue description vars
Dim TWSsecType As String
Dim TWSexpiry As String
Dim TWSstrike As Single
Dim TWSright As String
Dim TWSexchange As String
Dim TWScurency As String
'stock or future for demo?
If Combo1.ListIndex = 0 Then
TWSsecType = "STK"
TWSexpiry = ""
TWSexchange = "INSTINET"
ElseIf Combo1.ListIndex = 1 Then
TWSsecType = "FUT"
TWSexpiry = "200206"
TWSexchange = "GLOBEX"
End If
'options and currency vars
TWSstrike = 0
TWSright = ""
TWScurency = ""
' must have symbol, secType, and exchange
If TWSsymbol = "" Or TWSsecType = "" Or TWSexchange = "" Then
Beep
MsgBox ("You must enter at least symbol, security type, and
exchange.")
Exit Sub
End If
'calls for the market data
Tws1.reqMktData trow, TWSsymbol, TWSsecType, TWSexpiry, TWSstrike,
TWSright, TWSexchange, TWScurency
'displays the contract specs if a future
hFlexGrid.TextMatrix(trow, 8) = expiryNumToAlpha(TWSexpiry)
End Sub
Sub cancelMktData(trow As Long)
'cancel the market data
Tws1.cancelMktData trow
Dim iTemp As Integer
'blanks out the entire row after you cancel the data
For iTemp = 0 To hFlexGrid.Cols - 1
hFlexGrid.TextMatrix(trow, iTemp) = ""
Next iTemp
End Sub
Function findSymbolSlot(ByVal symbol As String) As Long
Dim lngTemp As Long
'this function selects the right row in the grid
With hFlexGrid
For lngTemp = 1 To .Rows - 1
If InStr(.TextMatrix(lngTemp, 1), symbol) Then
findSymbolSlot = lngTemp
Exit Function
End If
Next lngTemp
End With
End Function
Function expiryNumToAlpha(ByVal strExpiry As String) As String
'this function returns a user friendly formatted version of
contract date
Dim strTemp As String
strTemp = Mid$(strExpiry, 3, 2)
Select Case Right$(strExpiry, 2)
Case "03"
expiryNumToAlpha = "MAR" & strTemp
Exit Function
Case "06"
expiryNumToAlpha = "JUN" & strTemp
Exit Function
Case "09"
expiryNumToAlpha = "SEP" & strTemp
Exit Function
Case "12"
expiryNumToAlpha = "DEC" & strTemp
End Select
End Function
|
java developer your hired contact IB
Looks like you voluntered to me :) we really need to crank the heat
up on IB. I vote you contact them for the group and I am sure you
will get backed up by everyone. Let us know what there response is.
Thanks Kent
|
kybryan will be gone for a few days
2
and every time someone posts, we are all going to get his autoresponder
email. Could the moderator set him to nomail please?
*********** REPLY SEPARATOR
***********
|
|
java developer willing to lend a hand
12
about me: I'm a professional java developer with over 9 years of
total software development, 5 years exclusively in java and related
technologies. This includes banking systems, dept of defense, and
more - very large real world complex systems.
I used to daytrade during my down time (few days to few months), but
now I mostly trade options for time periods ranging from 1-3 weeks.
I've written my own analysis software, etc. After I put on a trade,
my primary concern is follow-up strategy when a trade goes wrong. I
wrote software to do this as well, as there was a lot of different
variables that went into it. I just now discovered that TWS gives a
java api, so I'm rebuilding my system and hooking it up to IB.
Unfortunately, i hear options trigger TWS pop-ups so i can't have a
true program trading platform in place :(
if anyone wishes to come to the dark side (java), I'd be happy to
help them out :)
Jason
|
e-mail correction
2
please change my auto responder from yobryan@... to
kybryan@... thanks
|
IB Post Questions answered & Q for Dkamp
4
Dkamp
Here is how I envision a workable solution:
(1) All interested parties need to make a list of what problems they
want solved.
(2) These problems need to be listed then voted on by the interested
parties.
(3) Their needs to be an agreement on what problems there will be
solutions for.
(4) We need a group of people that will meet the financial
requirements. By meet I mean a small group with large pockets or a
large group that can kick in $50 to $100. What ever it would take for
the design costs.
(5) There would have to be some organization structure and or format
that would give the group input.
(6) A lead designer will have to be given the authority and be in
charge to make the decisive final necessary decisions to move the
project along timely.
(7) A committee and or board would be formed that would represent the
team and be in charge. There cannot be mob rule, but active
participation will be encouraged. Professional people will hold these
positions.
(8) Legal documents will be signed. All paying members will own a
stake in the software. Owners will pay cash upfront and receive
receipts and documentation.
(9) Initial cash will pay for professional system analysis and
design. Programmers will be determined by bid and or selection after
system analysis and design is completed. Owners will be expected to
come up with monies for final coding of project.
(10) Resumes and references will be required to select members that
will be actively participating in the system analysis and design and
coding.
(11) Coding will be compartmentalized to ensure software ownership
security.
(12) As soon as we come up with the cash and a competent team then we
will move the dialog from the public forum to a secure system for
development.
I estimate about $10,000 to complete a design, but that may change
with the amount of interest and the bells and whistles wanted. I have
people that I have worked with on projects that are reasonable cost
wise and very competent to execute what this project would entail.
Bottom line there is over 124 members and interested parties on the
Yahoo spin off thread since this thread was first posted. It is the
little guy against the big boys and I smell blood. The problem is
that there are many lone wolves running down rabbit trails and that
is not the solution for everyone. There are those that will always go
that path but what I propose is organization and structure and people
that work well within the team environment. We need a place to post
resumes.
Everyone welcome those with just cash and also those with IT skills
and cash. If you are interested in being part owner and would like to
make a commitment in cash and or sweat please email and or post
Thanks dkamp for the questions, I will be out until Thursday night. A
Q for you. Would the elite trader link thread help the quest? I see
that you frequent there.
|
Resources: Two Excellent Sites For Code and Help
3
Both of these sites are highly recommended. They have been addded to
the Bookmarks section for future reference.
VB Explorer: http://www.vbexplorer.com/VBExplorer/VBExplorer.asp
The VB Explorer site has very active excellent message boards with
very helpful people.
Planet Source Safe: http://www.planet-source-code.com/
The Planet Source site has an excellent searchable code base.
Submissions are rated. Planet Source is the largest public code
database on the internet.
Scott
Owner
|
Todd Turner's AutoExecutor Program
2
Best of luck to Todd and his new for-sale AutoExecutor Program that
implements auto-stops:
http://bullhaven.tripod.com/TradeExecutor/TradeExecutor.htm
|
IB Management Comment On This Board: Brief
IB Mgt
Please review the use of banner on this message board...Our
discussion expands on the use of TWS API....
IB Mgt Response
We are fine for now, but reserve the right to change our decision.
Thanks for
the IB support.
Best Regards,
Steve Sanders
|
Todd Turner's AutoExecutor Program
I for one would like to see a commercial posting of a new available
product. IMHO, once is news, repeated infomation on same topic then becomes
spam. JMHO,
Regards,
Knyyt
|
ALL: Help Wanted_ Moderator
6
Well with 209 Members in 2 days I am little stunned...
I will need to have a few people willing to moderate when I am not
on....
Please private email if you are interested and give me a 20 Second
sound byte why you would want to moderate...
Scott
|
Improvements & Bugs Lists
2
Scott, is there a way to create and manage a couple of lists/polls up
here that would collect our votes for desired improvements and needed
bug fixes for TWS and the API? (I guess you could actually have such
a list for every aspect of the business, but TWS and the API would be
a good start.)
|
1 - 20 з 12923