You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SDK doesn't expose the http.Response object, so it's tricky to keep track of the rate limit state. Currently I’m logging that info using an http.RoundTripper, but it would be good to expose it in a simpler way; e.g., to display the rate limit state in a UI.
The simplest solution might be to add a callback field to alpaca.ClientOpts that is invoked on every request. It could take a http.Request and http.Response, or it could take a new object type that contains just the rate limit info from the response. Another option would be to use a resty.Client instead of a http.Client in the alpaca.Client.
My current work-around is to ensure I'm reserving some rate limit buffer when polling the broker API so that I never get a 429 when I need to place orders.
requestsPerTick:=4// e.g. get account, positions, orders, fills every time we pollpollingRate:= (200.0-20.0) /60.0// 200 request per min rate limit - 20 requests per min bufferpollingInterval:=time.Duration(float64(time.Second) *float64(requestsPerTick) /pollingRate)
The text was updated successfully, but these errors were encountered:
The SDK doesn't expose the http.Response object, so it's tricky to keep track of the rate limit state. Currently I’m logging that info using an
http.RoundTripper
, but it would be good to expose it in a simpler way; e.g., to display the rate limit state in a UI.The simplest solution might be to add a callback field to alpaca.ClientOpts that is invoked on every request. It could take a
http.Request
andhttp.Response
, or it could take a new object type that contains just the rate limit info from the response. Another option would be to use aresty.Client
instead of ahttp.Client
in thealpaca.Client
.My current work-around is to ensure I'm reserving some rate limit buffer when polling the broker API so that I never get a 429 when I need to place orders.
The text was updated successfully, but these errors were encountered: