Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Trading and crypto

Automated futures trading: from rules to a running server

How automated futures trading fits together: contract specs and rolls, strategy and execution algorithms, honest backtests, risk limits and the server.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of glowing order tickets moving along a track from a rule diagram into a server rack
On this pageContract mechanics your code must know

Automating futures trading means turning a written rule into code that watches data, sends orders and manages positions without anyone clicking. The words "automated" and "algorithmic" overlap: every automated strategy is an algorithm, but the industry also uses "algorithmic" for execution algorithms that only decide how to fill an order someone else chose. This guide covers the contract mechanics code must handle, the main families of algorithms, testing that does not fool you, risk limits and the server that runs it all. No strategy here is presented as one that works.

Contract mechanics your code must know

A futures contract is a standardized agreement with fixed terms, and an automated system has to encode every one of them. Using the E-mini S&P 500 as the example:

Specification E-mini S&P 500 Why the code cares
Multiplier $50 times the index Profit, loss and position size
Tick size and value 0.25 points, worth $12.50 Order prices must sit on the tick grid; stops are counted in ticks
Expiry Quarterly: March, June, September, December Positions must be rolled, and the traded symbol changes
Trading hours CME Globex, Sunday evening to Friday afternoon, with a daily one-hour break Session filters, bar building, when orders cannot fill
Margin Set by the exchange, with brokers adding their own levels Position limits in code

The Micro E-mini has the same structure at a tenth of the size: $5 times the index, so a tick is worth $1.25. Exchanges also apply price limits or pauses after large moves, so an order can be valid and still not fill.

Rollover deserves its own logic. Before expiry, trading activity moves to the next contract, and a live system must close the old contract and open the new one, or hand that job to a platform that does it. Backtests need a continuous series stitched across expiries, and the adjustment method changes indicator values, as explained in technical indicators across markets.

Strategy algorithms and execution algorithms

Strategy algorithms decide what to hold. The common families, described rather than rated:

  • Trend-following: positions in the direction of persistent moves, often triggered by channel breakouts or moving-average filters.
  • Mean reversion: positions against short-term deviations from an average.
  • Spread trading: positions in the price difference between two contracts, such as two expiries of the same future or two related commodities.
  • Market making: quotes on both sides of the book. It depends on very low latency and the exchange's fee structure, and is mostly the territory of firms with direct exchange access.
  • Time-based rules: behavior tied to session opens, closes or scheduled releases.

Each family has long stretches when it does poorly, and none works in every market condition.

Execution algorithms decide how to fill. TWAP spreads an order evenly over time, VWAP follows the market's typical volume pattern through the day, and an iceberg order shows only part of its size at a time. Bracket orders that attach a stop and a target to every entry are a simple execution tool almost every platform offers.

Platforms that run futures automation

Platform Language Runs on Notes
NinjaTrader 8 NinjaScript, a C# framework Windows desktop Charting, backtesting and simulation are free to use, according to NinjaTrader
MetaTrader 5 MQL5 Windows natively, macOS and Linux via Wine Exchange futures only where the broker offers them
QuantConnect LEAN Python or C# Any OS, usually Docker on Linux Open source (Apache-2.0); lean backtest and lean live from its CLI
Broker APIs Any Any The most control and the most work

Pick by what your broker connects to and which language you can maintain, not by feature lists.

Backtests that do not fool you

A backtest replays history through your rules. Its value depends on what it gets right:

  • Look-ahead bias: the rule must not use a bar's high, low or close before the bar has finished.
  • Overfitting: every parameter tuned on the same data makes the result fit that data better and say less about any other period.
  • Fills: a limit order touched by price is not necessarily filled, because other orders were queued at that price first. Assume fills only when price trades through.
  • Costs: commissions, exchange fees and slippage of at least a tick per side on market orders, more around news.
  • Sessions and rolls: test on the same session template and roll method you will trade.

Methods that help: keep a holdout period you never optimize on, use walk-forward analysis (optimize on one window, test on the next, then slide forward), and run the strategy in simulation on live data before it touches an account. NinjaTrader's free simulation, for example, runs on real market data. A clean backtest is a necessary check, not evidence of future results.

Risk limits written into the code

Code fails in ways a person at a screen would notice in seconds. Hard limits catch those failures:

MAX_CONTRACTS = 2          # absolute position limit
MAX_DAILY_LOSS = 500.0     # in account currency
MAX_ORDERS_PER_MIN = 10    # stops runaway order loops
MAX_TICKS_FROM_LAST = 20   # rejects prices far from the market

def order_allowed(order, state):
    if state.halted:
        return False
    if abs(state.position + order.signed_qty) > MAX_CONTRACTS:
        return False
    if state.pnl_today <= -MAX_DAILY_LOSS:
        state.halted = True            # stays halted until a person resets it
        return False
    if state.orders_last_minute >= MAX_ORDERS_PER_MIN:
        return False
    return abs(order.price - state.last_price) <= MAX_TICKS_FROM_LAST * state.tick_size

Add a kill switch that cancels working orders and flattens the position with one command. Keep protective stops resting at the broker, so they work while your system is down. On every restart, reconcile positions and working orders with the broker before the strategy sends anything.

The server it runs on

CME Group's matching engines are in the Chicago area, but a retail account's orders travel through the broker's servers first, so the network leg you can influence is the one from your platform to the broker's gateway. Ask your broker where its gateways are, then measure.

CloudSat has no data center in Chicago; the closest regions are New York (NYC1) and Dallas (DFW1), so test the round trip to your broker from both. A NinjaTrader VPS runs the Windows desktop platform on High Frequency Ryzen cores.

Whatever the provider, plan the routine: restarts and Windows updates during the daily break or the weekend, terminals that start again after a reboot, and an alert when the platform loses its connection or its positions stop matching the broker's.

Rules and conduct

Futures markets are regulated, and brokers set their own terms for automated order entry, so read both before going live. Exchanges monitor messaging and order-to-trade activity. In the US, spoofing, meaning placing orders you intend to cancel before they execute, is illegal, and code that floods and cancels orders can look exactly like it.

FAQ

Can individuals trade futures automatically?

Yes, through brokers and platforms that support automated order entry. Check your broker's terms, the exchange's rules and the regulation where you live before running anything live.

Does a VPS make my algorithm faster than the market?

No. Firms colocated at the exchange operate on another scale. A VPS removes the weak points of a home setup, such as sleep, Wi-Fi and power cuts, and shortens the path to your broker.

How should an automated strategy handle rollover?

Pick a rule, by date or by the next contract's volume overtaking the current one, and apply it the same way in testing and live trading. Test on an adjusted continuous series, but send live orders on the actual contract.

Can I test without risking money?

Yes: simulation accounts with live data, paper trading and the platform's strategy tester. The demo and paper trading guide covers what those tests leave out.

Trading involves risk of loss. Nothing in this article is financial advice.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.