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

Marketdata DefaultClient authentication does not seem to work #276

Open
LeventeLantos opened this issue Apr 4, 2024 · 3 comments
Open

Comments

@LeventeLantos
Copy link

marketdata DefaultClient authentication does not seem to work, I have this piece code:
`func printCurrentPrice(symbol string) {
lastQuote, err := marketdata.GetLatestQuote(symbol, marketdata.GetLatestQuoteRequest{
Feed: marketdata.SIP,
Currency: "USD",
})
if err != nil {
fmt.Printf("Failed to get last quote for %s: %s\n", symbol, err)
return
}

fmt.Printf("The last quoted price for %s is $%.2f\n", symbol, lastQuote.AskPrice)

}`

This will simple return:
`$ go run main.go
Failed to get last quote for AAPL:

<title>403 Forbidden</title>

403 Forbidden


nginx (HTTP 403) `
@gnvk
Copy link
Collaborator

gnvk commented Apr 4, 2024

Have you set the environment variables as described here?

@princefishthrower
Copy link

@LeventeLantos - did you ever figure this out? I'm running into the same issue, even when APCA_API_KEY_ID and APCA_API_SECRET_KEY exist in my env.

@princefishthrower
Copy link

princefishthrower commented May 30, 2024

Figured this out, the marketdata package has an identical NewClient function and ClientOpts just as in the alpaca package:

client := marketdata.NewClient(marketdata.ClientOpts{
    APIKey:    os.Getenv("APCA_API_KEY_ID"),
    APISecret: os.Getenv("APCA_API_SECRET_KEY"),
})

client.GetBars(...)
// etc.

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

3 participants