<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: joeschatzman</title>
    <description>The latest articles on DEV Community by joeschatzman (@joeschatzman).</description>
    <link>https://dev.to/joeschatzman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3974932%2F67cf3379-6770-40dc-9c6e-fbe91e4610b8.png</url>
      <title>DEV Community: joeschatzman</title>
      <link>https://dev.to/joeschatzman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joeschatzman"/>
    <language>en</language>
    <item>
      <title>Why Your Backtest Is Lying to You (and How to Close the Backtest-to-Live Gap)</title>
      <dc:creator>joeschatzman</dc:creator>
      <pubDate>Wed, 23 Sep 2026 00:46:47 +0000</pubDate>
      <link>https://dev.to/joeschatzman/why-your-backtest-is-lying-to-you-and-how-to-close-the-backtest-to-live-gap-9f2</link>
      <guid>https://dev.to/joeschatzman/why-your-backtest-is-lying-to-you-and-how-to-close-the-backtest-to-live-gap-9f2</guid>
      <description>&lt;p&gt;I once built a strategy with a beautiful backtest. Smooth equity curve, healthy Sharpe, a win rate that made me feel clever. I put it live.&lt;/p&gt;

&lt;p&gt;It proceeded to lose money at roughly an 8% win rate and cost me five figures before I pulled the plug.&lt;/p&gt;

&lt;p&gt;Nothing about the code was "wrong." The backtest was just lying to me — quietly, in the specific ways backtests always do. This post is the checklist I wish I'd run &lt;em&gt;before&lt;/em&gt; going live. None of it is exotic; all of it is the difference between a number that flatters you and a process you can trust.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why backtests overstate reality
&lt;/h2&gt;

&lt;p&gt;A backtest is a simulation, and every simulation makes assumptions. The optimistic ones stack up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Overfitting.&lt;/strong&gt; If you tune parameters until the curve looks great, you haven't found an edge — you've memorized the noise in one slice of history. The more knobs you turn, the more certain this becomes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lookahead bias.&lt;/strong&gt; Using information that wouldn't have been available at decision time. The classic version: computing a signal on today's &lt;em&gt;close&lt;/em&gt; and then "buying at the close." In reality you'd act on the &lt;em&gt;next&lt;/em&gt; bar. It's easy to leak the future without noticing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slippage and fills.&lt;/strong&gt; Backtests love to fill you at the exact price you wanted. Live markets don't. On anything less than deeply liquid instruments, the gap between assumed and actual fills eats returns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Survivorship bias.&lt;/strong&gt; Testing on today's index members ignores every ticker that got delisted. Your universe is quietly pre-filtered for winners.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regime dependence.&lt;/strong&gt; A strategy tuned on a 2023–2024 bull run has never seen a real drawdown. It looks robust because it was never stressed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Individually, each nudges results up a little. Together, they can turn a break-even system into a "genius" backtest.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to actually close the gap
&lt;/h2&gt;

&lt;p&gt;The goal isn't a prettier backtest. It's a strategy that behaves live roughly like it did in the test. Here's the sequence that gets you there.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Split your data — and mean it
&lt;/h3&gt;

&lt;p&gt;Tune on one stretch of history, then evaluate on data the strategy has &lt;strong&gt;never touched&lt;/strong&gt;. The simplest version: build on 2023–2024, validate on 2025. Better: &lt;strong&gt;walk-forward&lt;/strong&gt; — repeatedly optimize on a window, test on the next unseen window, and roll it forward. If performance falls off a cliff out-of-sample, you found an artifact, not an edge.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Conceptual walk-forward loop
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;train_window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_window&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;rolling_windows&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;optimize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_window&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# fit on the past
&lt;/span&gt;    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# judge ONLY on unseen data
&lt;/span&gt;    &lt;span class="n"&gt;oos_results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# The out-of-sample curve is the one that matters.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Stress the trade &lt;em&gt;order&lt;/em&gt;, not just the trades
&lt;/h3&gt;

&lt;p&gt;A single equity curve is one lucky (or unlucky) ordering of your trades. &lt;strong&gt;Monte Carlo&lt;/strong&gt; it: reshuffle the trade sequence thousands of times and look at the distribution of outcomes. If the 5th-percentile path is a catastrophe, your "safe" strategy isn't — you just got a friendly ordering the first time.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Model slippage and commissions on purpose
&lt;/h3&gt;

&lt;p&gt;Add realistic per-trade cost and slippage assumptions and re-run. If a small, honest slippage estimate erases the edge, the edge was never real — it lived in the frictionless fantasy of a naive fill model.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Paper trade before real capital
&lt;/h3&gt;

&lt;p&gt;Run the exact same logic against live market data with no money on the line. This is where lookahead bugs and data-feed quirks surface — the ones no historical test can catch because they only exist in the seam between "backtest engine" and "live engine." Ideally the &lt;em&gt;same code&lt;/em&gt; runs both, so there's no second implementation to drift.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Put the guardrails in before you need them
&lt;/h3&gt;

&lt;p&gt;Even a validated strategy meets a market it didn't expect. Decide your limits up front and let the machine enforce them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;position sizing rules (fixed fractional, volatility-scaled — pick one and stick to it),&lt;/li&gt;
&lt;li&gt;a hard per-trade risk cap,&lt;/li&gt;
&lt;li&gt;and a &lt;strong&gt;drawdown circuit breaker&lt;/strong&gt; that halts the strategy automatically if it hits your max-loss line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The point isn't to predict the bad day. It's to make sure the bad day can't compound while you're asleep.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest checklist
&lt;/h2&gt;

&lt;p&gt;Before anything goes live, I want a "yes" to all of these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Does it survive &lt;strong&gt;out-of-sample / walk-forward&lt;/strong&gt;, not just the fitted window?&lt;/li&gt;
&lt;li&gt;[ ] Is the &lt;strong&gt;Monte Carlo&lt;/strong&gt; distribution acceptable at the 5th percentile, not just the median?&lt;/li&gt;
&lt;li&gt;[ ] Does it still work with &lt;strong&gt;realistic slippage + commissions&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;[ ] Did it run in &lt;strong&gt;paper trading&lt;/strong&gt; and behave like the backtest?&lt;/li&gt;
&lt;li&gt;[ ] Are &lt;strong&gt;position sizing, risk limits, and a drawdown halt&lt;/strong&gt; actually wired in?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any answer is "no," I don't have an edge yet. I have a hypothesis and a pretty chart.&lt;/p&gt;

&lt;h2&gt;
  
  
  A note on tooling
&lt;/h2&gt;

&lt;p&gt;You can do all of this by hand — walk-forward loops, a Monte Carlo reshuffler, a slippage model, a paper-trading harness, a risk monitor. I eventually got tired of rebuilding that scaffolding for every idea and built a self-hosted framework where the same engine backtests and trades live, so there's no second implementation to drift. That's &lt;a href="https://algo-deploy.com/" rel="noopener noreferrer"&gt;AlgoDeploy&lt;/a&gt; if you're curious — but the &lt;em&gt;method&lt;/em&gt; above is the thing that matters, whatever you run it with.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-sentence version
&lt;/h2&gt;

&lt;p&gt;A great backtest is easy; a real edge is hard — and the entire job of a serious process is to tell them apart &lt;strong&gt;before&lt;/strong&gt; you fund the account, not after.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Backtested and hypothetical results have inherent limitations and do not guarantee future performance. Nothing here is investment advice — it's about software and process. Trade your own decisions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>I built a self-hosted algo-trading stack in Python — backtest to live, no black box</title>
      <dc:creator>joeschatzman</dc:creator>
      <pubDate>Wed, 29 Jul 2026 12:47:41 +0000</pubDate>
      <link>https://dev.to/joeschatzman/i-built-a-self-hosted-algo-trading-stack-in-python-backtest-to-live-no-black-box-pln</link>
      <guid>https://dev.to/joeschatzman/i-built-a-self-hosted-algo-trading-stack-in-python-backtest-to-live-no-black-box-pln</guid>
      <description>&lt;p&gt;Every "algo trading platform" I tried made me pick one of two bad options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A hosted black box&lt;/strong&gt; — upload your strategy to someone else's cloud, run it on their runtime, pay a monthly fee, and hope their fills resemble reality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Roll your own&lt;/strong&gt; — weeks of plumbing (broker APIs, data feeds, order lifecycle, risk management) before you place a single live trade.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I wanted a third option: &lt;strong&gt;bring my own Python strategy and run it on infrastructure I control&lt;/strong&gt; — my machine, my broker keys, no cloud lock-in. Here's what that actually takes, the parts that bit me, and the tool I ended up building.&lt;/p&gt;

&lt;h2&gt;
  
  
  The strategy is the easy part. It's everything &lt;em&gt;around&lt;/em&gt; it that's hard.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Backtest-to-live parity (the #1 way backtests lie)
&lt;/h3&gt;

&lt;p&gt;The most common way a backtest lies to you: &lt;strong&gt;your live code path differs from your backtest code path.&lt;/strong&gt; If your backtest fills at the bar close but live fills at next-bar-open with slippage, your equity curve is fiction.&lt;/p&gt;

&lt;p&gt;The fix is architectural: the &lt;strong&gt;same engine runs both&lt;/strong&gt;. Signal evaluation, position sizing, and risk checks share one implementation — only the &lt;em&gt;data source&lt;/em&gt; and the &lt;em&gt;execution target&lt;/em&gt; swap out. A vectorized pass gives you speed for research; an event-driven pass gives you realism (next-bar fills, slippage, commissions) and is the exact code that runs live.&lt;/p&gt;

&lt;p&gt;If your "live trader" is a separate implementation from your backtester, you don't actually know what you're deploying.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Broker abstraction — Alpaca vs Interactive Brokers
&lt;/h3&gt;

&lt;p&gt;These two brokers could not be more different to integrate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Alpaca&lt;/strong&gt; is a clean REST API. Keys in, JSON out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IBKR&lt;/strong&gt; is a socket API through TWS or IB Gateway that has to be &lt;em&gt;running&lt;/em&gt;, with session quirks, contract qualification, and a forced daily restart.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your strategy code talks directly to either one, you're locked in. The fix is a thin &lt;strong&gt;broker interface&lt;/strong&gt; — &lt;code&gt;place_order&lt;/code&gt;, &lt;code&gt;get_positions&lt;/code&gt;, &lt;code&gt;get_quote&lt;/code&gt;, &lt;code&gt;get_bars&lt;/code&gt; — with adapters behind it. Strategy code never sees broker-specific objects.&lt;/p&gt;

&lt;p&gt;A few real IBKR gotchas I hit building the adapter, in case they save you time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Contracts must be "qualified"&lt;/strong&gt; (populate &lt;code&gt;conId&lt;/code&gt;) before you can request market data or
place orders — otherwise &lt;code&gt;reqTickers&lt;/code&gt; throws.&lt;/li&gt;
&lt;li&gt;IBKR returns &lt;code&gt;1.7976931348623157e+308&lt;/code&gt; (max double, its "UNSET" sentinel) for empty price
fields — a market order will report a bogus ~1.8e308 limit price if you don't strip it.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;daily gateway restart&lt;/strong&gt; means a 24/7 live strategy needs reconnection handling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of that is in the strategy. All of it has to be abstracted away so the strategy stays portable.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Risk management as a first-class citizen — not an afterthought
&lt;/h3&gt;

&lt;p&gt;Bugs happen. A runaway loop or a bad signal shouldn't drain an account. So risk lives &lt;em&gt;in the&lt;br&gt;
execution path&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pre-trade checks&lt;/strong&gt; — position limits, buying power, max order size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A runtime drawdown circuit breaker&lt;/strong&gt; — halts trading when equity draws down past a threshold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If risk is a wrapper you can forget to call, it's not risk management.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Be honest about what's still hard
&lt;/h3&gt;

&lt;p&gt;No backtest fully models &lt;strong&gt;slippage, fill timing, or market impact&lt;/strong&gt; — configurable slippage and commission modeling narrows the gap but doesn't close it. And live-trading &lt;em&gt;reliability&lt;/em&gt; (the IBKR gateway restart, reconnection, monitoring) is genuine operational work. Anyone selling you "backtest = live" is selling you something.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I ended up building: AlgoDeploy
&lt;/h2&gt;

&lt;p&gt;I packaged all of the above into &lt;strong&gt;&lt;a href="https://algo-deploy.com" rel="noopener noreferrer"&gt;AlgoDeploy&lt;/a&gt;&lt;/strong&gt; — backtest,&lt;br&gt;
risk-manage, and go live on &lt;strong&gt;your own Alpaca or Interactive Brokers account&lt;/strong&gt; (US equities,&lt;br&gt;
single-leg options, crypto). You build strategies in a no-code dashboard, a YAML config, or&lt;br&gt;
Python — all the same engine underneath. It runs on your machine with your keys; nothing is&lt;br&gt;
routed through a hosted backend.&lt;/p&gt;

&lt;p&gt;It's a one-time license (you own the version you buy), source-available, with a 7-day free trial. &lt;strong&gt;Honest scope:&lt;/strong&gt; IBKR is US equities + single-leg options + crypto today; multi-leg spreads, futures, and forex are on the roadmap.&lt;/p&gt;

&lt;p&gt;If you've ever wanted to run your own strategies without renting a platform &lt;em&gt;or&lt;/em&gt; building all&lt;br&gt;
the plumbing yourself, I'd genuinely value your feedback — especially on what's missing for&lt;br&gt;
your workflow.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://algo-deploy.com" rel="noopener noreferrer"&gt;https://algo-deploy.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>fintech</category>
      <category>showdev</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>How I Built a Python Backtesting Engine with 623 Tests</title>
      <dc:creator>joeschatzman</dc:creator>
      <pubDate>Mon, 08 Jun 2026 23:16:17 +0000</pubDate>
      <link>https://dev.to/joeschatzman/how-i-built-a-python-backtesting-engine-with-623-tests-1njo</link>
      <guid>https://dev.to/joeschatzman/how-i-built-a-python-backtesting-engine-with-623-tests-1njo</guid>
      <description>&lt;p&gt;I spent the last year building a backtesting and live trading engine in Python. It started as a personal tool — I was tired of rewriting the same plumbing every time I wanted to test a strategy. Here's how it turned into a real product.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Every time I wanted to backtest a trading strategy, I ended up writing the same boilerplate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pull OHLCV data from somewhere&lt;/li&gt;
&lt;li&gt;Wire up indicators&lt;/li&gt;
&lt;li&gt;Write entry/exit logic&lt;/li&gt;
&lt;li&gt;Track positions, P&amp;amp;L, drawdowns&lt;/li&gt;
&lt;li&gt;Build some kind of report&lt;/li&gt;
&lt;li&gt;Hope nothing broke when I changed one thing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I tried the existing tools. Some were abandoned. Some forced you into their API patterns. Some were notebooks-only with no path to live execution. None of them let me go from "I have an idea" to "it's running live" without rewriting half the code.&lt;/p&gt;

&lt;p&gt;So I built my own.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;AlgoDeploy is a Python engine that covers the full loop:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategy definition&lt;/strong&gt; → &lt;strong&gt;Backtesting&lt;/strong&gt; → &lt;strong&gt;Risk management&lt;/strong&gt; → &lt;strong&gt;Live execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The key design decision was making strategies declarative. Most strategies don't need custom Python — they're just indicator conditions, entry rules, exit rules, and position sizing. So I built a YAML config layer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;symbol&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SPY&lt;/span&gt;
&lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2020-01-01&lt;/span&gt;
&lt;span class="na"&gt;end&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2025-01-01&lt;/span&gt;
&lt;span class="na"&gt;capital&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100000&lt;/span&gt;

&lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;close &amp;lt; sma(40)&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;rsi(14) &amp;lt; &lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;

&lt;span class="na"&gt;exit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;hard_stop&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2%&lt;/span&gt;
  &lt;span class="na"&gt;trailing&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3%&lt;/span&gt;
  &lt;span class="na"&gt;take_profit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;8%&lt;/span&gt;

&lt;span class="na"&gt;position_size&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5%&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That config is a complete strategy. No Python required. But if you need custom logic, you can drop to Python and use the same engine programmatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;The engine has a few distinct layers, and keeping them separate was the most important decision I made:&lt;/p&gt;

&lt;h3&gt;
  
  
  Indicators
&lt;/h3&gt;

&lt;p&gt;11 built-in indicators (ATR, EMA, SMA, RSI, MACD, Bollinger, VWAP, Beta, OBV, Stochastic, ADX), all computed as pandas Series from OHLCV data. The indicator layer is stateless — it takes a DataFrame and returns Series. This means you can test indicators independently, swap them out, or add custom ones without touching anything else.&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparators
&lt;/h3&gt;

&lt;p&gt;Entry conditions are built from composable comparator functions: &lt;code&gt;greater_than&lt;/code&gt;, &lt;code&gt;less_than&lt;/code&gt;, &lt;code&gt;crosses_above&lt;/code&gt;, &lt;code&gt;crosses_below&lt;/code&gt;, &lt;code&gt;within_pct_of&lt;/code&gt;, &lt;code&gt;between&lt;/code&gt;. In YAML, you write &lt;code&gt;close &amp;gt; sma(20)&lt;/code&gt;. Under the hood, it's parsed into a comparator chain that evaluates on each bar.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exit Rules
&lt;/h3&gt;

&lt;p&gt;Hard stops, trailing stops, take-profit targets, time-based exits, and scale-outs. Each exit rule is independent — you can stack them, and the first one that triggers wins. This was important because exit logic is where most backtesting frameworks get messy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Risk Layer
&lt;/h3&gt;

&lt;p&gt;This runs independently from strategy logic. Drawdown limits, daily loss caps, position-level risk caps, exposure constraints, and a "require stop" rule that rejects any order without a stop price. The risk layer can veto any trade the strategy wants to make.&lt;/p&gt;

&lt;p&gt;Keeping risk separate from strategy means you can swap strategies without re-implementing risk checks, and you can tighten risk rules without touching strategy code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Position Sizing
&lt;/h3&gt;

&lt;p&gt;Kelly Criterion, volatility-scaled (target a dollar risk per trade), and fixed fractional (risk X% of equity per trade). Each sizer takes the current portfolio state and returns a position size. Again, independent from everything else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;The project has 623 automated tests. That's not a vanity metric — it's a survival mechanism.&lt;/p&gt;

&lt;p&gt;When you're dealing with financial calculations, a subtle bug in position sizing or exit logic can silently produce wrong results. You won't see it in a stack trace. You'll see it when your backtest returns don't match reality.&lt;/p&gt;

&lt;p&gt;So I test aggressively:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unit tests for every indicator, comparator, exit rule, position sizer, and risk check&lt;/li&gt;
&lt;li&gt;Integration tests for the backtest engine (known inputs → verified outputs)&lt;/li&gt;
&lt;li&gt;End-to-end tests for the full pipeline: config → data → backtest → report&lt;/li&gt;
&lt;li&gt;Edge cases: zero-volume bars, gaps, splits, single-bar strategies, empty universes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The test suite runs in CI on every commit. If I change how trailing stops calculate, I know within seconds whether anything else broke.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Dashboard
&lt;/h2&gt;

&lt;p&gt;I built a web UI on top of the engine because not everything needs to be done in code. The dashboard lets you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configure strategies with dropdowns and form fields (no YAML or Python needed)&lt;/li&gt;
&lt;li&gt;Run backtests and see results in real-time via WebSocket updates&lt;/li&gt;
&lt;li&gt;View metrics: total return, CAGR, Sharpe, Sortino, max drawdown, win rate, profit factor&lt;/li&gt;
&lt;li&gt;Compare against benchmarks (SPY, QQQ, etc.)&lt;/li&gt;
&lt;li&gt;Save and load strategy configurations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The dashboard is a local web app — it talks to the same Python engine underneath. Nothing goes to the cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reports
&lt;/h2&gt;

&lt;p&gt;Backtest results export as self-contained HTML files. One file, no server needed, you can email it or archive it. They include equity curves, drawdown charts, trade logs, and all the summary metrics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Live Trading
&lt;/h2&gt;

&lt;p&gt;The engine connects to Alpaca for live execution. The same strategy that ran in a backtest can run live with one config change. The live runner follows a state machine: scan universe → evaluate entry rules → risk check → size position → execute. It logs every decision for audit.&lt;/p&gt;

&lt;p&gt;There's also a paper trading mode that logs orders without placing them, so you can validate before risking real money.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Declarative first, escape to code.&lt;/strong&gt; Most users don't want to write Python for a simple moving average crossover. But some users need custom logic. Supporting both from the same engine was the right call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk is not part of strategy.&lt;/strong&gt; This was the biggest architectural win. When risk checks are independent, you can reason about them separately. "Does my strategy generate good signals?" and "Am I risking too much?" are different questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test financial code like your money depends on it.&lt;/strong&gt; Because eventually, it does. A 0.1% rounding error in position sizing compounds fast.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reports need to be portable.&lt;/strong&gt; Nobody wants to spin up a Jupyter server to share backtest results. Self-contained HTML files solved this completely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current Status
&lt;/h2&gt;

&lt;p&gt;The engine is feature-complete and I'm looking for beta testers to stress-test it before public launch. If you're interested in algo trading and want to try it, the site is at &lt;a href="https://algo-deploy.com" rel="noopener noreferrer"&gt;algo-deploy.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy to answer questions about the architecture, the testing approach, or anything else in the comments.&lt;/p&gt;

</description>
      <category>python</category>
      <category>showdev</category>
      <category>software</category>
      <category>devtool</category>
    </item>
  </channel>
</rss>
