国内品种持仓:
Call Order.HoldingInfoByCode2(Code,Market,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,Pnl,Usemargin,"123")
今持多:BuyTodayHolding
今持空:SellTodayHolding
IB中的今持多与今持空,用什么名称代码表未。
请教各位大师,VBA如何读取IB持仓信息。恭谢各位。
属性
Holding 得到当前IB帐户的持仓品种数量
范例
HoldingInfo 方法
取指定基于0索引的持仓和约信息
HoldingInfo(Index, Hold, MktPrice, AvgPrice, MktValue, AgeCost, PNL, Code, Market)
Index 输入参数,指定基于0索引的持仓和约信息,持仓和约总量参见 Holding 属性。
Hold 输出参数,该该持仓品种持仓量,若空仓返回负数
MktPrice 输出参数,该持仓品种市价
AvgPrice 输出参数,该持仓品种均价
MktValue 输出参数,该持仓品种市值
AgeCost 输出参数,该持仓品种成本
PNL 输出参数,该持仓品种浮动盈亏
Code 输出参数,该持仓品种代码
Market 输出参数,该持仓品种市场
返回值: 成功返回1,失败返回0
例如:
dim Hold
dim MktPrice
dim AvgPrice
dim MktValue
dim AgeCost
dim PNL
dim Code
dim Market
'取第一个持仓品种
Result = Order.HoldingInfo(0,Hold,MktPrice,AvgPrice,MktValue,AgeCost,PNL,Code,Market)
If Result <> 1 Then
Exit Sub
End If
'显示持仓量
MsgBox Hold
谢谢指教,已可用。