Home                           

 Try Investor/RT             

 Investor/RT Tour           

 Getting Started              

 What's New                  

 Testimonials                 

Investor/RT
Tutorials
Pairs Trading: Creating Spreads (Using Custom Instruments)

Also See: Custom Instrument Tour

This Tutorial will demonstrate how to create a Custom Instrument which represents the spread between two instruments (in the case, between two stocks, LLY and MRK).   The term "Instruments" is synonymous with the term "Symbol" for the context of this tutorial.  The steps involved are as follows:

  • Define both of the component instruments in your system (if they are not already)
  • Mark the component instruments for intraday monitoring (if applicable)
  • Download data for the component instruments
  • Create the spread (custom instrument)
  • Place spread in quotepage and chart the spread

Define Component Instruments
The first step will be to make sure that the two component instruments exist in your system and that they are setup properly.  In our example, let's assume we are trying to create an instrument which will represent the spread between LLY (Eli Lilly) and MRK (Merck).  Let's start by creating a new quotepage which we'll use to hold our component instruments.  From the menu, choose "File: New: QuotePage".  A new quotepage should appear.  In the ticker column, enter the instruments "LLY" and "MRK" in the ticker symbol field of the first two rows.  Now, save this quotepage by choosing menu option "File: Save: Save As" and then giving it a name like "Spread Components".  At this point, your quotepage should resemble the one seen below.

Spread Components QuotePage

Setup Component Instrument for Intraday Monitoring (if applicable)
Now, you need to decide if you're going to want to track your spread on an intraday basis, or only on a daily basis.  If you'll be tracking it on an intraday basis, you'll want to mark each of the component instruments for intraday monitoring.  By marking instruments for intraday monitoring, you are telling Investor/RT to always monitor the instruments tick by tick regardless of whether the instruments is open in a quotepage or chart, or not.  This will ensure that our spread will always be receiving any trades coming in on either component.

You can either mark the instruments individually, or mark a whole quotepage at once.  To mark a instruments individually, right-click on the instruments in a quotepage a choose "Setup" from the popup list.  Check the "Intraday" and "Daily" Monitoring options at the bottom (leave Weekly and Monthly unchecked).  Your Setup Instrument window for MRK should resemble the one below at this point.

Setup Instruments - MRK (Merck)

Click "Modify" then "Close" to dismiss this window.  Do the same for both component instruments (if you are monitoring intraday).  You can also mark all the instruments in a quotepage for intraday at one time by just clicking on the "Mark/Unmark for Intraday" button in the lower left corner of the quotepage toolbar.

Download Data for the Component Instrument
At this point, our component instruments should be properly setup.  We now should ensure that we have sufficient data on the component instruments.  When we create our spread (custom instrument), we will be able to generate historical data (daily and intraday) on the spread based on the historical data that we have on the component instruments.  There are several ways to download data on the symbols.  The quickest way would be using the "Download Data" window.  Click on the "Download Data" button in the main toolbar to bring up this window.  First, we'll download daily data.  The window should be setup similar to what you see below.

Download Data - Daily

Notice we have selected our "Spread Components" quotepage on the list on the left (you must unselect "One Instrument" checkbox in order to be able to select a quotepage).  The download type should be "Historical Quotes" and the periodicity "Daily".  I have chosen to download approximately 2 years of daily data (current date is 12/12/02).  I've chosen a "From" date of "12/12/00" and a "To" date of "Current Date".  Now click the "Download" button and give the program a few moments to download the data.  If you bring up a daily chart on either of these two instruments, you should see complete data for the past 2 years now.

If you will be monitoring your spread intraday, you'll want to repeat this process again for 1-minute data.  Again, click on the "Download Data" button in the main toolbar.  This time, set the window up something like this. 

Download Data - Intraday

I've chose to download the last 6 days of data.  Click the "Download" button to execute the download and give the program a few moments to complete the download.  Again, you should be able to bring up an intraday chart and view the last 6 days of data (you may need to adjust the viewing period of your chart preferences to actually see 6 days back).

Create the Spread
At this point, our component instruments are created, setup properly, and loaded with data.  We are now ready to create our spreads.  Spreads are created using our "Custom Instrument" facility.  From the menu, choose "Setup: Custom Instruments...".  

Enter a unique ticker symbol to identify your spread (custom instrument).  I've chosen "LLYMRK" to represent the difference between LLY and MRK.  Now provide a name for the spread.  Again, I've chosen "Eli Lilly - Merck Spread".  Choose "Difference" for the "calculation type" since we will be subtracting one component instrument (MRK) from the other (LLY).  Now, in the list on the left, find the first component "LLY", and click on it, then click on the right arrow button to move the instrument into the list on the right.  Now repeat this process to move "MRK" to the list on the right just below "LLY".  This signifies that the spread will take the difference between the first instrument in the list (LLY) and the second (MRK).   Check the "Generate Historical Data When Saving" checkbox so that historical data will be generated on our spread from the historical data that we loaded on the component instruments.  Check the "Monitor Custom Instrument Intra-day" checkbox if you intend to monitor the spread on an intraday basis (based on your decision above).  Before you proceed, ensure that your Custom Instrument Definition window looks something like this.

Custom Instrument Setup Window

Now, click the "Save and Close" button.  This button will create your spread, mark it for intraday (if applicable), and generate daily and intraday (if applicable) historical data on spread based on the pre-loaded data of the component instruments.

Place the Spread in a QuotePage and Chart the Spread
Now, let's create another quotepage which will contain only our custom instrument spreads (you can choose to put the spreads in the same quotepage with the spread components if you wish).  Again, create a new quotepage by choosing "File: New: QuotePage".  Enter our spread ticker symbol "LLYMRK" in the ticker symbol column of the first row.  Now save the quotepage using "File: Save: Save As" and give it a name like "Spreads".  At this point, your quotepage should look something like the one below.

Spreads QuotePage

Notice that the Change and % Change columns probably won't fill in until the day after the spread (custom instrument) is created.

You can now double-click on your spread ticker symbol to bring up a chart on the spread.  To change the periodicity of the chart, right-click in the chart and choose "Periodicity".

This entire process may seem somewhat lengthy, but can be completed very quickly once you get the hang of it.  Also, now that the quotepages are created, these steps won't be necessarily next time through.  As far as expediting the download process, Investor/RT 5.9.1 has a new schedule action option called "Download Data".  This action gives the user to download 1-minute or daily data, for any number of days, on the instruments in any quotepage, directly from a schedule.  Since the schedule can be run using a shortcut key (like F2), a single keystroke can download the daily and intraday data based on the number of days you require.  To accomplish this, from the menu, go to "Setup Schedules".  Create a new schedule that is setup to run from a function key of your choice.  Then assign to this schedule two actions.  The first action should download maybe 500 days of daily data.  The second schedule should download maybe 6 days of 1-minute data.  The resulting schedule window will look something like this.

Schedule For Downloading Data

With the first action download 500 days of daily data, and the second action downloading 6 days of 1-minute data.

If you have any confusion regarding the process above, or would like me to supplement this tutorial with additional information regarding the creation of spreads for pairs trading, please email me at support@linnsoft.com .