Skip to content

Add trading bot: technical analysis + Alpaca broker integration#130

Open
christianjolevski wants to merge 1 commit intovirattt:mainfrom
christianjolevski:main
Open

Add trading bot: technical analysis + Alpaca broker integration#130
christianjolevski wants to merge 1 commit intovirattt:mainfrom
christianjolevski:main

Conversation

@christianjolevski
Copy link

Summary

  • Technical analysis tools: RSI, MACD, Bollinger Bands, EMA/SMA, ATR, Stochastic, VWAP — computed via technicalindicators library on OHLCV data from the existing financial API
  • Alpaca broker integration: Paper/live mode trading with account info, position tracking, order placement (market/limit/stop/stop_limit), and order management
  • Trading assistant meta-tool: LLM-routed meta-tool (follows financial_search pattern) that dispatches natural language queries to appropriate sub-tools
  • Safety guardrails: Paper mode default, confirmation gate before order execution, position-size limits (warns >5%, refuses >20% of equity), trading policy in system prompt, "not a financial advisor" disclaimer
  • Three strategy skills: trading-signals (combined TA + news + fundamentals), momentum-trading (RSI + MACD crossover), mean-reversion (Bollinger Bands)
  • Conditional registration: Trading tools only appear when ALPACA_API_KEY + ALPACA_SECRET_KEY are set, following the existing Exa/Tavily pattern

Test plan

  • bun install resolves technicalindicators dependency
  • bun run typecheck — no new type errors introduced
  • bun test — existing tests pass (9/9)
  • Set Alpaca paper keys → ask "analyze AAPL for trading" → verify TA output with indicator signals
  • Ask "buy 1 share of AAPL" → verify order preview shown with confirmation prompt
  • Confirm → verify paper order placed and position appears
  • Verify trading tools do NOT appear when ALPACA_API_KEY is unset
  • Verify skills discovered: ask "should I buy NVDA?" → trading-signals skill invoked

🤖 Generated with Claude Code

Extends Dexter from a research agent into a trading bot with:
- Technical analysis tools (RSI, MACD, Bollinger Bands, EMA/SMA, ATR, Stochastic, VWAP)
- Alpaca broker integration for trade execution (stocks + crypto, paper mode default)
- Trading assistant meta-tool with LLM-routed sub-tools (account, positions, orders, TA)
- Position-size safety checks (warns >5%, refuses >20% of equity)
- Confirmation gate: never executes trades without explicit user approval
- Trading safety policy injected into system prompt when Alpaca keys are configured
- Three strategy skills: trading-signals, momentum-trading, mean-reversion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant