Nuove: multi-strategy, indicatori avanzati, posizioni
- Sidebar portfolio con metriche dettagliate (Totale, Investito, Disponibile, P&L, ROI) e aggiornamento real-time - Sistema multi-strategia: 8 strategie assegnabili per asset, voting decisionale, pagina Trading Control - Nuova pagina Posizioni: gestione, chiusura manuale, P&L non realizzato, notifiche - Sistema indicatori tecnici: 7+ indicatori configurabili, segnali real-time, raccomandazioni, storico segnali - Refactoring TradingBotService per capitale, P&L, ROI, eventi - Nuovi modelli e servizi per strategie/indicatori, persistenza configurazioni - UI/UX: navigazione aggiornata, widget, modali, responsive - Aggiornamento README e CHANGELOG con tutte le novità
This commit is contained in:
94
TradingBot/Models/IndicatorModels.cs
Normal file
94
TradingBot/Models/IndicatorModels.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
namespace TradingBot.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for a trading indicator
|
||||
/// </summary>
|
||||
public class IndicatorConfig
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public IndicatorType Type { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
// Thresholds for signals
|
||||
public decimal? OverboughtThreshold { get; set; }
|
||||
public decimal? OversoldThreshold { get; set; }
|
||||
public decimal? BuyThreshold { get; set; }
|
||||
public decimal? SellThreshold { get; set; }
|
||||
|
||||
// Indicator-specific parameters
|
||||
public int Period { get; set; } = 14;
|
||||
public int FastPeriod { get; set; } = 12;
|
||||
public int SlowPeriod { get; set; } = 26;
|
||||
public int SignalPeriod { get; set; } = 9;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Real-time indicator signal
|
||||
/// </summary>
|
||||
public class IndicatorSignal
|
||||
{
|
||||
public string IndicatorId { get; set; } = string.Empty;
|
||||
public string IndicatorName { get; set; } = string.Empty;
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
||||
public SignalStrength Strength { get; set; }
|
||||
public SignalType Type { get; set; }
|
||||
public string Message { get; set; } = string.Empty;
|
||||
public decimal? Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicator status for a specific asset
|
||||
/// </summary>
|
||||
public class IndicatorStatus
|
||||
{
|
||||
public string IndicatorId { get; set; } = string.Empty;
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public decimal CurrentValue { get; set; }
|
||||
public decimal? PreviousValue { get; set; }
|
||||
public MarketCondition Condition { get; set; }
|
||||
public string Recommendation { get; set; } = string.Empty;
|
||||
public DateTime LastUpdate { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Types of trading indicators
|
||||
/// </summary>
|
||||
public enum IndicatorType
|
||||
{
|
||||
RSI, // Relative Strength Index
|
||||
MACD, // Moving Average Convergence Divergence
|
||||
SMA, // Simple Moving Average
|
||||
EMA, // Exponential Moving Average
|
||||
BollingerBands, // Bollinger Bands
|
||||
Stochastic, // Stochastic Oscillator
|
||||
Volume, // Volume indicators
|
||||
ATR // Average True Range (volatility)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signal strength levels
|
||||
/// </summary>
|
||||
public enum SignalStrength
|
||||
{
|
||||
Weak,
|
||||
Moderate,
|
||||
Strong,
|
||||
VeryStrong
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Market condition based on indicators
|
||||
/// </summary>
|
||||
public enum MarketCondition
|
||||
{
|
||||
Neutral,
|
||||
Overbought,
|
||||
Oversold,
|
||||
Bullish,
|
||||
Bearish,
|
||||
Ranging,
|
||||
Trending
|
||||
}
|
||||
137
TradingBot/Models/TradingEngine.cs
Normal file
137
TradingBot/Models/TradingEngine.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
namespace TradingBot.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the mapping between an asset and its assigned trading strategies
|
||||
/// </summary>
|
||||
public class AssetStrategyMapping
|
||||
{
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public string AssetName { get; set; } = string.Empty;
|
||||
public List<string> StrategyIds { get; set; } = new();
|
||||
public bool IsActive { get; set; }
|
||||
public DateTime ActivatedAt { get; set; }
|
||||
public DateTime? DeactivatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Strategy-specific parameters override
|
||||
/// Key: StrategyId, Value: Dictionary of parameter names and values
|
||||
/// </summary>
|
||||
public Dictionary<string, Dictionary<string, object>> StrategyParameters { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a trading strategy instance
|
||||
/// </summary>
|
||||
public class StrategyInfo
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string Category { get; set; } = string.Empty; // Trend, Oscillator, Volatility, etc.
|
||||
public StrategyRisk RiskLevel { get; set; }
|
||||
public TimeFrame RecommendedTimeFrame { get; set; }
|
||||
public List<string> RequiredIndicators { get; set; } = new();
|
||||
public Dictionary<string, ParameterInfo> Parameters { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter information for strategy configuration
|
||||
/// </summary>
|
||||
public class ParameterInfo
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public ParameterType Type { get; set; }
|
||||
public object DefaultValue { get; set; } = 0;
|
||||
public object? MinValue { get; set; }
|
||||
public object? MaxValue { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trading engine status for an asset
|
||||
/// </summary>
|
||||
public class TradingEngineStatus
|
||||
{
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public bool IsRunning { get; set; }
|
||||
public int ActiveStrategies { get; set; }
|
||||
public DateTime? LastSignalTime { get; set; }
|
||||
public List<StrategySignal> RecentSignals { get; set; } = new();
|
||||
public TradingDecision? LastDecision { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signal from a specific strategy
|
||||
/// </summary>
|
||||
public class StrategySignal
|
||||
{
|
||||
public string StrategyId { get; set; } = string.Empty;
|
||||
public string StrategyName { get; set; } = string.Empty;
|
||||
public TradingSignal Signal { get; set; } = new();
|
||||
public DateTime GeneratedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggregated trading decision from multiple strategies
|
||||
/// </summary>
|
||||
public class TradingDecision
|
||||
{
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public SignalType Decision { get; set; }
|
||||
public decimal Confidence { get; set; }
|
||||
public string Reason { get; set; } = string.Empty;
|
||||
public int BuyVotes { get; set; }
|
||||
public int SellVotes { get; set; }
|
||||
public int HoldVotes { get; set; }
|
||||
public List<string> SupportingStrategies { get; set; } = new();
|
||||
public List<string> OpposingStrategies { get; set; } = new();
|
||||
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strategy performance metrics
|
||||
/// </summary>
|
||||
public class StrategyPerformance
|
||||
{
|
||||
public string StrategyId { get; set; } = string.Empty;
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public int TotalSignals { get; set; }
|
||||
public int CorrectSignals { get; set; }
|
||||
public decimal Accuracy { get; set; }
|
||||
public decimal TotalProfit { get; set; }
|
||||
public decimal AverageConfidence { get; set; }
|
||||
public DateTime FirstSignalTime { get; set; }
|
||||
public DateTime LastSignalTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Risk level for strategies
|
||||
/// </summary>
|
||||
public enum StrategyRisk
|
||||
{
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
VeryHigh
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recommended time frame for strategy
|
||||
/// </summary>
|
||||
public enum TimeFrame
|
||||
{
|
||||
ShortTerm, // Minutes to hours
|
||||
MediumTerm, // Hours to days
|
||||
LongTerm // Days to weeks
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter data type
|
||||
/// </summary>
|
||||
public enum ParameterType
|
||||
{
|
||||
Integer,
|
||||
Decimal,
|
||||
Boolean,
|
||||
String
|
||||
}
|
||||
@@ -5,6 +5,7 @@ public class TradingSignal
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public SignalType Type { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal Confidence { get; set; } // 0-100 confidence level
|
||||
public string Reason { get; set; } = string.Empty;
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user