Risk & position-sizing checksIntermediate#pre-market#checklist#python#position-sizing#long-only

Check your drawdown rules before each session and record the day's mode

Before you look for anything new, a script reads your equity log and your own drawdown rules and records today's mode: normal, reduced size or review-only. If the data is missing or stale, it records review-only and explains why.

How it works

  1. Write your drawdown rules as plain thresholds before you need them, for example: more than 5% below the equity peak means reduced size for new positions; more than 10% below, or three losing trades in a row, means review-only (no new positions until you've done a written review). The numbers are yours.
  2. Keep a daily equity log you update yourself: date, closing account value, the result of any trade closed that day, and any deposit or withdrawal (0 if none). Use your broker statement or export as the source; a sheet saved as a CSV works.
  3. A short script, which you can have a coding agent write, reads the log and rules each morning and works out the distance from peak, the losing streak and the date of the last entry.
  4. It records today's mode in your journal (normal, reduced or review-only) with the numbers and the rule that set it.
  5. If the log is missing, older than your limit or doesn't add up (a gap, a duplicate date, or a jump on a day with no closed trade or cash flow that is bigger than a tolerance you set), the script records review-only and the reason. Ordinary moves in open positions are not a failed check. It never assumes normal.
  6. You read the mode before your pre-market routine starts. Leaving review-only needs your written review and a dated line in the journal saying why, not just a new day.

Copy-paste prompt

Write a small Python script for my own pre-session check. It gives no trading advice and never suggests trades,
markets or securities.

Inputs: my equity log {{equity_log_csv}} (date, closing_value, closed_trade_results, deposit_withdrawal) and my rules
file {{rules_file}} (thresholds for "reduced" and "review-only", the losing-streak rule, the maximum data age in days
and {{jump_tolerance}}).

The script must:
1. Work out the current distance from the equity peak in percent (adjusting the peak for logged deposits and
   withdrawals), the current losing streak in consecutive closed trades, and the date of the latest row.
2. Choose the mode, normal, reduced or review-only, using only my rules. Where rules conflict, the stricter mode wins.
3. Choose review-only, giving the reason, if the log is missing, older than the maximum data age, has duplicate or
   missing dates, or shows a day-over-day jump that closed trades plus deposit_withdrawal cannot explain within
   {{jump_tolerance}} on a day with no closed trade. Ordinary mark-to-market moves in open positions are not bad data.
4. Print the proposed journal line (date, mode, distance from peak, streak, the rule that applied, data checks passed
   or failed) and append it to my journal file only when I confirm.
It must not connect to any broker or place orders, and must not change my rules file or my equity log.
Include three test cases with expected modes that I can check by hand.

Guardrails

  • The thresholds are yours and written in advance; the script doesn't suggest or adjust them.
  • Bad, stale or missing data means review-only. The script never falls back to normal.
  • Where rules conflict, the stricter mode wins.
  • It reads your own log and appends one line to your journal. It has no broker connection and cannot place orders.
  • Only your own dated note gets you out of review-only, not the calendar.

What can go wrong

A drawdown rule written in the middle of a drawdown tends to be generous, which is why the thresholds have to exist on a calm day. The script only reads what you log. A deposit or withdrawal you forget to note will make a drawdown look smaller or larger, so the consistency check flags unexplained jumps instead of guessing. And a mode you don't read is just a log line: put it at the top of the routine, not in a file you open on Fridays.

Why it helps

Drawdown rules are easy to write and hard to follow, because the moment they apply is the moment you least want them to. Having the script work out the mode from your own log before the session moves the decision to a time and place where it's just arithmetic. Treating bad data as review-only closes the easiest loophole: "the numbers are probably fine."

How it fits with other entries

The sizing check (aft-0008) uses the mode to cap risk per trade on reduced days. Proving the script on hand-checked cases (aft-0036) applies directly to the three test cases in the prompt. The pre-trade checklist (aft-0015) can open with the mode, and the emotion check (aft-0026) is a natural part of the written review that ends review-only.

Where this comes from

A public post by Dan Kornas (@DanKornas) on X about an open-source collection of Claude skills whose swing workflow checks drawdown and discipline gates before any screening. One of those skills is a drawdown circuit-breaker. We kept the idea that risk comes before research and wrote our own minimal version around your thresholds and your log.

Source and references

Inspired by a public post by @DanKornas on X about an open-source collection of Claude skills that checks drawdown and discipline gates before any screening, one of which is a drawdown circuit-breaker. The modes, the stale-data rule and the journal line are our own adaptation and wording.

Original: Dan Kornas on x

Spotted an error, or want your post removed? Email hello@agentsfortraders.com.

Educational content only. Not investment advice or a personal recommendation. No tickers, signals or trade alerts. Trading involves risk of loss.

Conteúdo exclusivamente educativo. Não constitui aconselhamento nem recomendação de investimento. Sem tickers, sinais ou alertas de negociação. Negociar envolve risco de perda.

Related use cases