LendingHistory.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. using Application.Abstractions.Messaging;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Stocks;
  5. /// <summary>종목 대차거래 시계열 — 단축코드(6자리) 대차잔고·외국인 대여비율 추이 (익명 열람). 종목 상세 대차 차트. SEIBro 수급 수집.</summary>
  6. internal sealed class LendingHistory : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/stocks/{code:regex(^\\d{{6}}$)}/lending", async (
  11. string code,
  12. ISender sender,
  13. DateOnly? from = null,
  14. DateOnly? to = null,
  15. int page = 1,
  16. ushort perPage = 90,
  17. CancellationToken ct = default
  18. ) => {
  19. var result = await sender.Send(new Application.Features.Api.Stocks.GetLendingHistory.Query(code, from, to, page, perPage), ct);
  20. return result.Match(
  21. () => ApiResponse.Ok(result.Value),
  22. CustomResults.Problem
  23. );
  24. })
  25. .WithTags("Stocks")
  26. .AllowAnonymous();
  27. }
  28. }