Hi all,
I am a trader and very much a vba novice (so please use very small words!).
I have a spreadsheet from my broker, on which I have built a trading system.
Everything works very well, but approximately 10% of the time, the "order status" does not fill back into the spreadsheet and I use this "status" ("filled" etc) for subsequent actions on the orders.
I have found the following code in vba, but cannot (manually - I suspect it runs on a call from elsewhere) get it to run - it opens a dialogue box asking for a macro name (the same box that would open if I clicked the View-->Macros -->View Macros menu).
The macro itself is in the (I'm not sure of the exact terminology) worksheet module (VBAProject-->Microsoft Excel Objects-->Worksheet Name)
There is also a module (under Modules) called OrderUtils, containing the following code:
All variables (as far as I can tell) are properly declared at the beginning of each of the modules.
Is this enough information to answer the question:
Is there anything I can change, add, or rewrite, to enable this macro "UpdateOrderStatus" to be run manually?
Thanks
Phil
I am a trader and very much a vba novice (so please use very small words!).
I have a spreadsheet from my broker, on which I have built a trading system.
Everything works very well, but approximately 10% of the time, the "order status" does not fill back into the spreadsheet and I use this "status" ("filled" etc) for subsequent actions on the orders.
I have found the following code in vba, but cannot (manually - I suspect it runs on a call from elsewhere) get it to run - it opens a dialogue box asking for a macro name (the same box that would open if I clicked the View-->Macros -->View Macros menu).
The macro itself is in the (I'm not sure of the exact terminology) worksheet module (VBAProject-->Microsoft Excel Objects-->Worksheet Name)
Code:
' update order status
Public Sub UpdateOrderStatus(id As Long, status As String, filled As Double, remaining As Double, avgFillPrice As Double, parentId As Long, lastFillPrice As Double)
OrderUtils.UpdateOrderStatus orderStatusTable, id, status, filled, remaining, avgFillPrice, parentId, lastFillPrice
End Sub
There is also a module (under Modules) called OrderUtils, containing the following code:
Code:
' update order status
Public Sub UpdateOrderStatus(orderStatusTable As Range, orderId As Long, status As String, filled As Double, remaining As Double, avgFillPrice As Double, parentId As Long, lastFillPrice As Double)
' find row to update by using orderId
Dim rowId As Long
rowId = FindOrderRowIndex(orderId, orderStatusTable)
If rowId = 0 Then Exit Sub
If rowId <= orderStatusTable.Rows.count Then
orderStatusTable(rowId, Col_ORDERSTATUS).value = status
orderStatusTable(rowId, Col_FILLED).value = filled
orderStatusTable(rowId, Col_REMAINING).value = remaining
orderStatusTable(rowId, Col_AVGFILLPRICE).value = avgFillPrice
orderStatusTable(rowId, Col_LASTFILLPRICE).value = lastFillPrice
orderStatusTable(rowId, Col_PARENTID).value = parentId
End If
End Sub
All variables (as far as I can tell) are properly declared at the beginning of each of the modules.
Is this enough information to answer the question:
Is there anything I can change, add, or rewrite, to enable this macro "UpdateOrderStatus" to be run manually?
Thanks
Phil
Last edited by a moderator: