c211c42c6c
✅ Step 1 COMPLETE: API 직접 호출 검증 Validation Results: - Host startup: ASPNETCORE_ENVIRONMENT=Development 설정 필수 - Authentication: DevelopmentHeaderAuthenticationHandler 작동 확인 - Endpoint routing: FastEndpoints 라우팅 정상 - Phase 1 API: POST /api/shadow-runs HTTP 202 Accepted - Execution: runId 688040e2-c481-4fea-9b88-d54a3ec02631, status: Queued - Data mode: Stub data (KRX API 미사용) Window validation: 252 days required (2024-01-02 ~ 2024-09-10) Rate limiting: RateLimiterService 토큰 소비 정상 Next steps: - Step 2: DB 결과 데이터 확인 (shadow_run_metrics) - Step 3: Hangfire 자동화 완전성 검증 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
#!/usr/bin/env dotnet-script
|
|
// Real KRX Data Collection Test
|
|
// 1개 심볼, 1일 실제 데이터 수집
|
|
|
|
#r "nuget: System.Net.Http, 4.3.4"
|
|
|
|
using System;
|
|
using System.Net.Http;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
|
|
var httpClient = new HttpClient();
|
|
var ticker = "005930"; // 삼성전자
|
|
var date = "20240102"; // 2024-01-02
|
|
|
|
Console.WriteLine("=== KRX 실제 데이터 수집 테스트 ===");
|
|
Console.WriteLine($"Ticker: {ticker} (삼성전자)");
|
|
Console.WriteLine($"Date: {date}");
|
|
Console.WriteLine("");
|
|
|
|
try
|
|
{
|
|
// KRX OpenAPI 호출
|
|
var requestUri = "https://data.krx.co.kr/svc/sample/apis/idx/krx_dd_trd";
|
|
var payload = new { basDd = date };
|
|
var json = JsonSerializer.Serialize(payload);
|
|
|
|
Console.WriteLine($"요청: POST {requestUri}");
|
|
Console.WriteLine($"본문: {json}");
|
|
Console.WriteLine("");
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Post, requestUri)
|
|
{
|
|
Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
|
|
};
|
|
|
|
var response = await httpClient.SendAsync(request);
|
|
var responseContent = await response.Content.ReadAsStringAsync();
|
|
|
|
Console.WriteLine($"상태: {response.StatusCode}");
|
|
Console.WriteLine("");
|
|
|
|
if (response.IsSuccessStatusCode)
|
|
{
|
|
Console.WriteLine("✅ KRX API 응답 성공!");
|
|
Console.WriteLine("");
|
|
Console.WriteLine("응답 데이터 (처음 500자):");
|
|
Console.WriteLine(responseContent.Substring(0, Math.Min(500, responseContent.Length)));
|
|
|
|
// 데이터 행 수 세기
|
|
var lines = responseContent.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
|
Console.WriteLine("");
|
|
Console.WriteLine($"데이터 행: {lines.Length}");
|
|
|
|
// 첫 데이터 행 출력
|
|
if (lines.Length > 1)
|
|
{
|
|
Console.WriteLine($"첫 행: {lines[0].Substring(0, Math.Min(100, lines[0].Length))}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine($"❌ API 에러: {response.StatusCode}");
|
|
Console.WriteLine(responseContent);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"❌ 오류: {ex.Message}");
|
|
}
|
|
|
|
Console.WriteLine("");
|
|
Console.WriteLine("테스트 완료.");
|