Trading grain spread mechanically

Post on: 21 Июль, 2015 No Comment

Trading grain spread mechanically

When trading moved into the modern age, with sophisticated trading system development software that gave individual traders the ability to test their ideas on the market without adding a professional programmer to the payroll, certain disciplines were left behind. This wasnt because these methods lacked merit, but they simply didnt easily transfer into most popular trading software.

One of those disciplines was spread trading. Spread trading offers a unique mix of low margins, pronounced trends and hidden opportunities that appeal to many traders, but because most programs dont cleanly handle spreads, on either the testing or the execution side, they have been left out of most individual traders toolboxes.

This second of two parts on spreads will look at specific applications in spreads to demonstrate how new technologies are extending the power of computers to these time-tested markets.

ALL CRACKED UP

The crack spread displays the relationship between energy contracts traded by integrated oil companies. Crack spreads provide a natural economic hedge against adverse price movements. Given a target optimal product mix, an independent oil refiner can work to hedge itself against adverse price movements by buying oil futures and selling futures based on its primary refined products, according to the proportions of its optimal mix.

Refiners who wish to hedge their price exposure will use a crack ratio usually expressed as X:Y:Z, where X represents a number of barrels of crude oil, Y represents a number of gallons of gasoline and Z represents a number of barrels of distillate fuel oil. The only constraint is that X = Y + Z. The hedger buys X barrels of crude oil and sells Y gallon of gasoline and Z barrels of distillate in the futures market. Widely used crack spread ratios include 3:2:1, 5:3:2 and 2:1:1. The 3:2:1 crack spread is the most popular of these, and widely quoted crack spread benchmarks are the Gulf Coast 3:2:1 and the Chicago 3:2:1.

Different numbers of contracts must be traded for each component of the spread. For this reason, calculating the minimum move value so results can be converted to dollars is not always easy. This situation also can come up with spreads that do not have fixed ratios and they are based on market volatility in dollars. This often happens with equity indexes or individual stocks.

In a perfect world, a backtesting platform would correctly account for these complex issues. In addition, the platform would need to be available to backtest over a large number of years using individual contracts and still provide consolidated results.

BACKTESTING SPREADS

The approach well cover requires portfolio analysis, intermarket analysis and the ability to handle individual contracts, testing our strategies on them only when they are active. This last point is a significant one, as it allows us to avoid the common pitfalls of back-adjusted price data and to test our strategies on individual contract prices, just as they would have traded through time.

Also critical is the portfolio-level analysis, which allows us to use December corn and December wheat for one intermarket pair and March corn and wheat for the next. This walk-through uses TradersStudio (software developed by Ruggiero Associates) because it has features that address all of these concerns.

To review, intermarket spread trading requires the trader to buy one market while selling another. The contracts are in the same position and must have some economic relationship to be considered a true spread. The transaction does not have to occur at the same time; it is possible to leg into and out of spread positions.

One way to accomplish this is to use a Trade Plan, which can trade multiple systems across a portfolio on the same account. In this case, we could have created two systems to trade corn and wheat. If we had a three-way spread such as the crack spread the Trade Plan feature would have been a better solution, but for the two-way grain spread, its better to tackle this at the session level and rely on the inter-market analysis and portfolio level trading capabilities of the software.

CONTRACT SELECTION

Before we get to the actual trader, we need to cover some basic logistical concerns. The first step is to create a function that returns when a given contract is the actively traded market. We will use the following format C_1976U.CSV. The contract symbol is the first two letters, the year is the next four and the contract month symbol is the last digit (see Contract months, below) followed by the file extension. This will be compared to the current date and will be used to filter the system so it only trades a particular contract month while the contract is active.

We are using Pinnacle Deep historic price data and will use a fixed expiration date of the 22nd of the month prior to the contract expiration month. This means that the last trading date for corn and wheat for each contract is Feb. 22, April 22, June 22, Aug. 22 and Nov. 22.

The code in Which contract for corn? (below) puts this logic into a function. It disables a contract month when it is not the active month, but it lets the indicators still calculate.

When trading single contracts, we want the system to buy, sell, exit long and exit short positions. The next step is to create functions for order placement. Remember, if the contract is no longer the active one, positions in that market must be exited.

This is the buy entry code:

SubBuySingleContract(Signal

Name,Size,Price,OrderType,Order

Time)

If IsActiveCornContract () Then

Buy(SignalName,Size, Price, OrderType,OrderTime)


Categories
Futures  
Tags
Here your chance to leave a comment!