Skip to content

Commit b84d0c9

Browse files
committed
Refactor: yield를 roi로 변경
1 parent 7138b03 commit b84d0c9

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/main/java/com/fund/stockProject/experiment/service/ExperimentService.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ public PortfolioResultResponse getPortfolioResult(final CustomUserDetails custom
828828
.map(e -> PortfolioResultResponse.HistoryPoint.builder()
829829
.date(PortfolioResultResponse.HistoryPoint.toDateLabel(e.getSellAt() != null ? e.getSellAt() : e.getBuyAt()))
830830
.score(e.getScore())
831-
.yield(e.getRoi() != null ? e.getRoi() : 0.0)
831+
.roi(roundTo1Decimal(e.getRoi() != null ? e.getRoi() : 0.0))
832832
.stockId(e.getStock().getId())
833833
.stockName(e.getStock().getSecurityName())
834834
.isDuplicateName(stockNameCount.get(e.getStock().getSecurityName()) > 1)
@@ -844,14 +844,14 @@ public PortfolioResultResponse getPortfolioResult(final CustomUserDetails custom
844844

845845
for (PortfolioResultResponse.HistoryPoint point : history) {
846846
double dx = point.getScore() - 50.0;
847-
double dy = point.getYield();
847+
double dy = point.getRoi();
848848
double distance = Math.sqrt(dx * dx + dy * dy);
849849

850-
if (point.getScore() < 50 && point.getYield() > 0) {
850+
if (point.getScore() < 50 && point.getRoi() > 0) {
851851
valuePreemptiveSum += distance; // 가치 선점형
852-
} else if (point.getScore() >= 50 && point.getYield() > 0) {
852+
} else if (point.getScore() >= 50 && point.getRoi() > 0) {
853853
trendPreemptiveSum += distance; // 트렌드 선점형
854-
} else if (point.getScore() < 50 && point.getYield() <= 0) {
854+
} else if (point.getScore() < 50 && point.getRoi() <= 0) {
855855
reverseInvestorSum += distance; // 역행 투자형
856856
} else {
857857
laggingFollowerSum += distance; // 후행 추종형
@@ -1032,6 +1032,10 @@ private String toScoreRangeLabel(int score) {
10321032
return "90+";
10331033
}
10341034

1035+
private double roundTo1Decimal(double value) {
1036+
return Math.round(value * 10.0) / 10.0;
1037+
}
1038+
10351039
// 영업일 기준 실험 진행한 기간이 5일 이상 지난 실험 데이터 조회
10361040
@Transactional(readOnly = true)
10371041
public List<Experiment> findExperimentsAfter5BusinessDays() {

src/main/java/com/fund/stockProject/portfolio/dto/PortfolioResultResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static class Pattern {
7272
public static class HistoryPoint {
7373
private String date; // MM.DD
7474
private int score; // X축 (0~100)
75-
private double yield; // Y축
75+
private double roi; // Y축 (수익률)
7676
private Integer stockId; // 종목 ID
7777
private String stockName; // 종목명
7878
private boolean isDuplicateName; // 리스트 내 이름 중복 여부

0 commit comments

Comments
 (0)