using Managing.Domain.Bots;
using Managing.Domain.Indicators;
using Managing.Domain.Synth.Models;
using static Managing.Common.Enums;
namespace Managing.Application.Abstractions.Services;
///
/// Service interface for Synth prediction business logic and probability calculations
///
public interface ISynthPredictionService
{
///
/// Calculates the probability of price reaching a target within a specified time horizon
///
/// Asset symbol (e.g., "BTC", "ETH")
/// Current market price
/// Target price to reach
/// Time horizon in seconds
/// True for long positions (liquidation when price drops), false for short positions (liquidation when price rises)
/// Synth configuration for this operation
/// Probability as a decimal between 0.0 and 1.0
Task GetProbabilityOfTargetPriceAsync(
string asset,
decimal currentPrice,
decimal targetPrice,
int timeHorizonSeconds,
bool isLongPosition,
SynthConfiguration config);
///
/// Gets probabilities for multiple price thresholds at once
///
/// Asset symbol
/// Current market price
/// Dictionary of threshold names to prices
/// Time horizon in seconds
/// True for long positions, false for short positions
/// Synth configuration for this operation
/// Parameter for backtest
/// Signal date
/// Dictionary of threshold names to probabilities
Task> GetMultipleThresholdProbabilitiesAsync(
string asset,
decimal currentPrice,
Dictionary priceThresholds,
int timeHorizonSeconds,
bool isLongPosition,
SynthConfiguration config,
bool isBacktest,
DateTime signalDate);
///
/// Clears cached predictions (useful for testing or forced refresh)
///
void ClearCache();
///
/// Clears cached predictions from MongoDB asynchronously
///
Task ClearCacheAsync();
///
/// Validates a trading signal using Synth predictions to check for adverse price movements
///
/// The trading signal containing ticker, direction, candle data, and other context
/// Current market price (required)
/// Bot configuration with Synth settings
/// Whether this is a backtest
/// Custom probability thresholds for decision-making. If null, uses default thresholds.
/// Comprehensive signal validation result including confidence, probabilities, and risk analysis
Task ValidateSignalAsync(LightSignal signal, decimal currentPrice,
TradingBotConfig botConfig, bool isBacktest, Dictionary customThresholds = null);
///
/// Performs risk assessment before opening a position
///
/// Trading ticker
/// Position direction
/// Current market price
/// Bot configuration with Synth settings
/// Whether this is a backtest
/// True if position should be allowed, false if blocked
Task AssessPositionRiskAsync(Ticker ticker, TradeDirection direction, decimal currentPrice,
TradingBotConfig botConfig, bool isBacktest);
///
/// Monitors liquidation risk for an open position
///
/// Trading ticker
/// Position direction
/// Current market price
/// Position liquidation price
/// Position identifier for logging
/// Bot configuration with Synth settings
/// Risk assessment result
Task MonitorPositionRiskAsync(Ticker ticker, TradeDirection direction, decimal currentPrice,
decimal liquidationPrice, Guid positionIdentifier, TradingBotConfig botConfig);
///
/// Estimates liquidation price based on money management settings
///
/// Current market price
/// Position direction
/// Money management settings
/// Estimated liquidation price
decimal EstimateLiquidationPrice(decimal currentPrice, TradeDirection direction,
LightMoneyManagement moneyManagement);
}