Skip to content

BasicFist/thunes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

72 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

THUNES - Quantitative Crypto Trading System

A quantitative cryptocurrency trading system implementing micro-transaction strategies (DCA, Grid, HFT) with comprehensive risk management and automated execution.

🎯 Project Status

Phase: Phase 13 - Binance Spot Testnet Deployment (Ready for Configuration + DR Drill) Environment: Binance Spot Testnet Strategy: SMA Crossover (baseline) Readiness: 51% current β†’ 72% post-drill β†’ 81% post-rodage Test Coverage: 203/225 tests passing (90.2%)

πŸš€ Quick Links

🧭 Where to Go Next?

πŸ‘€ I'm new to the project β†’ Read README.md (this page, 5 min) β†’ Then START-HERE.md (deployment guide)

πŸš€ I want to deploy Phase 13 to testnet β†’ Go to START-HERE.md β†’ Follow 6-step execution plan (2.5-3 hours)

πŸ” I want to explore the documentation β†’ Go to docs/README.md β†’ Navigate by topic, date, or task

πŸ’» I want to contribute code β†’ Read .github/CONTRIBUTING.md β†’ Follow development workflow

πŸ“Š I want to understand the architecture β†’ Read CLAUDE.md β†’ Review code organization and critical files

πŸ”¬ I want to research ML/AI strategies β†’ Go to docs/research/ β†’ Start with REGULATORY-ML-LANDSCAPE-2025.md

πŸ› I found a bug β†’ Check .github/CONTRIBUTING.md#bug-reports β†’ File issue with template

❓ I have a question β†’ Check docs/phase-13/CONFIGURATION_GUIDE.md (troubleshooting) β†’ Or file issue

πŸ—οΈ Architecture

THUNES/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ backtest/      # Vectorbt backtesting
β”‚   β”œβ”€β”€ optimize/      # Optuna hyperparameter optimization
β”‚   β”œβ”€β”€ live/          # Paper & live trading
β”‚   β”œβ”€β”€ filters/       # Exchange order filters (critical)
β”‚   β”œβ”€β”€ data/          # Data fetching & WebSocket streaming
β”‚   β”œβ”€β”€ alerts/        # Telegram notifications
β”‚   β”œβ”€β”€ risk/          # Risk management (kill-switch, limits)
β”‚   └── utils/         # Logging, config
β”œβ”€β”€ tests/             # Pytest test suite
β”œβ”€β”€ artifacts/         # Backtest results, optimization studies
β”œβ”€β”€ logs/              # Application logs
└── .github/workflows/ # CI/CD pipelines

πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • Binance Spot Testnet account with API keys
  • (Optional) Telegram bot for alerts

Installation

# Clone repository
git clone <your-repo-url>
cd THUNES

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
make install

# Configure environment
cp .env.template .env
# Edit .env with your API keys

Configuration

Edit .env with your credentials:

BINANCE_TESTNET_API_KEY=your_testnet_api_key
BINANCE_TESTNET_API_SECRET=your_testnet_secret
TELEGRAM_BOT_TOKEN=your_telegram_bot_token  # Optional
TELEGRAM_CHAT_ID=your_chat_id  # Optional

Run Backtest (Phase 3)

make backtest
# Output: artifacts/backtest/stats_BTCUSDT_1h.csv

Run Optimization (Phase 4)

make optimize
# Output: artifacts/optuna/study.csv

Run Paper Trading (Phase 5)

make paper
# Executes trades on Binance Testnet if signal detected

πŸ“Š Development Phases

Phase Description Status DoD
0 Prerequisites & Setup βœ… .env configured, testnet account ready
1 Import & Setup βœ… Dependencies installed, pre-commit active
2 Smoke Tests βœ… pytest passes, linting clean
3 Backtest MVP βœ… SMA strategy backtested, stats generated
4 Optimization βœ… Optuna study completed, best params identified
5 Paper Trading βœ… Market orders executed on testnet
6 Order Filters βœ… Tick/step/minNotional validation, no -1013 errors
7 WebSocket Streaming βœ… Real-time bookTicker/aggTrade, reconnection logic
8 Risk Management βœ… Kill-switch, max loss limits, cool-down, audit trail
9 Alerts βœ… Telegram notifications for trades/errors/kill-switch
10 Orchestration βœ… APScheduler jobs, anti-overlap, monitoring
11 Observability 🚧 Prometheus metrics prepared, deployment pending
12 CI/CD βœ… GitHub workflows, quality gates enforced
13 Paper 24/7 🚧 Code complete, ready for configuration + DR drill
14 Micro-Live ⏳ Pending Phase 13 completion (7-day rodage)

Legend: βœ… Complete | 🚧 In Progress | ⏳ Pending

πŸ›‘οΈ Risk Management

Hard Limits (Non-Negotiable):

  • Max loss per trade: 5 USDT
  • Max daily loss: 20 USDT
  • Max concurrent positions: 3
  • Cool-down after loss: 60 minutes

Kill-Switch: Automatically stops trading if daily loss exceeds threshold.

πŸ§ͺ Testing

# Run all tests
make test

# Run linters
make lint

# Format code
make format

# Run pre-commit hooks
make pre-commit

🐳 Docker

# Build image
make docker-build

# Run container
make docker-run

# Stop container
make docker-stop

πŸ“ˆ CI/CD Workflows

  • CI: Runs on push/PR (lint, test, type-check)
  • Backtest: Weekly or on-demand
  • Optimize: Manual trigger only
  • Paper Trading: Every 10 minutes (requires approval)

πŸ” Security

  • Secrets: Stored in GitHub Secrets (never committed)
  • Testnet First: Always test on testnet before production
  • API Permissions: Trading only, no withdrawals
  • Environment Guards: Production mode requires explicit confirmation

πŸ“š Key Technologies

πŸŽ“ Educational Insights

This project implements concepts from quantitative finance and algorithmic trading:

  1. Vectorized Backtesting: Faster than event-driven for strategy validation
  2. Bayesian Optimization: TPE sampler finds optimal parameters efficiently
  3. Exchange Filters: Critical for preventing order rejections (tick/step/notional)
  4. Slippage Modeling: Realistic backtest includes fees + slippage
  5. Kill-Switch Pattern: Prevents runaway losses in production

⚠️ Disclaimer

This software is for educational purposes only. Trading cryptocurrencies carries significant risk. Never trade with money you cannot afford to lose. Always start with testnet/paper trading.

πŸ“ License

MIT License - See LICENSE file for details

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contributor Setup:

# 1. Fork & clone
git clone https://github.com/YOUR_USERNAME/THUNES.git
cd THUNES

# 2. Setup environment
make install-dev
pre-commit install

# 3. Create feature branch
git checkout -b feature/amazing-feature

# 4. Make changes, test, commit
make test && make lint
git commit -m "feat: add amazing feature"

# 5. Push and create PR
git push origin feature/amazing-feature

Read Before Contributing:

πŸ“š Documentation

Explore by Category:

πŸ“ž Support

πŸ“ˆ Project Metrics

Metric Value
Version 0.13.0 (Phase 13 pre-deployment complete)
Test Coverage 203/225 tests passing (90.2%)
Documentation ~78 files, ~35,000 words
Code Quality 85% (excellent)
Deployment Readiness 51% β†’ 72% (post-drill) β†’ 81% (post-rodage)
CI/CD βœ… All quality gates enforced

Built with ❀️ for the quant community | Version 0.13.0 | Last Updated: 2025-10-09

About

Trading platform integration

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages