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
{{ message }}
Repository navigation
fix(borrow): support Alpaca live API endpoints and clear borrow cache on mode/key changes #74
test_alpaca() (app/api.py:139), _sync_bulk_assets() (app/borrow.py:134), and _query_alpaca() (app/borrow.py:230) hardcode https://paper-api.alpaca.markets/v2/..., causing live Alpaca API keys (AK...) to fail with HTTP 401.
BorrowService.update_credentials() (app/borrow.py:81-95) does not clear self._cache when switching mode to "heuristic" or updating keys, leaving stale Alpaca statuses cached.
When mode == "alpaca" and Alpaca returns 404/error, _worker() still falls back to heuristic estimation instead of returning N/A.
Enter live Alpaca keys (AK...) and click Test Alpaca Connection -> fails with HTTP 401 against paper-api.
Switch Borrow source mode from auto/alpaca to heuristic and save -> cached source: "alpaca" entries remain returned by get_status().
Expected Behavior
Automatically select https://paper-api.alpaca.markets for paper keys (PK...) and https://api.alpaca.markets for live keys (AK...), clear self._cache/self._details on mode or credential updates, and return N/A rather than heuristic when mode == "alpaca".
Operating System & Version
OS: Windows 11 x64 / macOS arm64 / Linux x86_64
Version: v2.12.0
Display / Scale: Verified via live Chrome CDP (1600x960) & local unit/backend suite
Logs & Additional Context
Backend reproduction confirmed paper-api hardcoded and stale alpaca cache after switching to heuristic = True.
Summary of Changes: Added alpaca_trading_base() in app/borrow.py to auto-select paper-api.alpaca.markets (PK...) vs api.alpaca.markets (AK...) with 401/403 fallback, cleared borrow caches on credential/mode changes, and respected strict mode='alpaca'. Verified via unit tests.
Verification: compileall clean, 84/84 unit tests passing (including tests/test_audit_fixes.py), and live Chrome CDP verification passed.
This issue will automatically close upon PR #82 review and merge into main.
Activity
github-actions commentedon Dec 2, 2026
✅ Issue Validation Passed
fix(borrow))This issue is well-structured and ready for work according to the Issue-First Protocol.
mlgitdev commentedon Dec 2, 2026
🚀 Resolution In Progress
A fix for this issue has been implemented and submitted in Pull Request #82 (
v2.12.1).fix/audit-remediation-67alpaca_trading_base()inapp/borrow.pyto auto-selectpaper-api.alpaca.markets(PK...) vsapi.alpaca.markets(AK...) with 401/403 fallback, cleared borrow caches on credential/mode changes, and respected strictmode='alpaca'. Verified via unit tests.compileallclean, 84/84 unit tests passing (includingtests/test_audit_fixes.py), and live Chrome CDP verification passed.This issue will automatically close upon PR #82 review and merge into
main.