alpacahq / alpaca-trade-api-go

Go client for Alpaca's trade API
Apache License 2.0
317 stars 86 forks source link

GetAccount returns "account not found for (account id)" #17

Closed herzo175 closed 5 years ago

herzo175 commented 5 years ago

Hi,

I was calling client.GetAccount() and I get an error saying "account not found for (my account id)". I'm wondering if this endpoint is working properly - When I make a request to "https://paper-api.alpaca.markets/v1/account", I can successfully get my account information

Thanks

umitanuki commented 5 years ago

Make sure you are using the right API key. The error appears when you use paper API key with live endpoint.

herzo175 commented 5 years ago

I think I am using the correct API key. I only have a paper trading account and I was using that endpoint. On a related note, when I tried to call SetBaseUrl, I got a message saying that method was undefined (it appears in the code though), but I worked around it by setting the environment variable "APCA_API_BASE_URL" to the paper trading endpoint.

umitanuki commented 5 years ago

Right. So if your API key has prefix "PK", that is your paper trading API key and it won't work for live trading endpoint which is the default unless you set APCA_API_BASE_URL environment variable.

herzo175 commented 5 years ago

That makes sense, but I'm still confused why I'm getting an error saying SetBaseUrl is undefined:

apca.SetBaseUrl("https://paper-api.alpaca.markets")
alpacaClient := apca.NewClient(common.Credentials())

acct, err := alpacaClient.GetAccount()

if err != nil {
    panic(err)
}

log.Println(acct)

service/alpaca.go:53:2: undefined: alpaca.SetBaseUrl

umitanuki commented 5 years ago

Someone just told that we are missing release tag so you need to explicitly set go.mod to master to use the latest

herzo175 commented 5 years ago

Yeah, I just saw that and it fixed the issue. Thanks for your help!