StockClaw: Using OpenClaw to Quickly Build Your AI Stock Manager

March 14, 2026

Level: Intermediate Β· Duration: 30 minutes Β· Key Takeaway: Master the setup of a multi-agent stock analysis system based on OpenClaw, enabling automated stock selection, deep analysis, and simulated trading.

Target Audience

  • Developers with 1-3 years of experience
  • Programmers interested in AI Agents and quantitative trading
  • Investors looking to build a personal stock assistant

Core Dependencies and Environment

  • Node.js 18+
  • OpenAI compatible API (Claude/Gemini/DeepSeek, etc.)
  • Optional: Telegram Bot Token
  • Optional: Historical market data (CSV format)

Project Structure Tree

StockClaw/
β”œβ”€β”€ config/                      # Configuration files
β”‚   β”œβ”€β”€ llm.local.toml          # LLM large model configuration
β”‚   β”œβ”€β”€ telegram.json           # Telegram integration configuration
β”‚   β”œβ”€β”€ tools.json              # Tool configuration
β”‚   └── agents.json             # Agent configuration
β”œβ”€β”€ skills/                     # Skill modules
β”‚   └── crypto-stock-market-data/   # Market data acquisition skill
β”œβ”€β”€ prompts/                    # Prompt templates
β”‚   β”œβ”€β”€ agents/                 # Specialized agent role definitions
β”‚   β”‚   β”œβ”€β”€ value_analyst/      # Value Analyst
β”‚   β”‚   β”œβ”€β”€ technical_analyst/  # Technical Analyst
β”‚   β”‚   β”œβ”€β”€ news_sentiment_analyst/  # Sentiment Analyst
β”‚   β”‚   β”œβ”€β”€ risk_manager/       # Risk Manager
β”‚   β”‚   β”œβ”€β”€ portfolio_agent/    # Portfolio Agent
β”‚   β”‚   └── trade_executor/     # Trade Executor
β”‚   β”œβ”€β”€ workflows/              # Workflow templates
β”‚   β”‚   β”œβ”€β”€ backtest_mode/      # Backtest mode
β”‚   β”‚   └── portfolio_review/   # Portfolio review
β”‚   └── shared/                 # Shared rules
β”œβ”€β”€ data/                       # Data storage
β”‚   └── portfolio.json         # Portfolio status
└── src/                        # Core code
    β”œβ”€β”€ index.ts               # Entry file
    β”œβ”€β”€ router.ts              # Request routing
    └── ...

Step-by-Step Instructions

1. Clone Project and Install Dependencies

First, clone the StockClaw project from GitHub, then install the dependencies:

git clone https://github.com/24mlight/StockClaw.git
cd StockClaw
npm install

TIP

If you are in mainland China, it is recommended to configure the npm mirror to speed up installation:

npm config set registry https://registry.npmmirror.com

2. Configure the LLM Model

StockClaw supports any OpenAI-compatible LLM API. Create a local configuration file:

# Copy example configuration
cp config/llm.local.example.toml config/llm.local.toml

Edit config/llm.local.toml. Taking Claude as an example:

# config/llm.local.toml
[llm]
# Use OpenAI compatible interface
model = "claude-sonnet-4-20250514"
baseUrl = "https://api.anthropic.com/v1"
apiKey = "sk-ant-your-api-key-here"

# Optional: Advanced configuration
[llm.context]
maxTokens = 200000  # Set based on model context window
compactionThreshold = 150000  # Threshold to trigger compression

If you use DeepSeek, Qwen, or other compatible APIs, simply modify baseUrl and model.

WARNING

The API Key must be kept safe and not submitted to version control. The project ignores config/llm.local.toml by default.

3. Start the Service

Run the start command directly:

npm start

On the first start, the service will automatically detect configuration files. If Telegram configuration is missing, it will prompt you to set it up.

The service runs by default at http://127.0.0.1:8000. Open your browser to access the Web UI.

4. Configure Telegram (Optional)

To interact with StockClaw via Telegram:

  1. Search for @BotFather in Telegram, create a new bot, and get the Bot Token.
  2. On the first start, type yes in the terminal to enable Telegram integration.
  3. Paste your Bot Token.
  4. Send any message to your bot in Telegram.
  5. Paste the pairing code shown in the terminal back to complete binding.

Alternatively, manually create the config file config/telegram.json:

{
  "enabled": true,
  "botToken": "YOUR_BOT_TOKEN_HERE",
  "allowedUsers": ["your_telegram_id"]
}

TIP

Once Telegram is linked, you can check stocks, receive analysis reports, and even execute simulated trades from anywhere using your phone.

5. Configure Market Data Skills

StockClaw has built-in skills for cryptocurrency and stock market data. The skills directory is located at skills/, with the core skill being crypto-stock-market-data.

The skill configuration file config/tools.json already includes the built-in skills:

{
  "skills": [
    {
      "name": "crypto-stock-market-data",
      "enabled": true,
      "path": "skills/crypto-stock-market-data"
    }
  ]
}

This skill provides tools such as:

  • get_crypto_price - Get real-time crypto prices
  • get_coin_historical_chart - Get historical K-line data
  • get_global_market_data - Get global market data
  • get_company_profile - Get basic company info for stocks
  • get_coin_details - Get detailed token information

6. Create Your First Portfolio

StockClaw manages portfolios using JSON files. Create data/portfolio.json:

{
  "cash": 100000,
  "positions": [
    {
      "symbol": "AAPL",
      "shares": 100,
      "entryPrice": 175.5
    },
    {
      "symbol": "MSFT",
      "shares": 50,
      "entryPrice": 380.0
    },
    {
      "symbol": "NVDA",
      "shares": 25,
      "entryPrice": 450.0
    }
  ],
  "createdAt": "2026-03-14T00:00:00Z"
}

This configuration represents:

  • Initial Cash: $100,000
  • Holdings: 100 shares of Apple, 50 shares of Microsoft, 25 shares of NVIDIA

7. Execute Deep Stock Analysis

Now ask StockClaw to analyze a stock via the Web UI or Telegram.

Via Web UI:

  1. Open http://127.0.0.1:8000
  2. Type in the input box: Do a deep analysis on NVDA

StockClaw will trigger multi-agent collaborative analysis:

  1. Value Analyst - Analyzes fundamentals, financial data, and valuation levels.
  2. Technical Analyst - Analyzes price trends, technical indicators, and chart patterns.
  3. Sentiment Analyst - Analyzes news sentiment, market mood, and institutional holdings.
  4. Risk Manager - Evaluates potential risks, downside room, and position suggestions.
  5. Root Agent - Synthesizes all professional opinions to output the final recommendation.

You can watch each specialized agent being called in sequence, culminating in a complete analysis report.

Via Telegram:

/analyze NVDA

8. Simulated Trading Operations

StockClaw supports Paper Trading; all trades are recorded locally and not executed on a real exchange.

Buy Operation:

Buy 10 shares of GOOGL at market price

The system will:

  1. Fetch real-time quotes
  2. Verify sufficient cash
  3. Calculate transaction costs
  4. Update portfolio status
  5. Return trade confirmation

Sell Operation:

Sell 5 shares of AAPL

Query Portfolio:

Show my portfolio

Or use the slash command:

/portfolio

9. Run Historical Backtesting

This is one of StockClaw's most powerful featuresβ€”using historical data to validate your investment strategy.

Backtest Current Portfolio:

Backtest my portfolio for the last 7 trading days

StockClaw will:

  1. Prepare historical market data
  2. Isolate decision contexts for each trading day (T-1 constraint)
  3. Simulate daily trading decisions
  4. Calculate returns, maximum drawdown, and Sharpe ratio
  5. Generate a detailed backtest report

WARNING

The longer the backtest period, the more tokens consumed and the longer it takes. It is recommended to start with small tests of 7 or 30 days.

Backtest Specific Strategy:

Backtest a strategy: buy when RSI < 30, sell when RSI > 70

You can also let StockClaw discover investment opportunities:

Find a few US stocks with strong value and technical alignment

Troubleshooting Common Issues

1. LLM API Connection Failure

Symptoms: Connection refused or 401 Unauthorized errors on startup.

Steps:

  1. Confirm apiKey in config/llm.local.toml is correct.
  2. Check if baseUrl is accessible: curl -I <your-baseUrl>.
  3. Confirm model name is correct (case-sensitive).
  4. Check logs for detailed error messages.

2. Telegram Bot Fails to Start

Symptoms: No response to Telegram messages.

Steps:

  1. Confirm Bot Token is correct.
  2. Check that enabled is true in config/telegram.json.
  3. Check bot status with @BotFather.
  4. Ensure you have sent a message to complete user binding.

3. Market Data Retrieval Failure

Symptoms: Failed to fetch stock data message during analysis.

Steps:

  1. Check network connection.
  2. Confirm skills/crypto-stock-market-data is enabled.
  3. Review skill logs for specific API errors.
  4. Some data sources require an API Key; check if it is configured.

4. Portfolio State Abnormalities

Symptoms: Position data does not update or displays incorrectly.

Steps:

  1. Check if data/portfolio.json is in valid JSON format.
  2. Confirm file write permissions.
  3. Check logs for state change records.

5. Inaccurate Backtest Results

Symptoms: Backtest returns do not match reality.

Steps:

  1. Confirm T-1 snapshot data is being used (cannot use same-day data).
  2. Check for look-ahead bias.
  3. Confirm slippage settings are reasonable.
  4. Review backtest logs for specific trade records.

6. Context Too Long / Truncation

Symptoms: Conversation cuts off midway; analysis is incomplete.

Steps:

  1. Increase compactionThreshold in llm.local.toml.
  2. Use session_compaction to manually compress context.
  3. Shorten the backtest time window.
  4. Consider switching to a model with a longer context window.

Further Reading / Advanced Directions

1. OpenClaw Official Documentation

Deepen your understanding of OpenClaw's architecture and skill system:

2. Deep Dive into MCP Protocol

StockClaw extends data capabilities via the Model Context Protocol (MCP):

  • How to write custom MCP Servers
  • Data providers in the MCP ecosystem

3. Multi-Agent System Design

StockClaw demonstrates best practices for agent collaboration:

  • Root agent for decision-making and coordination
  • Specialized agents providing domain knowledge
  • Isolated temporary sessions to avoid polluting the main context

4. Quant Strategy Backtesting

Learn backtesting methodology in depth:

  • Avoiding overfitting
  • Considering transaction costs and slippage
  • Multi-timeframe validation

Now you have mastered the core usage of StockClaw. This AI stock manager built on OpenClaw can help you with stock selection, portfolio management, simulated trading, and historical backtesting. Go ahead and try to let it help you find some investment opportunities!

Updated March 14, 2026