패키지 구성
구매 시 제공되는 실제 파일 구성
regime-dynamic-rebal-001/
파일 구성
📊backtest.py백테스트 & 전략 로직
1import yaml23def run_backtest(start, end, params, trade_start):4"""레짐 기반 동적 리밸런싱 백테스트"""5df = download_data(symbols, start, end)6ma = df['close'].rolling(params['ma_period']).mean()78for date in df.index:9regime = "bull" if close > ma else "bear"1011if regime == "bull":12rebalance(QQQM, TQQQ, threshold=3.5)13else:14rebalance(TQQQ, SQQQ, threshold=0.75)1516return calculate_metrics(portfolio)1718if __name__ == '__main__':19with open('config.yaml') as f:20config = yaml.safe_load(f)21result = run_backtest(params=config)
이용 방법
03
실행
config.yaml에서 파라미터를 조정하고 python backtest.py로 바로 실행합니다.