We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've several stocks in my portfolio and I'd like to access them using go,
right now I've the current code
account,err := ib.NewPrimaryAccountManager(engine) if err != nil { fmt.Println("error getting account ",err) } portfolio := account.Portfolio() fmt.Println("Portfolio ", portfolio)
but I'm getting an empty map as portfolio
hope you can help me, thank you so much
The text was updated successfully, but these errors were encountered:
In your case you need to wait for the request to the gateway to complete. Here is an example code you can use:
account, err := ib.NewPrimaryAccountManager(engine) if err != nil { fmt.Println("error getting account ", err) } notify := account.Refresh() for { select { case <-notify: fmt.Printf("Portfolio\n") portfolio := account.Portfolio() for _, xc := range portfolio { fmt.Printf("%v\n", xc) } } }
You will get multiple calls to returned from the Manager.
Or you can use the following code if just want one time use:
<-account.Refresh() fmt.Printf("Portfolio\n") portfolio := account.Portfolio() for _, xc := range portfolio { fmt.Printf("%v\n", xc) }
Sorry, something went wrong.
No branches or pull requests
I've several stocks in my portfolio and I'd like to access them using go,
right now I've the current code
but I'm getting an empty map as portfolio
hope you can help me, thank you so much
The text was updated successfully, but these errors were encountered: