fix: KrxDataService HTTPS protocol + Accept headers

- Changed: http:// → https://data-dbg.krx.co.kr
- Added: Accept: application/json header
- Added: Content-Type: application/json; charset=utf-8 header
- Result: HTTP 200 OK (verified with real KRX API)

KRX API now fully functional. Response includes OutBlock_1 with real stock data:
- ISU_CD (stock code)
- ISU_NM (stock name)
- TDD_CLSPRC (closing price)
- ACC_TRDVOL (trading volume)
- Plus: Open/High/Low prices, market cap

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 15:34:09 +09:00
parent 29e037e75c
commit 3953da0993
@@ -19,7 +19,7 @@ public sealed class KrxDataService : IKrxDataService
private const int MaxRetries = 3;
private const int InitialBackoffMs = 100;
private const int MaxBackoffMs = 30000;
private const string KrxApiBaseUrl = "http://data-dbg.krx.co.kr"; // Stock price API (from pykrx-openapi)
private const string KrxApiBaseUrl = "https://data-dbg.krx.co.kr"; // Stock price API (HTTPS, from pykrx-openapi)
private const string KrxApiEndpoint = "/svc/apis/sto/stk_bydd_trd"; // KOSPI daily trading endpoint
private static readonly Action<ILogger, string, DateOnly, DateOnly, Exception?> LogFetchingOhlcv =
@@ -187,6 +187,8 @@ public sealed class KrxDataService : IKrxDataService
{
var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
request.Headers.Add("AUTH_KEY", apiKey);
request.Headers.Add("Accept", "application/json");
request.Content = new StringContent("", System.Text.Encoding.UTF8, "application/json; charset=utf-8");
var response = await _httpClient.SendAsync(request, cancellationToken);