API Support Forum
OEC API > API Support > removal orders
Author Topic: removal orders
(20 messages, Page 1 of 1)
Moderators: VPfau
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 16, 2010 @ 10:16 AM             Msg. 1 of 20
I need to cancel the order.
I created a procedure.

Public Sub OrderCancel1(numberID as String)
If Not Glob Is Nothing Then
If Glob.Connected Then

Dim Draft As OrderDraft
Set Draft = api.CreateDraft
Set Draft.Account = Config.GetAccount()
Draft.TicketNumber = CLng(numberID)

Draft.ClearExtData

api.CancelOrder Draft
Set Draft = Nothing

End If
End If
End Sub

what am I doing wrong?

Maksim Posp
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 17, 2010 @ 08:45 AM             Msg. 2 of 20
Hello,

CancelOrder method requires Order object, not OrderDraft. You can find out this order in api.Orders collection by your numberID.

Victor Vins
Software Developer
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 17, 2010 @ 09:58 AM             Msg. 3 of 20
do you have in mind?

For i = api.orders.Count - 1 To 0

Dim Order As OECAPICOM.Order
Set Order = api.orders.ItemByIndex(i)

IF Order.ID = numberID then
api.CancelOrder Order

exit for

end if

Next

Maksim Posp
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 17, 2010 @ 10:42 AM             Msg. 4 of 20
Can I make this function more efficiently?
to avoid going through the entire array?

Maksim Posp
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 18, 2010 @ 03:25 PM             Msg. 5 of 20
You can use api.Orders.Item(numberID) to get an order more efficiently.

Victor Vins
Software Developer
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 22, 2010 @ 04:53 AM             Msg. 6 of 20
thanks

Maksim Posp
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 22, 2010 @ 04:59 AM             Msg. 7 of 20
I have a window appears with the error message:
"application-defined or object-defined error"

during the execution of the function:
SumOrders Order.price, Order.side

possibly in other functions, too

Why can it be?

Maksim Posp
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 22, 2010 @ 08:18 AM             Msg. 8 of 20
Sorry, I cannot help with it, because it is a common VB error.

Victor Vins
Software Developer
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 28, 2010 @ 11:30 AM             Msg. 9 of 20
Prompt please
I need to use:
1) time of filing
2) time of the transaction or cancel

(ORDER. ..... ?)

this can be done?

Maksim Posp
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 29, 2010 @ 10:35 AM             Msg. 10 of 20
Order object has collections of versions and fills. You can use them to find out all necessary information.

Victor Vins
Software Developer
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 29, 2010 @ 10:52 AM             Msg. 11 of 20
I unfortunately do not find the right methods

Maksim Posp
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 29, 2010 @ 10:59 AM             Msg. 12 of 20
I'm working on a demo account.
Here are the data from the file Log.txt:

Order.TicketNumber: 201154980 (row=24)
GetStrOrderState(Order.CurrentState): Completed
Order.price: 150,6
(Order.quantity - Order.Fills.TotalQuantity): 1
Order.quantity: 1
Order.Timestamp: 29.06.2010 13:07:22

value Order.Fills.TotalQuantity
was supposed to be equal to 1. Right?
difference between the two values should be equal to 0
(Order.quantity - Order.Fills.TotalQuantity)
Correct value appeared only the second time.

Maksim Posp
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 29, 2010 @ 11:00 AM             Msg. 13 of 20
You can use something like that:
- Order.Fills.Last.Timestamp: timestamp of the last fill
- Order.States.Current.Timestamp: timestamp of the last order status
- Order.Versions.Current: the current working version of order
- Order.Commands.Last.ResultTimestamp: execution time of the last cancel or modify request.

Victor Vins
Software Developer
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 29, 2010 @ 11:06 AM             Msg. 14 of 20
About TotalQuantity: "Completed" order status can appear before the final fill.

Victor Vins
Software Developer
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 29, 2010 @ 11:09 AM             Msg. 15 of 20
Thank you very much

Maksim Posp
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 29, 2010 @ 11:34 AM             Msg. 16 of 20
another inaccuracy:
"Complete" does not occur, although according
to "Balances" operation has been accomplished.
Net pos: 1

such things happen?

Maksim Posp
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 29, 2010 @ 11:35 AM             Msg. 17 of 20
ID 201155737

Maksim Posp
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 29, 2010 @ 12:28 PM             Msg. 18 of 20
Yes, position (and corresponding balance) can be updated before the corresponding fill.

Victor Vins
Software Developer
MMaksim49
Posts: 20
Joined: Apr 26, 2010


Posted: Jun 30, 2010 @ 03:24 AM             Msg. 19 of 20
The problem is that sometimes the state is not updated.
Position changes. To see the current state
Have to do a manual update.
Otherwise the update does not occur.

Maybe this? How can I fix it?

Maksim Posp
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 30, 2010 @ 08:23 AM             Msg. 20 of 20
Could you please specify - what state is not updated and what do you mean - "manual update"?

Victor Vins
Software Developer