Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get open positions #32

Open
aries1998 opened this issue Oct 2, 2016 · 3 comments
Open

how to get open positions #32

aries1998 opened this issue Oct 2, 2016 · 3 comments

Comments

@aries1998
Copy link

i'm trying to get open positions from ib with getOpenPositions but find out that it only returns an empty array from InteractiveBrokersBroker.getAllPositions() .  
Then in EClientSocket.reqPositions() method , it just do nothing but print some version numbers. I'm a liitle confused how to do it .
@rterp
Copy link
Owner

rterp commented Oct 3, 2016

I'll need to double check on this one. I've only been implementing the functionality as I have needed it, and it could be that the getAllPositions() method is currently stubbed out right now. I'll let you know.

@aries1998
Copy link
Author

thanks for your replay.
It seems the simplest way to do is assemble the Posistion in InteractiveBrokerBroker.position() method and filter the closed position (don't know why ib return closed positions here ........)

And i think maybe Position need a avgCost as its element. Ticker + size + avgCost can make a complete position structure.

@rterp
Copy link
Owner

rterp commented Oct 7, 2016

I started to implement this and then remember why I had not fully implemented it yet. There are builder classes to take a Ticker object and convert it into a Contract object which the IB API uses. However there are not yet any builders which will take an IB Contract object and convert it into a Ticker object. The IB position() callback method returns an IB Contract object, so I'll need to create a builder to translate this to a Ticker object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants