Skip to content

Commit

Permalink
Merge pull request #99 from boostcampwm-2024/feature/api/stockDetail-#54
Browse files Browse the repository at this point in the history
[BE] 6.02 각 주식 정보 가져오기 API 구현 #54
  • Loading branch information
uuuo3o authored Nov 14, 2024
2 parents 0d2fc52 + 5f7d33c commit d814d9c
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 213 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

export class InquirePriceOutput2Dto {
export class InquirePriceChartDataDto {
@ApiProperty({ description: '주식 영업 일자' })
stck_bsop_date: string;

Expand All @@ -19,24 +19,6 @@ export class InquirePriceOutput2Dto {
@ApiProperty({ description: '누적 거래량' })
acml_vol: string;

@ApiProperty({ description: '누적 거래 대금' })
acml_tr_pbmn: string;

@ApiProperty({ description: '락 구분 코드' })
flng_cls_code: string;

@ApiProperty({ description: '분할 비율' })
prtt_rate: string;

@ApiProperty({ description: '분할변경여부' })
mod_yn: string;

@ApiProperty({ description: '전일 대비 부호' })
prdy_vrss_sign: string;

@ApiProperty({ description: '전일 대비' })
prdy_vrss: string;

@ApiProperty({ description: '재평가사유코드' })
revl_issu_reas: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ApiProperty } from '@nestjs/swagger';
/**
* 국내주식기간별시세(일/주/월/년) API를 이용할 때 필요한 요청 데이터를 담고 있는 DTO
*/
export class StockDetailRequestDto {
export class StockDetailChartRequestDto {
@ApiProperty({ description: '조회 시작일자 (ex) 20220501' })
fid_input_date_1: string;

Expand Down
5 changes: 5 additions & 0 deletions BE/src/stock/detail/dto/stock-detail-chart-response.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { InquirePriceChartDataDto } from './stock-detail-chart-data.dto';

export class InquirePriceChartResponseDto {
output: InquirePriceChartDataDto[];
}
27 changes: 0 additions & 27 deletions BE/src/stock/detail/dto/stock-detail-output1.dto.ts

This file was deleted.

34 changes: 0 additions & 34 deletions BE/src/stock/detail/dto/stock-detail-query-parameter.dto.ts

This file was deleted.

31 changes: 22 additions & 9 deletions BE/src/stock/detail/dto/stock-detail-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { ApiProperty } from '@nestjs/swagger';
import { InquirePriceOutput1Dto } from './stock-detail-output1.dto';
import { InquirePriceOutput2Dto } from './stock-detail-output2.dto';

/**
* 국내주식기간별시세(일/주/월/년) API 응답값 정제 후 FE에 보낼 DTO
*/
export class InquirePriceResponseDto {
@ApiProperty({ type: InquirePriceOutput1Dto, description: '상승률 순위' })
output1: InquirePriceOutput1Dto;
@ApiProperty({ description: 'HTS 한글 종목명' })
hts_kor_isnm: string;

@ApiProperty({ type: [InquirePriceOutput2Dto], description: '하락률 순위' })
output2: InquirePriceOutput2Dto[];
@ApiProperty({ description: '종목코드' })
stck_shrn_iscd: string;

@ApiProperty({ description: '주식 현재가' })
stck_prpr: string;

@ApiProperty({ description: '전일 대비' })
prdy_vrss: string;

@ApiProperty({ description: '전일 대비 부호' })
prdy_vrss_sign: string;

@ApiProperty({ description: '전일 대비율' })
prdy_ctrt: string;

@ApiProperty({ description: 'HTS 시가총액' })
hts_avls: string;

@ApiProperty({ description: 'PER' })
per: string;
}
56 changes: 56 additions & 0 deletions BE/src/stock/detail/interface/stock-detail-chart.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export interface InquirePriceOutput1Data {
prdy_vrss: string;
prdy_vrss_sign: string;
prdy_ctrt: string;
stck_prdy_clpr: string;
acml_vol: string;
acml_tr_pbmn: string;
hts_kor_isnm: string;
stck_prpr: string;
stck_shrn_iscd: string;
prdy_vol: string;
stck_mxpr: string;
stck_llam: string;
stck_oprc: string;
stck_hgpr: string;
stck_lwpr: string;
stck_prdy_oprc: string;
stck_prdy_hgpr: string;
stck_prdy_lwpr: string;
askp: string;
bidp: string;
prdy_vrss_vol: string;
vol_tnrt: string;
stck_fcam: string;
lstn_stcn: string;
cpfn: string;
hts_avls: string;
per: string;
eps: string;
pbr: string;
itewhol_loan_rmnd_ratem_name: string;
}

export interface InquirePriceOutput2Data {
stck_bsop_date: string;
stck_clpr: string;
stck_oprc: string;
stck_hgpr: string;
stck_lwpr: string;
acml_vol: string;
acml_tr_pbmn: string;
flng_cls_code: string;
prtt_rate: string;
mod_yn: string;
prdy_vrss_sign: string;
prdy_vrss: string;
revl_issu_reas: string;
}

export interface InquirePriceChartApiResponse {
output1: InquirePriceOutput1Data;
output2: InquirePriceOutput2Data[];
rt_cd: string;
msg_cd: string;
msg1: string;
}
104 changes: 66 additions & 38 deletions BE/src/stock/detail/interface/stock-detail.interface.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,83 @@
export interface InquirePriceOutput1Data {
export interface InquirePriceOutputData {
iscd_stat_cls_code: string;
marg_rate: string;
rprs_mrkt_kor_name: string;
new_hgpr_lwpr_cls_code: string;
btsp_kor_isnm: string;
temp_stop_yn: string;
oprc_rang_cont_yn: string;
clpr_rang_cont_yn: string;
crdt_able_yn: string;
grmn_rate_cls_code: string;
elw_pblc_yn: string;
stck_prpr: string;
prdy_vrss: string;
prdy_vrss_sign: string;
prdy_ctrt: string;
stck_prdy_clpr: string;
acml_vol: string;
acml_tr_pbmn: string;
hts_kor_isnm: string;
stck_prpr: string;
stck_shrn_iscd: string;
prdy_vol: string;
stck_mxpr: string;
stck_llam: string;
acml_vol: string;
prdy_vrss_vol_rate: string;
stck_oprc: string;
stck_hgpr: string;
stck_lwpr: string;
stck_prdy_oprc: string;
stck_prdy_hgpr: string;
stck_prdy_lwpr: string;
askp: string;
bidp: string;
prdy_vrss_vol: string;
vol_tnrt: string;
stck_mxpr: string;
stck_llam: string;
stck_sdpr: string;
wghn_avrg_stck_prc: string;
hts_frgn_ehrt: string;
frgn_ntby_qty: string;
pgtr_ntby_qty: string;
dmrs_val: string;
dmsp_val: string;
cpfn: string;
rstc_wdth_prc: string;
stck_fcam: string;
stck_sspr: string;
aspr_unit: string;
hts_deal_qty_unit_val: string;
lstn_stcn: string;
cpfn: string;
hts_avls: string;
per: string;
eps: string;
pbr: string;
itewhol_loan_rmnd_ratem_name: string;
}

export interface InquirePriceOutput2Data {
stck_bsop_date: string;
stck_clpr: string;
stck_oprc: string;
stck_hgpr: string;
stck_lwpr: string;
acml_vol: string;
acml_tr_pbmn: string;
flng_cls_code: string;
prtt_rate: string;
mod_yn: string;
prdy_vrss_sign: string;
prdy_vrss: string;
revl_issu_reas: string;
stac_month: string;
vol_tnrt: string;
eps: string;
bps: string;
d250_hgpr: string;
d250_hgpr_date: string;
d250_hgpr_vrss_prpr_rate: string;
d250_lwpr: string;
d250_lwpr_date: string;
d250_lwpr_vrss_prpr_rate: string;
stck_dryy_hgpr: string;
dryy_hgpr_vrss_prpr_rate: string;
dryy_hgpr_date: string;
stck_dryy_lwpr: string;
dryy_lwpr_vrss_prpr_rate: string;
dryy_lwpr_date: string;
w52_hgpr: string;
w52_hgpr_vrss_prpr_ctrt: string;
w52_hgpr_date: string;
w52_lwpr: string;
w52_lwpr_vrss_prpr_ctrt: string;
w52_lwpr_date: string;
whol_loan_rmnd_rate: string;
ssts_yn: string;
stck_shrn_iscd: string;
fcam_cnnm: string;
cpfn_cnnm: string;
apprch_rate: string;
frgn_hldn_qty: string;
vi_cls_code: string;
ovtm_vi_cls_code: string;
last_ssts_cntg_qty: string;
invt_caful_yn: string;
mrkt_warn_cls_code: string;
short_over_yn: string;
sltr_yn: string;
}

export interface InquirePriceApiResponse {
output1: InquirePriceOutput1Data;
output2: InquirePriceOutput2Data[];
output: InquirePriceOutputData;
rt_cd: string;
msg_cd: string;
msg1: string;
Expand Down
37 changes: 28 additions & 9 deletions BE/src/stock/detail/stock-detail.controller.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
import { Body, Controller, Param, Post } from '@nestjs/common';
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ApiBody, ApiOperation, ApiParam, ApiResponse } from '@nestjs/swagger';
import { StockDetailService } from './stock-detail.service';
import { StockDetailRequestDto } from './dto/stock-detail-request.dto';
import { InquirePriceResponseDto } from './dto/stock-detail-response.dto';
import { StockDetailChartRequestDto } from './dto/stock-detail-chart-request.dto';
import { InquirePriceChartResponseDto } from './dto/stock-detail-chart-response.dto';

@Controller('/api/stocks')
export class StockDetailController {
constructor(private readonly stockDetailService: StockDetailService) {}

@Post(':stockCode')
@Get(':stockCode')
@ApiOperation({ summary: '단일 주식 종목 detail 페이지 상단부 조회 API' })
@ApiParam({
name: 'stockCode',
required: true,
description:
'종목 코드\n' +
'(ex) 005930 삼성전자 / 005380 현대차 / 001500 현대차증권',
})
@ApiResponse({
status: 200,
description: '단일 주식 종목 기본값 조회 성공',
type: InquirePriceResponseDto,
})
getStockDetail(@Param('stockCode') stockCode: string) {
return this.stockDetailService.getInquirePrice(stockCode);
}

@Post(':stockCode')
@ApiOperation({ summary: '국내주식기간별시세(일/주/월/년) 조회 API' })
@ApiParam({
name: 'stockCode',
required: true,
Expand All @@ -23,19 +42,19 @@ export class StockDetailController {
'fid_input_date_1: 조회 시작일자 (ex) 20240505\n\n' +
'fid_input_date_2: 조회 종료일자 (ex) 20241111\n\n' +
'fid_period_div_code: 기간 분류 코드 (ex) D(일봉), W(주봉), M(월봉), Y(년봉)',
type: StockDetailRequestDto,
type: StockDetailChartRequestDto,
})
@ApiResponse({
status: 201,
description: '단일 주식 종목 기본값 조회 성공',
type: InquirePriceResponseDto,
description: '국내주식기간별시세(일/주/월/년) 조회 성공',
type: InquirePriceChartResponseDto,
})
getStockDetail(
getStockDetailChart(
@Param('stockCode') stockCode: string,
@Body() body: StockDetailRequestDto,
@Body() body: StockDetailChartRequestDto,
) {
const { fid_input_date_1, fid_input_date_2, fid_period_div_code } = body;
return this.stockDetailService.getInquirePrice(
return this.stockDetailService.getInquirePriceChart(
stockCode,
fid_input_date_1,
fid_input_date_2,
Expand Down
Loading

0 comments on commit d814d9c

Please sign in to comment.