Skip to content

Latest commit

Β 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Note

πŸš€ Zero-cost autonomous trading is here

No OpenAI subscription. No Brave API key. No hidden costs. One command:

npx llm-trader-opencode --continuous

Your agent gets a free model, keyless web search, and FRED macro confluence β€” then trades Alpaca's paper market on its own.

Tip

Fully automated. Fully free.

The agent sleeps nights, weekends, and holidays. It wakes at the opening bell, checks macro confluence, scans news sentiment, and only pulls the trigger when at least 2 of 3 signals agree.

Total LLM bill after months of continuous running: $0.00.

πŸ€– LLM Trader

Free AI-Powered Trading Agent

License Model LLM Cost Search Macro Platform Node npm

npm i -g llm-trader-opencode && llm-trader --continuous

You juggle charting tools, news feeds, macro calendars, and gut feelings. You second-guess entries. You chase moves that already happened.

We already did that work. Tested every signal combination. Kept only what actually gates a bad trade.

Install LLM Trader. Type llm-trader --continuous. Done.


Skip This README

We are past the era of reading documentation. Just paste this into your agent:

Read this and tell me if this free AI trading agent is legit or vaporware:
https://raw.githubusercontent.com/Parithosh-Varma/llm_trader-opencode/main/README.md

Installation

For Humans

Copy and paste this prompt into your LLM agent (Claude Code, OpenCode, Cursor, etc.):

Install and configure the llm-trader trading agent by following these steps:
1. Run: npm i -g llm-trader-opencode
2. Create a free API key at https://opencode.ai
3. Create a free paper trading account at https://app.alpaca.markets/paper/dashboard/overview
4. Write a .env file with OPENCODE_API_KEY, ALPACA_API_KEY, ALPACA_SECRET_KEY,
   MODEL=x-preview-f-free, PROFILE_NAME=opencode
5. Run: llm-trader --continuous

Or follow the Quick Start below β€” but seriously, let your agent do it. Humans make config mistakes.

For LLM Agents

npx llm-trader-opencode                 # single session
npx llm-trader-opencode --continuous    # every 30 min during market hours

Key Features

Feature What It Does
πŸ†“ Zero LLM Cost Powered by x-preview-f-free via OpenCode Zen β€” no credit card, no token metering
πŸ” Keyless Web Search DuckDuckGo HTML scraping β€” no API key, no quotas, no setup
πŸ“Š Macro Confluence FRED integration checks rates, inflation, unemployment, VIX & yield curve before every trade
🧠 2-of-3 Signal Rule Trades execute only when macro + news + price action agree
πŸ’° Alpaca Paper Trading $100K virtual capital on real market data
⏰ Market-Hours Scheduler Sleeps nights and weekends, wakes at the open, handles timezone conversion automatically
πŸ“ˆ Auto Reporting Portfolio dashboard, per-trade P&L, and CSV reports refresh after every session
🐳 Docker Ready One-command deployment with persistent volumes

How the Confluence System Works

The agent doesn't guess. Before executing any trade it checks three independent signal sources:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  1️⃣  MACRO (FRED)                                    β”‚
β”‚      β€’ Federal Funds Rate trend                      β”‚
β”‚      β€’ CPI / inflation level                         β”‚
β”‚      β€’ Unemployment rate                             β”‚
β”‚      β€’ VIX fear index                                β”‚
β”‚      β€’ Yield curve shape (10Y–2Y spread)             β”‚
β”‚                                                      β”‚
β”‚  2️⃣  NEWS SENTIMENT (DuckDuckGo)                     β”‚
β”‚      β€’ Real-time stock-specific headlines            β”‚
β”‚      β€’ Market mood from search results               β”‚
β”‚                                                      β”‚
β”‚  3️⃣  PRICE ACTION (Yahoo Finance)                    β”‚
β”‚      β€’ Current price vs recent movement              β”‚
β”‚      β€’ Momentum indicators                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β–Ό
   At least 2 of 3 agree β†’ EXECUTE TRADE
   Fewer than 2 agree    β†’ STAY IN CASH

This dramatically reduces false signals and prevents the agent from trading blind.

Quick Start

Prerequisites

Service Cost Sign Up
OpenCode Zen Free Get your API key
Alpaca Paper Free Instant paper account ($100k virtual)
FRED Free (optional) For macro confluence

Total cost: $0

Install & Run

git clone https://github.com/Parithosh-Varma/llm_trader-opencode.git
cd llm_trader-opencode
npm install

# Create .env
cat > .env << 'EOF'
OPENCODE_API_KEY=your_key_here
ALPACA_API_KEY=your_alpaca_key_id
ALPACA_SECRET_KEY=your_alpaca_secret_key
FRED_API_KEY=your_fred_key_here
MODEL=x-preview-f-free
PROFILE_NAME=opencode
ALPACA_BASE_URL=https://paper-api.alpaca.markets
EOF

# Run a single trading session
npm start

Global Install (Recommended)

npm i -g llm-trader-opencode

# Create your .env in whatever directory you want to trade from
cat > .env << 'EOF'
OPENCODE_API_KEY=your_key_here
ALPACA_API_KEY=your_alpaca_key_id
ALPACA_SECRET_KEY=your_alpaca_secret_key
FRED_API_KEY=your_fred_key_here
MODEL=x-preview-f-free
PROFILE_NAME=opencode
ALPACA_BASE_URL=https://paper-api.alpaca.markets
EOF

llm-trader                              # single session
llm-trader --continuous                 # every 30 min during market hours
llm-trader --continuous --interval=120  # custom interval (minutes)

Docker Deployment

docker-compose up --build -d
docker logs -f priced-in-opencode

Configuration Reference

# Required
OPENCODE_API_KEY=          # Your OpenCode Zen key
ALPACA_API_KEY=            # Paper trading key ID
ALPACA_SECRET_KEY=         # Paper trading secret

# Optional
FRED_API_KEY=              # Enables macro confluence
MODEL=x-preview-f-free     # Default free model
PROFILE_NAME=opencode      # Results directory name
OPENCODE_BASE_URL=         # Override endpoint if needed

Trading Schedule

  • βœ… Runs every 30 minutes during market hours (9:30 AM – 4:00 PM ET)
  • βœ… Automatically sleeps nights, weekends, and holidays
  • βœ… Wakes up at market open each trading day
  • βœ… Handles timezone conversion automatically

Reporting & Dashboards

Every session writes to results/{profile}/:

  • README-{profile}.md β€” live dashboard: portfolio value, CAGR, holdings, last 10 trades with P&L
  • pnl_{model}_{date}.csv β€” per-trade P&L reports for cross-model comparison
  • thread-{profile}.json β€” persisted conversation history for session continuity
  • agent-{profile}.log β€” full activity log

Testing

npm test              # All 37 tests
npm run test:watch    # Watch mode
npm run test:coverage # Coverage report
Architecture
OpenCode Zen API ───► Agent SDK (@openai/agents) ───► Alpaca Paper Trading
       β”‚                        β”‚                              β”‚
       β”‚                 Tool Execution Loop                    β”‚
       β”‚                        β”‚                              β”‚
       β–Ό                        β–Ό                              β–Ό
 x-preview-f-free      FRED + DuckDuckGo + Yahoo        Market Orders
 (Chat Completions)    (Confluence Signals)             (Buy/Sell/Short)

Uninstall

To remove llm-trader:

  1. Remove the global CLI

    npm uninstall -g llm-trader-opencode
  2. Stop containers (if using Docker)

    docker-compose down
  3. Delete trading data (optional)

    rm -rf results/ logs/

A Word From the Author

I wanted an autonomous trading agent that actually runs every single day β€” without a $200/month subscription and without juggling five API keys.

OpenCode Zen gave the model away free. DuckDuckGo gave search away free. Alpaca gave the broker away free. So I built on top of all three.

Every problem I hit running agents continuously β€” schema validation crashes, thread corruption, market-hours scheduling, rate limits β€” is already solved in this codebase. Clone it and let it work.

Not affiliated with any of the services mentioned above. Just personal experiments. Paper trading only β€” never real money.


Warning

Disclaimer

This software executes trades on Alpaca's paper trading platform using virtual money. It does not trade real capital. Past performance does not guarantee future results. Always do your own research before investing real money.

License

MIT

About

AI trading agent with OpenCode Zen, DuckDuckGo search, and FRED macro confluence

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages