65 lines
2.5 KiB
C#
65 lines
2.5 KiB
C#
using Predictalytics.Application.Interfaces;
|
|
using Predictalytics.Application.Services;
|
|
|
|
namespace Predictalytics.Api.Endpoints;
|
|
|
|
public static class TraderEndpoints
|
|
{
|
|
public static void MapTraderEndpoints(this WebApplication app)
|
|
{
|
|
var group = app.MapGroup("/api/traders").WithTags("Traders");
|
|
|
|
group.MapGet("/", async (IAnalyticsService svc, int? skip, int? take, string? platform, bool? highlyCopyable, CancellationToken ct) =>
|
|
Results.Ok(await svc.GetTradersAsync(skip ?? 0, take ?? 50, platform, highlyCopyable ?? false, ct)));
|
|
|
|
group.MapGet("/{id:int}", async (int id, IAnalyticsService svc, CancellationToken ct) =>
|
|
{
|
|
var detail = await svc.GetTraderDetailAsync(id, ct);
|
|
return detail is not null ? Results.Ok(detail) : Results.NotFound();
|
|
});
|
|
|
|
group.MapGet("/{id:int}/deep-dive", async (int id, IAnalyticsService svc, CancellationToken ct) =>
|
|
{
|
|
var dd = await svc.GetTraderDeepDiveAsync(id, ct);
|
|
return dd is not null ? Results.Ok(dd) : Results.NotFound();
|
|
});
|
|
|
|
group.MapGet("/{id:int}/positions", async (int id, IAnalyticsService svc, CancellationToken ct) =>
|
|
{
|
|
var positions = await svc.GetTraderPositionsAsync(id, ct);
|
|
return Results.Ok(positions);
|
|
});
|
|
|
|
group.MapPost("/{id:int}/priority", async (int id, int? score, IScoringService svc, CancellationToken ct) =>
|
|
{
|
|
await svc.SetManualOverrideAsync(id, score, ct);
|
|
return Results.Ok();
|
|
});
|
|
|
|
|
|
group.MapPost("/{id:int}/watchlist", async (int id, WatchlistService svc, CancellationToken ct) =>
|
|
{
|
|
await svc.AddAsync(id, "Watched via UI", null, ct);
|
|
return Results.Ok();
|
|
});
|
|
|
|
group.MapDelete("/{id:int}/watchlist", async (int id, WatchlistService svc, CancellationToken ct) =>
|
|
{
|
|
await svc.RemoveByTraderIdAsync(id, ct);
|
|
return Results.Ok();
|
|
});
|
|
|
|
group.MapPost("/{id:int}/ai-analysis", async (int id, bool manual, IAiStrategyAnalysisService aiSvc, CancellationToken ct) =>
|
|
{
|
|
var summary = await aiSvc.AnalyzeTraderStrategyAsync(id, manual, ct);
|
|
return Results.Ok(new { summary });
|
|
});
|
|
|
|
group.MapPost("/", async (string platform, string wallet, IAnalyticsService svc, CancellationToken ct) =>
|
|
{
|
|
var id = await svc.AddTraderAsync(platform, wallet, ct);
|
|
return Results.Ok(new { id });
|
|
});
|
|
}
|
|
}
|