Skip to content

πŸ”§ Source Installation Guide

Difficulty: ⭐⭐⭐ Advanced
Time: 15 minutes


βœ… Prerequisites

  • Python 3.11+ (Get Python)
  • Git (Get Git)
  • pip (Python package manager)
  • API Keys (Twelve Data, Alpha Vantage)

πŸš€ Quick Start

1. Clone Repository

git clone https://github.com/XuXuClassMate/trading-assistant.git
cd trading-assistant
# Create virtual environment
python3 -m venv venv

# Activate (Linux/macOS)
source venv/bin/activate

# Activate (Windows)
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Install in Development Mode

pip install -e .

5. Verify Installation

ta --version
# Output: OpenClaw Trading Assistant CLI v1.3.0

βš™οΈ Configuration

1. Copy Configuration Templates

cp .env.example .env
cp watchlist.txt.example watchlist.txt

2. Edit Configuration

# Edit .env with your API keys
nano .env

Required API Keys:

TWELVE_DATA_API_KEY=your_key_here
ALPHA_VANTAGE_API_KEY=your_key_here
LANGUAGE=en  # or 'zh' for Chinese


🎯 Usage

Interactive Mode

ta

Direct Commands

# Trading signals
ta sig

# Support/Resistance
ta sr

# Position calculator
ta pos --symbol NVDA --price 175 --capital 10000

# All analysis
ta all

πŸ§ͺ Development

Run Tests

# Install test dependencies
pip install -r requirements-dev.txt

# Run tests
pytest

Run Linter

# Install linting tools
pip install flake8 black

# Check code style
flake8 .

# Format code
black .

Make Changes

  1. Create feature branch:

    git checkout -b feature/my-feature
    

  2. Make changes and test

  3. Commit changes:

    git add .
    git commit -m "feat: Add my feature"
    

  4. Push and create PR:

    git push origin feature/my-feature
    


πŸ“ Project Structure

trading-assistant/
β”œβ”€β”€ cli.py                    # CLI entry point
β”œβ”€β”€ config.py                 # Configuration management
β”œβ”€β”€ i18n.py                   # Internationalization
β”œβ”€β”€ position_calculator.py    # Position sizing
β”œβ”€β”€ stop_loss_alerts.py       # Alert management
β”œβ”€β”€ technical_analysis.py     # Technical indicators
β”œβ”€β”€ pyproject.toml            # Project metadata
β”œβ”€β”€ requirements.txt          # Dependencies
β”œβ”€β”€ .env.example              # Environment template
β”œβ”€β”€ watchlist.txt.example     # Watchlist template
β”œβ”€β”€ docs/                     # Documentation
β”‚   β”œβ”€β”€ index.md
β”‚   β”œβ”€β”€ CLI.md
β”‚   └── guides/
β”‚       β”œβ”€β”€ docker-install.md
β”‚       β”œβ”€β”€ pip-install.md
β”‚       β”œβ”€β”€ npm-install.md
β”‚       └── source-install.md
└── .github/workflows/        # CI/CD workflows
    β”œβ”€β”€ docker-publish.yml
    β”œβ”€β”€ pypi-publish.yml
    β”œβ”€β”€ publish-npm.yml
    └── publish-gh.yml

πŸ”„ Update from Source

# Pull latest changes
git pull origin main

# Update dependencies
pip install -r requirements.txt --upgrade

# Reinstall in development mode
pip install -e .

# Verify version
ta --version

πŸ—‘οΈ Uninstall

# Uninstall package
pip uninstall openclaw-trading-assistant

# Remove virtual environment (if created)
rm -rf venv

# Remove cloned repository
cd ..
rm -rf trading-assistant

❓ Troubleshooting

Dependency Conflicts

# Upgrade pip
pip install --upgrade pip

# Clear pip cache
pip cache purge

# Reinstall dependencies
pip install -r requirements.txt --force-reinstall

Import Errors

# Make sure you're in the project directory
cd trading-assistant

# Make sure virtual environment is activated
source venv/bin/activate  # Linux/macOS

# Reinstall in development mode
pip install -e .

Python Version Issues

# Check Python version
python3 --version

# If < 3.11, upgrade Python
# macOS: brew install python@3.11
# Ubuntu: sudo apt install python3.11
# Windows: Download from python.org

πŸ“š Next Steps