rterp / SumZeroTrading

A Java API for Developing Automated Trading Applications for the Equity, Futures, and Currency Markets
http://rterp.github.io/SumZeroTrading/
Other
145 stars 48 forks source link

Ability to request all positions opened by an API app #1

Open rterp opened 8 years ago

rterp commented 8 years ago

Request all positions from TWS that were opened by the API application

rterp commented 8 years ago

IB returns the following data from the reqPositions() method

Equity Position - Account: DU15046 Contract: contractId: 43661924 currency: USD expiry: null include expiry: false local symbol: QQQ multiplier: null primary exchange: null right: null sec id: null sec id type: null strike: 0.0 symbol: QQQ trading class: NMS under comp: null size: 100 avgCost: 112.32

Futures 2016-04-09 09:20:52 INFO InteractiveBrokersBroker:409 - Position - Account: DU15046 Contract: contractId: 187532577 currency: USD expiry: 20160617 include expiry: false local symbol: ESM6 multiplier: 50 primary exchange: null right: null sec id: null sec id type: null strike: 0.0 symbol: ES trading class: ES under comp: null size: 1 avgCost: 103102.4

Currency 2016-04-09 09:23:09 INFO InteractiveBrokersBroker:409 - Position - Account: DU15046 Contract: contractId: 12087792 currency: USD expiry: null include expiry: false local symbol: EUR.USD multiplier: null primary exchange: null right: null sec id: null sec id type: null strike: 0.0 symbol: EUR trading class: EUR.USD under comp: null size: 20000 avgCost: 1.1287749999999999

Options 2016-04-09 09:25:17 INFO InteractiveBrokersBroker:409 - Position - Account: DU15046 Contract: contractId: 226373565 currency: USD expiry: 20160415 include expiry: false local symbol: QQQ 160415P00111500 multiplier: 100 primary exchange: null right: P sec id: null sec id type: null strike: 111.5 symbol: QQQ trading class: QQQ under comp: null size: 1 avgCost: 108.25

rterp commented 8 years ago

Also, it appears that IB returns ALL positions, both open and closed, as well as positions created outside of the API client itself.