我当前只有一个品种,可是用金字塔的数据接口获得的保证金不一样,即账户里面的保证金和
我唯一的品种的保证金对不上,账户保证金明显是错的,它也是金字塔软件本身显示的保证金。
主要代码如下:
'-------------------------------------------------------------------------------------------------------'
'@@获取持仓信息
Private MarketArray(), CodeArray(),HoldingArray(), HoldingCostArray(), UserMarginArray(), PNLArray()
Function GetHoldInfo(sAccount)
On Error resume Next
HoldingCount = Order.Holding2(sAccount)
If HoldingCount > 0 then
此主题相关图片如下:截图.png

redim MarketArray(HoldingCount-1)
redim CodeArray(HoldingCount-1)
redim HoldingArray(HoldingCount-1)
redim HoldingCostArray(HoldingCount-1)
redim UserMarginArray(HoldingCount-1)
redim PNLArray(HoldingCount-1)
For i=0 to HoldingCount-1
Call Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,Code,Market_,sAccount)
if BuyHolding > 0 then
HoldStr="+" & BuyHolding
HoldCost = BuyCost
end if
if SellHolding>0 then
HoldStr= "-" & SellHolding
HoldCost = SellCost
end if
MarketArray(i) = Market_
CodeArray(i) = Code
HoldingArray(i) = HoldStr
HoldingCostArray(i) = HoldCost
UserMarginArray(i) = UseMargin
PNLArray(i)=PNL
' application.MsgOut(usemargin)
Next
End If
GetHoldInfo = HoldingCount
End Function
Sub APPLICATION_Timer(ID)
If ID = 0 Then
c & "保证金: " & "现金余额: " & "浮动盈亏: " & "仓位比例:" & NewLine
b=Order.Account2(28)
d=Order.Account2(6)
content = content & Cstr(d) &" "& Cstr(b) &" "& Cstr(Order.Account2(3)) &" "& Cstr(Order.Account2(4)) &" "& Cstr(b/d*100) &"%"& NewLine
content = content & "******************************************************************" & NewLine
GetHoldInfo("808400")
content = content & "市场: " & " 品种: " & " 持仓量: " & " 持仓成本: " & " 保证金: " & " 浮动盈亏: " & "仓位比例:" & NewLine
For i=0 To Ubound(HoldingArray)
content = content & MarketArray(i) &" " & CodeArray(i) & " " & HoldingArray(i) &" " & Cstr(HoldingCostArray(i))& " "& Cstr(UserMarginArray(i)) &" " & PNLArray(i) &" " & Cstr(UserMarginArray(i)/d*100)&"%" & NewLine
Next
Asset_Manager_HoldingTable.value = content
End If
end sub