以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  [求助]IB持仓  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=78336)

--  作者:S8031
--  发布时间:2015/5/7 0:50:03
--  [求助]IB持仓

国内品种持仓:

Call Order.HoldingInfoByCode2(Code,Market,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,Pnl,Usemargin,"123")

今持多:BuyTodayHolding

今持空:SellTodayHolding

IB中的今持多与今持空,用什么名称代码表未。


--  作者:王锋
--  发布时间:2015/5/7 9:46:40
--  
IB外盘是没有锁仓机制的,因此无法使用该方法函数。
--  作者:S8031
--  发布时间:2015/5/7 15:27:17
--  
有什么方法可使用。
--  作者:S8031
--  发布时间:2015/5/7 16:17:28
--  

请教各位大师,VBA如何读取IB持仓信息。恭谢各位。


--  作者:王锋
--  发布时间:2015/5/7 18:15:21
--  

属性

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


--  作者:S8031
--  发布时间:2015/5/8 9:07:57
--  

谢谢指教,已可用。