Fix: Implement FixPlan part A9, A10, B
This commit is contained in:
@@ -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}";
|
||||
|
||||
Reference in New Issue
Block a user