Skip to content

Sync upstream to v0.9.0-beta.9#2

Merged
timFinn merged 29 commits intomasterfrom
sync/upstream-beta9
Apr 16, 2026
Merged

Sync upstream to v0.9.0-beta.9#2
timFinn merged 29 commits intomasterfrom
sync/upstream-beta9

Conversation

@timFinn
Copy link
Copy Markdown
Owner

@timFinn timFinn commented Apr 4, 2026

Summary

Conflicts resolved (5 files)

  • src/main.ts — merged new SDK clients with fork's economy + tool registrations
  • AlpacaBroker.ts / CcxtBroker.ts — kept nativeOrderId + TPSL
  • config.ts — took upstream's SDK-based test-provider
  • analysis.ts — merged commodity examples with fork's indicator examples

Verified

  • IBKR package: zero bare imports
  • tsup build passes
  • Service running (both Alpaca accounts connected)

Ame and others added 29 commits March 30, 2026 22:20
…aderAlice#90)

CCXT exchanges store conditional orders (stop-loss, take-profit) on
separate endpoints. getOrder/cancelOrder/modifyOrder now fall back to
fetchOrder with { stop: true } so these orders are no longer invisible.
This also prevents the duplicate order placement described in TraderAlice#91.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CCXT's "unified API" behaves differently per exchange (Bybit needs
fetchOpenOrder/fetchClosedOrder, others use fetchOrder). Instead of
if/else patches, introduce an override system:

- overrides.ts: interface + default impls + registry
- exchanges/bybit.ts: Bybit-specific fetchOrderById override
- CcxtBroker delegates to override ?? default

Bybit conditional order e2e test confirms stop-loss orders are now
visible to getOrder and cancellable — the core TraderAlice#90 fix verified
against a real exchange.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Node.js ESM requires explicit file extensions on all imports.
The decoder module and protobuf files had bare paths (e.g.
from './base' instead of './base.js'), causing
ERR_UNSUPPORTED_DIR_IMPORT when running `node dist/main.js`.

- decoder/index.ts + client/base.ts + index.ts: 10 bare imports fixed
- generate-proto.sh: add importSuffix=.js, regenerate 203 protobuf files
- pnpm dev (tsx) was unaffected; this fixes production builds only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
waitFor(delivered.length) returns before handleFire completes
(dedup.record + eventLog.append happen after send). Second fire
hits the processing guard instead of dedup logic. Wait for
heartbeat.done event instead to ensure full cycle completion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fix: conditional order visibility + ibkr ESM imports (TraderAlice#90, TraderAlice#94)
… fields

Rename AI tool and StagePlaceOrderParams/StageModifyOrderParams to use
IBKR-native field names (action, orderType, totalQuantity, lmtPrice,
auxPrice, tif, outsideRth, etc.), eliminating the toIbkrOrderType/toIbkrTif
translation layer. Fixes semantic bug where trailingAmount was incorrectly
mapped to trailStopPrice instead of auxPrice. Adds missing trailStopPrice
merge in IbkrBroker.modifyOrder.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New optional takeProfit/stopLoss params on placeOrder AI tool, with string
prices to avoid precision loss. TpSlParams flows through the full pipeline:
tool → StagePlaceOrderParams → Operation → dispatcher → IBroker.placeOrder().

Broker implementations:
- CCXT: maps to createOrder params { takeProfit, stopLoss }
- Alpaca: maps to order_class "bracket" with take_profit/stop_loss
- IBKR: signature updated, params ignored (use parentId bracket path)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Read takeProfitPrice/stopLossPrice from CCXT orders in convertCcxtOrder,
and parse bracket order legs in Alpaca's mapOpenOrder. OpenOrder now
carries optional tpsl field matching the TpSlParams shape used at
placement time.

Unit tests (TDD): 3 CCXT + 3 Alpaca extraction tests.
E2E tests: TPSL round-trip on Bybit (3 files), IBKR pass-through,
Alpaca bracket (market-hours gated).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace raw IBKR OpenOrder spread (~200 fields, mostly UNSET_DOUBLE) with
compact OrderSummary (~15 fields, UNSET values filtered out). Add optional
groupBy: "contract" parameter to cluster orders by aliceId — critical for
portfolios with many positions + TPSL orders.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: IBKR-aligned order params + TPSL support + order summarization
…ding

Alpaca: add null guards before UNSET_DOUBLE comparisons on lmtPrice,
auxPrice, trailingPercent — prevents sending undefined to exchange API.

CCXT: add null guard on lmtPrice, forward auxPrice/trailStopPrice/
trailingPercent/tif via params object to editOrder.

MockBroker: extend modifyOrder to handle trailStopPrice, trailingPercent,
orderType, tif fields.

TDD: 7 new tests (3 Alpaca + 4 CCXT) verify correct field isolation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MCP SDK validates tool inputs with strict Zod parse before the handler
runs. When MCP clients send "80" (string) instead of 80 (number), the
call fails with -32602. Both mcp.ts and tool-bridge.ts had duplicated
code (toMcpContent, .shape extraction, execute wrapper) and the same
missing coercion.

Add core/mcp-export.ts as the single Vercel→MCP bridge:
- extractMcpShape(): extracts Zod shape + coerces number fields
  (z.number() → z.coerce.number(), preserving all refinements)
- wrapToolExecute(): shared try/catch + content conversion
- toMcpContent(): deduplicated from both consumers

Tool definitions stay strict; coercion only at the MCP boundary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.9.0-beta.9: MCP number coercion fix + modifyOrder safety
…getConfirm)

These overlap with the current architecture and see minimal usage.
Only calculate remains active. Code preserved in git history.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Analyst consensus data (yfinance) is low quality and doesn't
drive actionable trading decisions. Reduces tool context pollution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
openTypeBB routers already define endpoints for these asset classes
but Alice had no client layer to consume them. Add SDK clients
(EtfClient 7 methods, IndexClient 8, DerivativesClient 7) and
initialize in main.ts. Tool layer not yet connected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace Record<string, unknown> return types with proper openTypeBB
types (EquityInfoData, CalendarEarningsData, FuturesCurveData, etc.)
across all 8 SDK clients and 3 openbb-api clients. 125/149 methods
now have strong return types; 24 without matching models stay untyped.

Also re-export standard-models from opentypebb main index so types
are importable from '@traderalice/opentypebb' directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace manual `pnpm --filter` chains with turbo-managed builds.
Turbo auto-discovers the dependency graph, builds packages in parallel
where possible, and caches results locally.

Cherry-picked from claude/refine-local-plan-9XzEB (19fecbc).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Establishes provider-level integration testing for openTypeBB data
sources. Tests hit real APIs to verify fetchers return schema-compliant
data. Credentials read from config.json — missing keys auto-skip.

Includes yfinance (32 fetcher tests) as first bbProvider. Separate
vitest config (test:bbProvider) to avoid impacting regular test suite.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Initial run: 18 passed, 15 failed. Failures are:
- EquityInfo schema mismatch (FMP changed field types)
- 9 endpoints behind paid tier (402)
- 2 model names not registered in FMP provider
- 2 param/format issues

These failures document the current state of FMP compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- EquityInfo: default is_etf/is_adr/is_fund/is_actively_trading (FMP
  no longer returns these); coerce employees string→number
- CurrencyPairs: add alias mapping (fromCurrency→from_currency etc.)
- New EquitySearch fetcher using FMP /stable/search-name endpoint
- Update tests: 28 passed, 4 skipped (higher-tier endpoints)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 'commodity' asset class to calculateIndicator tool using
  CommoditySpotPrice OHLCV data (gold, oil, etc.)
- Add CommodityClientLike interface + initialize commodity client
- Exclude *.bbProvider.spec.* from default test suite (pnpm test)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
test-provider was fetching typebb's external HTTP server to test API
keys, but the port config didn't match (apiUrl=6900 vs apiServer=6901).

Root fix: Alice shouldn't depend on its own external HTTP port. Now
test-provider calls bbEngine.execute() directly — same SDK path as
all other data fetching.

- Add bbEngine (QueryExecutor) to EngineContext
- Rewrite TEST_ENDPOINTS as { provider, model, params } instead of
  HTTP paths
- Remove readMarketDataConfig dependency from test-provider

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Separate "which provider for which asset" from "API key management":

1. Asset Providers — pure routing (equity/crypto/currency/commodity),
   no key inputs. Added commodity (yfinance).
2. API Keys — all provider credentials in one place
   (FMP/FRED/BLS/EIA/EconDB/Intrinio/Nasdaq/TradingEconomics),
   each with Test button.
3. Advanced — data backend switch + embedded API server, collapsed
   by default.

Previously FMP key was inline with the equity provider dropdown while
FRED/BLS were in a separate "Macro" section. Now all keys are unified.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Independent fetcher using /stable/historical-price-eod/full with
commodity symbols (GCUSD, CLUSD, etc.). Same FMP endpoint as equities
but own fetcher class — no bridging through equity code.

- Add FMP commodity provider option in UI
- Add CommoditySpotPrice test to FMP bbProvider suite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
refactor: market data infrastructure overhaul
# Conflicts:
#	src/connectors/web/routes/config.ts
#	src/domain/trading/brokers/alpaca/AlpacaBroker.ts
#	src/domain/trading/brokers/ccxt/CcxtBroker.ts
#	src/main.ts
#	src/tool/analysis.ts
@timFinn timFinn merged commit 46042a6 into master Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants