using System;
using NT8.Core.Common.Models;

namespace NT8.Adapters.NinjaTrader
{
    /// <summary>
    /// Data adapter for converting between NT8 and SDK formats
    /// </summary>
    public class NT8DataAdapter
    {
        /// <summary>
        /// Convert NT8 bar data to SDK format
        /// </summary>
        public BarData ConvertToSdkBar(string symbol, DateTime time, double open, double high, double low, double close, long volume, int barSizeMinutes)
        {
            return NT8DataConverter.ConvertBar(symbol, time, open, high, low, close, volume, barSizeMinutes);
        }

        /// <summary>
        /// Convert NT8 account data to SDK format
        /// </summary>
        public AccountInfo ConvertToSdkAccount(double equity, double buyingPower, double dailyPnL, double maxDrawdown, DateTime lastUpdate)
        {
            return NT8DataConverter.ConvertAccount(equity, buyingPower, dailyPnL, maxDrawdown, lastUpdate);
        }

        /// <summary>
        /// Convert NT8 position data to SDK format
        /// </summary>
        public Position ConvertToSdkPosition(string symbol, int quantity, double averagePrice, double unrealizedPnL, double realizedPnL, DateTime lastUpdate)
        {
            return NT8DataConverter.ConvertPosition(symbol, quantity, averagePrice, unrealizedPnL, realizedPnL, lastUpdate);
        }

        /// <summary>
        /// Convert NT8 market session data to SDK format
        /// </summary>
        public MarketSession ConvertToSdkSession(DateTime sessionStart, DateTime sessionEnd, bool isRth, string sessionName)
        {
            return NT8DataConverter.ConvertSession(sessionStart, sessionEnd, isRth, sessionName);
        }

        /// <summary>
        /// Convert NT8 strategy context to SDK format
        /// </summary>
        public StrategyContext ConvertToSdkContext(string symbol, DateTime currentTime, Position currentPosition, AccountInfo account, MarketSession session, System.Collections.Generic.Dictionary<string, object> customData)
        {
            return NT8DataConverter.ConvertContext(symbol, currentTime, currentPosition, account, session, customData);
        }
    }
}
