fix: strip /v2 suffix from broker base URL to prevent doubled path
The alpaca.url config file contains https://paper-api.alpaca.markets/v2 but the adapter code also prepends /v2/ to all paths, resulting in /v2/v2/positions which returns 404. Now strips trailing /v2 or /v1 from the configured base URL since the adapter manages API versioning. This was causing 1,017 consecutive broker sync failures.
This commit is contained in:
@@ -308,6 +308,11 @@ class AlpacaBrokerAdapter(BrokerDataAdapter):
|
||||
self.api_secret = api_secret
|
||||
if base_url:
|
||||
self.base_url = base_url.rstrip("/")
|
||||
# Strip trailing /v2 or /v1 — the adapter adds API version prefixes itself
|
||||
for suffix in ("/v2", "/v1"):
|
||||
if self.base_url.endswith(suffix):
|
||||
self.base_url = self.base_url[: -len(suffix)]
|
||||
break
|
||||
elif mode == TradingMode.LIVE:
|
||||
self.base_url = self.LIVE_BASE_URL
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user