An indie quant project to (hopefully?) find alpha on the Monero (XMR) market.
This repository provides a framework for algorithmic trading of Monero (XMR) with:
- Multi-strategy support: Modular architecture for implementing and testing different trading strategies
- Risk management: Position sizing, stop-loss/take-profit, and drawdown monitoring
- Real-time monitoring: Comprehensive logging, metrics collection, and alerting
- Market data integration: CCXT (Kraken) for multi-asset price data (BTC, XMR, ZEC, LTC)
- Exchange integration: CCXT for order execution and portfolio management
- Notifications: Telegram bot for real-time trade alerts and system status
xmr-quant/
βββ shared/ # Shared utilities across all strategies
β βββ config.py # Centralized configuration management
β βββ market_data/ # Market data collection and processing
β βββ exchange/ # Exchange API integration (Kraken)
β βββ risk/ # Risk management and position sizing
β βββ monitoring/ # Logging and metrics collection
β βββ notification/ # Telegram bot for alerts
βββ strategies/ # Trading strategy implementations
β βββ README.md # Strategy development guidelines
βββ .env.example # Environment variable template
βββ requirements.txt # Python dependencies
βββ pyproject.toml # Project configuration
- Python 3.8+
- API keys for:
- Kraken (exchange & market data)
- Telegram Bot (notifications)
-
Clone the repository
git clone https://github.com/xerk-dot/xmr-quant.git cd xmr-quant -
Install dependencies
pip install -r requirements.txt
-
Set up pre-commit hooks (optional but recommended)
./setup_precommit.sh # or manually: pre-commit install -
Configure environment variables
cp .env.example .env # Edit .env with your API keys
Edit .env with your credentials:
# Kraken API
KRAKEN_API_KEY=your_api_key_here
KRAKEN_API_SECRET=your_api_secret_here
# Telegram Bot
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
# Trading Parameters
MAX_POSITION_SIZE=1000.0
MAX_DRAWDOWN_PERCENT=10.0
RISK_PER_TRADE_PERCENT=2.0- CCXTClient: Fetch real-time and historical price data for BTC, XMR, ZEC, LTC via CCXT (defaults to Kraken)
- DataProcessor: Technical indicators (RSI, Bollinger Bands), moving averages, volatility calculations
from shared.market_data import CCXTClient, DataProcessor
client = CCXTClient()
quotes = client.get_latest_quotes(['XMR'])
print(f"XMR Price: ${quotes['XMR']['price']:.2f}")- KrakenClient: Full Kraken API integration for order execution and portfolio management
- Support for market orders, limit orders, order cancellation, and trade history
from shared.exchange import KrakenClient
kraken = KrakenClient()
balance = kraken.get_account_balance()
ticker = kraken.get_ticker('XMRUSD')- RiskManager: Position sizing, stop-loss/take-profit calculation, drawdown monitoring
- Risk metrics: Sharpe ratio, maximum drawdown, win rate
from shared.risk import RiskManager
risk_mgr = RiskManager()
position_size = risk_mgr.calculate_position_size(
portfolio_value=10000,
entry_price=150.0,
stop_loss_price=145.0
)- Logger: Structured logging with file rotation
- MetricsCollector: Track API calls, trade execution, system performance
- TelegramNotifier: Real-time alerts for trades, system status, and performance reports
from shared.notification import TelegramNotifier
notifier = TelegramNotifier()
notifier.send_trade_notification(
symbol='XMR',
side='buy',
price=150.0,
volume=10.0
)The strategies/ directory is designed to house multiple trading strategies, each in its own subdirectory. Strategies are currently under development and will be implemented based on various market analysis approaches.
Each strategy should implement:
- Signal generation based on market data
- Position sizing logic
- Entry/exit criteria
- Backtesting capabilities
See strategies/README.md for detailed development guidelines.
- Technical Analysis: Price action, indicators, chart patterns
- Machine Learning: Predictive models using historical data
- Market Correlation: Cross-asset analysis (BTC correlation, privacy coin dynamics)
- Sentiment Analysis: News and social media sentiment
Individual strategy implementations will be added in future updates.
This project uses pre-commit hooks to ensure code quality:
- Ruff: Fast Python linter and formatter
- Mypy: Static type checking
- Additional checks: Trailing whitespace, YAML validation, private key detection
Run manually:
pre-commit run --all-files# Run all tests (when implemented)
pytest
# Run specific test file
pytest tests/test_strategy.py- pyproject.toml: Ruff and mypy configuration
- requirements.txt: Python dependencies
- .pre-commit-config.yaml: Pre-commit hook configuration
from shared.market_data import CCXTClient
from shared.exchange import KrakenClient
from shared.risk import RiskManager
from shared.monitoring import setup_logger
from shared.notification import TelegramNotifier
# Initialize components
logger = setup_logger('trading_bot')
cmc = CCXTClient()
kraken = KrakenClient()
risk_mgr = RiskManager()
notifier = TelegramNotifier()
# Get market data
quotes = cmc.get_latest_quotes(['XMR'])
xmr_price = quotes['XMR']['price']
# Calculate position size
position_size = risk_mgr.calculate_position_size(
portfolio_value=10000,
entry_price=xmr_price,
stop_loss_price=xmr_price * 0.98 # 2% stop loss
)
# Place order (validation mode)
order = kraken.place_market_order(
pair='XMRUSD',
side='buy',
volume=position_size,
validate=True # Validate without executing
)
# Send notification
notifier.send_trade_notification(
symbol='XMR',
side='buy',
price=xmr_price,
volume=position_size
)- Never commit API keys: Use
.envfile (gitignored) - Pre-commit hooks: Detect private keys before commit
- Validation mode: Test orders without execution
This project is for educational and research purposes. Use at your own risk. Cryptocurrency trading involves substantial risk of loss.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Ensure pre-commit hooks pass
- Submit a pull request
For questions or suggestions, please open an issue on GitHub.
Disclaimer: This software is provided "as is" without warranty. Trading cryptocurrencies carries significant financial risk. Always do your own research and never invest more than you can afford to lose.