Files
Encelado/TradingBot/README.md
Alberto Balbo cc34d2b57f Riorganizzazione deployment, doc e publish automatico
- Spostata tutta la configurazione di deployment in /deployment (docker-compose, unraid-template, guide)
- Aggiunte e aggiornate guide dettagliate: publishing su Gitea, installazione Unraid, struttura progetto
- Migliorato target MSBuild: publish automatico su Gitea Registry da Visual Studio, log dettagliati, condizioni più robuste
- Aggiornato e ampliato .gitignore per escludere build, dati e file locali
- Rimossi file obsoleti dalla root (ora tutto in /deployment)
- Struttura più chiara, zero script esterni, documentazione completa e workflow di deploy semplificato
2025-12-17 23:15:46 +01:00

9.9 KiB

?? TradingBot

Automated Crypto Trading Bot con interfaccia Blazor Server per trading algoritmico simulato.

.NET 10 Blazor Docker License


?? Indice


? Caratteristiche

?? Trading Algoritmico

  • Simple Moving Average (SMA) strategy integrata
  • Analisi tecnica in tempo reale
  • Gestione portfolio automatizzata
  • Simulazione trading senza rischi reali

?? Dashboard Interattiva

  • Blazor Server UI reattiva e moderna
  • Real-time updates ogni 3 secondi
  • Grafici statistiche di performance
  • Gestione asset con configurazione granulare

?? Gestione Completa

  • 15 Criptovalute supportate (BTC, ETH, BNB, etc.)
  • Configurazione per asset (importo, strategia)
  • History completa delle operazioni
  • Settings centralizzate e persistenti

?? Docker-Ready

  • Container ottimizzato per produzione
  • Health checks integrati
  • Volume persistente per dati
  • Gitea Registry integration

??? Architettura

TradingBot/
??? Components/           # Blazor Components
?   ??? Pages/           # Pagine (Dashboard, Market, etc.)
?   ??? Layout/          # Layout e ReconnectModal
?   ??? Shared/          # Componenti condivisi
??? Services/            # Business Logic
?   ??? TradingBotService.cs          # Core service
?   ??? SimulatedMarketDataService.cs # Market data
?   ??? SimpleMovingAverageStrategy.cs # Trading strategy
?   ??? SettingsService.cs            # Persistenza settings
?   ??? TechnicalAnalysis.cs          # Indicatori tecnici
??? Models/              # Data Models
?   ??? Trade.cs
?   ??? MarketPrice.cs
?   ??? TradingSignal.cs
?   ??? ...
??? wwwroot/             # Static assets
?   ??? css/
?   ??? lib/
??? Properties/          # Configuration
?   ??? PublishProfiles/ # Docker publish profiles
?   ??? launchSettings.json
??? docs/                # Documentation
?   ??? deployment/      # Deployment guides
??? Dockerfile           # Docker multi-stage build
??? docker-compose.yml   # Compose configuration
??? Program.cs           # App entry point

?? Data Flow

Market Data ? Analysis ? Signal ? Execution ? Portfolio Update ? UI Refresh
     ?           ?         ?          ?            ?              ?
Simulated    SMA       Buy/Sell   Simulated    Statistics    Dashboard
  Prices   Strategy    Hold       Trade         Update        Update

?? Quick Start

Prerequisiti

Esecuzione Locale

# Clone repository
git clone https://gitea.encke-hake.ts.net/Alby96/Encelado
cd Encelado/TradingBot

# Restore dependencies
dotnet restore

# Run
dotnet run

# Oppure da Visual Studio:
# F5 (Debug) o Ctrl+F5 (senza debug)

Accedi a: http://localhost:5243


?? Deployment

?? Docker

Build & Run Locale

# Build image
docker build -t tradingbot:latest .

# Run container
docker run -d \
  --name tradingbot \
  -p 8080:8080 \
  -v tradingbot-data:/app/data \
  tradingbot:latest

Accedi a: http://localhost:8080

Con Docker Compose

docker-compose up -d

?? Unraid

Guida completa: docs/deployment/UNRAID_NATIVE_INSTALL.md

Quick Install:

# Login Gitea Registry
docker login gitea.encke-hake.ts.net

# Download template
wget -O /boot/config/plugins/dockerMan/templates-user/TradingBot.xml \
  https://gitea.encke-hake.ts.net/Alby96/Encelado/raw/branch/main/TradingBot/deployment/unraid-template.xml

# Install via Unraid Docker UI

?? Gitea Container Registry

Publish da Visual Studio

  1. Build ? Configuration Manager ? Release
  2. Build ? Publish TradingBot
  3. Seleziona profilo "Docker"
  4. Click "Publish"

Visual Studio automaticamente:

  • ? Build immagine Docker
  • ? Tag per Gitea Registry
  • ? Push su gitea.encke-hake.ts.net/alby96/encelado/tradingbot

Pull & Deploy

docker pull gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
docker run -d -p 8080:8080 gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest

?? Sviluppo

Struttura Progetto

  • .NET 10 - Latest .NET version
  • Blazor Server - Interactive server-side rendering
  • C# 14 - Latest language features
  • Bootstrap 5 - Responsive UI framework

Debug

Visual Studio

1. Set startup profile: "TradingBot" (HTTP) o "Docker"
2. F5 per debug con breakpoints
3. Hot Reload abilitato per UI changes

VS Code

# Install C# Dev Kit extension
# Open folder in VS Code
code .

# F5 per debug

Test Locale

# Run senza debug
dotnet run --no-build

# Watch mode (auto-rebuild on changes)
dotnet watch run

Build Configuration

  • Debug: Development, verbose logging, no optimizations
  • Release: Production-ready, optimized, Docker-compatible

?? Documentazione

Guide Deployment

API & Architettura

Services

  • TradingBotService: Core trading logic e portfolio management
  • SimulatedMarketDataService: Generazione dati di mercato simulati
  • SimpleMovingAverageStrategy: Strategia SMA per segnali trading
  • SettingsService: Persistenza configurazioni utente
  • TechnicalAnalysis: Calcolo indicatori tecnici (SMA, EMA, RSI, MACD)

Models

  • Trade: Rappresenta un'operazione di trading
  • MarketPrice: Snapshot prezzo e volume di un asset
  • TradingSignal: Segnale generato dalla strategia (Buy/Sell/Hold)
  • PortfolioStatistics: Statistiche aggregate del portfolio
  • AssetConfiguration: Configurazione per singolo asset

Configurazione

Environment Variables

ASPNETCORE_ENVIRONMENT=Production   # Development|Production
ASPNETCORE_URLS=http://+:8080     # Bind URL
EXTERNAL_PORT=8080                 # External port (docker-compose)

Ports

  • 5243: HTTP (Development)
  • 7241: HTTPS (Development)
  • 8080: HTTP (Production/Docker)

Volumes

  • /app/data: Persistenza dati (settings, trade history)

?? Configurazione Avanzata

Custom Strategy

Implementa ITradingStrategy per creare strategie personalizzate:

public class MyCustomStrategy : ITradingStrategy
{
    public string Name => "My Custom Strategy";
    
    public Task<TradingSignal> AnalyzeAsync(string symbol, List<MarketPrice> prices)
    {
        // Your strategy logic here
        return Task.FromResult(new TradingSignal { ... });
    }
}

Registra nel Program.cs:

builder.Services.AddSingleton<ITradingStrategy, MyCustomStrategy>();

Asset Configuration

Modifica asset supportati in TradingBotService.cs:

private void InitializeAssetConfigurations()
{
    AssetConfigurations.Add("MYNEWCOIN", new AssetConfiguration
    {
        Symbol = "MYNEWCOIN",
        Name = "My New Coin",
        TradingAmount = 1000,
        IsEnabled = true
    });
}

?? Features Roadmap

? Implementato

  • Dashboard con statistiche real-time
  • Simulazione trading multi-asset
  • Simple Moving Average strategy
  • Portfolio management
  • Trade history
  • Settings persistenti
  • Docker support
  • Unraid template
  • Gitea Registry integration

?? In Sviluppo

  • Autenticazione utenti
  • Strategie avanzate (RSI, MACD, Bollinger Bands)
  • Backtesting su dati storici
  • API REST per integrazione esterna
  • Notifiche (email, Telegram)
  • Grafici interattivi (ChartJS/ApexCharts)

?? Pianificato

  • Integrazione exchange reali (Binance, Coinbase)
  • Machine Learning per prediction
  • Multi-utente con isolation
  • Mobile app (MAUI)
  • Advanced analytics dashboard

??? Tecnologie Utilizzate

Backend

  • .NET 10 - Framework applicativo
  • ASP.NET Core - Web server
  • C# 14 - Linguaggio programmazione

Frontend

  • Blazor Server - UI framework
  • Bootstrap 5.3 - CSS framework
  • Bootstrap Icons - Iconografia

Infrastructure

  • Docker - Containerization
  • Gitea - Git repository & Container Registry
  • Unraid - Home server platform

?? License

Questo progetto è rilasciato sotto licenza MIT. Vedi LICENSE per dettagli.


?? Contributi

Contributi, issues e feature requests sono benvenuti!

  1. Fork il progetto
  2. Crea un feature branch (git checkout -b feature/AmazingFeature)
  3. Commit le modifiche (git commit -m 'Add AmazingFeature')
  4. Push al branch (git push origin feature/AmazingFeature)
  5. Apri una Pull Request

?? Autore

Alberto (Alby96)


?? Acknowledgments


Made with ?? for algorithmic trading enthusiasts

?? Happy Trading!