Skip to content

Latest commit

History

228 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

⚡ IntelliTrader

Algorithmic Crypto Trading That Never Sleeps

.NETBuildTestsCoverageLicenseReleaseDockerStarsCodeFactor


Trade smarter. Execute faster. Sleep better.


Getting StartedFeaturesArchitectureAPIRoadmap


rainbow

🎯 Mission

IntelliTrader empowers traders with an autonomous, signal-driven trading engine that executes strategies 24/7. Built with modern .NET 9, designed for resilience, and architected for extensibility.


🛠 Tech Stack

.NET
.NET 9
Runtime
C#
C# 13
Language
Bootstrap
Bootstrap 5
UI
Docker
Docker
Container
Actions
Actions
CI/CD
🔐
Autofac
IoC/DI
🛡️
Polly v8
Resilience
📡
SignalR
Real-time
📊
OpenTelemetry
Observability

WebSocket
Streaming
📈
TradingView
Signals
💹
Binance
Exchange
📱
Telegram
Alerts
🔒
BCrypt
Security

FluentValidation
Validation

✨ Features

🔄 Trading Modes

  • Virtual paper trading
  • Live exchange execution
  • Seamless mode switching
  • Async order execution

📈 Order Types

  • Market orders
  • Trailing buy/sell
  • ATR-based dynamic stops
  • Pair swapping

💰 DCA Engine

  • 4+ configurable levels
  • Margin-based triggers
  • Kelly Criterion sizing
  • Custom multipliers

📊 Signal Intelligence

  • TradingView integration
  • Multi-timeframe (5m→4h)
  • WebSocket streaming
  • Domain event dispatch

⚙️ Rules Engine

  • Specification pattern
  • Signal-based buy rules
  • Sell/DCA trading rules
  • Hot-reload config

🛡️ Resilience

  • Circuit breakers
  • Exponential backoff
  • Bulkhead isolation
  • Rate limiting

🌐 Web Dashboard

  • SignalR real-time updates
  • Manual controls
  • P&L tracking
  • REST + Minimal APIs

📊 Observability

  • OpenTelemetry tracing
  • Custom metrics
  • Structured logging
  • Health checks

🏛️ Architecture

  • Clean Architecture
  • CQRS pattern
  • Domain Events
  • Pure DI (no statics)

🏗 Architecture

System Overview

flowchart TB
subgraph EXT["☁️ EXTERNAL SERVICES"]
direction LR
TV["📊 TradingView"]
BN["💹 Binance<br/>REST + WebSocket"]
TG["📱 Telegram"]
end
subgraph APP["📦 APPLICATION LAYER"]
direction TB
CMD["Commands<br/>Buy • Sell • Swap"]
QRY["Queries<br/>Portfolio • Pairs"]
DISP["Dispatchers<br/>Command • Query"]
end
subgraph DOMAIN["🎯 DOMAIN LAYER"]
direction TB
AGG["Aggregates<br/>Position • Portfolio"]
EVT["Domain Events<br/>OrderPlaced • Filled"]
SVC["Domain Services<br/>MarginCalc • Validation"]
end
subgraph INFRA["⚙️ INFRASTRUCTURE"]
direction TB
EXCH["Exchange Service<br/>+ Polly Resilience"]
OTEL["OpenTelemetry<br/>Traces • Metrics"]
PERSIST["Persistence<br/>JSON • Files"]
end
subgraph WEB["🌐 PRESENTATION"]
direction TB
HUB["SignalR Hub<br/>Real-time"]
API["REST API<br/>+ Minimal APIs"]
UI["Web Dashboard"]
end
TV -.->|"WebSocket"| INFRA
BN <-->|"REST/WS"| EXCH
TG <-.->|"Bot API"| INFRA
WEB --> APP
APP --> DOMAIN
DOMAIN --> INFRA
EVT -.->|"async"| HUB
style EXT fill:#1a1a2e,stroke:#00d4ff,stroke-width:2px
style APP fill:#16213e,stroke:#00ff88,stroke-width:2px
style DOMAIN fill:#1a1a2e,stroke:#ffd93d,stroke-width:2px
style INFRA fill:#0f3460,stroke:#ff6b6b,stroke-width:2px
style WEB fill:#16213e,stroke:#00d4ff,stroke-width:2px
Loading

CQRS & Domain Events Flow

sequenceDiagram
autonumber
participant UI as 🌐 Dashboard
participant CMD as CommandDispatcher
participant HDL as BuyOrderHandler
participant SVC as TradingService
participant EVT as EventDispatcher
participant HUB as SignalR Hub
rect rgb(26, 26, 46)
note over UI,CMD: Command Dispatch
UI->>CMD: PlaceBuyOrderCommand
CMD->>HDL: Dispatch to handler
end
rect rgb(22, 33, 62)
note over HDL,SVC: Business Logic
HDL->>HDL: Validate command
HDL->>SVC: BuyAsync()
SVC->>SVC: Place order via Polly
end
rect rgb(15, 52, 96)
note over SVC,HUB: Event-Driven Updates
SVC->>EVT: Raise OrderPlacedEvent
EVT-->>HUB: Dispatch async
HUB-->>UI: Push notification
end
Loading

Resilience Pipeline

flowchart LR
subgraph PIPELINE["🛡️ POLLY RESILIENCE PIPELINE"]
direction LR
TO["⏱️ Timeout<br/>30s read / 15s order"]
BH["📦 Bulkhead<br/>10 concurrent"]
CB["🔌 Circuit Breaker<br/>50% failure → open"]
RT["🔄 Retry<br/>3x read / 1x order"]
end
REQ["API Request"] --> TO
TO --> BH
BH --> CB
CB --> RT
RT --> API["Binance API"]
style PIPELINE fill:#1a1a2e,stroke:#00ff88,stroke-width:2px
Loading

Clean Architecture Layers

graph TB
subgraph PRESENTATION["🌐 Presentation"]
WEB["Web Controllers"]
HUB["SignalR Hubs"]
MINI["Minimal APIs"]
end
subgraph APPLICATION["📦 Application"]
CMD["Commands"]
QRY["Queries"]
HDL["Handlers"]
PRT["Ports"]
end
subgraph DOMAIN["🎯 Domain"]
ENT["Entities"]
VAL["Value Objects"]
AGG["Aggregates"]
EVT["Domain Events"]
SPC["Specifications"]
end
subgraph INFRASTRUCTURE["⚙️ Infrastructure"]
EXC["Exchange Adapters"]
PST["Persistence"]
TEL["Telemetry"]
MSG["Messaging"]
end
PRESENTATION --> APPLICATION
APPLICATION --> DOMAIN
INFRASTRUCTURE --> APPLICATION
INFRASTRUCTURE -.->|"implements"| PRT
style PRESENTATION fill:#16213e,stroke:#00d4ff
style APPLICATION fill:#1a1a2e,stroke:#00ff88
style DOMAIN fill:#0f3460,stroke:#ffd93d
style INFRASTRUCTURE fill:#1a1a2e,stroke:#ff6b6b
Loading

Deployment View

C4Deployment
title Deployment Diagram
Deployment_Node(local, "Local Machine", "Windows/Linux/macOS") {
Deployment_Node(runtime, ".NET 9 Runtime") {
Container(bot, "IntelliTrader", "Console App", "Trading engine")
Container(web, "Dashboard", "ASP.NET Core", "Web UI + API")
}
Deployment_Node(storage, "Local Storage") {
ContainerDb(cfg, "Config", "JSON", "Trading rules")
ContainerDb(data, "Data", "JSON", "Positions")
ContainerDb(logs, "Logs", "Serilog", "Structured logs")
}
}
Deployment_Node(cloud, "Cloud Services", "External") {
Container(binance, "Binance", "REST + WS", "Exchange API")
Container(tv, "TradingView", "HTTP", "Signal source")
Container(tg, "Telegram", "Bot API", "Notifications")
}
Loading

🚀 Getting Started

Prerequisites

RequirementVersionNotes
.NET SDK9.0+Download
Binance AccountFor live trading
TradingViewFree tierSignal source

Quick Start

# Clone repository
git clone https://github.com/blackms/IntelliTrader.git
cd IntelliTrader
# Restore & build
dotnet restore
dotnet build
# Run (virtual trading mode)
dotnet run --project IntelliTrader

Access Dashboard

http://localhost:7000

Enable Live Trading

# 1. Encrypt API keys
dotnet run --project IntelliTrader -- \
--encrypt --path keys.bin \
--publickey YOUR_API_KEY \
--privatekey YOUR_API_SECRET
# 2. Update config/trading.json# Set "VirtualTrading": false

Running with Docker

A multi-stage Dockerfile is provided for production-grade containerized deployments. The final image is based on mcr.microsoft.com/dotnet/aspnet:9.0-alpine, runs as a non-root user, and stays under 200 MB.

# Build the image
docker build -t intellitrader:latest .# Run with named volumes for config, data, and logs
docker run -d \
--name intellitrader \
-p 7000:7000 \
-v intellitrader-config:/app/config \
-v intellitrader-data:/app/data \
-v intellitrader-log:/app/log \
intellitrader:latest

Volumes

PathPurpose
/app/configTrading rules, exchange, signals, and web configuration (overrides the baked-in baseline)
/app/dataPersisted runtime state (positions, snapshots)
/app/logSerilog output

Live trading inside Docker — bind-mount an encrypted keys.bin at runtime instead of baking it into the image:

docker run -d \
--name intellitrader \
-p 7000:7000 \
-v $PWD/keys.bin:/app/keys.bin:ro \
-v intellitrader-config:/app/config \
-v intellitrader-data:/app/data \
-v intellitrader-log:/app/log \
intellitrader:latest

Healthcheck — the container exposes a Docker HEALTHCHECK that polls GET /api/health every 30 seconds. The endpoint is anonymous and returns 200 OK whenever the web host is running, so docker inspect / orchestrators can reliably detect liveness.

Running with docker compose

A docker-compose.yml is provided alongside a docker-compose.override.yml for local development. Compose merges them automatically.

# 1. Copy the sample env file and tweak host port / image tag if needed
cp .env.example .env
# 2. Build (first run only) and start in the background
docker compose up -d
# 3. Tail logs
docker compose logs -f
# 4. Stop and remove containers (volumes persist)
docker compose down

Production-like vs development

docker-compose.yml (base)+ docker-compose.override.yml (default)
ASPNETCORE_ENVIRONMENTProductionDevelopment
Config bind mountread-onlyread-write
Log directorynamed volume intellitrader-logbind to ./IntelliTrader/log
Healthcheckevery 30severy 10s

To run with the production-like base only (skipping the dev override):

docker compose -f docker-compose.yml up -d

Live trading inside compose — drop an encrypted keys.bin next to docker-compose.yml and uncomment the corresponding bind mount in the file. The same encryption command shown above for plain Docker applies.

Deploying to Kubernetes with Helm

A Helm chart is provided under deploy/helm/intellitrader/.

# Install (virtual trading, default values)
helm install intellitrader deploy/helm/intellitrader
# Install with custom config overrides
helm install intellitrader deploy/helm/intellitrader \
--set image.repository=ghcr.io/blackms/intellitrader \
--set image.tag=v1.0.0 \
--set-file config.files.trading\\.json=./my-trading.json
# Check the deployment
kubectl get pods -l app.kubernetes.io/name=intellitrader
kubectl logs -f deployment/intellitrader
# Upgrade
helm upgrade intellitrader deploy/helm/intellitrader --reuse-values
# Uninstall
helm uninstall intellitrader

The chart includes Deployment, Service, ConfigMap, Secret, PVC, Ingress (optional), HPA (optional), and ServiceAccount templates. Liveness and readiness probes point at /health/live and /health/ready respectively. See deploy/helm/intellitrader/values.yaml for the full set of configurable parameters.

Note: IntelliTrader is a stateful singleton — the HPA defaults to maxReplicas: 1. Do not scale beyond 1 without external state coordination.

Environment Variable Configuration

All JSON configuration settings can be overridden via environment variables, following 12-factor app principles. Environment variables take precedence over values in JSON config files.

Naming convention:

INTELLITRADER_{Section}__{Key}
INTELLITRADER_{Section}__{NestedObject}__{Key}

The prefix INTELLITRADER_ is stripped automatically. Double underscores (__) map to the : hierarchy separator used by .NET Configuration (this is standard Microsoft.Extensions.Configuration behavior).

Examples:

JSON pathEnvironment variable
core.json > Core.DebugModeINTELLITRADER_Core__DebugMode=false
core.json > Core.InstanceNameINTELLITRADER_Core__InstanceName=Prod
trading.json > Trading.EnabledINTELLITRADER_Trading__Enabled=true
trading.json > Trading.VirtualTradingINTELLITRADER_Trading__VirtualTrading=false
trading.json > Trading.MarketINTELLITRADER_Trading__Market=USDT
exchange.json > Exchange.KeysPathINTELLITRADER_Exchange__KeysPath=/secrets/keys.bin

This works with docker run -e, docker compose environment blocks, Kubernetes env specs, and .env files. See .env.example for a full list of documented overrides.


🔌 API Overview

REST Endpoints

MethodEndpointDescription
GET/api/statusBot status, balance, health
GET/api/signal-namesAvailable signal sources
GET/api/healthHealth check endpoint
POST/api/trading-pairsActive positions
POST/api/market-pairsMarket data + signals
POST/api/market-pairs/filteredFiltered market data
GET/health/liveKubernetes liveness probe
GET/health/readyKubernetes readiness probe

Trading Operations

MethodEndpointDescription
POST/BuyManual buy order
POST/SellManual sell order
POST/SwapSwap position
POST/SettingsUpdate runtime settings

SignalR Hub

// Connect to real-time updatesconstconnection=newsignalR.HubConnectionBuilder().withUrl("/tradingHub").withAutomaticReconnect().build();// Subscribe to eventsconnection.on("StatusUpdate",(status)=>{/* ... */});connection.on("TradingPairsUpdate",(pairs)=>{/* ... */});connection.on("OrderPlaced",(order)=>{/* ... */});

📍 Roadmap

PriorityTaskStatus
P1.NET 9 migration✅ Done
P1Pure DI (remove static locator)✅ Done
P1Polly resilience patterns✅ Done
P1Domain events✅ Done
P1CQRS architecture✅ Done
P1Async throughout✅ Done
P2Multi-exchange support (Kraken, Coinbase)🔲 Planned
P2PostgreSQL persistence option🔲 Planned
P2Event sourcing for positions🔬 Research
P2ML-enhanced signal analysis🔬 Research
P3Kubernetes Helm chart✅ Done
P3GraphQL API layer📋 Backlog
P3Strategy marketplace📋 Backlog

🤝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feat/amazing-feature
  3. Commit with conventional commits: feat:, fix:, docs:
  4. Test changes: dotnet test (1,010 tests must pass)
  5. Push to fork: git push origin feat/amazing-feature
  6. Open Pull Request
# Development commands
dotnet restore # Install dependencies
dotnet test# Run all 1,010 tests
dotnet test --collect:"XPlat Code Coverage"# Run with coverage
dotnet build -c Release # Build for release

⚠️ Disclaimer

Trading cryptocurrency involves substantial risk of loss. This software is provided "AS IS" without warranties. You are solely responsible for trading decisions and potential losses. Always start with virtual trading mode.


📄 License

CC-BY-NC-SA-4.0 — Creative Commons Attribution-NonCommercial-ShareAlike 4.0

CC BY-NC-SA 4.0

  • Non-commercial use only
  • Attribution required
  • Share-alike for derivatives


DocumentationReport BugRequest Feature


Built with 💜 for the trading community


⬆ Back to Top

About

Cryptocurrency trading bot for Binance exchange with virtual/live trading, DCA support, signal-based buying, and web dashboard

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages