바스켓 현금배분 기능(target_stock_weight) — 안정성 처방을 자동매매 기능으로 - #390
Merged
Conversation
정적 배분 분석(주식 비중 낮추고 현금 섞으면 낙폭 절반)이 문서 권장에만 머물렀는데, 이걸 실제 자동매매 기능으로 구현했다. BasketRebalancer가 바스켓의 target_stock_weight를 읽어 주식 목표 비중(총자산 대비)을 정하고 나머지는 현금으로 유보한다. - _stock_fraction() = min(target_stock_weight, 1 - min_cash_ratio). target_stock_weight 미지정 시 기존 동작(1 - min_cash_ratio) 그대로 → 하위 호환. - investable 계산 2곳을 _stock_fraction() 기반으로 통일. - config/baskets.yaml에 kr_balanced_5050(주식50/현금50) 추가: 백테스트상 순수 주식 대비 MDD -25.5%→-11.9%, Sharpe 0.58→0.64로 안정성↑. enabled:false(운영자 검증 후). - 단위 테스트 4개: 기본 비중, 50% 배분, 현금 하한 cap, plan notional이 비중에 비례. 검증: 전체 1330 테스트 통과. 균형 바스켓 주식 50%·기본 바스켓 기존 동작 유지 확인.
easygap
added a commit
that referenced
this pull request
Jul 6, 2026
바스켓 현금배분 기능(target_stock_weight) — 안정성 처방을 자동매매 기능으로
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
정적 자산배분 분석(낙폭을 절반으로 줄이는 주식/현금 혼합)이 그동안 문서 권장에만 머물렀는데,
이걸 실제 자동매매 기능으로 구현했습니다. 바스켓이
target_stock_weight로 주식 목표 비중을명시하면, 리밸런서가 나머지를 현금으로 유보합니다. 이제 "안정성 처방"이 운영자 수작업이 아니라
시스템이 집행하는 기능입니다.
변경 내용
core/basket_rebalancer.py:target_stock_weight(총자산 대비 주식 비중) 읽기._stock_fraction()=min(target_stock_weight, 1 - min_cash_ratio).1 - min_cash_ratio) 그대로 → 하위 호환.investable계산 2곳을_stock_fraction()으로 통일.config/baskets.yaml:kr_balanced_5050(주식50/현금50) 추가. 백테스트상 순수 주식 대비MDD −25.5%→−11.9%, Sharpe 0.58→0.64.
enabled:false(운영자 검증 후 활성화).비중에 비례(balanced < full).
효과
운영자가 "안정적"을 원하면
kr_balanced_5050처럼target_stock_weight: 0.5바스켓을 켜면,자동매매가 주식 50%만 유지하고 50%를 현금으로 둬 낙폭을 절반 수준으로 관리합니다. 자본을
수동으로 쪼개 배정할 필요가 없습니다.
검증
전체 1330 테스트 통과. 균형 바스켓이 주식 50%, 기본 바스켓이 기존 동작(0.80) 유지함을 확인.