Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0fe61e1
[BE] SISC1-56 [FEAT] 백테스트 실행 로직 구현
discipline24 Oct 29, 2025
7df6f56
[BE] SISC1-56 [FEAT] 외부 DB의 주식 정보 이용을 위한 멀티 데이터소스 구현
discipline24 Oct 29, 2025
2652c9b
[BE] SISC1-56 [FIX] @AuthenticationPrincipal 작동 안되는 문제 해결
discipline24 Oct 29, 2025
368f2cc
[BE] SISC1-56 [FEAT] 주식 데이터 관련 간단한 테스트용 컨트롤러 추가
discipline24 Nov 1, 2025
45fa9d3
[BE] SISC1-56 [FEAT] 주식 데이터 관련 멀티 데이터소스 설정 추가
discipline24 Nov 1, 2025
ec45228
[BE] SISC1-56 [DOCS] 백테스트, 템플릿, 포인트 관련 스웨거 요청 JSON 예시, 컨트롤러 설명 등 추가
discipline24 Nov 1, 2025
b623024
[BE] SISC1-56 [REFACTOR] 템플릿 상세 조회 시, 해당 템플릿에 속한 백테스트 리스트 반환 추가
discipline24 Nov 1, 2025
5a7a15c
Merge branch 'main' into SISC1-56-BE-백테스팅-실행-API-구현
discipline24 Nov 1, 2025
70c2b70
[BE] SISC1-56 [FIX] 테스트 전용 컨트롤러 삭제 및 스웨거 관련 주석 수정
discipline24 Nov 2, 2025
49d5ff1
Update .gitignore
discipline24 Nov 2, 2025
42634fe
[BE] SISC1-56 [FIX] 리포지토리 @Param 추가
discipline24 Nov 2, 2025
8bf8c52
[BE] SISC1-56 [FIX] ByteBuddy 직렬화 오류 수정
discipline24 Nov 5, 2025
0b13e1e
[BE] SISC1-56 [FIX] ByteBuddy 직렬화 오류 수정
discipline24 Nov 6, 2025
20476eb
Merge branch 'SISC1-56-BE-백테스팅-실행-API-구현' of https://github.com/SISC-…
discipline24 Nov 6, 2025
b7641f2
conflict 해결
discipline24 Nov 6, 2025
043c54c
Merge branch 'main' into SISC1-56-BE-백테스팅-실행-API-구현
discipline24 Nov 11, 2025
744cdb2
[BE] SISC1-56 [FEAT] 백테스팅 실행 API 구현
discipline24 Nov 13, 2025
3afe57f
Merge branch 'main' into SISC1-56-BE-백테스팅-실행-API-구현
discipline24 Nov 13, 2025
6bb3d3b
[BE] SISC1-56 [FEAT] 토끼 오류 반영
discipline24 Nov 13, 2025
5211c44
[BE] SISC1-56 [FEAT] 토끼 오류 반영
discipline24 Nov 13, 2025
3d0b5e9
[BE] SISC1-56 [COMMENT] 주석 추가
discipline24 Nov 16, 2025
a219d85
[BE] SISC1-56 [REFACTOR] 한국 시간 기준으로 bar 생성 설정
discipline24 Nov 16, 2025
4b47ada
[BE] SISC1-56 [FEAT] 매수 매도 비중 설정 구현중
discipline24 Nov 19, 2025
6c595da
Merge branch 'main' into SISC1-56-BE-백테스팅-실행-API-구현
discipline24 Nov 19, 2025
eb1176b
Merge branch 'main' into SISC1-56-BE-백테스팅-실행-API-구현
discipline24 Nov 19, 2025
46dbcae
[BE] SISC1-56 [FEAT] 기본 청산 기간 추가 및 백테스팅 가능한 티커 반환 API 구현
discipline24 Nov 20, 2025
48ee07b
[BE] SISC1-56 [FEAT] 토끼 오류 반영
discipline24 Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
public class BacktestController {
private final BacktestService backtestService;

@GetMapping("/stocks/info")
@Operation(
summary = "백테스트용 주식 정보 조회",
description = "백테스트에 사용되는 주식의 기본 정보를 조회합니다."
)
public ResponseEntity<BacktestResponse> getBacktestStockInfo() {
return ResponseEntity.ok(backtestService.getBacktestStockInfo());
}

// 백테스트 실행 상태 조회
@GetMapping("/runs/{backtestRunId}/status")
@Operation(
Expand Down Expand Up @@ -73,6 +82,7 @@ public ResponseEntity<BacktestResponse> getBackTestResultDetails(@PathVariable L
"strategy": {
"initialCapital": 100000.00,
"ticker": "AAPL",
"defaultExitDays" : 30,
"buyConditions": [
{
"leftOperand": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public class BacktestRequest {
@Schema(description = "백테스트 실행 요청 JSON")
private BacktestRunRequest strategy;

@Schema(description = "기본 청산 기간")
private int defaultExitDays;


// 백테스트 리스트 삭제
@Schema(description = "삭제할 백테스트 실행 리스트")
private List<Long> backtestRunIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.sejongisc.backend.template.entity.Template;

import java.time.LocalDate;
import java.util.List;


@Getter
Expand All @@ -18,4 +19,5 @@
public class BacktestResponse {
private BacktestRun backtestRun;
private BacktestRunMetricsResponse backtestRunMetricsResponse;
private List<String> availableTickers;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class BacktestRunRequest {
@Schema(description = "대상 종목 티커", defaultValue = "AAPL")
private String ticker;

@Schema(description = "기본 청산 기간")
private int defaultExitDays;

@Schema(description = "매수 조건 그룹")
private List<StrategyCondition> buyConditions;

Expand All @@ -33,6 +36,10 @@ public class BacktestRunRequest {
@Schema(description = "노트", defaultValue = "골든크로스 + RSI 필터 전략 테스트")
private String note;

//@Schema(description = "거래 시 매수 비중", defaultValue = "10")
//private int buyRatio;
//@Schema(description = "거래 시 매도 비중", defaultValue = "10")
//private int sellRatio;
/*
* 타임 프레임 (예: "D", "W", "M")
private String timeFrame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import java.time.LocalDateTime;

public class TradeLog {
public enum Type { BUY, SELL }
public enum Type {
BUY,
SELL,
SELL_FORCED // 기본 청산 기간에 의한 강제 매도 구분용 추가
}
public final Type type;
public final LocalDateTime time;
public final BigDecimal price;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.UUID;

@Entity
@Getter
Expand Down Expand Up @@ -37,4 +36,20 @@ public class BacktestRunMetrics {

@Column(nullable = false)
private int tradesCount; // 총 거래 횟수

public static BacktestRunMetrics fromDto(BacktestRun backtestRun,
BigDecimal totalReturn,
BigDecimal maxDrawdown,
BigDecimal sharpeRatio,
BigDecimal avgHoldDays,
int tradesCount) {
return BacktestRunMetrics.builder()
.backtestRun(backtestRun)
.totalReturn(totalReturn)
.maxDrawdown(maxDrawdown)
.sharpeRatio(sharpeRatio)
.avgHoldDays(avgHoldDays)
.tradesCount(tradesCount)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.sejongisc.backend.backtest.repository.BacktestRunRepository;
import org.sejongisc.backend.common.exception.CustomException;
import org.sejongisc.backend.common.exception.ErrorCode;
import org.sejongisc.backend.stock.repository.PriceDataRepository;
import org.sejongisc.backend.template.entity.Template;
import org.sejongisc.backend.template.repository.TemplateRepository;
import org.sejongisc.backend.user.dao.UserRepository;
Expand All @@ -34,7 +35,17 @@ public class BacktestService {
private final BacktestingEngine backtestingEngine;
private final ObjectMapper objectMapper;
private final UserRepository userRepository;
private final PriceDataRepository priceDataRepository;

// 백테스트용 주식 정보 조회
@Transactional
public BacktestResponse getBacktestStockInfo() {
return BacktestResponse.builder()
.availableTickers(priceDataRepository.findDistinctTickers())
.build();
}

@Transactional
public BacktestResponse getBacktestStatus(Long backtestRunId, UUID userId) {
log.info("백테스팅 실행 상태 조회를 시작합니다.");
BacktestRun backtestRun = findBacktestRunByIdAndVerifyUser(backtestRunId, userId);
Expand Down Expand Up @@ -105,7 +116,7 @@ public BacktestResponse runBacktest(BacktestRequest request) {
log.info("백테스팅 실행 요청이 성공적으로 처리되었습니다. ID: {}", savedRun.getId());

// 비동기로 백테스팅 실행 시작
backtestingEngine.execute(savedRun.getId());
backtestingEngine.execute(savedRun);

// 사용자에게 실행 중 응답 반환
return BacktestResponse.builder()
Expand Down
Loading