
A comprehensive, modular autonomous trading agent for Hyperliquid, featuring advanced risk management and monitoring.
Baby Smith has been completely refactored! The codebase has been transformed from a monolithic structure into a modern, modular architecture. See CLAUDE.md for detailed refactoring documentation.
- β Modular Architecture - Clean separation of concerns
- β Advanced Error Handling - Comprehensive exception hierarchy
- β Type Safety - Full type annotations throughout
- β Zero Dead Code - Optimized and cleaned codebase
- β Enhanced Monitoring - Improved dashboard and logging
- β Better Risk Management - Sophisticated risk controls
Baby Smith is experimental software that can autonomously trade with real money. The consequences of bugs, market events, or other unforeseen circumstances could result in immediate and total loss of funds.
By using this software:
- You acknowledge that you are solely responsible for any losses
- You understand that autonomous trading is inherently risky
- You accept that no warranties or guarantees are provided
- You agree to the terms of the MIT license
Baby Smith is a sophisticated, modular autonomous trading agent for Hyperliquid perpetual futures. The v2.0 architecture includes:
- Advanced Market Making - Momentum-driven strategies with dynamic spread calculation
- Comprehensive Risk Management - Multi-layer risk controls and position limits
- Modular Design - Separate modules for trading, market data, orders, and positions
- Enhanced Monitoring - Real-time dashboard with detailed analytics
- Robust Error Handling - Custom exception hierarchy with graceful recovery
- Type Safety - Full type annotations for better development experience
- Poetry (Python package manager)
- Docker and Docker Compose (optional)
- A funded Hyperliquid account
- Private key with trading permissions
- Basic understanding of perpetual futures trading
- Clone the repository:
git clone https://github.com/hydralabs-sh/baby-smith.git
cd baby-smith
- Copy and configure environment variables:
cp .env.template .env
- Edit
.env
with your credentials:
# Required - Trading Account
HL_ACCOUNT_ADDRESS=your_account_address
HL_SECRET_KEY=your_private_key
# Optional - Trading Parameters
HL_ASSET=HYPE
HL_MAX_POSITION=5.0
HL_BASE_POSITION=1.0
HL_LEVERAGE=3
HL_TESTNET=true
- Start the agent:
docker compose up
- Clone and enter the repository:
git clone https://github.com/hydralabs-sh/baby-smith.git
cd baby-smith
- Install dependencies using Poetry:
poetry install
- Copy and configure environment variables:
cp .env.template .env
# Edit .env with your settings
- Run the agent:
poetry run python -m agent_smith.main
Parameter | Description | Default |
---|---|---|
HL_ACCOUNT_ADDRESS | Your Hyperliquid account address (required) | None |
HL_SECRET_KEY | Private key with trading permissions (required) | None |
HL_ASSET | Trading asset | HYPE |
HL_MAX_POSITION | Maximum position size | 5.0 |
HL_BASE_POSITION | Target position size | 1.0 |
HL_LEVERAGE | Trading leverage | 3 |
HL_TESTNET | Use testnet instead of mainnet | true |
Baby Smith v2.0 features a modular, scalable architecture:
trading_engine.py
- Main orchestration and trading loop managementmarket_data.py
- Real-time market data fetching and validationorder_manager.py
- Order execution, verification, and managementposition_manager.py
- Position tracking and risk metrics
enhanced_market_maker.py
- Advanced market making with momentum analysisrisk_manager.py
- Comprehensive risk management systemmomentum_analyzer.py
- Technical analysis and signal generationorder_utils.py
- Order processing and validation utilities
main.py
- Dashboard orchestration and renderingdata_fetchers.py
- Data collection and processingchart_components.py
- Interactive charts and visualizationsui_components.py
- User interface components and styling
- Custom exception hierarchy for robust error handling
- Specific exceptions for different error scenarios
- Graceful error recovery and logging
For detailed architecture documentation, see CLAUDE.md
The agent provides a real-time dashboard at http://localhost:8501
showing:
- Current positions
- Account value
- Recent trades
- PnL metrics
- Market data
Enhanced risk management system with multiple layers of protection:
- Dynamic position limits based on market conditions
- Automated position reduction when limits are approached
- Real-time utilization monitoring with alerts
- Pre-execution validation for all orders
- Slippage protection with dynamic adjustment
- Order size validation against minimum notional requirements
- Price deviation checks to prevent errant orders
- Spread threshold monitoring - avoid trading in illiquid conditions
- Volatility-based adjustments - reduce exposure during high volatility
- Rate limiting with exponential backoff - prevent API violations
- Consecutive loss limits - pause trading after multiple losses
- Win rate monitoring - adjust strategy based on performance
- Risk metrics tracking - comprehensive performance analysis
The entire codebase has been refactored from a monolithic structure (1600+ line files) into a clean, modular architecture:
- File size reduction: All files now under 500 lines
- Modular design: Clear separation of concerns across 30+ focused modules
- Zero dead code: Removed 120+ lines of unused code
- Type safety: 95%+ type annotation coverage
- Error handling: Comprehensive exception hierarchy with specific error types
Metric | Before | After | Improvement |
---|---|---|---|
Max file size | 1,651 lines | 366 lines | -78% |
Files > 500 lines | 3 files | 0 files | β |
Dead code | 120+ lines | 0 lines | β |
Type coverage | ~20% | ~95% | +75% |
- Dependency injection for better testability
- Event-driven architecture with proper separation
- Centralized configuration with environment variable support
- Comprehensive logging with structured output
- Performance optimizations throughout
π For complete refactoring details, see CLAUDE.md
The project uses Poetry for dependency management. To set up a development environment:
- Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 -
- Install dependencies:
poetry install
- Activate the virtual environment:
poetry shell
- Run tests:
poetry run pytest
- Run the agent:
poetry run python -m agent_smith.main
- Fork the repository
- Create a feature branch
- Install development dependencies:
poetry install --with dev
- Run tests:
poetry run pytest
- Commit your changes
- Push to the branch
- Create a Pull Request
This project uses Poetry for dependency management. Key dependencies include:
- hyperliquid-python-sdk
- streamlit (for dashboard)
- pandas (for data processing)
- loguru (for logging)
- pydantic (for config)
To add new dependencies:
poetry add package_name
For development dependencies:
poetry add --group dev package_name
This project is licensed under the MIT License - see the LICENSE file for details.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The developers of Baby Smith take no responsibility and assume no liability for any money lost through the use of this software. Use at your own risk.
For questions and support:
- Join the Hyperliquid Discord
- Visit the Hyperliquid Documentation
Remember: This is experimental software for educational purposes. Never trade with more money than you can afford to lose.
Β© Copyright 2025 Algo Traders Club LLC - MIT License