using Predictalytics.Domain.Entities;
using Predictalytics.Domain.Enums;

namespace Predictalytics.Domain.Interfaces;

public interface ITradeRepository
{
    Task<Trade?> GetByPlatformTradeIdAsync(PlatformType platform, string platformTradeId, CancellationToken ct = default);
    Task<IReadOnlyList<Trade>> GetByTraderIdAsync(int traderId, int skip = 0, int take = 50, CancellationToken ct = default);
    /// <summary>Fast INT-based market lookup (preferred after DbMarketId backfill).</summary>
    Task<IReadOnlyList<Trade>> GetByDbMarketIdAsync(int dbMarketId, int skip = 0, int take = 50, CancellationToken ct = default);
    /// <summary>String-based fallback for trades not yet linked to a DB market.</summary>
    Task<IReadOnlyList<Trade>> GetByMarketIdAsync(string platformMarketId, int skip = 0, int take = 50, CancellationToken ct = default);
    Task<IReadOnlyList<Trade>> GetRecentAsync(int count = 50, PlatformType? platform = null, CancellationToken ct = default);
    Task<IReadOnlyList<Trade>> GetLargestAsync(int count = 5, DateTime? since = null, CancellationToken ct = default);
    Task<int> GetCountAsync(int? traderId = null, CancellationToken ct = default);
    Task AddRangeAsync(IEnumerable<Trade> trades, CancellationToken ct = default);
    Task<decimal> GetTotalVolumeAsync(DateTime? since = null, CancellationToken ct = default);
    Task<IReadOnlyList<Trade>> GetOrphanedTradesAsync(int limit, CancellationToken ct = default);
    Task<HashSet<string>> GetKnownPlatformTradeIdsAsync(PlatformType platform, int traderId, IEnumerable<string> platformTradeIds, CancellationToken ct = default);
    Task UpdateAsync(Trade trade, CancellationToken ct = default);
    Task<IReadOnlyList<Trade>> GetTradesForContextEnrichmentAsync(int limit, CancellationToken ct = default);
}
