using System.ComponentModel.DataAnnotations;
using Managing.Domain.MoneyManagements;
using static Managing.Common.Enums;

namespace Managing.Domain.Bots;

public class TradingBotConfig
{
    [Required] public string AccountName { get; set; }
    [Required] public MoneyManagement MoneyManagement { get; set; }
    [Required] public Ticker Ticker { get; set; }
    [Required] public string ScenarioName { get; set; }
    [Required] public Timeframe Timeframe { get; set; }
    [Required] public bool IsForWatchingOnly { get; set; }
    [Required] public decimal BotTradingBalance { get; set; }
    [Required] public BotType BotType { get; set; }
    [Required] public bool IsForBacktest { get; set; }
    [Required] public int CooldownPeriod { get; set; }
    [Required] public int MaxLossStreak { get; set; }
    [Required] public bool FlipPosition { get; set; }
    [Required] public string Name { get; set; }

    /// <summary>
    /// Maximum time in hours that a position can remain open before being automatically closed.
    /// If null, time-based position closure is disabled.
    /// </summary>
    public decimal? MaxPositionTimeHours { get; set; }

    /// <summary>
    /// When MaxPositionTimeHours is set and this is true, the position will be closed as soon as 
    /// it reaches breakeven or profit, rather than waiting for the full time duration.
    /// If false, the position will only be closed when MaxPositionTimeHours is reached.
    /// Default is false to maintain existing behavior.
    /// </summary>
    public bool CloseEarlyWhenProfitable { get; set; } = false;

    /// <summary>
    /// If true, positions will only be flipped when the current position is in profit.
    /// If false, positions will be flipped regardless of profit status.
    /// Default is true for safer trading.
    /// </summary>
    [Required]
    public bool FlipOnlyWhenInProfit { get; set; } = true;
}