Author |
Topic: removal orders (20 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
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 |
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 |
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 |
Can I make this function more efficiently?
to avoid going through the entire array? Maksim Posp |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
You can use api.Orders.Item(numberID) to get an order more efficiently.
Victor Vins Software Developer |
||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
thanks
Maksim Posp |
||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
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 |
Sorry, I cannot help with it, because it is a common VB error.
Victor Vins Software Developer |
||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
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 |
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 |
I unfortunately do not find the right methods
Maksim Posp |
||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
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 |
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 |
About TotalQuantity: "Completed" order status can appear before the final fill.
Victor Vins Software Developer |
||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
Thank you very much
Maksim Posp |
||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
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 |
ID 201155737
Maksim Posp |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
Yes, position (and corresponding balance) can be updated before the corresponding fill.
Victor Vins Software Developer |
||||
MMaksim49 Posts: 20 Joined: Apr 26, 2010 |
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 |
Could you please specify - what state is not updated and what do you mean - "manual update"?
Victor Vins Software Developer |
||||