So far our test measures trades in points and R. A real futures trade moves in ticks, is worth dollars per contract, and pays costs on every trade. By the end of this lesson, you'll have put all three into the code, and you'll see how costs change each result.
1 of 10
What you'll learn
- Round to real prices. Stops and targets go on tradable prices, rounded the same way.
- Name your settings once. Point value, contracts, fees and slippage go in capitals.
- Turn points into dollars. Multiply points by the point value and the number of contracts.
- Take off costs. Fees and slippage come off every trade. Net is what you keep.
- Test another contract. Change the settings and check its specs with the exchange.
Exercise
- Add the tick rounding and the cost settings to your own test, using your broker's real fees.
- Work one trade out by hand, gross to net, and check the code gives the same answer.
Quick check
1. On MES, what is one tick worth per contract?
2. Why put the point value and fees in settings at the top?
3. Costs are a fixed $8 a trade. Which trades do they hurt most, in R?
0 of 3 answered.
Finished this lesson?
Tick it off and keep your place
Read the full notes
To match a futures contract, the code rounds An order that closes a trade if price reaches a level you set against it. It aims to limit the loss, but in a fast market it can fill at a worse price.More in the glossary and An exit order that closes a trade when price reaches a level you choose in your favour.More in the glossary onto real The smallest step a price can move. On many stock index futures that’s 0.25 of a point.More in the glossary, turns points into dollars with the What a move of one whole point is worth for one futures contract. Tick value is the tick size times the point value.More in the glossary and contract count, and takes fees and The difference between the price you expected and the price your order filled at.More in the glossary off every trade to give the net result.
- On the A small futures contract on the S&P 500, traded at CME Group. Each point is worth $5, and its smallest step of 0.25 is worth $1.25.More in the glossary, a The smallest step a price can move. On many stock index futures that’s 0.25 of a point.More in the glossary is 0.25 of a point and each One whole unit of a price. On the S&P 500, a move from 5,000 to 5,001 is one point, and each futures contract sets what a point is worth in dollars.More in the glossary is worth $5 per contract, so a What one tick is worth in money for one futures contract. On the E-mini S&P 500 it’s $12.50.More in the glossary is worth $1.25 (Ticks and tick values).
- Ticks: after import math, math.floor(price / TICK) * TICK rounds down to a tick; math.ceil rounds up. Round the stop and target onto real prices, one way, written down.
- Settings in capitals: POINT_VALUE = 5.0, CONTRACTS = 2, FEES = 1.50 (made up, per contract in and out), SLIP_TICKS = 1 (made up, each way). Use your broker's real What your broker and the exchange charge for each contract you trade, often quoted per contract for the round trip: in and out.More in the glossary.
- Dollars: A trade’s result before commissions and fees are taken off.More in the glossary = points × POINT_VALUE × CONTRACTS; costs = (slippage in dollars + FEES) × CONTRACTS; net = gross − costs. Only A trade’s result after commissions and fees are taken off.More in the glossary is what you keep (Gross and net results). Net R = net ÷ risk in dollars.
- Another contract: change the settings, not the code. The The main size of stock index futures contract at CME Group. The E-mini S&P 500 is worth $50 a point, ten times the Micro S&P 500.More in the glossary is $50 a point. Check each contract's specs with the exchange. More: Slippage and commissions in a backtest.
Worked example
Made-up numbersOne trade, gross to net
Made-up numbers · long 2 MES · in 5,010.25 · out 5,022.75 · fees $1.50 per contract · 1 tick slippage each way
- 12.50 points × $5 × 2 = $125.00 gross
- Fees: $1.50 × 2 = $3.00
- Slippage: 2 ticks × $1.25 × 2 = $5.00
- $125.00 − $3.00 − $5.00 = $117.00 net
The code should give the same number for the same trade.
Your turn
DrillMade-up numbers · long 3 MES · up 8 points · fees $1.50 per contract · 1 tick slippage each way
Trading is risky. You can lose money. Test results are hypothetical, and a test can't tell you what will happen next. This lesson explains how testing works. It isn't advice.