buy_doji: refacut ca tutorial pe 3 niveluri, cu diagrame adnotate
Userul a respins mostra de format tutorial: prea lunga, prea multe trimiteri in text, termeni tehnici nedefiniti, prea multe cifre fara desen. Cerintele lui sunt acum contract in STYLE.md (FORMAT TUTORIAL v2). Textul: 8430 -> 4190 de cuvinte. Nivel 1 (din avion, cu mini-glosar) -> nivel 2 (6 pasi mecanici, o diagrama fiecare) -> oglinda short -> nivel 3 (rafinari). Trimiterile fisier:linie ies din corp si se aduna la final, cu legenda de prescurtari. Doua tabele in tot documentul. Toate cele 14 diagrame refacute: zone dreptunghiulare de evidentiere si sageti care spun si de ce, nu doar ce. svg_candles primeste Zone si Arrow; render() nu mai muta obiectul la iesire. Trei corecturi de continut: - un singur trade prin toata procedura (doji 50.10/49.25, intrare 50.40, stop 49.20, 1R 1.20, TP1 51.60); seria e acum o functie comuna, importata de stop/transe/iesire - short: stopul urca la 100.15, ca sa fie deasupra maximului cum cere regula oglindita; cifra cursului ramane in text ca observatie - LABU: trei minime dar doua atingeri ale pivotului 86.00, ceea ce impaca "triple bottom" cu "al doilea test", ambele din transcriere Reparat si bug-ul vechi din buy_doji_sell.svg: titlul peste eticheta dojiului. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ThN7ixZrowca8aTGrK1MUJ
This commit is contained in:
@@ -12,7 +12,7 @@ Rulare: python3 gen/strategii/buy_doji_directie.py
|
||||
from pathlib import Path
|
||||
|
||||
OUT = Path(__file__).with_suffix(".svg")
|
||||
W = 720
|
||||
W = 900
|
||||
|
||||
|
||||
def trend(start, closes, wick=0.15):
|
||||
@@ -55,10 +55,11 @@ for name, (o, h, l, c) in (("doji weekly", WK[7]), ("doji daily", DY[9])):
|
||||
assert WK[8][3] > WK[7][1], "weekly: fără confirmare"
|
||||
assert DY[10][3] < DY[9][2], "daily: fără confirmare Sell Doji"
|
||||
ENTRY = DY[10][3]
|
||||
SL = max(b[1] for b in DY[7:11])
|
||||
# stopul: 5 cenți peste high-ul ultimelor 4 candele, ca la pasul 5 (oglindit)
|
||||
SL = round(max(b[1] for b in DY[7:11]) + 0.05, 2)
|
||||
RISK = round(SL - ENTRY, 2)
|
||||
TP1 = round(ENTRY - RISK, 2)
|
||||
assert eq(ENTRY, 83.60) and eq(SL, 84.80) and eq(RISK, 1.20) and eq(TP1, 82.40)
|
||||
assert eq(ENTRY, 83.60) and eq(SL, 84.85) and eq(RISK, 1.25) and eq(TP1, 82.35)
|
||||
LOW_AFTER = min(b[2] for b in DY[11:])
|
||||
assert eq(LOW_AFTER, 83.00) and LOW_AFTER > TP1, "TP1 atins"
|
||||
HIT = next(i for i in range(11, 17) if DY[i][1] >= SL - 1e-9)
|
||||
@@ -89,6 +90,16 @@ def rect(x, y, w, h, fill, opacity, stroke="none"):
|
||||
f'fill-opacity="{opacity}" stroke="{stroke}" rx="3"/>')
|
||||
|
||||
|
||||
def arrow(x1, y1, x2, y2, color):
|
||||
"""Săgeată de la (x1,y1) la vârful (x2,y2): linie + cap triunghi."""
|
||||
d = max(((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5, 1e-9)
|
||||
ux, uy = (x2 - x1) / d, (y2 - y1) / d
|
||||
bx, by = x2 - 9 * ux, y2 - 9 * uy
|
||||
line(x1, y1, bx, by, color, 1.8)
|
||||
out.append(f'<polygon points="{x2:.1f},{y2:.1f} {bx - 4.5 * uy:.1f},{by + 4.5 * ux:.1f} '
|
||||
f'{bx + 4.5 * uy:.1f},{by - 4.5 * ux:.1f}" fill="{color}"/>')
|
||||
|
||||
|
||||
def candles(bars, x0, gap, yf):
|
||||
for i, (o, h, l, c) in enumerate(bars):
|
||||
cx = x0 + i * gap
|
||||
@@ -112,11 +123,12 @@ rect(xw(7) - 8, yw(WK[8][1]) - 4, WGAP + 16, yw(WK[7][2]) - yw(WK[8][1]) + 8,
|
||||
GREEN, 0.12, GREEN)
|
||||
candles(WK, WX0, WGAP, yw)
|
||||
text(xw(7), yw(WK[7][2]) + 16, "doji weekly", fill=ORANGE, anchor="middle", bold=True)
|
||||
text(xw(9) + 14, yw(WK[8][3]) + 4, "Buy Doji weekly: direcția = long", fill=GREEN, bold=True)
|
||||
# insigna de direcție
|
||||
rect(470, 66, 230, 58, GREEN, 0.10, GREEN)
|
||||
text(585, 90, "WEEKLY: LONG ↑", fill=GREEN, anchor="middle", bold=True, size=16)
|
||||
text(585, 110, "confirmare 81.30 > high doji 79.80", fill=GREEN, anchor="middle", size=11)
|
||||
# săgeata weekly: ce + de ce
|
||||
arrow(300, yw(WK[8][3]) - 6, xw(8) + 12, yw(WK[8][3]) - 6, GREEN)
|
||||
text(306, yw(WK[8][3]) - 10, "weekly: Buy Doji confirmat (close 81.30, peste high-ul doji-ului 79.80)",
|
||||
fill=GREEN, bold=True)
|
||||
text(306, yw(WK[8][3]) + 8, "deci direcția permisă e LONG: pe daily cauți doar Buy Doji",
|
||||
fill=GREEN)
|
||||
w_bottom = yw(min(b[2] for b in WK))
|
||||
|
||||
# ---- panoul de jos: daily -----------------------------------------------------
|
||||
@@ -136,42 +148,33 @@ rect(xd(9) - 8, yd(DY[9][1]) - 3, DGAP + 16, yd(DY[10][2]) - yd(DY[9][1]) + 6, O
|
||||
line(LX1, y_sl, LX2, y_sl, RED, 1.5, "6 3")
|
||||
line(xd(10) - 8, y_e, LX2, y_e, ORANGE, 1.5, "6 3")
|
||||
line(xd(10) - 8, y_tp, LX2, y_tp, GRAY, 1.5, "2 3")
|
||||
text(COL, y_sl + 4, "SL 84.80 = high 4 candele", fill=RED, size=11)
|
||||
text(COL, y_sl + 4, "stop 84.85 = 5 cenți peste high-ul de 4 candele", fill=RED, size=11)
|
||||
text(COL, y_e + 4, "intrare short 83.60", fill=ORANGE, size=11)
|
||||
text(COL, y_tp + 4, "TP1 82.40 — neatins", fill=GRAY, size=11)
|
||||
text(COL, y_tp + 4, "ținta 82.35 — neatinsă (a scăzut o zi, la 83.00)",
|
||||
fill=GRAY, size=11)
|
||||
candles(DY, DX0, DGAP, yd)
|
||||
|
||||
# paranteza „short de 1-2 zile" peste barele 10-11
|
||||
xa, xb, yb = xd(10) - 6, xd(11) + 6, y_sl - 12
|
||||
out.append(f'<path d="M{xa:.1f},{yb + 6:.1f} V{yb:.1f} H{xb:.1f} V{yb + 6:.1f}" '
|
||||
f'fill="none" stroke="{GRAY}" stroke-width="1.2"/>')
|
||||
text(xb, yb - 6, "short de 1-2 zile: permis", fill=GRAY, anchor="end", bold=True)
|
||||
|
||||
# SL lovit la bara 14
|
||||
# SL lovit la bara 14: săgeată din dreapta sus
|
||||
cx14 = xd(HIT)
|
||||
out.append(f'<circle cx="{cx14:.1f}" cy="{y_sl:.1f}" r="7" fill="none" stroke="{RED}" '
|
||||
f'stroke-width="2"/>')
|
||||
y_lbl = DT - 22
|
||||
line(cx14, y_sl - 8, cx14, y_lbl + 4, RED, 1.2)
|
||||
text(cx14 - 6, y_lbl, "SL lovit: poziția short contra weekly", fill=RED, anchor="middle", bold=True)
|
||||
y_hit = DT - 40
|
||||
arrow(560, y_hit + 6, cx14 + 9, y_sl - 9, RED)
|
||||
text(568, y_hit, "aici te-a scos: stopul 84.85, lovit a patra zi", fill=RED, bold=True)
|
||||
text(568, y_hit + 18, "banii mari de pe weekly cumpără mai departe", fill=RED)
|
||||
|
||||
# Sell Doji: etichetă sub panou, cu leader spre confirmare
|
||||
# intrarea short: săgeată de jos-dreapta spre close-ul confirmării
|
||||
y_bot = yd(min(b[2] for b in DY))
|
||||
y_sd = y_bot + 22
|
||||
line(xd(10), yd(DY[10][2]) + 4, xd(10), y_sd - 12, ORANGE, 1.2)
|
||||
text(xd(10) - 20, y_sd, "Sell Doji daily: tehnic valid (close 83.60 < low doji 83.95)",
|
||||
x_e = xd(12) + 6
|
||||
arrow(x_e, y_tp + 30, xd(10) + 7, y_e + 4, ORANGE)
|
||||
text(x_e + 6, y_tp + 28, "aici ai intrat SHORT, la 83.60: Sell Doji corect ca formă",
|
||||
fill=ORANGE, bold=True)
|
||||
text(x_e + 6, y_tp + 46, "(close sub low-ul doji-ului 83.95) — dar contra weekly-ului",
|
||||
fill=ORANGE)
|
||||
|
||||
# insigna de contrast
|
||||
rect(470, DT - 36, 230, 58, RED, 0.08, RED)
|
||||
text(585, DT - 12, "short daily = CONTRA ✗", fill=RED, anchor="middle", bold=True, size=16)
|
||||
text(585, DT + 8, "weekly zice long; daily urcă mai departe", fill=RED, anchor="middle", size=11)
|
||||
|
||||
y0 = y_sd + 32
|
||||
text(20, y0, "Short scurt înăuntrul structurii weekly: da. Poziție short contra ei: nu.",
|
||||
fill=INK, bold=True)
|
||||
text(20, y0 + 18, "Seria e construită: un singur caz ilustrează regula, nu o dovedește.", fill="#555")
|
||||
H = y0 + 30
|
||||
y0 = max(y_bot, y_tp + 46) + 34
|
||||
text(20, y0, "Seria e construită: un singur caz ilustrează regula, nu o dovedește.", fill="#555")
|
||||
H = y0 + 24
|
||||
|
||||
svg = (f'<svg viewBox="0 0 {W} {H:.0f}" xmlns="http://www.w3.org/2000/svg" '
|
||||
f'style="width:100%;height:auto;font:12px sans-serif">\n ' + "\n ".join(out) + "\n</svg>")
|
||||
|
||||
Reference in New Issue
Block a user