Trading Strategy Specification: What Your Developer Needs
A trading strategy specification is the document a developer turns into code. It defines every signal, filter, entry, exit, cost assumption and trading session so precisely that two developers would build the same system. An idea such as “buy when the trend turns up” is not enough; the gaps show up later as arguments about what was ordered, or as backtests that differ from live trading. The hard parts are rarely the indicators. They are the edge cases: two signals for the same instrument, more candidates than free position slots, a stop measured from the signal or from the fill, a partial exit, a holiday with an early close, a gap through the stop. This guide lists what to decide for each, with a neutral invented example, and shows which parameters to fix and which to leave open (as of November 2026).
What a developer-ready specification contains
A specification describes behavior, not code. For every rule it answers four questions: which data goes in, when the rule is evaluated, what the system does, and what happens if that fails. A workable structure:
| Part | Contents |
|---|---|
| Universe and data | Instruments, data source, bar size, time zone, closed or still-forming bars |
| Signals | Formulas, evaluation time, repeated and conflicting signals |
| Portfolio rules | Maximum positions, ranking of candidates, exposure limits |
| Entries | Filters, confirmation, order type, validity, partial fills |
| Exits | Stops, targets, time exits, partial exits, priority between them |
| Costs | Commissions, fees, spread and slippage per order type |
| Calendar | Sessions, holidays, early closes, daylight saving time, gaps |
| Parameters | Fixed, open for optimization, still to be decided |
| Failure behavior | Missing data, rejected orders, restarts with open positions |
Account setup, failure behavior, acceptance tests and code ownership are covered in the Interactive Brokers API developer hiring guide. This article goes deeper into the trading logic itself.
Several signals per instrument, and more candidates than free slots
Most rule descriptions cover one signal on one instrument. A live system meets combinations, and each one needs a decision:
- Repeated signal with a position open: ignore it, add to the position, or restart the exit rules?
- Opposite signal: close only, close and reverse, or ignore it until the exit rules close the trade?
- Signal while an entry order is still working: keep, replace or cancel the order?
- Two strategies or timeframes on one instrument: one combined position or separately tracked positions, and which exit rules apply to which part?
Ranking becomes necessary as soon as there are more candidates than free slots. The specification then needs:
- the ranking measure and its direction, for example highest value first;
- the moment of ranking, for example all candidates of the same bar close together rather than first come, first served;
- a deterministic tie-breaker, written down, for example alphabetical by symbol;
- what happens to candidates that miss out: discarded, or queued and for how long;
- whether a stronger candidate may replace an open position.
Without a fixed order, a backtest may process symbols alphabetically while the live system takes whichever signal arrives first, and the two trade different instruments from the same data.
Filters and entry confirmation
A filter allows or blocks signals. Three questions define it:
- When is it checked? Only when the signal appears, or again when the order is placed or filled?
- On which data? Closed bars only, or the current bar that is still forming? A forming bar keeps changing until it closes, which produces signals that appear and disappear.
- What if it cannot be computed? With missing data or too little history, does the filter block the signal or let it pass?
Confirmation turns a signal into an entry. It needs a condition, a time window and an expiry. Typical example: “Daily bars. Signal when, at the close, a stock’s 50-day moving average crosses above its 200-day moving average. Enter only if the 50-day average is still above the 200-day average at the next close: buy at the following open with a limit 1 percent above that close, valid for one day.” The rule is invented for illustration and is not a recommendation. Each element still hides a decision the developer should not have to guess: simple or exponential averages, prices adjusted for splits and dividends or not, which closing price counts, and what happens if the market opens more than 1 percent higher.
Stops, exits and partial exits: when each rule applies
Exit rules need a start time and a reference price:
- Start: does the stop exist from the fill, or from the moment the entry order is placed?
- Reference: is the stop distance measured from the signal price, the planned entry or the actual fill price? After a gap, these differ.
- Trigger price: last, bid/ask or mid? At Interactive Brokers (IBKR), the trigger method applies to stops that IBKR simulates. The default is the last price for stocks and futures (double bid/ask for OTC stocks), double bid/ask for US options and bid/ask for forex, and natively handled stops ignore the setting. The backtest should trigger the same way.
- Priority: if stop, target and time exit all trigger within the same bar, which one wins? A bar-based backtest cannot see the order of prices within the bar, so the specification states the conservative assumption, for example stop first.
- Hours: may stops trigger outside regular trading hours? At IBKR, the order attribute
outsideRth, when set to true, allows an order to trigger or fill outside regular trading hours.
Partial exits need sizes and a rounding rule: half of 75 shares is 37 or 38. After each partial exit, the stop must cover only the remaining size. At IBKR, orders in a one-cancels-all (OCA) group can be set to cancel the other orders when one executes (type 1) or to reduce them proportionately (types 2 and 3). The specification states the intended sizes after each step, and the acceptance test checks them in the paper account.
Costs, spreads and slippage assumptions
Costs belong in the specification because they decide which trades the backtest takes and how they end. Per instrument:
| Cost | What to specify |
|---|---|
| Commission and fees | Per share, contract or trade value; minimums; exchange and regulatory fees |
| Spread | Whether entries and exits are modeled at bid and ask or at mid |
| Slippage | Per order type: market and stop orders fill worse than the trigger; limit orders without slippage but with a fill rule |
| Financing | Overnight financing or borrowing costs for short positions, where relevant |
| Currency | Conversion of results and costs into the account currency, with rate source and time |
If signals are calculated on mid or last prices but fills happen at bid or ask, say so explicitly. Give stops their own slippage assumption as well: IBKR notes that a stop order is not guaranteed a specific execution price and may execute significantly away from its stop price.
Sessions, holidays, gaps and time zones
- Time zone: write session times in the exchange’s time zone (for NYSE, New York time), not as a fixed offset from UTC; the code can still store timestamps in UTC. Clocks change on different dates: in the US on the second Sunday in March and the first Sunday in November, in the EU on the last Sundays of March and October. In 2026, New York and Frankfurt were therefore five hours apart instead of six from March 8 to March 29 and from October 25 to November 1.
- Sessions: regular hours only, or extended hours too? The NYSE core trading session runs from 9:30 a.m. to 4:00 p.m. Eastern Time.
- Holidays and early closes: NYSE markets close early at 1:00 p.m. Eastern Time (1:15 p.m. for eligible options) on Friday, November 27, 2026 and on Thursday, December 24, 2026. A rule such as “exit 15 minutes before the close” must refer to the actual close of that day.
- Gaps: if the market opens beyond the entry trigger, the stop or the target, what happens? Enter at the open, skip the trade, or exit at the opening price? The backtest must apply the same rule.
- Order validity: day orders or good-till-canceled, and what happens to working orders at the end of the session? IBKR notes that good-till-canceled orders are canceled automatically in certain cases, for example after a stock split.
A calendar that covers holidays and early closes in advance belongs to the system, not to the strategy. The specification only states the rule; the developer implements it from the exchange’s published calendar.
Fixed versus open parameters
Every number in a specification is a parameter, and each one gets a status. Typical example: the rule from the section on filters and confirmation, invented for illustration and not a recommendation:
| Parameter | Status | Value or range | Decided by |
|---|---|---|---|
| Short moving average | Open | 20 to 60 days, step 10 | Test plan |
| Stop distance | Open | 1.5 to 3.0 times the average true range (ATR), step 0.5 | Test plan |
| Maximum open positions | Fixed | 5 | You |
| Long moving average | Fixed | 200 days | You |
| Entry limit above the confirmation close | Fixed | 1 percent | You |
| Slippage per stop order | Fixed assumption | 1 tick | You, reviewed after the paper phase |
| Tie-breaker | Fixed | Alphabetical by symbol | You |
| Exit on early-close days | To be decided | Open question | You, before the build |
Fixed parameters are never optimized. Open parameters get a range and a step before testing begins, which keeps the number of tested variants known: in the example, 5 short averages times 4 stop distances make 20 variants. Parameters still to be decided block the build until someone decides them. Version the specification as well: each change gets a date and a reason, so every later result can be traced to the rules it was produced with.
Limits of a specification, and next steps
A specification makes a strategy buildable and testable. It does not make it profitable: a precise description of a weak idea is still a weak idea. It also cannot foresee every market event, which is why the failure rules matter; in the unforeseen case, the system blocks, alerts and waits. Trading with leverage can lose more than the capital deployed.
- Write the rules in the order of the table above, one document per strategy.
- For every rule, answer: input, time, action, failure.
- Decide each edge case in this article, even if the answer is “not handled: block and alert”.
- Mark every parameter as fixed, open or to be decided.
- Hand the document to the developer and ask for a written list of open questions before any code is written.
Whether the specification can be built with the available data and broker is the subject of a trading system feasibility study.
Frequently asked questions
What should a trading strategy specification include?
The instruments and data source, signal formulas with their evaluation time, rules for repeated and conflicting signals, ranking when candidates exceed free slots, filters and entry confirmation, order types, stops, targets, time exits and partial exits with their priority, cost and slippage assumptions, sessions, holidays and gaps, the status of every parameter, and the behavior when data is missing or orders are rejected.
How detailed should trading rules be for a developer?
Detailed enough that two developers would build the same system without asking. Each rule needs its input data, the moment it is evaluated, the action and what happens if the action fails. Words such as strong, weak or pullback need a formula. Edge cases that you decide not to handle should still be written down, for example as block and alert.
How do you rank trade signals when there are more signals than open slots?
Define a ranking measure and its direction, rank all candidates of the same evaluation time together, and add a deterministic tie-breaker such as alphabetical order. Also decide what happens to candidates that miss out, whether they are discarded or queued, and whether a stronger candidate may replace an open position. Without these rules, a backtest and a live system can choose different trades.
Should a stop loss be based on the signal price or the fill price?
Either can work, but the specification must say which, because the two differ after gaps and slippage. A stop measured from the fill keeps the planned distance from the actual entry; a stop fixed at a chart level keeps the logic of the setup. Also specify which price triggers the stop, because brokers and backtests may use last, bid/ask or mid prices.
What is the difference between fixed and optimizable parameters?
Fixed parameters are set by you and never tuned, for example the maximum number of open positions. Optimizable parameters get a range and a step before testing starts, which keeps the number of tested variants known and makes overfitting easier to assess. Parameters still to be decided should block the build until they are settled, so the developer never has to guess.
Sources and status
- TWS API Reference: Order (outsideRth, ocaType, tif) — Interactive Brokers (retrieved November 19, 2026)
- TWS API: Trigger Methods (simulated stops, defaults per security type) — Interactive Brokers (retrieved November 19, 2026)
- Order Types: Stop — Interactive Brokers (retrieved November 19, 2026)
- Holidays and Trading Hours (2026 holidays and early closes, core trading session) — New York Stock Exchange (retrieved November 19, 2026)
- Summertime: Directive 2000/84/EC on summer-time arrangements — European Commission (retrieved November 19, 2026)
- 15 U.S. Code § 260a: Advancement of time or changeover dates — Legal Information Institute, Cornell Law School (retrieved November 19, 2026)
As of November 2026. Third-party rules, prices and APIs may have changed since; the providers' current documentation and the official texts are authoritative.
This article is also available in German: Handelsspezifikation schreiben: was jede Strategie klären muss.
Want your trading strategy specification checked before development starts? Get in touch — a free intro call clarifies the rules, the open questions and the next step toward a system that can be built and tested. More: Trading system code review and audit.