Skip to content

Commit

Permalink
#53 [refactor] : 차트 데이터 추가로 인한 기간 늘림
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbang105 committed Jun 12, 2024
1 parent 2f74cea commit 6e61b2e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions backend/src/main/java/org/dgu/backend/util/CandleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -15,8 +14,6 @@
@Component
@RequiredArgsConstructor
public class CandleUtil {
private static final List<String> SEVEN_DAY_CANDLES = Arrays.asList("minutes1", "minutes3", "minutes5", "minutes10", "minutes15", "minutes30");
private static final List<String> SIX_MONTH_CANDLES = Arrays.asList("minutes60", "minutes240");

// 캔들을 분 기준으로 변환하는 메서드
public int calculateCandleInterval(String candleName) {
Expand All @@ -35,13 +32,15 @@ public int calculateCandleInterval(String candleName) {
// 캔들 종류에 따라 시작 기간을 계산해 반환하는 메서드
public LocalDateTime getStartDateByCandleName(String candleName) {
LocalDateTime now = LocalDateTime.now();
if (SEVEN_DAY_CANDLES.contains(candleName)) {
return now.minusDays(7);
} else if (SIX_MONTH_CANDLES.contains(candleName)) {
return now.minusMonths(6);
} else {
return LocalDateTime.of(2019, 1, 1, 0, 0);
}
return switch (candleName) {
case "minutes1" -> now.minusMonths(1);
case "minutes3" -> now.minusMonths(3);
case "minutes5" -> now.minusMonths(5);
case "minutes10" -> now.minusMonths(10);
case "minutes15" -> now.minusMonths(15);
case "minutes30" -> now.minusMonths(30);
default -> LocalDateTime.of(2019, 1, 1, 0, 0);
};
}

// 캔들 차트에서 중복 데이터를 제거하는 메서드
Expand Down

0 comments on commit 6e61b2e

Please sign in to comment.