Fix: Implement FixPlan part A9, A10, B

This commit is contained in:
Richard
2026-07-10 12:04:27 +02:00
parent 44f48284a2
commit 1787422243
28 changed files with 1025 additions and 79 deletions
@@ -46,6 +46,39 @@ public class PolymarketApiClient
return await ExecuteWithRetryAsync<List<PolymarketTradeResponse>>(_client, url, "Data", ct) ?? [];
}
public async Task<List<PolymarketTradeResponse>> GetTradesPagedAsync(string walletAddress, int limit = 500, CancellationToken ct = default)
{
var allTrades = new List<PolymarketTradeResponse>();
long? endTimestamp = null;
while (true)
{
var url = $"/activity?user={walletAddress}&limit={limit}";
if (endTimestamp.HasValue)
{
url += $"&end={endTimestamp.Value}";
}
var batch = await ExecuteWithRetryAsync<List<PolymarketTradeResponse>>(_client, url, "Data", ct);
if (batch == null || batch.Count == 0)
{
break;
}
allTrades.AddRange(batch);
if (batch.Count < limit)
{
break;
}
var oldestTimestamp = batch.Min(t => t.Timestamp);
endTimestamp = oldestTimestamp - 1;
}
return allTrades;
}
public async Task<List<PolymarketTradeResponse>> GetMarketTradesAsync(string conditionId, int limit = 1000, int offset = 0, CancellationToken ct = default)
{
var url = $"/trades?condition_id={conditionId}&limit={limit}&offset={offset}";