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
This commit is contained in:
418
TradingBot/README.md
Normal file
418
TradingBot/README.md
Normal file
@@ -0,0 +1,418 @@
|
||||
# ?? TradingBot
|
||||
|
||||
**Automated Crypto Trading Bot** con interfaccia Blazor Server per trading algoritmico simulato.
|
||||
|
||||
[](https://dotnet.microsoft.com/)
|
||||
[](https://blazor.net/)
|
||||
[](https://www.docker.com/)
|
||||
[](LICENSE)
|
||||
|
||||
---
|
||||
|
||||
## ?? Indice
|
||||
|
||||
- [Caratteristiche](#-caratteristiche)
|
||||
- [Architettura](#-architettura)
|
||||
- [Quick Start](#-quick-start)
|
||||
- [Deployment](#-deployment)
|
||||
- [Sviluppo](#-sviluppo)
|
||||
- [Documentazione](#-documentazione)
|
||||
|
||||
---
|
||||
|
||||
## ? 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
|
||||
|
||||
- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop) (per deployment)
|
||||
- [Visual Studio 2022](https://visualstudio.microsoft.com/) (consigliato) o VS Code
|
||||
|
||||
### Esecuzione Locale
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### ?? Unraid
|
||||
|
||||
Guida completa: [docs/deployment/UNRAID_NATIVE_INSTALL.md](docs/deployment/UNRAID_NATIVE_INSTALL.md)
|
||||
|
||||
**Quick Install**:
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
# Install C# Dev Kit extension
|
||||
# Open folder in VS Code
|
||||
code .
|
||||
|
||||
# F5 per debug
|
||||
```
|
||||
|
||||
### Test Locale
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
- [**Unraid Native Install**](docs/deployment/UNRAID_NATIVE_INSTALL.md) - Installazione su Unraid senza Portainer
|
||||
- [**Docker Compose**](docker-compose.yml) - Configurazione Docker Compose
|
||||
- [**Template Unraid**](deployment/unraid-template.xml) - Template XML per Unraid
|
||||
|
||||
### 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
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
```csharp
|
||||
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`:
|
||||
|
||||
```csharp
|
||||
builder.Services.AddSingleton<ITradingStrategy, MyCustomStrategy>();
|
||||
```
|
||||
|
||||
### Asset Configuration
|
||||
|
||||
Modifica asset supportati in `TradingBotService.cs`:
|
||||
|
||||
```csharp
|
||||
private void InitializeAssetConfigurations()
|
||||
{
|
||||
AssetConfigurations.Add("MYNEWCOIN", new AssetConfiguration
|
||||
{
|
||||
Symbol = "MYNEWCOIN",
|
||||
Name = "My New Coin",
|
||||
TradingAmount = 1000,
|
||||
IsEnabled = true
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ?? Features Roadmap
|
||||
|
||||
### ? Implementato
|
||||
|
||||
- [x] Dashboard con statistiche real-time
|
||||
- [x] Simulazione trading multi-asset
|
||||
- [x] Simple Moving Average strategy
|
||||
- [x] Portfolio management
|
||||
- [x] Trade history
|
||||
- [x] Settings persistenti
|
||||
- [x] Docker support
|
||||
- [x] Unraid template
|
||||
- [x] 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](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)
|
||||
|
||||
- Gitea: [@Alby96](https://gitea.encke-hake.ts.net/Alby96)
|
||||
- Repository: [Encelado/TradingBot](https://gitea.encke-hake.ts.net/Alby96/Encelado)
|
||||
|
||||
---
|
||||
|
||||
## ?? Acknowledgments
|
||||
|
||||
- [Microsoft .NET](https://dotnet.microsoft.com/) - Amazing framework
|
||||
- [Blazor](https://blazor.net/) - Modern web UI
|
||||
- [Bootstrap](https://getbootstrap.com/) - Responsive design
|
||||
- [Docker](https://www.docker.com/) - Containerization
|
||||
- [Gitea](https://gitea.io/) - Self-hosted Git service
|
||||
|
||||
---
|
||||
|
||||
**Made with ?? for algorithmic trading enthusiasts**
|
||||
|
||||
?? **Happy Trading!**
|
||||
Reference in New Issue
Block a user