로고스 전략 FSM을 simulation 기본 실행에 통합한다.

수동 타점(logos_trades.json) 흐름에 맞춘 순차 매매 로직을 추가하고, python simulation.py 실행 시 로고스 백테스트·HTML을 생성한다. 규칙 탐색·BB 안전장치 개선과 함께 reports HTML은 gitignore로 제외한다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-29 19:07:10 +09:00
parent e218a8ea32
commit e631a5701f
12 changed files with 1639 additions and 100 deletions

View File

@@ -489,29 +489,44 @@ def evaluate_discovered_live(
최신 3분 봉 시점에서 discovered_rules + 전 봉 BB·일목 조합으로 신호 1건.
"""
from candle_features import build_master_feature_matrix
from rule_discovery import buy_mask, load_rules, rules_have_buy, sell_mask
from rule_discovery import (
_trigger_at,
buy_mask,
load_rules,
rules_have_buy,
sell_mask,
)
rules = load_rules()
if rules is None or not rules_have_buy(rules):
return None
matrix = build_master_feature_matrix(frames)
if len(matrix) < 22:
if len(matrix) < 23:
return None
last = matrix.iloc[[-1]]
ts = last.index[-1]
close = float(last["Close"].iloc[-1])
tail = matrix.iloc[-2:]
i = 1
ts = tail.index[-1]
close = float(tail["Close"].iloc[-1])
trend = get_trend_at(df_1d, df_1h, ts)
b_m = buy_mask(tail, rules)
s_m = sell_mask(tail, rules, stop=False)
st_m = (
sell_mask(tail, rules, stop=True)
if rules.sell_stop
else np.zeros(len(tail), dtype=bool)
)
position = float(balances.get(symbol, {}).get("balance", 0) or 0)
if position >= 1.0:
if rules.sell_stop and sell_mask(last, rules, stop=True)[0]:
if rules.sell_stop and _trigger_at(st_m, i):
return TradeSignal("sell", SIGNAL_SELL_STOP, close, trend)
if sell_mask(last, rules, stop=False)[0]:
if _trigger_at(s_m, i):
return TradeSignal("sell", SIGNAL_SELL_UPPER, close, trend)
return None
if buy_mask(last, rules)[0]:
if _trigger_at(b_m, i):
return TradeSignal("buy", SIGNAL_BUY_LOWER, close, trend)
return None