using Managing.Core.FixedSizedQueue;
using Managing.Domain.Accounts;
using Managing.Domain.Bots;
using Managing.Domain.Candles;
using Managing.Domain.Scenarios;
using Managing.Domain.Strategies;
using Managing.Domain.Strategies.Base;
using Managing.Domain.Trades;
using static Managing.Common.Enums;

namespace Managing.Application.Abstractions
{
    public interface ITradingBot : IBot
    {
        TradingBotConfig Config { get; set; }
        Account Account { get; set; }
        HashSet<IStrategy> Strategies { get; set; }
        FixedSizeQueue<Candle> OptimizedCandles { get; set; }
        HashSet<Candle> Candles { get; set; }
        HashSet<Signal> Signals { get; set; }
        List<Position> Positions { get; set; }
        Dictionary<DateTime, decimal> WalletBalances { get; set; }
        Dictionary<StrategyType, StrategiesResultBase> StrategiesValues { get; set; }
        DateTime StartupTime { get; set; }
        DateTime PreloadSince { get; set; }
        int PreloadedCandlesCount { get; set; }
        decimal Fee { get; set; }
        Scenario Scenario { get; set; }

        Task Run();
        Task ToggleIsForWatchOnly();
        int GetWinRate();
        decimal GetProfitAndLoss();
        decimal GetTotalFees();
        void LoadStrategies(IEnumerable<IStrategy> strategies);
        void LoadScenario(string scenarioName);
        void UpdateStrategiesValues();
        Task LoadAccount();
        Task<Position> OpenPositionManually(TradeDirection direction);

        Task CloseTrade(Signal signal, Position position, Trade tradeToClose, decimal lastPrice,
            bool tradeClosingPosition = false);

        /// <summary>
        /// Gets the current trading bot configuration.
        /// </summary>
        /// <returns>A copy of the current configuration</returns>
        TradingBotConfig GetConfiguration();

        /// <summary>
        /// Updates the trading bot configuration with new settings.
        /// </summary>
        /// <param name="newConfig">The new configuration to apply</param>
        /// <returns>True if the configuration was successfully updated, false otherwise</returns>
        Task<bool> UpdateConfiguration(TradingBotConfig newConfig);
    }
}