using Managing.Domain.Trades;
using Polly;
using Polly.Retry;
using static Managing.Common.Enums;

namespace Managing.Application.Trading;

public static class TradingPolicies
{
    public static RetryPolicy<Trade> OpenPosition(TradeStatus tradeStatus)
    {
        var policy = Policy
            .HandleResult<Trade>(res => res.Status != tradeStatus)
            .WaitAndRetry(3, retryAttempt => TimeSpan.FromSeconds(3));

        return policy;
    }
}
