market.ts 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. // 시장 데이터 도메인 타입 — Backend Application/Features/Api/Stocks/{GetIndices,GetEtp,...}/Response.cs 대응
  2. // 직렬화 주의: 필드명은 camelCase. enum 은 Web.Api Program.cs 에 JsonStringEnumConverter 미등록 →
  3. // Response DTO 에서 enum 은 숫자(정수)로 직렬화됨 (Paper 의 문자열 enum 과 다름).
  4. // 쿼리스트링으로 보낼 때는 ASP.NET model binding 이 enum 멤버명 문자열도 허용하므로 이름으로 전송한다.
  5. // (예외: session 은 숫자 1/2 로 전송 — MarketSession)
  6. // ── enum (응답 = 숫자, 요청 = 멤버명 문자열) ──
  7. // 지수 계열 (MarketIndexSeries)
  8. export const MarketIndexSeries = {
  9. KOSPI: 1,
  10. KOSDAQ: 2,
  11. KRX: 3,
  12. Bond: 4,
  13. Derivative: 5
  14. } as const;
  15. export type MarketIndexSeriesValue = (typeof MarketIndexSeries)[keyof typeof MarketIndexSeries];
  16. export const MARKET_INDEX_SERIES_LABEL: Record<MarketIndexSeriesValue, string> = {
  17. [MarketIndexSeries.KOSPI]: 'KOSPI',
  18. [MarketIndexSeries.KOSDAQ]: 'KOSDAQ',
  19. [MarketIndexSeries.KRX]: 'KRX',
  20. [MarketIndexSeries.Bond]: '채권',
  21. [MarketIndexSeries.Derivative]: '파생'
  22. };
  23. // ETP 종류 (EtpType) — 요청 파라미터명 'type'
  24. export const EtpType = {
  25. ETF: 1,
  26. ETN: 2,
  27. ELW: 3
  28. } as const;
  29. export type EtpTypeValue = (typeof EtpType)[keyof typeof EtpType];
  30. export type EtpTypeName = keyof typeof EtpType;
  31. export const ETP_TYPE_LABEL: Record<EtpTypeValue, string> = {
  32. [EtpType.ETF]: 'ETF',
  33. [EtpType.ETN]: 'ETN',
  34. [EtpType.ELW]: 'ELW'
  35. };
  36. // 채권 시장 (BondMarket) — 요청 파라미터명 'market'
  37. export const BondMarket = {
  38. KtsGovt: 1,
  39. General: 2,
  40. Small: 3
  41. } as const;
  42. export type BondMarketValue = (typeof BondMarket)[keyof typeof BondMarket];
  43. export type BondMarketName = keyof typeof BondMarket;
  44. export const BOND_MARKET_LABEL: Record<BondMarketValue, string> = {
  45. [BondMarket.KtsGovt]: '국채전문',
  46. [BondMarket.General]: '일반채권',
  47. [BondMarket.Small]: '소액채권'
  48. };
  49. // 매매 세션 (MarketSession) — 선물/옵션 공용. 요청 파라미터명 'session' (숫자 1/2 로 전송 — model binding 은 숫자·이름 모두 허용)
  50. export const MarketSession = {
  51. Regular: 1,
  52. Night: 2
  53. } as const;
  54. export type MarketSessionValue = (typeof MarketSession)[keyof typeof MarketSession];
  55. export type MarketSessionName = keyof typeof MarketSession;
  56. export const MARKET_SESSION_LABEL: Record<MarketSessionValue, string> = {
  57. [MarketSession.Regular]: '정규',
  58. [MarketSession.Night]: '야간'
  59. };
  60. // 선물 종류 (FuturesKind) — 요청 파라미터명 'kind'
  61. export const FuturesKind = {
  62. General: 1,
  63. StockKospi: 2,
  64. StockKosdaq: 3
  65. } as const;
  66. export type FuturesKindValue = (typeof FuturesKind)[keyof typeof FuturesKind];
  67. export type FuturesKindName = keyof typeof FuturesKind;
  68. export const FUTURES_KIND_LABEL: Record<FuturesKindValue, string> = {
  69. [FuturesKind.General]: '일반선물',
  70. [FuturesKind.StockKospi]: '주식선물(코스피)',
  71. [FuturesKind.StockKosdaq]: '주식선물(코스닥)'
  72. };
  73. // 옵션 종류 (OptionsKind) — 요청 파라미터명 'kind'
  74. export const OptionsKind = {
  75. General: 1,
  76. StockKospi: 2,
  77. StockKosdaq: 3
  78. } as const;
  79. export type OptionsKindValue = (typeof OptionsKind)[keyof typeof OptionsKind];
  80. export type OptionsKindName = keyof typeof OptionsKind;
  81. export const OPTIONS_KIND_LABEL: Record<OptionsKindValue, string> = {
  82. [OptionsKind.General]: '일반옵션',
  83. [OptionsKind.StockKospi]: '주식옵션(코스피)',
  84. [OptionsKind.StockKosdaq]: '주식옵션(코스닥)'
  85. };
  86. // 옵션 권리유형 (OptionRightType)
  87. export const OptionRightType = {
  88. Call: 1,
  89. Put: 2
  90. } as const;
  91. export type OptionRightTypeValue = (typeof OptionRightType)[keyof typeof OptionRightType];
  92. export const OPTION_RIGHT_TYPE_LABEL: Record<OptionRightTypeValue, string> = {
  93. [OptionRightType.Call]: '콜',
  94. [OptionRightType.Put]: '풋'
  95. };
  96. // 상품(파생상품시장) 시장 (CommodityMarket) — 요청 파라미터명 'market'
  97. export const CommodityMarket = {
  98. Oil: 1,
  99. Gold: 2,
  100. Emission: 3
  101. } as const;
  102. export type CommodityMarketValue = (typeof CommodityMarket)[keyof typeof CommodityMarket];
  103. export type CommodityMarketName = keyof typeof CommodityMarket;
  104. export const COMMODITY_MARKET_LABEL: Record<CommodityMarketValue, string> = {
  105. [CommodityMarket.Oil]: '석유',
  106. [CommodityMarket.Gold]: '금',
  107. [CommodityMarket.Emission]: '배출권'
  108. };
  109. // 금리 유형 (RateType) — 요청 파라미터명 'type'
  110. export const RateType = {
  111. Loan: 1,
  112. International: 2
  113. } as const;
  114. export type RateTypeValue = (typeof RateType)[keyof typeof RateType];
  115. export type RateTypeName = keyof typeof RateType;
  116. export const RATE_TYPE_LABEL: Record<RateTypeValue, string> = {
  117. [RateType.Loan]: '대출금리',
  118. [RateType.International]: '국제금리'
  119. };
  120. // 공시 법인구분 (corpCls — 문자열 Y/K/N/E)
  121. export type CorpClsCode = 'Y'|'K'|'N'|'E';
  122. export const CORP_CLS_LABEL: Record<CorpClsCode, string> = {
  123. Y: '유가',
  124. K: '코스닥',
  125. N: '코넥스',
  126. E: '기타'
  127. };
  128. // ── GET /api/market/indices ──
  129. export interface MarketIndexRow {
  130. series: MarketIndexSeriesValue;
  131. name: string;
  132. close: number;
  133. changeVal: number;
  134. // 등락률 basis point (%×100)
  135. flucRateBp: number;
  136. tradeDate: string;
  137. }
  138. export interface MarketIndicesResponse {
  139. list: MarketIndexRow[];
  140. }
  141. // ── GET /api/market/etp ──
  142. export interface EtpRow {
  143. type: EtpTypeValue;
  144. code: string;
  145. name: string;
  146. close: number;
  147. changeAmount: number;
  148. changeRate: number;
  149. volume: number;
  150. tradeValue: number;
  151. marketCap: number|null;
  152. nav: number|null;
  153. baseIndexName: string|null;
  154. underlying: string|null;
  155. }
  156. export interface EtpResponse {
  157. total: number;
  158. tradeDate: string|null;
  159. list: EtpRow[];
  160. }
  161. // ── GET /api/market/bonds ──
  162. export interface BondRow {
  163. market: BondMarketValue;
  164. code: string;
  165. name: string;
  166. close: number;
  167. changeAmount: number;
  168. yieldToMaturity: number|null;
  169. volume: number;
  170. tradeValue: number;
  171. maturityYears: string|null;
  172. issueType: string|null;
  173. }
  174. export interface BondsResponse {
  175. total: number;
  176. tradeDate: string|null;
  177. list: BondRow[];
  178. }
  179. // ── GET /api/market/futures ──
  180. export interface FuturesRow {
  181. kind: FuturesKindValue;
  182. // 매매 세션 (1=정규, 2=야간) — 숫자 직렬화
  183. session: MarketSessionValue;
  184. isuCode: string;
  185. isuName: string;
  186. close: number;
  187. changeAmount: number;
  188. settlePrice: number|null;
  189. volume: number;
  190. tradeValue: number;
  191. openInterest: number|null;
  192. productName: string|null;
  193. }
  194. export interface FuturesResponse {
  195. total: number;
  196. tradeDate: string|null;
  197. list: FuturesRow[];
  198. }
  199. // ── GET /api/market/options ──
  200. export interface OptionsRow {
  201. kind: OptionsKindValue;
  202. // 매매 세션 (1=정규, 2=야간) — 숫자 직렬화
  203. session: MarketSessionValue;
  204. isuCode: string;
  205. isuName: string;
  206. rightType: OptionRightTypeValue;
  207. strikePrice: number|null;
  208. close: number;
  209. changeAmount: number;
  210. impliedVolatility: number|null;
  211. volume: number;
  212. tradeValue: number;
  213. openInterest: number|null;
  214. productName: string|null;
  215. }
  216. export interface OptionsResponse {
  217. total: number;
  218. tradeDate: string|null;
  219. list: OptionsRow[];
  220. }
  221. // ── GET /api/market/commodities ──
  222. export interface CommodityRow {
  223. market: CommodityMarketValue;
  224. code: string;
  225. name: string;
  226. close: number;
  227. changeAmount: number|null;
  228. changeRate: number|null;
  229. weightedDiscussionPrice: number|null;
  230. volume: number;
  231. tradeValue: number;
  232. }
  233. export interface CommoditiesResponse {
  234. total: number;
  235. tradeDate: string|null;
  236. list: CommodityRow[];
  237. }
  238. // ── GET /api/market/esg/securities ──
  239. export interface EsgSecurityRow {
  240. name: string;
  241. close: number;
  242. changeAmount: number;
  243. changeRate: number;
  244. listedShares: number;
  245. volume: number;
  246. tradeValue: number;
  247. }
  248. export interface EsgSecuritiesResponse {
  249. total: number;
  250. tradeDate: string|null;
  251. list: EsgSecurityRow[];
  252. }
  253. // ── GET /api/market/esg/indices ──
  254. export interface EsgIndexRow {
  255. name: string;
  256. close: number;
  257. changeVal: number;
  258. // 등락률 basis point (%×100)
  259. flucRateBp: number;
  260. constituentCount: number;
  261. volume: number;
  262. value: number;
  263. }
  264. export interface EsgIndicesResponse {
  265. total: number;
  266. tradeDate: string|null;
  267. list: EsgIndexRow[];
  268. }
  269. // ── GET /api/market/esg/sri-bonds ──
  270. export interface SriBondRow {
  271. code: string;
  272. issuerName: string;
  273. sriBondType: string;
  274. name: string;
  275. listDate: string|null;
  276. issueDate: string|null;
  277. redemptionDate: string|null;
  278. couponRate: number|null;
  279. issueAmount: number;
  280. listAmount: number;
  281. bondType: string|null;
  282. }
  283. export interface SriBondsResponse {
  284. total: number;
  285. tradeDate: string|null;
  286. list: SriBondRow[];
  287. }
  288. // ── GET /api/market/exchange-rates ──
  289. export interface ExchangeRateRow {
  290. currencyUnit: string;
  291. currencyName: string;
  292. dealBasRate: number;
  293. // 전신환 받으실 때
  294. ttb: number|null;
  295. // 전신환 보내실 때
  296. tts: number|null;
  297. }
  298. export interface ExchangeRatesResponse {
  299. total: number;
  300. tradeDate: string|null;
  301. list: ExchangeRateRow[];
  302. }
  303. // ── GET /api/market/interest-rates ──
  304. export interface InterestRateRow {
  305. itemName: string;
  306. rate: number|null;
  307. }
  308. export interface InterestRatesResponse {
  309. type: RateTypeValue;
  310. total: number;
  311. tradeDate: string|null;
  312. list: InterestRateRow[];
  313. }
  314. // ── GET /api/disclosures · GET /api/stocks/{code}/disclosures ──
  315. export interface DisclosureRow {
  316. rceptNo: string;
  317. corpCode: string;
  318. corpName: string;
  319. stockCode?: string|null;
  320. corpCls: string;
  321. reportNm: string;
  322. flrNm: string;
  323. rceptDt: string;
  324. rm: string|null;
  325. }
  326. export interface DisclosuresResponse {
  327. total: number;
  328. list: DisclosureRow[];
  329. }