Skip to content
New issue

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

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

Already on GitHub? # to your account

GetExchangeCodes is missing from the library #286

Open
gcatlin opened this issue Jul 2, 2024 · 5 comments
Open

GetExchangeCodes is missing from the library #286

gcatlin opened this issue Jul 2, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@gcatlin
Copy link
Contributor

gcatlin commented Jul 2, 2024

https://docs.alpaca.markets/reference/stockmetaexchanges-1

Need to add a new marketdata.Client method.

Two potential approaches:

  • call it GetExchanges and return []Exchange (requires a new Exchange entity with e.g. Code and Name fields)
  • call it GetExchangeCodes and return map[string]string (with the code as the key and the name as the value)

I prefer GetExchanges but GetExchangeCodes might fit better with the library.

@gnvk what do you prefer?

Example API response body:

{
  "A": "NYSE American (AMEX)",
  "B": "NASDAQ OMX BX",
  "C": "National Stock Exchange",
  "D": "FINRA ADF",
  "E": "Market Independent",
  "H": "MIAX",
  "I": "International Securities Exchange",
  "J": "Cboe EDGA",
  "K": "Cboe EDGX",
  "L": "Long Term Stock Exchange",
  "M": "Chicago Stock Exchange",
  "N": "New York Stock Exchange",
  "P": "NYSE Arca",
  "Q": "NASDAQ OMX",
  "S": "NASDAQ Small Cap",
  "T": "NASDAQ Int",
  "U": "Members Exchange",
  "V": "IEX",
  "W": "CBOE",
  "X": "NASDAQ OMX PSX",
  "Y": "Cboe BYX",
  "Z": "Cboe BZ"
}
@gnvk gnvk added good first issue Good for newcomers enhancement New feature or request labels Jul 2, 2024
@brendisurfs
Copy link

@gcatlin I am happy to take this one over if that is ok :)

@gcatlin
Copy link
Contributor Author

gcatlin commented Oct 8, 2024

Absolutely. Thanks @brendisurfs!

@brendisurfs
Copy link

Rad! Just to confirm, any new structs/types would go in entities.go, correct?

And there could be a solid middle ground between the two ideas too, perhaps a map[ExchangeCode]ExchangeName? Where both the keys and values are typed (using structs as enum-like). That way, you still get the concept of having Name and Code fields, while still being flexible as a map for various use cases.

@gcatlin
Copy link
Contributor Author

gcatlin commented Oct 9, 2024

Just to confirm, any new structs/types would go in entities.go, correct?

That's right.

perhaps a map[ExchangeCode]ExchangeName? Where both the keys and values are typed (using structs as enum-like).

I'm not sure what you mean by "using structs as enum-like". Were you thinking of something like this?

type ExchangeCode string
type ExchangeName string

func (c *Client) GetExchangeCodes() (map[ExchangeCode]ExchangeName, error) { ... }

If so, that's equivalent to what I was suggesting for GetExchangeCodes in my first post, though having the types instead of strings may be nicer for type safety.

@brendisurfs
Copy link

Yup, seems like we are on the same page!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants