fix: Alpaca broker fixes + IBroker redesign (provider → meta, aliceId → UTA)#71
Merged
luokerenx4 merged 5 commits intomasterfrom Mar 17, 2026
Merged
fix: Alpaca broker fixes + IBroker redesign (provider → meta, aliceId → UTA)#71luokerenx4 merged 5 commits intomasterfrom
luokerenx4 merged 5 commits intomasterfrom
Conversation
…lete-branch Lesson learned: squash merge with --delete-branch destroyed dev's step-by-step commit history. Rules now explicit: no branch deletion, prefer merge over squash, never combine squash with delete-branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tests
- getOrder() was passing { order_id } object instead of string ID (SDK expects getOrder(id))
- UUID orderId no longer pointlessly parseInt'd (always 0, real ID via string interface)
- unrealizedPnL aggregation uses Decimal to prevent float drift
- Remove unused isFilled variable in modifyOrder
- Add 11 Alpaca paper e2e tests (account, clock, quote, order lifecycle)
- Add 3 unit tests for fixes (UUID handling, call signature, precision)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…r e2e - AccountInfo.realizedPnL → optional (IBKR/CCXT provide it natively, Alpaca doesn't) - Delete alpaca-pnl.ts, fetchAllFills, getRealizedPnL — was fetching ALL historical FILL activities on every getAccount() call, causing ECONNRESET under load - Delete computeRealizedPnL tests (11 tests removed, net test count stable) - Add UTA real-broker e2e: full stage→commit→push→sync lifecycle against Alpaca paper (AAPL) and Bybit demo (ETH perp) — both passing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
IBroker.provider had inconsistent semantics: Alpaca filled "alpaca",
CcxtBroker filled exchange name ("bybit"). No clear definition existed.
- Remove provider from IBroker, UTA, AccountManager, MockBroker
- Add IBroker<TMeta = unknown> with optional meta field
- CcxtBroker: implements IBroker<CcxtBrokerMeta>, meta.exchange = "bybit"
- AlpacaBroker: uses literal 'alpaca' for contract helpers
- AccountManager.resolve(): id-only matching (provider fallback removed)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
aliceId is now "{utaId}|{nativeKey}" (e.g. "alpaca-paper|META",
"bybit-main|ETH/USDT:USDT"). UTA owns construction and parsing;
brokers resolve contracts via symbol/localSymbol only.
- UTA: stampAliceId() wraps all broker output (positions, quotes, search)
- UTA: parseAliceId() extracts nativeKey for broker input (stage ops)
- Broker: no longer constructs aliceId in makeContract/marketToContract
- CCXT contractToCcxt: removed aliceId-first resolution, uses localSymbol
- Alpaca resolveSymbol: removed aliceId parsing, uses symbol directly
- CcxtBroker.closePosition: matches by localSymbol instead of aliceId
Fixes the root cause of AI constructing invalid aliceId "alpaca-paper-META"
(broker.id used as prefix instead of provider).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
providerfield, added genericmeta<TMeta>for broker-specific metadata (CcxtBroker usesmeta.exchange){utaId}|{nativeKey}(e.g.alpaca-paper|META). Brokers no longer construct aliceId — fixes root cause of AI building invalidalpaca-paper-METATest plan
🤖 Generated with Claude Code