SeibroUnlistCirclParser.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. namespace Infrastructure.StockData;
  2. /// <summary>
  3. /// SEIBro getUnlistCirclInfo(비상장유통추정) 응답 파서 — 순수 C#. 공용 SeibroXml envelope 입력.
  4. /// ⚠️ 응답엔 STD_DT 가 없다(fixture 확인) — 요청 파라미터(STD_DT)를 수집 배치가 스탬핑한다.
  5. /// ⚠️ 종목종류명 필드는 SECN_KACD_NM (스펙 xlsx 의 SECN_KACA_NM 은 오기 — docs/SEIBro/주식.md §2).
  6. /// 자연키(ISIN)·대표명(REP_SECN_NM) 없는 행은 건너뛴다.
  7. /// </summary>
  8. public static class SeibroUnlistCirclParser
  9. {
  10. public sealed record Row(
  11. string Isin,
  12. string? ShotnIsin,
  13. string RepSecnNm,
  14. string? SecnKacdNm,
  15. long? GenDepoQty,
  16. long? RthingReturnStkqty,
  17. long? AcnttrQty,
  18. bool? IsElectronicSecurity
  19. );
  20. public static IReadOnlyList<Row> Parse(SeibroXml.Envelope envelope)
  21. {
  22. var rows = new List<Row>();
  23. foreach (var fields in envelope.Rows)
  24. {
  25. var isin = SeibroXml.GetOrNull(fields, "ISIN")?.Trim();
  26. var repSecnNm = SeibroXml.GetOrNull(fields, "REP_SECN_NM")?.Trim();
  27. if (string.IsNullOrEmpty(isin) || string.IsNullOrEmpty(repSecnNm))
  28. {
  29. continue;
  30. }
  31. rows.Add(new Row(
  32. isin,
  33. SeibroXml.GetOrNull(fields, "SHOTN_ISIN")?.Trim(),
  34. repSecnNm,
  35. SeibroXml.GetOrNull(fields, "SECN_KACD_NM")?.Trim(),
  36. SeibroFieldParse.Long(SeibroXml.GetOrNull(fields, "GEN_DEPO_QTY")),
  37. SeibroFieldParse.Long(SeibroXml.GetOrNull(fields, "RTHING_RETURN_STKQTY")),
  38. SeibroFieldParse.Long(SeibroXml.GetOrNull(fields, "ACNTTR_QTY")),
  39. SeibroFieldParse.Yn(SeibroXml.GetOrNull(fields, "ELTSC_YN"))
  40. ));
  41. }
  42. return rows;
  43. }
  44. }