domesticSummary.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // 국내 증시 요약 도메인 타입 — Backend Application/Features/Api/Stocks/GetDomesticSummary/Response.cs 대응
  2. // 필드명 camelCase. flucRateBp = %×100. (투자자별 순매수·베이시스는 미지원으로 제외)
  3. export interface DomesticIndexRow {
  4. key: string; // kospi | kosdaq | kospi200
  5. name: string;
  6. close: number;
  7. changeVal: number;
  8. flucRateBp: number;
  9. tradeDate: string;
  10. // 등락 종목 수 (코스피/코스닥만; KOSPI200 은 null)
  11. advances?: number|null;
  12. declines?: number|null;
  13. unchanged?: number|null;
  14. limitUp?: number|null;
  15. limitDown?: number|null;
  16. }
  17. export interface DomesticSummaryResponse {
  18. list: DomesticIndexRow[];
  19. }
  20. // 전일비 절대값 — "45.12" (부호/색은 방향으로 별도)
  21. export function formatIndexChange(v: number): string {
  22. return Math.abs(v).toLocaleString('ko-KR', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
  23. }
  24. // 종목 수 — null 은 "–"
  25. export function formatCount(v?: number|null): string {
  26. if (v === null || v === undefined) {
  27. return '–';
  28. }
  29. return v.toLocaleString('ko-KR');
  30. }