Skip to content

Commit

Permalink
Merge pull request #67 from CSID-DGU/feature/#53/chart
Browse files Browse the repository at this point in the history
[refactor] : 차트 데이터 추가로 인한 기간 늘림
  • Loading branch information
bbbang105 authored Jun 12, 2024
2 parents ed3d998 + 6e61b2e commit cb796ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion backend/src/main/java/org/dgu/backend/domain/UpbitKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.dgu.backend.common.BaseEntity;

import java.util.UUID;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Table(name = "upbit_keys")
public class UpbitKey {
public class UpbitKey extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "upbit_keys_id")
Expand Down
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 cb796ca

Please sign in to comment.