alpacahq / alpaca-trade-api-go

Go client for Alpaca's trade API
Apache License 2.0
330 stars 93 forks source link

Additions to Calendar struct #266

Open nathanhack opened 12 months ago

nathanhack commented 12 months ago

Would it be possible to add the session open/close and settlement date to CalendarDay https://github.com/alpacahq/alpaca-trade-api-go/blob/efb7598b00a215d6ae06ca43b8592e7cbcb8e5c1/alpaca/entities.go#L177

{
      "date": "1970-01-02",
      "open": "09:30",
      "close": "16:00",
      "session_open": "0400",
      "session_close": "2000",
      "settlement_date": "1970-01-06"
}
gnvk commented 12 months ago

These fields are not returned by the server. If you'd like to open a feature request for this, please use https://github.com/alpacahq/Alpaca-API/ instead.

nathanhack commented 11 months ago

Thanks for the quick response. I'm unable to verify the broker API endpoint you provided has the requested fields or not. However, the endpoint under trader API: https://docs.alpaca.markets/reference/getcalendar does have those fields. The json from above is from the trader api.

It's possible when I gave the perm link for the entity I provided the wrong entity, if so I'm sorry for the confusion.

gnvk commented 11 months ago

You're absolutely right, my mistake.

Neal commented 11 months ago

Would it be possible to add the session open/close and settlement date to CalendarDay

@nathanhack What are you trying to use the session open/close values for? As to be honest, they were added to the calendar API response unintentionally (as you can tell by the different time format) and we've meant to mark them as deprecated in the docs so I would avoid adding them to the SDK.

nathanhack commented 11 months ago

Yeah I had noticed the format difference, I assumed I would have to put in a API request to get that fixed.

As far as how I use it, I use it to limit the trades that I use for training.

I was using Polygon.io for those values but I was happy to see them here, so that I can remove a dependency.

gnvk commented 10 months ago

I think removing Polygon as a dependency sounds like a huge plus :D

@Neal What if you changed the time format to match the rest of the API and add it properly?

Neal commented 10 months ago

@gnvk unfortunately changing the format won't be possible as even though it's an undocumented field, many users could still be using it and can break their code.

so in this case, I am fine to add the fields to the struct and we can just document its purpose accordingly.