How kieran-mackle/cryptobots works
Project type and purpose
• CryptoBots is an open-source Python package and command-line interface for deploying and backtesting pre-built (and user-defined) crypto trading strategies.
• It depends on the AutoTrader library for market data feeds, execution logic, and backtests, and uses YAML configs to parameterize strategy runs.
File structure
• Top-level:
• .github/ – CI/CD workflows for linting, formatting, version bump, publish
• pyproject.toml – build/config for packaging
• src/cryptobots/ – main package
– _cli/ – command-line entrypoint + utilities
– config/ – strategy default parameter files (YAML)
– strategies/ – Python modules implementing each trading strategy
• No separate frontend or database; state lives in the user’s home folder (~/.cryptobots/).
README for additional insights
• The CLI supports commands: configure, strategies, run, stop, backtest.
• Strategies load defaults from YAML, prompt user for overrides, then call AutoTrader to execute or backtest.
• API keys are stored locally under ~/.cryptobots/.
Main components & their interactions
a. Components
1. CLI Layer (cryptobots executable)
2. Config Loader (reads/writes ~/.cryptobots/ and strategy YAMLs)
3. Strategy Manager (selects and initializes Python strategy modules)
4. Execution Engine (AutoTrader core library)
5. Exchange Adapters (REST/WebSocket connectors within AutoTrader)
6. Persistence (local file store for API keys and logs)
7. (Optional) Backtest Module (simulation using historical data)
b. Data flows & relationships
• User → CLI Layer → Config Loader → Strategy Manager → Execution Engine
• Execution Engine ↔ Exchange Adapters → Crypto Exchange (market data & order placement)
• Backtest Module ← Strategy Manager ← Historical Data Provider
• Execution outcomes, logs, and results → Persistence
c. Architectural patterns & principles
• Modular, plugin-based strategy pattern (each strategy is a self-contained Python module)
• Separation of concerns: CLI, config, strategy logic, execution API all in distinct layers
• External dependency inversion: All exchange I/O delegated to AutoTrader adapters
d. Key technologies
• Python packaging (PEP 517 via pyproject.toml)
• Click or argparse (in cryptobots/_cli/cli.py) for CLI
• PyYAML for config loading
• AutoTrader library for market I/O and backtesting
• YAML strategy definitions under src/cryptobots/config/*.yaml
Detailed capture of essential elements
• That the Execution Engine calls both market data feeds and order endpoints via the Exchange Adapters.
• Component boundaries (CLI vs. core library vs. adapters)
• Data flow directions (user commands → execution → exchange)
• Extensibility points (strategy plugin modules)
• Deployment context (local filesystem for configs and keys)