Skip to content

Commit

Permalink
Merge pull request #101 from boostcampwm-2024/feature/api/stockTradeH…
Browse files Browse the repository at this point in the history
…istory-#55

[BE] 6.04 매수/매도 요청 현황 API 구현
  • Loading branch information
uuuo3o authored Nov 14, 2024
2 parents d814d9c + 4a686ac commit 7aadb45
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ApiProperty } from '@nestjs/swagger';

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

@ApiProperty({ description: '주식 시가' })
stck_oprc: string;

@ApiProperty({ description: '주식 최고가' })
stck_hgpr: string;

@ApiProperty({ description: '주식 최저가' })
stck_lwpr: string;

@ApiProperty({ description: '주식 종가' })
stck_clpr: string;

@ApiProperty({ description: '누적 거래량' })
acml_vol: string;

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

@ApiProperty({ description: '전일 대비율' })
prdy_ctrt: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ApiProperty } from '@nestjs/swagger';

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

@ApiProperty({ description: '주식 시가' })
stck_oprc: string;

@ApiProperty({ description: '주식 최고가' })
stck_hgpr: string;

@ApiProperty({ description: '주식 최저가' })
stck_lwpr: string;

@ApiProperty({ description: '주식 종가' })
stck_clpr: string;

@ApiProperty({ description: '누적 거래량' })
acml_vol: string;

@ApiProperty({ description: '전일 대비 거래량 비율' })
prdy_vrss_vol_rate: string;

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

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

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

@ApiProperty({ description: 'HTS 외국인 소진율' })
hts_frgn_ehrt: string;

@ApiProperty({ description: '외국인 순매수 수량' })
frgn_ntby_qty: string;

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

@ApiProperty({ description: '누적 분할 비율' })
acml_prtt_rate: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DailyStockTradeHistoryOutputDto } from './daily-stock-trade-history-ouput.dto';

/**
* 주식현재가 일자별 API 응답값 정제 후 FE에 보낼 DTO
*/
export class DailyStockTradeHistoryResponseDto {
output: DailyStockTradeHistoryOutputDto[];
}

This file was deleted.

10 changes: 0 additions & 10 deletions BE/src/stock/trade/history/dto/stock-trade-history-response.dto.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

export class StockTradeHistoryDataDto {
export class TodayStockTradeHistoryDataDto {
@ApiProperty({ description: '주식 체결 시간' })
stck_cntg_hour: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

export class StockTradeHistoryOutputDto {
export class TodayStockTradeHistoryOutputDto {
@ApiProperty({ description: '주식 체결 시간' })
stck_cntg_hour: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ApiProperty } from '@nestjs/swagger';
import { TodayStockTradeHistoryOutputDto } from './today-stock-trade-history-output.dto';

/**
* 주식현재가 체결 API 응답값 정제 후 FE에 보낼 DTO
*/
export class TodayStockTradeHistoryResponseDto {
@ApiProperty({
type: TodayStockTradeHistoryOutputDto,
description: '상승률 순위',
})
output: TodayStockTradeHistoryOutputDto[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export interface InquireDailyPriceOutputData {
stck_bsop_date: string;
stck_oprc: string;
stck_hgpr: string;
stck_lwpr: string;
stck_clpr: string;
acml_vol: string;
prdy_vrss_vol_rate: string;
prdy_vrss: string;
prdy_vrss_sign: string;
prdy_ctrt: string;
hts_frgn_ehrt: string;
frgn_ntby_qty: string;
flng_cls_code: string;
acml_prtt_rate: string;
}

export interface InquireDailyPriceApiResponse {
output: InquireDailyPriceOutputData[];
rt_cd: string;
msg_cd: string;
msg1: string;
}
29 changes: 24 additions & 5 deletions BE/src/stock/trade/history/stock-trade-history.controller.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiOperation, ApiParam, ApiResponse } from '@nestjs/swagger';
import { StockTradeHistoryService } from './stock-trade-history.service';
import { StockTradeHistoryResponseDto } from './dto/stock-trade-history-response.dto';
import { TodayStockTradeHistoryResponseDto } from './dto/today-stock-trade-history-response.dto';
import { DailyStockTradeHistoryDataDto } from './dto/daily-stock-trade-history-data.dto';

@Controller('/api/stocks')
export class StockTradeHistoryController {
constructor(
private readonly stockTradeHistoryService: StockTradeHistoryService,
) {}

@Get(':stockCode/trade-history')
@Get(':stockCode/today-trade-history')
@ApiOperation({ summary: '단일 주식 종목에 대한 주식현재가 체결 API' })
@ApiParam({
name: 'stockCode',
Expand All @@ -21,9 +22,27 @@ export class StockTradeHistoryController {
@ApiResponse({
status: 200,
description: '단일 주식 종목에 대한 주식현재가 체결값 조회 성공',
type: StockTradeHistoryResponseDto,
type: TodayStockTradeHistoryResponseDto,
})
getStockDetail(@Param('stockCode') stockCode: string) {
return this.stockTradeHistoryService.getStockTradeHistory(stockCode);
getTodayStockTradeHistory(@Param('stockCode') stockCode: string) {
return this.stockTradeHistoryService.getTodayStockTradeHistory(stockCode);
}

@Get(':stockCode/daily-trade-history')
@ApiOperation({ summary: '단일 주식 종목에 대한 일자별 주식현재가 API' })
@ApiParam({
name: 'stockCode',
required: true,
description:
'종목 코드\n\n' +
'(ex) 005930 삼성전자 / 005380 현대차 / 001500 현대차증권',
})
@ApiResponse({
status: 200,
description: '단일 주식 종목에 대한 일자별 주식현재가 조회 성공',
type: DailyStockTradeHistoryDataDto,
})
getDailyStockTradeHistory(@Param('stockCode') stockCode: string) {
return this.stockTradeHistoryService.getDailyStockTradeHistory(stockCode);
}
}
Loading

0 comments on commit 7aadb45

Please sign in to comment.