在VN trader中,用什么指令函数,或者取哪个变量,能获取持仓信息?变量的数据结构是怎样的?
在VN trader中,用什么指令函数,或者取哪个变量,能获取持仓信息?变量的数据结构是怎样的?
在文档里,没看到有关的获取持仓的函数介绍。
请问,在UI界面,用什么函数与变量,能获得制定合约的持仓数量,多仓与空仓都有的情况?
底层持仓的数据,请通过PositionMonitor来查看,相关代码实现里面都有
找到了持仓监控的类,没看懂如何读取持仓数据?是放在self.下的哪个变量?用什么机制读取?
class PositionMonitor(BaseMonitor):
"""
Monitor for position data.
"""
event_type = EVENT_POSITION
data_key = "vt_positionid"
sorting = True
headers = {
"symbol": {"display": "代码", "cell": BaseCell, "update": False},
"exchange": {"display": "交易所", "cell": EnumCell, "update": False},
"direction": {"display": "方向", "cell": DirectionCell, "update": False},
"volume": {"display": "数量", "cell": BaseCell, "update": True},
"yd_volume": {"display": "昨仓", "cell": BaseCell, "update": True},
"frozen": {"display": "冻结", "cell": BaseCell, "update": True},
"price": {"display": "均价", "cell": BaseCell, "update": False},
"pnl": {"display": "盈亏", "cell": PnlCell, "update": True},
"gateway_name": {"display": "接口", "cell": BaseCell, "update": False},
}
CTA策略模块无法访问底层账户的实际持仓,可以通过self.pos查看自己的逻辑持仓