# Bitfinex Maker-Kit
> **Modular Market Making Platform for Bitfinex**
A professional, production-ready command-line interface for automated trading and market making on the Bitfinex cryptocurrency exchange. Built with modern software architecture principles including dependency injection, domain-driven design, and comprehensive testing frameworks.
[](https://github.com/0xferit/bitfinex-maker-kit/stargazers)
[](https://github.com/0xferit/bitfinex-maker-kit/network/members)
[](https://github.com/0xferit/bitfinex-maker-kit/issues)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
## ๐ฏ Key Features
### ๐ก๏ธ Safety-First Architecture
- **POST_ONLY Enforcement**: Architecturally impossible to place market orders
- **Dry-Run Mode**: Test strategies without real trading
- **Multi-Layer Validation**: Domain objects, service layer, and API boundary validation
- **Risk Management**: Built-in safeguards and confirmation prompts
### โก Modern Architecture
- **Dependency Injection**: Clean separation of concerns with container pattern
- **Domain-Driven Design**: Type-safe domain objects (OrderId, Price, Amount, Symbol)
- **Service-Oriented**: Modular services (trading, cache, market data, performance monitoring)
- **Event-Driven**: WebSocket integration with async event handling
### ๐งช Comprehensive Testing
- **Property-Based Testing**: 1000+ generated test cases using Hypothesis
- **Realistic Load Testing**: Integration tests against Bitfinex Paper Trading API
- **Performance Benchmarking**: Automated regression detection with real network conditions
- **Security Scanning**: Continuous vulnerability assessment
### ๐ Production Ready
- **Modular Commands**: Extensible command system with core abstractions
- **Performance Monitoring**: Real-time metrics and profiling tools (API response time, error rate, CPU, memory)
- **Configuration Management**: Environment-aware configuration system
- **Quality Tooling**: Streamlined workflow with Ruff, MyPy, Bandit, and pytest
## ๐๏ธ Architecture Overview
### Modern Software Design
- **Safety First**: Architecturally enforced POST_ONLY orders with multiple validation layers
- **Modular Design**: Extensible architecture supporting multiple strategies and update methods
- **Domain-Driven**: Rich domain objects with business logic encapsulation
- **Service-Oriented**: Clean dependency injection with focused service responsibilities
### Core Architecture Components
#### ๐ฏ **Command Layer** (`commands/`)
- **Individual Commands**: `test`, `wallet`, `list`, `cancel`, `put`, `market-make`, `fill-spread`, `update`
- **Core Abstractions**: `core/` with base commands, executors, and result handling
- **Extensible Design**: Plugin-style command architecture
#### ๐๏ธ **Service Layer** (`services/`)
- **Container**: Dependency injection system managing service lifecycle
- **Trading Services**: Sync/async trading facades with monitoring
- **Cache Service**: Intelligent caching with namespace isolation
- **Performance Monitor**: Real-time metrics collection and analysis
- **Market Data Service**: Real-time price feeds and historical data
#### ๐จ **Domain Layer** (`domain/`)
- **Value Objects**: `OrderId`, `Price`, `Amount`, `Symbol` with validation
- **Business Logic**: Type-safe operations and domain rules
- **Immutable Design**: Functional programming principles
#### โ๏ธ **Core Layer** (`core/`)
- **API Client**: Clean Bitfinex API wrapper with POST_ONLY enforcement
- **Trading Facade**: Unified interface coordinating focused components
- **Order Management**: Sophisticated order lifecycle management
- **Validation**: Multi-layer validation system
## ๐ ๏ธ Installation
### Production Installation
```bash
# Install with pipx (recommended)
pipx install bitfinex-maker-kit
# Configure API credentials
echo 'BITFINEX_API_KEY=your_api_key_here' > .env
echo 'BITFINEX_API_SECRET=your_api_secret_here' >> .env
```
### Development Installation
**Recommended: One-Command Setup** (solves externally-managed-environment errors)
```bash
# Clone repository
git clone https://github.com/0xferit/bitfinex-maker-kit.git
cd bitfinex-maker-kit
# One-command setup (creates venv + installs everything)
make setup
# Activate virtual environment (if not already active)
source venv/bin/activate # On Windows: venv\Scripts\activate
# Verify installation
make quality # Run all quality checks
pytest # Run tests
```
**Alternative: Using pipx** (for tool installation)
```bash
# Install as isolated application
pipx install git+https://github.com/0xferit/bitfinex-maker-kit.git
# For development
git clone https://github.com/0xferit/bitfinex-maker-kit.git
cd bitfinex-maker-kit
pipx install -e .
```
**Manual Installation** (if virtual environment setup fails)
```bash
# Option 1: Force install (not recommended)
pip install -e ".[dev]" --break-system-packages
# Option 2: User install
pip install -e ".[dev]" --user
# Option 3: Traditional virtual environment
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install
```
**๐ก Troubleshooting "externally-managed-environment" Error:**
- **Modern Python/macOS**: Use virtual environment (recommended above)
- **System Python**: Use `pipx` for isolated installation
- **Docker**: Use the provided Dockerfile for containerized development
## ๐ Quick Start
### Basic Usage
```bash
# Test API connection
maker-kit test
# View wallet balances
maker-kit wallet
# List active orders
maker-kit list
# Get help
maker-kit --help
```
### Market Making
```bash
# Create symmetric market making orders
maker-kit market-make --symbol tBTCUSD --levels 5 --spread 1.0 --size 0.1
# Start automated market making
maker-kit market-make --symbol tBTCUSD --levels 5
# Fill spread gaps
maker-kit fill-spread --symbol tETHUSD --levels 10
```
### Advanced Features
```bash
# Dry-run mode (recommended for testing)
maker-kit market-make --symbol tBTCUSD --levels 3 --dry-run
# Custom order placement
maker-kit put --symbol tBTCUSD --amount 0.01 --price 50000.0 --side buy
# Batch order cancellation
maker-kit cancel --symbol tBTCUSD --side buy
# Cancel all orders for a symbol
maker-kit cancel --all --symbol tBTCUSD
```
#### ๐งฉ **Strategies Layer** (`strategies/`)
- **Order Generation**: Flexible order generation strategies
Update strategies are handled directly by the API client (atomic update if available) or cancel-recreate fallback.
- **Strategy Factory**: Dynamic strategy selection based on market conditions
#### ๐ **WebSocket Layer** (`websocket/`)
- **Connection Manager**: Robust WebSocket connection handling
- **Event Handler**: Real-time order updates and market data
- **Async Event Loop**: Non-blocking event processing
#### ๐ฅ๏ธ **UI Layer** (`ui/`)
- **Market Maker Console**: Interactive trading interface
- **Performance Dashboard**: Real-time metrics visualization
- **Profiler Integration**: Memory and performance monitoring
#### โ๏ธ **Configuration Layer** (`config/`)
- **Environment Management**: Development, staging, production configs
- **Trading Configuration**: Dynamic configuration with validation
- **Feature Flags**: Environment-specific feature control
## ๐ Available Commands
| Command | Description | Architecture Features |
|---------|-------------|----------------------|
| `test` | Test API connection | Service container validation, credential testing |
| `wallet` | Show wallet balances | Real-time balance with caching and formatting |
| `list` | List active orders | Advanced filtering, display helpers, pagination |
| `cancel` | Cancel orders | Bulk operations, criteria matching, dry-run support, --all flag |
| `put` | Place single order | Domain validation, order builder pattern |
| `market-make` | Create staircase orders | Strategy-based generation, symmetric placement |
| `fill-spread` | Fill bid-ask gaps | Market data analysis, intelligent spacing |
| `update` | Update existing orders | Multiple update strategies, WebSocket optimization |
## ๐งช Testing & Quality Assurance
### Comprehensive Test Architecture
#### **Test Categories**
- **Unit Tests** (`tests/unit/`): Isolated component testing with mocks
- **Integration Tests** (`tests/integration/`): Service interaction validation
- **Property Tests** (`tests/property/`): Hypothesis-based fuzzing and edge cases
- **Load Tests** (`tests/load/`): Stress testing and traffic pattern simulation
- **Performance Tests** (`tests/performance/`): Benchmark suite with regression detection
- **Benchmarks** (`tests/benchmarks/`): Comprehensive performance analysis
#### **Test Infrastructure**
- **Fixtures** (`tests/fixtures/`): Reusable test data (API responses, market data, trading scenarios)
- **Mocks** (`tests/mocks/`): Service mocks (API, client, trading service, WebSocket)
- **Utilities** (`tests/utilities/`): Test helpers and profiling tools
#### **Specialized Testing**
- **POST_ONLY Enforcement**: Architectural safety validation
- **Python Version Compliance**: Version requirement testing
- **Wrapper Architecture**: API boundary validation
### Running Tests
```bash
# Run all tests with coverage
pytest --cov=bitfinex_maker_kit --cov-report=html
# Run specific test categories
pytest tests/unit/ # Unit tests
pytest tests/integration/ # Integration tests
pytest tests/property/ # Property-based tests
pytest tests/load/ # Load and stress tests
pytest tests/performance/ # Performance benchmarks
# Run with markers
pytest -m unit # Unit tests only
pytest -m integration # Integration tests
pytest -m property # Property-based tests
pytest -m load # Load tests
pytest -m benchmark # Performance benchmarks
# Run specific architectural tests
pytest tests/test_post_only_enforcement.py # Safety validation
pytest tests/test_python_version_requirement.py # Version compliance
```
### Code Quality - Simple Workflow
**Three commands for everything:**
```bash
# Quick setup
make install # Install all dev dependencies
# Main workflow
make quality # Run all quality checks (recommended)
make test # Run tests with coverage
# Individual checks (if needed)
make format # Auto-format code
make lint # Run linter with auto-fix
make type-check # Run type checking
make security # Run security scan
```
**Alternative: Direct commands**
```bash
# All-in-one linter and formatter (replaces black, isort, flake8)
ruff check . --fix # Lint with auto-fix
ruff format . # Format code
# Type checking and security
mypy bitfinex_maker_kit/ # Type checking
bandit -r bitfinex_maker_kit/ # Security scan
```
**Quick validation** (30 seconds):
```bash
./scripts/check.sh # Fast pre-commit check
```
## ๐ Performance Monitoring & Observability
### Built-in Performance Infrastructure
#### **Performance Monitor Service** (`services/performance_monitor.py`)
- **Real-Time Metrics**: P50, P95, P99 percentiles for API operations
- **Error Tracking**: Success/failure rates with categorization
- **Resource Monitoring**: CPU and memory tracking
#### **Profiler Utilities** (`utilities/profiler.py`)
- **Execution Profiling**: Function-level performance analysis
- **Memory Monitoring**: Detailed memory usage tracking
- **Bottleneck Detection**: Automated performance regression alerts
- **Resource Utilization**: CPU, memory, and I/O monitoring
#### **Performance Dashboard** (`utilities/performance_dashboard.py`)
- **Real-Time Visualization**: Live metrics display
- **Historical Analysis**: Performance trend tracking
- **Alert System**: Automated threshold-based notifications (API time, errors, CPU, memory)
- **Export Capabilities**: JSON, CSV data export
#### **Market Data Policy**
- Live data only for trading decisions; no caching in trading paths
- UI/monitoring may query public endpoints directly without persistence
### Using Performance Tools
```bash
# Enable performance monitoring in commands
maker-kit market-make --enable-monitoring
# View performance metrics (via dashboard integration)
# Dashboard accessible through market-make UI console
# Load and stress testing
pytest tests/load/ -v
```
## ๐ Security Features
### Built-in Security
- **POST_ONLY Orders**: Market orders architecturally impossible
- **API Key Protection**: Secure credential management
- **Input Validation**: Comprehensive parameter validation
- **Rate Limiting**: API abuse prevention
- **Audit Logging**: Complete operation tracking
### Security Scanning
- **Dependency Scanning**: Automated vulnerability detection
- **Code Analysis**: Static security analysis with Bandit
- **Secret Detection**: Credential leak prevention
- **License Compliance**: MIT license for maximum flexibility
## ๐ณ Docker Deployment
### Docker Usage
```bash
# Build image
docker build -t maker-kit .
# Run container
docker run -d \
--name maker-kit \
-e BITFINEX_API_KEY=your_key \
-e BITFINEX_API_SECRET=your_secret \
maker-kit
# View logs
docker logs maker-kit
```
### Docker Compose
```yaml
version: '3.8'
services:
maker-kit:
build: .
environment:
- BITFINEX_API_KEY=${BITFINEX_API_KEY}
- BITFINEX_API_SECRET=${BITFINEX_API_SECRET}
volumes:
- ./logs:/app/logs
restart: unless-stopped
```
## ๐ Robustness Metrics
- **API Response Time**: P95/P99 latency
- **Error Rate**: Success/failure ratio
- **CPU Usage**: Process CPU percent
- **Memory Usage**: RSS/MB
## ๐ค Contributing
### Development Setup
```bash
# Install development dependencies
pip install -e ".[dev,test,security]"
# Install pre-commit hooks
pre-commit install
# Run full test suite
tox
```
### Code Standards
- **Python 3.12+** required
- **Type hints** mandatory
- **100% test coverage** for new features
- **Security review** for all changes
- **Performance benchmarks** for optimizations
### Pull Request Process
1. Fork the repository
2. Create feature branch: `git checkout -b feature/amazing-feature`
3. Make changes with tests and documentation
4. Run quality checks: `tox`
5. Submit pull request with detailed description
## ๐ Codebase Structure
### Directory Organization
```
bitfinex_maker_kit/
โโโ __init__.py # Package entry point and exports
โโโ cli/ # CLI interface (argument parsing and routing)
โโโ cli/ # CLI-specific components
โ โโโ argument_parser.py # Command-line argument parsing
โ โโโ command_router.py # Command routing logic
โโโ commands/ # Individual command implementations
โ โโโ core/ # Command abstractions and patterns
โ โ โโโ base_command.py # Base command interface
โ โ โโโ command_executor.py # Command execution framework
โ โ โโโ command_result.py # Result handling
โ โ โโโ [specialized_commands] # Command implementations
โ โโโ [individual_commands].py # Main CLI commands
โโโ core/ # Core business logic
โ โโโ api_client.py # Clean Bitfinex API wrapper
โ โโโ order_update_service.py # Deprecated shim; use TradingService.update_order
โ โโโ order_manager.py # Order lifecycle management
โ โโโ order_validator.py # Multi-layer validation
โโโ domain/ # Domain objects and business rules
โ โโโ order_id.py # Order identification value object
โ โโโ price.py # Price value object with validation
โ โโโ amount.py # Amount value object with validation
โ โโโ symbol.py # Trading pair symbol validation
โโโ services/ # Service layer with dependency injection
โ โโโ container.py # Dependency injection container
โ โโโ trading_service.py # Core trading operations
โ โโโ cache_service.py # (removed) no caching in trading paths
โ โโโ performance_monitor.py # Real-time metrics collection
โโโ strategies/ # Trading strategy implementations
โ โโโ order_generator.py # Flexible order generation
โโโ update_strategies/ # (deprecated)
โ โโโ cancel_recreate_strategy.py # Cancel-recreate fallback
โโโ websocket/ # WebSocket integration
โ โโโ connection_manager.py # Connection lifecycle
โ โโโ event_handler.py # Real-time event processing
โโโ ui/ # User interface components
โ โโโ market_maker_console.py # Interactive trading console
โโโ config/ # Configuration management
โ โโโ environment.py # Environment-aware configuration
โ โโโ trading_config.py # Trading-specific settings
โโโ utilities/ # Shared utilities and helpers
โโโ [various_utilities].py # Helper functions and utilities
โโโ performance_dashboard.py # Performance visualization
โโโ profiler.py # Performance profiling tools
```
### Key Design Patterns
- **Dependency Injection**: Clean service boundaries with container pattern
- **Command Pattern**: Extensible command system with undo capabilities
- **Strategy Pattern**: Pluggable algorithms for order generation and updates
- **Facade Pattern**: Simplified interfaces over complex subsystems
- **Domain-Driven Design**: Rich domain objects with business logic
## โ ๏ธ Risk Disclaimer
**IMPORTANT**: Trading cryptocurrency involves substantial risk of loss and is not suitable for every investor. The volatile nature of cryptocurrency markets may result in significant financial losses. You should carefully consider whether trading is suitable for you in light of your circumstances, knowledge, and financial resources.
- **Test First**: Always use `--dry-run` mode before live trading
- **Start Small**: Begin with minimal position sizes
- **Monitor Closely**: Actively supervise automated strategies
- **Risk Management**: Never trade more than you can afford to lose
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
### Third-Party Dependencies
All dependencies use compatible permissive licenses (MIT, BSD, Apache-2.0). See [THIRD_PARTY_LICENSES.md](THIRD_PARTY_LICENSES.md) for complete license attributions.
## ๐ Acknowledgments
- **Bitfinex API Team** for comprehensive API documentation
- **Open Source Community** for testing frameworks and tools
- **Security Researchers** for vulnerability disclosure
- **Trading Community** for feature requests and feedback
---
**Ready for Enterprise Trading!** ๐
Start with `maker-kit test` to verify your setup, then explore the comprehensive feature set designed for professional market making.
Raw data
{
"_id": null,
"home_page": null,
"name": "bitfinex-maker-kit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "bitfinex, cryptocurrency, trading, market-making, automated-trading",
"author": "Bitfinex Maker-Kit Contributors",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/be/f7/7684dc448a7631c722edad9537bd134fbd5eab79f1423ed9618a3076127b/bitfinex_maker_kit-4.2.49.tar.gz",
"platform": null,
"description": "# Bitfinex Maker-Kit\n\n> **Modular Market Making Platform for Bitfinex**\n\nA professional, production-ready command-line interface for automated trading and market making on the Bitfinex cryptocurrency exchange. Built with modern software architecture principles including dependency injection, domain-driven design, and comprehensive testing frameworks.\n\n[](https://github.com/0xferit/bitfinex-maker-kit/stargazers)\n[](https://github.com/0xferit/bitfinex-maker-kit/network/members)\n[](https://github.com/0xferit/bitfinex-maker-kit/issues)\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n\n## \ud83c\udfaf Key Features\n\n### \ud83d\udee1\ufe0f Safety-First Architecture\n- **POST_ONLY Enforcement**: Architecturally impossible to place market orders\n- **Dry-Run Mode**: Test strategies without real trading\n- **Multi-Layer Validation**: Domain objects, service layer, and API boundary validation\n- **Risk Management**: Built-in safeguards and confirmation prompts\n\n### \u26a1 Modern Architecture\n- **Dependency Injection**: Clean separation of concerns with container pattern\n- **Domain-Driven Design**: Type-safe domain objects (OrderId, Price, Amount, Symbol)\n- **Service-Oriented**: Modular services (trading, cache, market data, performance monitoring)\n- **Event-Driven**: WebSocket integration with async event handling\n\n### \ud83e\uddea Comprehensive Testing\n- **Property-Based Testing**: 1000+ generated test cases using Hypothesis\n- **Realistic Load Testing**: Integration tests against Bitfinex Paper Trading API\n- **Performance Benchmarking**: Automated regression detection with real network conditions\n- **Security Scanning**: Continuous vulnerability assessment\n\n### \ud83d\ude80 Production Ready\n- **Modular Commands**: Extensible command system with core abstractions\n- **Performance Monitoring**: Real-time metrics and profiling tools (API response time, error rate, CPU, memory)\n- **Configuration Management**: Environment-aware configuration system\n- **Quality Tooling**: Streamlined workflow with Ruff, MyPy, Bandit, and pytest\n\n## \ud83c\udfd7\ufe0f Architecture Overview\n\n### Modern Software Design\n- **Safety First**: Architecturally enforced POST_ONLY orders with multiple validation layers\n- **Modular Design**: Extensible architecture supporting multiple strategies and update methods\n- **Domain-Driven**: Rich domain objects with business logic encapsulation\n- **Service-Oriented**: Clean dependency injection with focused service responsibilities\n\n### Core Architecture Components\n\n#### \ud83c\udfaf **Command Layer** (`commands/`)\n- **Individual Commands**: `test`, `wallet`, `list`, `cancel`, `put`, `market-make`, `fill-spread`, `update`\n- **Core Abstractions**: `core/` with base commands, executors, and result handling\n- **Extensible Design**: Plugin-style command architecture\n\n#### \ud83c\udfdb\ufe0f **Service Layer** (`services/`)\n- **Container**: Dependency injection system managing service lifecycle\n- **Trading Services**: Sync/async trading facades with monitoring\n- **Cache Service**: Intelligent caching with namespace isolation\n- **Performance Monitor**: Real-time metrics collection and analysis\n- **Market Data Service**: Real-time price feeds and historical data\n\n#### \ud83c\udfa8 **Domain Layer** (`domain/`)\n- **Value Objects**: `OrderId`, `Price`, `Amount`, `Symbol` with validation\n- **Business Logic**: Type-safe operations and domain rules\n- **Immutable Design**: Functional programming principles\n\n#### \u2699\ufe0f **Core Layer** (`core/`)\n- **API Client**: Clean Bitfinex API wrapper with POST_ONLY enforcement\n- **Trading Facade**: Unified interface coordinating focused components\n- **Order Management**: Sophisticated order lifecycle management\n- **Validation**: Multi-layer validation system\n\n## \ud83d\udee0\ufe0f Installation\n\n### Production Installation\n```bash\n# Install with pipx (recommended)\npipx install bitfinex-maker-kit\n\n# Configure API credentials\necho 'BITFINEX_API_KEY=your_api_key_here' > .env\necho 'BITFINEX_API_SECRET=your_api_secret_here' >> .env\n```\n\n### Development Installation\n\n**Recommended: One-Command Setup** (solves externally-managed-environment errors)\n```bash\n# Clone repository\ngit clone https://github.com/0xferit/bitfinex-maker-kit.git\ncd bitfinex-maker-kit\n\n# One-command setup (creates venv + installs everything)\nmake setup\n\n# Activate virtual environment (if not already active)\nsource venv/bin/activate # On Windows: venv\\Scripts\\activate\n\n# Verify installation\nmake quality # Run all quality checks\npytest # Run tests\n```\n\n**Alternative: Using pipx** (for tool installation)\n```bash\n# Install as isolated application\npipx install git+https://github.com/0xferit/bitfinex-maker-kit.git\n\n# For development\ngit clone https://github.com/0xferit/bitfinex-maker-kit.git\ncd bitfinex-maker-kit\npipx install -e .\n```\n\n**Manual Installation** (if virtual environment setup fails)\n```bash\n# Option 1: Force install (not recommended)\npip install -e \".[dev]\" --break-system-packages\n\n# Option 2: User install\npip install -e \".[dev]\" --user\n\n# Option 3: Traditional virtual environment\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -e \".[dev]\"\npre-commit install\n```\n\n**\ud83d\udca1 Troubleshooting \"externally-managed-environment\" Error:**\n- **Modern Python/macOS**: Use virtual environment (recommended above)\n- **System Python**: Use `pipx` for isolated installation \n- **Docker**: Use the provided Dockerfile for containerized development\n\n## \ud83d\ude80 Quick Start\n\n### Basic Usage\n```bash\n# Test API connection\nmaker-kit test\n\n# View wallet balances\nmaker-kit wallet\n\n# List active orders\nmaker-kit list\n\n# Get help\nmaker-kit --help\n```\n\n### Market Making\n```bash\n# Create symmetric market making orders\nmaker-kit market-make --symbol tBTCUSD --levels 5 --spread 1.0 --size 0.1\n\n# Start automated market making\nmaker-kit market-make --symbol tBTCUSD --levels 5\n\n# Fill spread gaps\nmaker-kit fill-spread --symbol tETHUSD --levels 10\n```\n\n### Advanced Features\n```bash\n# Dry-run mode (recommended for testing)\nmaker-kit market-make --symbol tBTCUSD --levels 3 --dry-run\n\n# Custom order placement\nmaker-kit put --symbol tBTCUSD --amount 0.01 --price 50000.0 --side buy\n\n# Batch order cancellation\nmaker-kit cancel --symbol tBTCUSD --side buy\n\n# Cancel all orders for a symbol\nmaker-kit cancel --all --symbol tBTCUSD\n```\n\n#### \ud83e\udde9 **Strategies Layer** (`strategies/`)\n- **Order Generation**: Flexible order generation strategies\n \nUpdate strategies are handled directly by the API client (atomic update if available) or cancel-recreate fallback.\n- **Strategy Factory**: Dynamic strategy selection based on market conditions\n\n#### \ud83c\udf10 **WebSocket Layer** (`websocket/`)\n- **Connection Manager**: Robust WebSocket connection handling\n- **Event Handler**: Real-time order updates and market data\n- **Async Event Loop**: Non-blocking event processing\n\n#### \ud83d\udda5\ufe0f **UI Layer** (`ui/`)\n- **Market Maker Console**: Interactive trading interface\n- **Performance Dashboard**: Real-time metrics visualization\n- **Profiler Integration**: Memory and performance monitoring\n\n#### \u2699\ufe0f **Configuration Layer** (`config/`)\n- **Environment Management**: Development, staging, production configs\n- **Trading Configuration**: Dynamic configuration with validation\n- **Feature Flags**: Environment-specific feature control\n\n## \ud83d\udccb Available Commands\n\n| Command | Description | Architecture Features |\n|---------|-------------|----------------------|\n| `test` | Test API connection | Service container validation, credential testing |\n| `wallet` | Show wallet balances | Real-time balance with caching and formatting |\n| `list` | List active orders | Advanced filtering, display helpers, pagination |\n| `cancel` | Cancel orders | Bulk operations, criteria matching, dry-run support, --all flag |\n| `put` | Place single order | Domain validation, order builder pattern |\n| `market-make` | Create staircase orders | Strategy-based generation, symmetric placement |\n| `fill-spread` | Fill bid-ask gaps | Market data analysis, intelligent spacing |\n| `update` | Update existing orders | Multiple update strategies, WebSocket optimization |\n\n## \ud83e\uddea Testing & Quality Assurance\n\n### Comprehensive Test Architecture\n\n#### **Test Categories**\n- **Unit Tests** (`tests/unit/`): Isolated component testing with mocks\n- **Integration Tests** (`tests/integration/`): Service interaction validation\n- **Property Tests** (`tests/property/`): Hypothesis-based fuzzing and edge cases\n- **Load Tests** (`tests/load/`): Stress testing and traffic pattern simulation\n- **Performance Tests** (`tests/performance/`): Benchmark suite with regression detection\n- **Benchmarks** (`tests/benchmarks/`): Comprehensive performance analysis\n\n#### **Test Infrastructure**\n- **Fixtures** (`tests/fixtures/`): Reusable test data (API responses, market data, trading scenarios)\n- **Mocks** (`tests/mocks/`): Service mocks (API, client, trading service, WebSocket)\n- **Utilities** (`tests/utilities/`): Test helpers and profiling tools\n\n#### **Specialized Testing**\n- **POST_ONLY Enforcement**: Architectural safety validation\n- **Python Version Compliance**: Version requirement testing\n- **Wrapper Architecture**: API boundary validation\n\n### Running Tests\n```bash\n# Run all tests with coverage\npytest --cov=bitfinex_maker_kit --cov-report=html\n\n# Run specific test categories\npytest tests/unit/ # Unit tests\npytest tests/integration/ # Integration tests \npytest tests/property/ # Property-based tests\npytest tests/load/ # Load and stress tests\npytest tests/performance/ # Performance benchmarks\n\n# Run with markers\npytest -m unit # Unit tests only\npytest -m integration # Integration tests\npytest -m property # Property-based tests\npytest -m load # Load tests\npytest -m benchmark # Performance benchmarks\n\n# Run specific architectural tests\npytest tests/test_post_only_enforcement.py # Safety validation\npytest tests/test_python_version_requirement.py # Version compliance\n```\n\n### Code Quality - Simple Workflow\n\n**Three commands for everything:**\n```bash\n# Quick setup\nmake install # Install all dev dependencies\n\n# Main workflow \nmake quality # Run all quality checks (recommended)\nmake test # Run tests with coverage\n\n# Individual checks (if needed)\nmake format # Auto-format code\nmake lint # Run linter with auto-fix\nmake type-check # Run type checking\nmake security # Run security scan\n```\n\n**Alternative: Direct commands**\n```bash\n# All-in-one linter and formatter (replaces black, isort, flake8)\nruff check . --fix # Lint with auto-fix\nruff format . # Format code\n\n# Type checking and security\nmypy bitfinex_maker_kit/ # Type checking\nbandit -r bitfinex_maker_kit/ # Security scan\n```\n\n**Quick validation** (30 seconds):\n```bash\n./scripts/check.sh # Fast pre-commit check\n```\n\n## \ud83d\udcca Performance Monitoring & Observability\n\n### Built-in Performance Infrastructure\n\n#### **Performance Monitor Service** (`services/performance_monitor.py`)\n- **Real-Time Metrics**: P50, P95, P99 percentiles for API operations\n- **Error Tracking**: Success/failure rates with categorization\n- **Resource Monitoring**: CPU and memory tracking\n\n#### **Profiler Utilities** (`utilities/profiler.py`)\n- **Execution Profiling**: Function-level performance analysis\n- **Memory Monitoring**: Detailed memory usage tracking\n- **Bottleneck Detection**: Automated performance regression alerts\n- **Resource Utilization**: CPU, memory, and I/O monitoring\n\n#### **Performance Dashboard** (`utilities/performance_dashboard.py`)\n- **Real-Time Visualization**: Live metrics display\n- **Historical Analysis**: Performance trend tracking\n- **Alert System**: Automated threshold-based notifications (API time, errors, CPU, memory)\n- **Export Capabilities**: JSON, CSV data export\n\n#### **Market Data Policy**\n- Live data only for trading decisions; no caching in trading paths\n- UI/monitoring may query public endpoints directly without persistence\n\n### Using Performance Tools\n```bash\n# Enable performance monitoring in commands\nmaker-kit market-make --enable-monitoring\n\n# View performance metrics (via dashboard integration)\n# Dashboard accessible through market-make UI console\n\n# Load and stress testing\npytest tests/load/ -v\n```\n\n## \ud83d\udd12 Security Features\n\n### Built-in Security\n- **POST_ONLY Orders**: Market orders architecturally impossible\n- **API Key Protection**: Secure credential management\n- **Input Validation**: Comprehensive parameter validation\n- **Rate Limiting**: API abuse prevention\n- **Audit Logging**: Complete operation tracking\n\n### Security Scanning\n- **Dependency Scanning**: Automated vulnerability detection\n- **Code Analysis**: Static security analysis with Bandit\n- **Secret Detection**: Credential leak prevention\n- **License Compliance**: MIT license for maximum flexibility\n\n## \ud83d\udc33 Docker Deployment\n\n### Docker Usage\n```bash\n# Build image\ndocker build -t maker-kit .\n\n# Run container\ndocker run -d \\\n --name maker-kit \\\n -e BITFINEX_API_KEY=your_key \\\n -e BITFINEX_API_SECRET=your_secret \\\n maker-kit\n\n# View logs\ndocker logs maker-kit\n```\n\n### Docker Compose\n```yaml\nversion: '3.8'\nservices:\n maker-kit:\n build: .\n environment:\n - BITFINEX_API_KEY=${BITFINEX_API_KEY}\n - BITFINEX_API_SECRET=${BITFINEX_API_SECRET}\n volumes:\n - ./logs:/app/logs\n restart: unless-stopped\n```\n\n## \ud83d\udcc8 Robustness Metrics\n\n- **API Response Time**: P95/P99 latency\n- **Error Rate**: Success/failure ratio\n- **CPU Usage**: Process CPU percent\n- **Memory Usage**: RSS/MB\n\n## \ud83e\udd1d Contributing\n\n### Development Setup\n```bash\n# Install development dependencies\npip install -e \".[dev,test,security]\"\n\n# Install pre-commit hooks\npre-commit install\n\n# Run full test suite\ntox\n```\n\n### Code Standards\n- **Python 3.12+** required\n- **Type hints** mandatory\n- **100% test coverage** for new features\n- **Security review** for all changes\n- **Performance benchmarks** for optimizations\n\n### Pull Request Process\n1. Fork the repository\n2. Create feature branch: `git checkout -b feature/amazing-feature`\n3. Make changes with tests and documentation\n4. Run quality checks: `tox`\n5. Submit pull request with detailed description\n\n## \ud83d\udcd6 Codebase Structure\n\n### Directory Organization\n```\nbitfinex_maker_kit/\n\u251c\u2500\u2500 __init__.py # Package entry point and exports\n\u251c\u2500\u2500 cli/ # CLI interface (argument parsing and routing)\n\u251c\u2500\u2500 cli/ # CLI-specific components\n\u2502 \u251c\u2500\u2500 argument_parser.py # Command-line argument parsing\n\u2502 \u2514\u2500\u2500 command_router.py # Command routing logic\n\u251c\u2500\u2500 commands/ # Individual command implementations\n\u2502 \u251c\u2500\u2500 core/ # Command abstractions and patterns\n\u2502 \u2502 \u251c\u2500\u2500 base_command.py # Base command interface\n\u2502 \u2502 \u251c\u2500\u2500 command_executor.py # Command execution framework\n\u2502 \u2502 \u251c\u2500\u2500 command_result.py # Result handling\n\u2502 \u2502 \u2514\u2500\u2500 [specialized_commands] # Command implementations\n\u2502 \u2514\u2500\u2500 [individual_commands].py # Main CLI commands\n\u251c\u2500\u2500 core/ # Core business logic\n\u2502 \u251c\u2500\u2500 api_client.py # Clean Bitfinex API wrapper\n\u2502 \u251c\u2500\u2500 order_update_service.py # Deprecated shim; use TradingService.update_order\n\u2502 \u251c\u2500\u2500 order_manager.py # Order lifecycle management\n\u2502 \u2514\u2500\u2500 order_validator.py # Multi-layer validation\n\u251c\u2500\u2500 domain/ # Domain objects and business rules\n\u2502 \u251c\u2500\u2500 order_id.py # Order identification value object\n\u2502 \u251c\u2500\u2500 price.py # Price value object with validation\n\u2502 \u251c\u2500\u2500 amount.py # Amount value object with validation\n\u2502 \u2514\u2500\u2500 symbol.py # Trading pair symbol validation\n\u251c\u2500\u2500 services/ # Service layer with dependency injection\n\u2502 \u251c\u2500\u2500 container.py # Dependency injection container\n\u2502 \u251c\u2500\u2500 trading_service.py # Core trading operations\n\u2502 \u251c\u2500\u2500 cache_service.py # (removed) no caching in trading paths\n\u2502 \u2514\u2500\u2500 performance_monitor.py # Real-time metrics collection\n\u251c\u2500\u2500 strategies/ # Trading strategy implementations\n\u2502 \u2514\u2500\u2500 order_generator.py # Flexible order generation\n\u251c\u2500\u2500 update_strategies/ # (deprecated)\n\u2502 \u2514\u2500\u2500 cancel_recreate_strategy.py # Cancel-recreate fallback\n\u251c\u2500\u2500 websocket/ # WebSocket integration\n\u2502 \u251c\u2500\u2500 connection_manager.py # Connection lifecycle\n\u2502 \u2514\u2500\u2500 event_handler.py # Real-time event processing\n\u251c\u2500\u2500 ui/ # User interface components\n\u2502 \u2514\u2500\u2500 market_maker_console.py # Interactive trading console\n\u251c\u2500\u2500 config/ # Configuration management\n\u2502 \u251c\u2500\u2500 environment.py # Environment-aware configuration\n\u2502 \u2514\u2500\u2500 trading_config.py # Trading-specific settings\n\u2514\u2500\u2500 utilities/ # Shared utilities and helpers\n \u251c\u2500\u2500 [various_utilities].py # Helper functions and utilities\n \u251c\u2500\u2500 performance_dashboard.py # Performance visualization\n \u2514\u2500\u2500 profiler.py # Performance profiling tools\n```\n\n### Key Design Patterns\n- **Dependency Injection**: Clean service boundaries with container pattern\n- **Command Pattern**: Extensible command system with undo capabilities \n- **Strategy Pattern**: Pluggable algorithms for order generation and updates\n- **Facade Pattern**: Simplified interfaces over complex subsystems\n- **Domain-Driven Design**: Rich domain objects with business logic\n\n## \u26a0\ufe0f Risk Disclaimer\n\n**IMPORTANT**: Trading cryptocurrency involves substantial risk of loss and is not suitable for every investor. The volatile nature of cryptocurrency markets may result in significant financial losses. You should carefully consider whether trading is suitable for you in light of your circumstances, knowledge, and financial resources.\n\n- **Test First**: Always use `--dry-run` mode before live trading\n- **Start Small**: Begin with minimal position sizes\n- **Monitor Closely**: Actively supervise automated strategies\n- **Risk Management**: Never trade more than you can afford to lose\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n### Third-Party Dependencies\nAll dependencies use compatible permissive licenses (MIT, BSD, Apache-2.0). See [THIRD_PARTY_LICENSES.md](THIRD_PARTY_LICENSES.md) for complete license attributions.\n\n## \ud83d\ude4f Acknowledgments\n\n- **Bitfinex API Team** for comprehensive API documentation\n- **Open Source Community** for testing frameworks and tools\n- **Security Researchers** for vulnerability disclosure\n- **Trading Community** for feature requests and feedback\n\n---\n\n**Ready for Enterprise Trading!** \ud83d\ude80\n\nStart with `maker-kit test` to verify your setup, then explore the comprehensive feature set designed for professional market making. \n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Professional market making toolkit for Bitfinex cryptocurrency exchange",
"version": "4.2.49",
"project_urls": null,
"split_keywords": [
"bitfinex",
" cryptocurrency",
" trading",
" market-making",
" automated-trading"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "866f302837ae6a0917160590a06113b808771c0dff44d8bb4676cb8e3de47165",
"md5": "fc1203341cab6a265fc3ac41dc9139df",
"sha256": "93f4d729dcdbe10ae3e48bc0518356ff5e6f8aec9d4230d83b63e10262e846d9"
},
"downloads": -1,
"filename": "bitfinex_maker_kit-4.2.49-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fc1203341cab6a265fc3ac41dc9139df",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 180894,
"upload_time": "2025-08-17T00:09:49",
"upload_time_iso_8601": "2025-08-17T00:09:49.738208Z",
"url": "https://files.pythonhosted.org/packages/86/6f/302837ae6a0917160590a06113b808771c0dff44d8bb4676cb8e3de47165/bitfinex_maker_kit-4.2.49-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bef77684dc448a7631c722edad9537bd134fbd5eab79f1423ed9618a3076127b",
"md5": "9bdd62b601da389da54318f2df37392c",
"sha256": "f5b52498f44369f8c0d5382804ad0b363d1c1aecdc6fc8de44bb04aaaff32e5e"
},
"downloads": -1,
"filename": "bitfinex_maker_kit-4.2.49.tar.gz",
"has_sig": false,
"md5_digest": "9bdd62b601da389da54318f2df37392c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 148178,
"upload_time": "2025-08-17T00:09:50",
"upload_time_iso_8601": "2025-08-17T00:09:50.928738Z",
"url": "https://files.pythonhosted.org/packages/be/f7/7684dc448a7631c722edad9537bd134fbd5eab79f1423ed9618a3076127b/bitfinex_maker_kit-4.2.49.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-17 00:09:50",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "bitfinex-maker-kit"
}