function GetHoldStr(sAccount)
dim i
dim BuyHold
dim BuyCost
dim SellHold
dim SellCost
dim CurCode
dim CurMarket
On Error resume Next
HoldStr=""
HoldingCount=Order.Holding2(sAccount)
If HoldingCount>0 then
For i=0 to HoldingCount-1
Call Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,Code,Market,sAccount)
CurCode=Code
CurMarket=Market
BuyHold=BuyHolding
SellHold=SellHolding
HoldStr=HoldStr & CurCode
if BuyHold>0 then
HoldStr=HoldStr & ":+" & BuyHold
end if
if SellHold>0 then
HoldStr=HoldStr & ":-" & SellHold
end if
HoldStr=HoldStr & ","
Next
HoldStr=Left(HoldStr,len(HoldStr)-1)
End If
GetHoldStr=HoldStr
End function
Sub ORDER_OrderStatusEx2(OrderID, Status, Filled,
Remaining, Price, Code, Market, OrderType, Aspect, Kaiping,Account,
AccountType)
'账户类型 0 IB 1 CTP 2 金仕达 3其他
Dim sStatus '成交状态
If AccountType=0 then
sAccType="0.IB"
ElseIf AccountType=1 then
sAccType="1.CTP"
ElseIf AccountType=2 then
sAccType="2.金士达"
End if
If AccountType=0 then
sStatus="FILLED"
ElseIf AccountType=1 then
sStatus="TRADEING"
lseIf AccountType=2 then
sStatus="FILLED"
End if
If UCase(Status)="FILLED" then '只跟踪成交的单
if Aspect=0 and Kaiping=0 then '买入
Call
Document.SetExtString("Order-Buy-time",time) '成交时间
Call
Document.SetExtData("Order-B-Price",Price) '成交价格
Call
Document.SetExtData("Order-B-Vol",Filled) '成交手数
Call Document.SetExtData("Order-B-OrderID",OrderID) '成交单号
end if
End if
End Sub
变量不能省略
time是VBA的函数,取自你计算机的本地时间
https://zhidao.baidu.com/question/204610833.html
建议先百度下,自己运行看看效果