[英]How to get P&L on a trade through Interactive Brokers TWS Java API
有没有办法通过其Java API获得IB TWS特定交易的盈亏(每日和总到日期)?
You can, but not in the way you seem to be asking. 你可以,但不是你想要的方式。 All profit and loss in the API is calculated by you until the trade is closed and then you can use the commissionReport method of the wrapper. API中的所有损益都由您计算,直到交易结束,然后您可以使用包装器的commissionReport方法。 A commissionReport is sent after every execDetails. 在每个execDetails之后发送一个commissionReport。 API doc API文档
You can always check your statements for previous profits and losses. 您可以随时查看您的报表以了解以前的损益。
The flow is like this. 流程是这样的。
In the TWS v9.72+ API there is a reqPnl
method on the EClient which can be used to subscribe to real-time PnL (unrealized and realized) updates for a full portfolio via the associated method on the EWrapper 在TWS v9.72 + API中, reqPnl
上有一个reqPnl
方法,可用于通过EWrapper上的相关方法订阅完整产品组合的实时PnL(未实现和已实现)更新。
https://interactivebrokers.github.io/tws-api/classIBApi_1_1EClient.html#a0351f22a77b5ba0c0243122baf72fa45 https://interactivebrokers.github.io/tws-api/classIBApi_1_1EClient.html#a0351f22a77b5ba0c0243122baf72fa45
Additionally, for a single contractID, you can use: reqPnLSingle
on the Client. 此外,对于单个contractID,您可以在客户端上使用: reqPnLSingle
。
https://interactivebrokers.github.io/tws-api/interfaceIBApi_1_1EWrapper.html#aebeb008f2b763d7bed2969b66bbd1b33 https://interactivebrokers.github.io/tws-api/interfaceIBApi_1_1EWrapper.html#aebeb008f2b763d7bed2969b66bbd1b33
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.