IRYS Securities

Algo trading

What an automated strategy is made of, how backtests mislead, and the parts of the problem that automation does not solve.

What an algo actually is

An algorithmic strategy is a rule set that turns market data into orders without a person deciding each one. The rules can be trivial. The difficulty is never the rule, it is everything around it.

A working system has five parts: a data feed, a signal that reads the data, a risk layer that sizes and limits positions, an execution layer that places and manages orders, and monitoring that tells you when any of the first four has stopped behaving.

Most retail algo projects build the signal thoroughly and the other four parts casually. That is backwards. The signal decides whether you have an edge; the other four decide whether you keep it.

The five layers

Data

Live data comes from a broker feed or a licensed vendor. Historical data for research needs to be adjusted for corporate actions, and for derivatives it needs a consistent contract roll convention. Bad historical data produces confident nonsense.

Signal

The rule that generates intent. Keep the number of tunable parameters small. Each additional parameter is another dimension in which you can fit the past.

Risk

Position sizing, maximum exposure, maximum daily loss, and a hard stop that halts the system. This layer should be able to override the signal, never the other way round.

Execution

Order placement, modification, retries, and reconciliation against the broker's actual position. Assume every API call can fail, time out, or succeed after you gave up on it.

Monitoring

A running system that nobody is watching is an unhedged bet. At minimum you need an alert when the process dies, when a position differs from what the system believes it holds, and when the day's loss crosses a threshold.

Four ways a backtest lies

  1. Lookahead. The code uses information that was not available at the decision point. Using a bar's close to decide a trade at that bar's open is the classic version.
  2. Survivorship. Testing on today's index constituents removes every company that failed or was delisted, which inflates returns.
  3. Overfitting. Enough parameters will fit any history. The test is out-of-sample performance on data the parameters never saw.
  4. Frictionless fills. Assuming you trade at the touch price with no slippage and no impact. For anything intraday or in illiquid strikes, this alone can invert the result.

A strategy that looks excellent in backtest and mediocre in forward test is normal. A strategy that looks excellent in both is rare, and usually has a smaller edge than the backtest claimed.

Costs and slippage

Model the full cost stack in the backtest: brokerage, statutory charges, and slippage. For option selling, also model the margin blocked, because return on capital is the number that matters and premium collected is not.

Slippage is not a constant. It widens in exactly the conditions that make a signal fire, which is the mechanism by which profitable-looking high-frequency rules turn unprofitable in production.

Running it

  • Broker API access, with session handling that survives a token expiry mid-session.
  • Hosting. A cloud instance near the exchange beats a home connection, mostly for reliability rather than latency. Retail strategies rarely live or die on microseconds.
  • State. Persist positions and orders to disk. A process restart must not lose track of what is open.
  • Kill switch. A way to flatten everything and stop the system from a phone, without access to the machine.

Rate limits, partial fills, rejected orders, and stale quotes are not edge cases. Over a year of trading days they are certainties, and code that has not planned for them fails on a day that matters.

The regulatory position

SEBI has set out a framework for retail participation in algorithmic trading through brokers, under which algorithms are routed via the broker, registered with the exchange, and tagged so orders are identifiable. Brokers carry responsibility for the algos their clients run.

The practical consequences: your algo needs to fit within your broker's approved API and any registration they require, strategies that generate orders above specified thresholds attract additional scrutiny, and distributing or selling a strategy to others is a different activity with its own requirements. Confirm the current position with your broker before deploying anything, since this framework has changed more than once.

What automation does not fix

Automation removes hesitation, fatigue and the temptation to override a plan. It does not create an edge, and it executes a flawed rule faster and more consistently than a human would.

It also introduces failure modes discretionary trading does not have: a stale feed that keeps the system trading on a price that no longer exists, a reconnect loop that doubles a position, a config change deployed mid-session. Every one of those has cost someone real money.