MODUL 5: 13 reparatii pe lectiile 1-3, dupa verificare

Trei blocante: regula "masori de la extrem" era trecuta la "din curs" desi
cursul masoara doar din punctul 2 pe exemplul Pepsi, fara sa enunte regula;
"dubleaza de doua ori R-ul" nu se potrivea cu propriile cifre (2.7R -> 6.5R);
si partea a 4-a proiecteaza tinta de la close-ul de breakout, nu de la linia
sparta ca partile 2-3, fara sa semnaleze diferenta - acum o spune, cu citatele.

Restul: 122% era pus pe WBD desi cursul il rosteste pe un simbol nenumit; o
afirmatie de exclusivitate falsa; SPY dat ca "la jumatate" cand sursa spune
"aproape indeplinit"; Apple mutat din daily in 4 ore; "sell the rally"
atribuit bear flag-ului in loc de wedge; doua enumerari de "singurele cifre"
incomplete; si trei suprapuneri de eticheta pe diagrame.

Anti-regresie: _desprinse() in gen/patternuri_complexe_4.py pica daca o
eticheta din lista clear= sta la sub 5 px de o linie desenata. L-a prins de
sase ori in timpul reparatiilor.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThN7ixZrowca8aTGrK1MUJ
This commit is contained in:
Claude Agent
2026-10-02 02:26:39 +00:00
parent 68cc117c08
commit aea592091e
11 changed files with 403 additions and 347 deletions

View File

@@ -58,7 +58,31 @@ def txt(i, p, s, color="#8b5cf6", anchor="middle", dx=0.0, dy=0.0, bold=True):
return dict(i=i, p=p, s=s, color=color, anchor=anchor, dx=dx, dy=dy, bold=bold)
def deco(ch, name, segs=(), texts=(), distante=()):
def _desprinse(svg, name, etichete, min_px=5.0):
"""Etichetele date nu au voie sa stea pe nicio linie (regresia 11/12)."""
# fitilele candelelor (#1a1a1a) nu se numara: desenul le traverseaza oricum
lines = [tuple(map(float, m.groups()[:4])) for m in re.finditer(
r'<line x1="(-?[\d.]+)" y1="(-?[\d.]+)" x2="(-?[\d.]+)" y2="(-?[\d.]+)"'
r'[^/]*?stroke="(#[0-9a-f]{6})"', svg) if m.group(5) != "#1a1a1a"]
for m in re.finditer(r'<text x="(-?[\d.]+)" y="(-?[\d.]+)"([^>]*)>([^<]*)</text>', svg):
tx, ty, attrs, s = float(m.group(1)), float(m.group(2)), m.group(3), m.group(4)
if s not in etichete:
continue
w = 6.2 * len(s)
x0 = tx if 'anchor="start"' in attrs else tx - w if 'anchor="end"' in attrs else tx - w / 2
x1, top, bot = x0 + w, ty - 9 - min_px, ty + 3 + min_px
for lx1, ly1, lx2, ly2 in lines:
if max(lx1, lx2) < x0 or min(lx1, lx2) > x1:
continue
ys = [ly1 + (ly2 - ly1) * (max(min(x, max(lx1, lx2)), min(lx1, lx2)) - lx1)
/ ((lx2 - lx1) or 1) for x in (x0, x1)] if lx1 != lx2 else [ly1, ly2]
if min(ys) <= bot and max(ys) >= top:
raise AssertionError(
f"{name}: eticheta '{s}' sta pe linia "
f"({lx1:.0f},{ly1:.0f})-({lx2:.0f},{ly2:.0f})")
def deco(ch, name, segs=(), texts=(), distante=(), clear=()):
"""Randează graficul, injectează liniile/textele, verifică, salvează."""
saved = ch.top, ch.left, ch.width
try:
@@ -89,6 +113,8 @@ def deco(ch, name, segs=(), texts=(), distante=()):
for m in re.finditer(r"\d+\.\d\d", re.sub(r"<[^>]+>", "", t)):
assert m.group(0) in desenate, \
f"{name}: eticheta numește {m.group(0)}, care nu e un nivel desenat"
if clear:
_desprinse(svg, name, set(clear))
sus = min(ch._y(c.h) for c in ch.candles)
jos = max(ch._y(c.l) for c in ch.candles)
for lv in ch.levels:
@@ -161,15 +187,15 @@ deco(Chart(
Level(E_D, f"intrare {E_D:.2f}", "#188a3e"),
Level(TP_D, f"TP1 {TP_D:.2f} = {R_D}R", "#1a5fb4")],
marks=[Mark(2, "trend ascendent anterior", "#188a3e", "below", dy=8),
Mark(13, "picior 1", "#c00", "below"),
Mark(13, "picior 1", "#c00", "below", dy=16),
Mark(19, "picior 2 (mai jos)", "#c00", "below"),
Mark(25, "hammer in capul triunghiului", "#b06000", "below"),
Mark(25, "hammer in capul triunghiului", "#b06000", "below", dy=8),
Mark(27, "breakout cu volum", "#188a3e")],
zones=[Zone(10, 26, "wedge descendent = consolidare contra-trend (17 bare)",
"#8b5cf6")],
arrows=[Arrow(29, "stopul sta sub low-ul candelei de breakout:\n"
"daca pretul se intoarce in triunghi, ideea a murit",
price=SL_D, where="below", color="#c00", dy=18)],
price=SL_D, where="below", color="#c00", dy=30, dx=44)],
mas=[MA(20, "#b06000", dash="4 3", text="SMA-20")],
scale=24, gap=16, body_w=9, left=46, width=730, top=62, vol_h=70,
title="Wedge descendent — bull",
@@ -179,11 +205,12 @@ deco(Chart(
seg(10, L0, 13, lo_d(13), "#8b5cf6", "4 3", 1.2),
seg(13, lo_d(13), 27, lo_d(27)),
seg(10.0, L0, 10.0, U0, "#8b5cf6", "", 2.2),
seg(30.6, E_D, 30.6, TP_D, "#1a5fb4", "", 2.2)],
seg(35.6, E_D, 35.6, TP_D, "#1a5fb4", "", 2.2)],
texts=[txt(10.1, (U0 + L0) / 2, f"baza = {BAZA_D:.2f}", anchor="start", dx=4),
txt(30.4, (E_D + TP_D) / 2, f"aceeasi {BAZA_D:.2f}", "#1a5fb4",
anchor="end", dx=-4)],
distante=(BAZA_D,))
txt(35.8, (E_D + TP_D) / 2, f"aceeasi {BAZA_D:.2f}", "#1a5fb4",
anchor="start", dx=4)],
distante=(BAZA_D,),
clear=("picior 1", "breakout cu volum", "hammer in capul triunghiului"))
# ================================================ 2. wedge vs flag (forma)
cl = (ramp(29.6, 34.00, 6) # 0-5 urcare
@@ -420,7 +447,7 @@ deco(Chart(
Level(TP2_F, f"TP2 {TP2_F:.2f} = batul steagului = {R2_F}R", "#1a5fb4")],
marks=[Mark(2, "A", "#555", "below"), Mark(11, "B", "#555", dy=-20),
Mark(20, "C = aici era by the dip", "#b06000", "below"),
Mark(23, "breakout cu volum", "#188a3e", dy=-16)],
Mark(23, "breakout cu volum", "#188a3e", dy=-36)],
zones=[Zone(11, 22, "flamura (12 bare)", "#999")],
mas=[MA(20, "#b06000", dash="4 3", text="SMA-20")],
scale=13, gap=16, body_w=9, left=46, width=730, top=62, vol_h=70,
@@ -432,9 +459,11 @@ deco(Chart(
seg(14, lo_f(14), 23, lo_f(23), "#1a5fb4"),
seg(11.0, 37.00, 11.0, 40.00, "#1a5fb4", "", 2.2),
seg(3.3, POLE_A, 3.3, POLE_B, "#188a3e", "", 2.2)],
texts=[txt(11.1, 38.50, f"canal {CANAL:.2f}", "#1a5fb4", anchor="start", dx=4),
texts=[txt(11.1, 37.00, f"canal {CANAL:.2f}", "#1a5fb4", anchor="start",
dx=4, dy=32),
txt(3.2, 33.00, f"batul = {BAT:.2f}", "#188a3e", anchor="end", dx=-4)],
distante=(CANAL, BAT))
distante=(CANAL, BAT),
clear=(f"canal {CANAL:.2f}", "breakout cu volum"))
# ======================================================= 6. bear flag / ABCD short
POLE_A2, POLE_B2 = 60.00, 50.00
@@ -498,7 +527,7 @@ deco(Chart(
Level(TP2_B, f"TP2 {TP2_B:.2f} = batul steagului = {R2_B}R", "#1a5fb4")],
marks=[Mark(2, "A", "#555", "below", dy=4), Mark(11, "B", "#555", "below", dy=14),
Mark(20, "C = aici era sell the rally", "#b06000", dy=-20),
Mark(23, "breakdown cu volum", "#c00", "below", dy=14)],
Mark(23, "breakdown cu volum", "#c00", "below", dy=38)],
zones=[Zone(11, 22, "flamura (12 bare)", "#999")],
mas=[MA(20, "#b06000", dash="4 3", text="SMA-20")],
scale=13, gap=16, body_w=9, left=46, width=730, top=66, vol_h=70,
@@ -510,9 +539,11 @@ deco(Chart(
seg(11, 50.00, 23, lo_b(23), "#1a5fb4"),
seg(11.0, 50.00, 11.0, 53.00, "#1a5fb4", "", 2.2),
seg(3.3, POLE_B2, 3.3, POLE_A2, "#c00", "", 2.2)],
texts=[txt(11.1, 51.50, f"canal {CANAL2:.2f}", "#1a5fb4", anchor="start", dx=4),
texts=[txt(11.1, 50.00, f"canal {CANAL2:.2f}", "#1a5fb4", anchor="start",
dx=4, dy=28),
txt(3.2, 56.00, f"batul = {BAT2:.2f}", "#c00", anchor="end", dx=-4)],
distante=(CANAL2, BAT2))
distante=(CANAL2, BAT2),
clear=(f"canal {CANAL2:.2f}", "breakdown cu volum", "C = aici era sell the rally"))
# ============================================ 7. marubozu retestat — DA si NU
def marubozu_serie(retest_close, retest_wick_up, cont):