-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] 26.08 이동 평균선 계산 로직 추가 (#183) #199
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
95884b8
✨ feat : 이동 평균선 데이터 dto에 담아서 전송(#183)
jinddings 5c5408e
🔧 fix : 요청 시작일 변경(#183)
jinddings 93c569f
🔧 fix :
jinddings 0053da9
🔧 fix : 연간 주식 조회를 위한 조회 시작 날짜 수정(#183)
jinddings 0a84632
Merge branch 'back/main' of https://github.com/boostcampwm-2024/web16…
jinddings 0d2dd8f
🔧 fix : prevDay 중복 대입 수정
jinddings File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ export class RankingService { | |
|
||
return { | ||
topRank: parsedTopRank, | ||
userRank: userRank, | ||
userRank, | ||
}; | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -82,11 +82,25 @@ export class StockDetailService { | |
date2: string, | ||
periodDivCode: string, | ||
) { | ||
let newDate1 = date1; | ||
let newDate2 = date2; | ||
|
||
if (date1 === '') { | ||
const today = new Date(); | ||
const prevDay = new Date(); | ||
if (periodDivCode === 'D') prevDay.setDate(today.getDate() - 60); | ||
if (periodDivCode === 'M') prevDay.setDate(today.getDate() - 1200); | ||
if (periodDivCode === 'Y') prevDay.setDate(today.getDate() - 20000); | ||
prevDay.setDate(today.getDate() - 365); | ||
newDate2 = new Date().toISOString().slice(0, 10).replace(/-/g, ''); | ||
newDate1 = prevDay.toISOString().slice(0, 10).replace(/-/g, ''); | ||
Comment on lines
+95
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟢 이 부분 좀 더 간단하게 하는 내장 메소드 없나 찾아봤는데 없네요...ㅋㅋ 고생하셨습니다!! |
||
} | ||
|
||
const queryParams = { | ||
fid_cond_mrkt_div_code: 'J', | ||
fid_input_iscd: stockCode, | ||
fid_input_date_1: date1, | ||
fid_input_date_2: date2, | ||
fid_input_date_1: newDate1, | ||
fid_input_date_2: newDate2, | ||
fid_period_div_code: periodDivCode, | ||
fid_org_adj_prc: '0', | ||
}; | ||
|
@@ -98,7 +112,7 @@ export class StockDetailService { | |
queryParams, | ||
); | ||
|
||
return this.formatStockInquirePriceData(response).slice().reverse(); | ||
return this.formatStockInquirePriceData(response).slice(-30); | ||
} | ||
|
||
/** | ||
|
@@ -111,7 +125,13 @@ export class StockDetailService { | |
private formatStockInquirePriceData(response: InquirePriceChartApiResponse) { | ||
const { output2 } = response; | ||
|
||
return output2.map((info) => { | ||
output2.sort((a, b) => { | ||
if (a.stck_bsop_date > b.stck_bsop_date) return 1; | ||
if (a.stck_bsop_date < b.stck_bsop_date) return -1; | ||
return 0; | ||
}); | ||
|
||
return output2.map((info, index) => { | ||
const stockData = new InquirePriceChartDataDto(); | ||
const { | ||
stck_bsop_date, | ||
|
@@ -131,6 +151,20 @@ export class StockDetailService { | |
stockData.acml_vol = acml_vol; | ||
stockData.prdy_vrss_sign = prdy_vrss_sign; | ||
|
||
if (index >= 4) { | ||
const movAvg5 = output2 | ||
.slice(index - 4, index + 1) | ||
.reduce((acc, cur) => acc + Number(cur.stck_clpr), 0); | ||
stockData.mov_avg_5 = (movAvg5 / 5).toFixed(2); | ||
} | ||
|
||
if (index >= 19) { | ||
const movAvg20 = output2 | ||
.slice(index - 19, index + 1) | ||
.reduce((acc, cur) => acc + Number(cur.stck_clpr), 0); | ||
stockData.mov_avg_20 = (movAvg20 / 20).toFixed(2); | ||
} | ||
|
||
return stockData; | ||
}); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 얘는 린트 오류때문에 수정하신 건가요? 갑자기 왜 수정하신 건지 모를 파일이 끼어있는 느낌이에요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉 시정하겠습니다