using KArtSell.Modules.SignalEngine.Domain;

namespace KArtSell.Modules.SignalEngine.Application;

public sealed record SellDecisionContext(
    Guid ContextId,
    Guid PositionLotId,
    Guid CycleId,
    string EvidenceId,
    string DatasetId,
    string ModelVersion,
    string ConfigVersion,
    string CodeSha,
    DateTimeOffset AsOf,
    DateTimeOffset PublishedAtCutoff,
    decimal CurrentSecurityPortfolioWeight,
    decimal CurrentLotPortfolioWeight,
    decimal StrategicCoreFloorWeight,
    bool HardImpairmentApproved,
    bool CapitalFloorBreached,
    decimal SurvivalSellRatioOfLot,
    decimal GapBelowFloorAtr,
    int ConsecutiveCloseBreaches,
    bool CooldownSatisfied,
    decimal ConcentrationSellRatioOfLot,
    decimal OpportunityEdgeLowerBound,
    decimal OpportunitySellRatioOfLot,
    string QualityStatus,
    string ContentHash)
{
    public SellDecisionInput ToDomainInput()
        => new(
            PositionLotId,
            CycleId,
            EvidenceId,
            DatasetId,
            ModelVersion,
            ConfigVersion,
            CodeSha,
            AsOf,
            PublishedAtCutoff,
            CurrentSecurityPortfolioWeight,
            CurrentLotPortfolioWeight,
            StrategicCoreFloorWeight,
            HardImpairmentApproved,
            CapitalFloorBreached,
            SurvivalSellRatioOfLot,
            GapBelowFloorAtr,
            ConsecutiveCloseBreaches,
            CooldownSatisfied,
            ConcentrationSellRatioOfLot,
            OpportunityEdgeLowerBound,
            OpportunitySellRatioOfLot);
}

public interface ISellDecisionContextReader
{
    Task<SellDecisionContext?> GetApprovedAsync(
        Guid positionLotId,
        DateTimeOffset asOf,
        CancellationToken cancellationToken);
}
