-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from boostcampwm-2024/back/main
[BE] alpha 서버 배포 (11.11)
- Loading branch information
Showing
30 changed files
with
183 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
BE/src/koreaInvestment/interface/korea-investment.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface AccessTokenInterface { | ||
access_token: string; | ||
access_token_token_expired: string; | ||
token_type: string; | ||
expires_in: number; | ||
} |
2 changes: 1 addition & 1 deletion
2
...oreaInvestment/korea.investment.module.ts → ...oreaInvestment/korea-investment.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 5 additions & 1 deletion
6
...dto/stock.index.list.chart.element.dto.ts → ...dto/stock-index-list-chart.element.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class StockIndexListChartElementDto { | ||
constructor(time: string, value: string) { | ||
constructor(time: string, value: string, diff: string) { | ||
this.time = time; | ||
this.value = value; | ||
this.diff = diff; | ||
} | ||
|
||
@ApiProperty({ description: 'HHMMSS', example: '130500' }) | ||
time: string; | ||
|
||
@ApiProperty({ description: '주가 지수' }) | ||
value: string; | ||
|
||
@ApiProperty({ description: '전일 대비 주가 지수' }) | ||
diff: string; | ||
} |
14 changes: 14 additions & 0 deletions
14
BE/src/stock/index/dto/stock-index-response-element.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { StockIndexValueElementDto } from './stock-index-value-element.dto'; | ||
import { StockIndexListChartElementDto } from './stock-index-list-chart.element.dto'; | ||
|
||
export class StockIndexResponseElementDto { | ||
@ApiProperty({ description: '실시간 값', type: StockIndexValueElementDto }) | ||
value: StockIndexValueElementDto; | ||
|
||
@ApiProperty({ | ||
description: '실시간 차트', | ||
type: [StockIndexListChartElementDto], | ||
}) | ||
chart: StockIndexListChartElementDto[]; | ||
} |
2 changes: 1 addition & 1 deletion
2
...ock/index/dto/stock.index.response.dto.ts → ...ock/index/dto/stock-index-response.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 5 additions & 17 deletions
22
...ndex/dto/stock.index.value.element.dto.ts → ...ndex/dto/stock-index-value-element.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
BE/src/stock/index/dto/stock.index.response.element.dto.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
BE/src/stock/index/stock.index.module.ts → BE/src/stock/index/stock-index.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { Injectable, InternalServerErrorException } from '@nestjs/common'; | ||
import axios from 'axios'; | ||
import { StockIndexListChartElementDto } from './dto/stock-index-list-chart.element.dto'; | ||
import { StockIndexValueElementDto } from './dto/stock-index-value-element.dto'; | ||
import { | ||
StockIndexChartInterface, | ||
StockIndexValueInterface, | ||
} from './interface/stock-index.interface'; | ||
import { getFullURL } from '../../util/get-full-URL'; | ||
import { getHeader } from '../../util/get-header'; | ||
|
||
@Injectable() | ||
export class StockIndexService { | ||
async getDomesticStockIndexListByCode(code: string, accessToken: string) { | ||
const result = await this.requestDomesticStockIndexListApi( | ||
code, | ||
accessToken, | ||
); | ||
|
||
return result.output.map((element) => { | ||
return new StockIndexListChartElementDto( | ||
element.bsop_hour, | ||
element.bstp_nmix_prpr, | ||
element.bstp_nmix_prdy_vrss, | ||
); | ||
}); | ||
} | ||
|
||
async getDomesticStockIndexValueByCode(code: string, accessToken: string) { | ||
const result = await this.requestDomesticStockIndexValueApi( | ||
code, | ||
accessToken, | ||
); | ||
|
||
const data = result.output; | ||
|
||
return new StockIndexValueElementDto( | ||
data.bstp_nmix_prpr, | ||
data.bstp_nmix_prdy_vrss, | ||
data.bstp_nmix_prdy_ctrt, | ||
data.prdy_vrss_sign, | ||
); | ||
} | ||
|
||
private async requestDomesticStockIndexListApi( | ||
code: string, | ||
accessToken: string, | ||
) { | ||
const response = await axios | ||
.get<StockIndexChartInterface>( | ||
getFullURL( | ||
'/uapi/domestic-stock/v1/quotations/inquire-index-timeprice', | ||
), | ||
{ | ||
headers: getHeader(accessToken, 'FHPUP02110200'), | ||
params: { | ||
fid_input_hour_1: 300, | ||
fid_cond_mrkt_div_code: 'U', | ||
fid_input_iscd: code, | ||
}, | ||
}, | ||
) | ||
.catch(() => { | ||
throw new InternalServerErrorException( | ||
'주가 지수 차트 정보를 조회하지 못했습니다.', | ||
); | ||
}); | ||
|
||
return response.data; | ||
} | ||
|
||
private async requestDomesticStockIndexValueApi( | ||
code: string, | ||
accessToken: string, | ||
) { | ||
const response = await axios | ||
.get<StockIndexValueInterface>( | ||
getFullURL('/uapi/domestic-stock/v1/quotations/inquire-index-price'), | ||
{ | ||
headers: getHeader(accessToken, 'FHPUP02100000'), | ||
params: { | ||
fid_cond_mrkt_div_code: 'U', | ||
fid_input_iscd: code, | ||
}, | ||
}, | ||
) | ||
.catch(() => { | ||
throw new InternalServerErrorException( | ||
'주가 지수 값 정보를 조회하지 못했습니다.', | ||
); | ||
}); | ||
|
||
return response.data; | ||
} | ||
} |
Oops, something went wrong.