0% found this document useful (0 votes)
14 views

Option Lab - User's Guide

Uploaded by

alexgrios
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Option Lab - User's Guide

Uploaded by

alexgrios
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Option Database Explorer

User’s Guide
www.OptionLAB.ch
Table of Contents
1. Introduction ................................................................................................ 4
2. Installation .................................................................................................. 5
How to Install............................................................................................. 5
LicenseKEY and Purchased Database Installation ..................................... 6
3. How it Works ............................................................................................ 10
General Aspects ....................................................................................... 10
Rule-Based Trading .................................................................................. 10
4. System Implementation ............................................................................ 12
Cadence, Symbol and Dates .................................................................... 12
Strike Selection ........................................................................................ 13
Backtest Box ............................................................................................ 15
5. Exit Logics ................................................................................................. 16
Time Exits................................................................................................. 16
Profit Target and Stop Loss ...................................................................... 16
6. Automation and Defaults........................................................................... 18
Option Language...................................................................................... 18
Defaults.................................................................................................... 19
7. The Option Chain Window ......................................................................... 21
8. Price Modelling and Database Adjusting ............ Error! Bookmark not defined.
9. The Performance Report............................................................................ 24
10.Grouping Trades ........................................................................................ 27
11.TS Code Generator for Naked Shorts Hedging ............................................. 28
Hedging Strategy Code ............................................................................ 29
Launching the strategy ............................................................................ 33
Confronting Results ................................................................................. 35
12.Exporting Results....................................................................................... 37
13.Miscellaneous ........................................................................................... 39
Test Name ................................................................................................ 39
Save and Open a Backtest ....................................................................... 39
Clear All .................................................................................................... 39
Data Folder .............................................................................................. 39

3
www.OptionLAB.ch
1. Introduction
The Option Database Explorer is a software aimed at testing and evaluating trading
systems based on options on futures and their underlying instruments.
We provide our users with an options on futures price database based on the
symbols needed by the subscriber.
Because of the intrinsic complexity of the task, option price databases are not easy
to navigate. This is partially due to the massive number of contracts available for
each underlying instrument and partially to the nature of the variables involved.
When navigating a futures price series, the main complexity is to select an
appropriate algorithm for contracts aggregation that allows a multiple instruments
database to be evaluated as it was a single time series. When dealing with an option
database this is not possible, the multi-dimensional nature of the task makes
reducing intrinsic complexity not a feasible way forward with regard to the problem
of data navigation.
Our approach has been to create a framework that would allow the user to navigate
an option price database with ease, hiding the underlying complexity behind a
friendly user interface.
In this guide, you will find instructions on how to use the Option Database Explorer
for testing and evaluating a trading system.
For a detailed list of the markets available, please refer to www.OptionLAB.ch
For reference on how to use Option Language to automatically backtest trading
strategies please refer to the Option Language Guide.

4
www.OptionLAB.ch
2. Installation
How to Install
To install the Option Database Explorer you have to download the installer first,
request it at [email protected].
Execute the installer and follow the instructions.

When choosing the installation directory consider that by default it will also be the
location of the database. If you prefer you will be able to choose a custom directory
in a different location for your database, but this will require extra steps.

5
www.OptionLAB.ch
Press Next two times and wait for windows to ask for the authorisation to install.
Wait for the process to be completed, it may require a few seconds.
After loading has finished press Close and installation will be completed.
At this point you can execute the program, and after a brief check on internet
connection the following window will appear:

Press Continue to proceed, then, after reading the Disclaimer, press OK. You are
now ready to use the Option Database Explorer, try the software for free.

LicenseKEY and Purchased Database Installation


If you purchased the Option Database Explorer you have received a file called
Option Explorer License KEY and Database.rar.
Inside you will find a folder called Database and a file called License KEY.txt.
It’s important to point out that both the License Key and the Database will be linked
to the machine of first activation, thus we suggest activating the Option Database
Explorer on the computer on which you are willing to use it.

6
www.OptionLAB.ch
In order to be activated, the Option DBE has to be launched. If it has not been
activated yet, after a brief check for internet connection status, a window asking
for the license key will be shown.

Here you can find information about your demo subscription expiration date and
controls for PC registration of you license, you will find your license in the file
License KEY.txt.
Enter your License KEY and press Activate.

Your computer will be registered and a confirmation message will inform you that
the registration process was successful.

Next step will be to install your new Database.


In order to do it you will have to move the folder database contained in the file
Option Explorer License KEY and Database.rar in the installation folder of the
Option Database Explorer.

7
www.OptionLAB.ch
The default directory is C:\Program Files (x86)\OptionLab\OptionDB Explorer, but
if during installation a custom location was selected the database will have to be
moved to the appropriate directory.
Even if it is not necessary to delete the folder Database (DEMO) we suggest doing
it because the DEMO sample cannot be accessed by the full version of the Option
Database Explorer, and keeping it would result in a waste of disk space. Once the
Database moving process has been completed the installation folder should look as
follow:

The folder that contains the database MUST be named “Database”, changing its
name would require manual indication to the software on where to find it.
If you want to put the database in a custom location you should follow these steps.
Move the database folder in your directory of choice.
In the figure the selected directory is D:\Cartella di Esempio.

8
www.OptionLAB.ch
If you have chosen the default directory for your database, it will be automatically
found at program start-up, and a confirmation message in the Log dialog will inform
you of the success as shown in the figure.

If you have chosen a custom location, when launching the program for the first
time, the following error message will be reported:

This happens because the database is not in the default location, and a custom
directory has never been specified.
To manually set the database directory click on Edit -> Select Database Location.

Provide the program with the directory of the folder Database, selecting it in the
dialog box as shown, then press OK.

The Log will inform you that the operation succeeded.

As long as you don’t move the database folder, this operation will not have to be
repeated, the Option Database Explorer will remember your custom location at any
future start-ups.
Your Option Database Explorer full version is now ready to be used
9
www.OptionLAB.ch
3. How it Works
General Aspects
The purpose of the Option Database Explorer is to allow the user to test trading
systems that are based on options on futures.
The program provides the user with easily accessible high quality option
information.
Available data, for every available contract at any given point of time (on a daily
basis) features:
- Price
- Delta
- Gamma
- Vega
- Theta
- Rho
- Implied Volatility

To test a strategy means to simulate the rule-based orders generation process on


past data, to see how it would have performed during the time span of the backtest.
This means that a series of historical trades has to be generated before some
valuable information can be obtained.
To generate an option trade some information must be provided. First, the opening
date of the trade to screen the contracts that were available at that time from those
who weren’t.
Entry (and exit) dates are enough to identify a trade in Futures/Stock backtesting,
but not when working with Options. Further information has to be provided in
order to select a contract from the multitude available.
An option contract is identified by three “coordinates”:
- Maturity Date
- Exercise (Strike) Price
- Option Right: Put/Call
Once these three fields are known, along with dates, an historical trade can be
generated.

Rule-Based Trading
The selection of these 1+3 coordinates (Dates + Maturity/Strike/Right) should be
based on some kind of algorithmic logic.
A way to simulate the selected logic is through manual implementation of the
orders generation algorith. This means that the calculation of the 1+3 coordinates
will have to be performed by some external tool and then manually entered in the
Option DBE, or be based on some easily reproducible set of rules so to make direct
manual selection possible.
An example of easy to implement set of rules is:

10
www.OptionLAB.ch
Sell Short a strangle on 30Year - US Treasury Bonds using contracts with closest
monthly expiry date, with both legs at Delta = 0.1, and let the trade survive until
maturity. Then open the next trade using the same rules.

Rules like these are easy to implement in the Option DBE, thanks to the possibility
of accessing historical option chains that make strike selection very easy.

The second possible way is to implement the algorithmic logic using our proprietary
programming language Option language.
For more information refer to the Option Language Guide.

11
www.OptionLAB.ch
4. System Implementation
To show how to implement a system we will take as an example the methodology
stated before:

Sell Short a strangle on 30Year - US Treasury Bonds using contracts with closest
monthly expiry date, with both legs at Delta = 0.1, and let the trade survive until
maturity. Then open the next trade using the same rules.

This will be our system of choice for every future examples.

Cadence, Symbol and Dates


The first thing to do is to select the Cadence of the options and the Symbol of the
underlying futures needed. In our case Cadence is Monthly, and underlying symbol
is US.

Next step is to define the starting and ending dates of the test. Let’s assume we
want to start our test on May 2012 and run it until May 2016.

Once the date of the first trade is set, the list of available Expiry Dates is updated.
From now on, every time the Quote Date is changed the Expiry Dates list will be
updated. We want to let our trade run until maturity and then we want to start the
following trade on the same day. Thus, it has been natural to select as starting date
for the test, the maturity date of the option expiring on May 2012.

12
www.OptionLAB.ch
This is why the first element of the Expiry Dates list is labelled with “Maturity”, to
highlight the fact that the Quote Date selected is also the Maturity Date of some
contracts.
Since we want to sell short a strangle on the first available maturity we select the
second item of the list, as just said we ignore the first item because there’s no life
remaining for those contracts expiring on that same day.

Strike Selection
Once an Expiry Date has been selected two things happen: first the list of available
Strike Prices is updated, second the historical Option Chain is elaborated for the
contract expiring on the selected date.
In order to create our trades we now have to select the strike price needed.
There are two ways of achieving this:
1) By selecting the strike price from the list using the main control panel.

13
www.OptionLAB.ch
In the list, available strike prices are sorted in ascending order, with Call
Moneyness shown between brackets. Call Moneyness is useful to get a quick
idea of how far from the At The Money contract the strike we are reading is.
After the strike is chosen the main control panel becomes available.
This happens because we gave to the program all the information it needs to
identify an option trade: an opening date, the expiry date of the contract we
want to trade, a strike price, and the option right. By default, the selected
option right is Call, to change it click on Put in the Right block on the right of the
strike selection drop down menu.
Now, by clicking on Buy or Sell in the lower right corner, we can create an
historical trade.

2) The second way of selecting the strike price consists in choosing the contract
we need to trade from the option chain. This option is often better because the
option chain carries a lot of information that is usually taken into account when
trading options.
To open the option chain, click on View Chain button on the right-hand side
close to the expiry date selection drop down menu. When the chain is loaded,
this is what will appear:

We will cover the details of the Option Chain window in a later section. For now
we will just use it as a tool to select and open historical trades. By default the

14
www.OptionLAB.ch
information shown include: Price, Delta, Implied Volatility, for both Call and Put
contracts.
Since our strategy was to sell a delta 10 strangle, what we should do is to find
the call and put strikes with delta closest to 0.1.
After we found the correct strike all we have to do is right click on any cell of
the line and select the Sell Option:

The $154 strike price contract carries a delta of 0.11, and therefor is the closest
strike to our needs.

The price of the option is shown in USD unit term. To see the actual whole value of
the contract, which in the US case is unit price times 1000, flag the “Dollar Value”
label in the upper left corner.

Backtest Box
After having sold both legs of the strangle, in the backtest box, two new trades will
have been created as shown in the figure:

The size of the trade can be changed by double clicking on the cell in the column
Contracts, and manually changing the number of contracts traded.
Now, before the outcome of the trade can be calculated an Exit Logic has to be
chosen.

15
www.OptionLAB.ch
5. Exit Logics
For now, there are 4 different ways an option trade can be closed:

Time Exits
1) Wait until Maturity.
The trade will run until Maturity, then autonomous exercise is assumed to
occur.
2) Exit on a specific date.
The trade will be closed on a specific date between the opening date and
the maturity date.

These first two represent a time limit after which the position is closed. Once a time
exit is set, an intermediate exit can be setup to close the position before the time
exit occurs as shown in the next paragraph.

Profit Target and Stop Loss


3) Stop Loss.
The trade is closed when a stop loss level is reached, based on one of the
logics available.
4) Profit Target.
The trade is closed when a take profit level is reached, based on one of the
logics available.

To setup a time exit for the trade, click on the drop-down cell in the column with
header Time Close. The list will show all available days between opening and
maturity. Click Maturity to let the trade run until expiration date.

As soon as an exit date is chosen the trade is calculated and profit registered. At
this point a Stop Loss and a Profit Target can be set up.
Currently there are 3 different ways available to define exit levels.
16
www.OptionLAB.ch
These 3 ways are analogous for Profit Targets (TP) and for Stop Losses (SL), in the
first case they will identify a level of profit at which the trade will be closed, in the
latter they will identify a level of loss instead.

1) % of Open Price.
The trade is closed when the option premium moves of a certain % in profit (TP)
or in loss (SL). For example, our first trade was a sell short call, and we sold it at
a premium of 0.265625$ (256.625$ Dollar Value). If we set up a SL of 80%, since
we are selling short, our SL will be set at an 80% appreciation: 0.265625 x (1 +
0.8) = 0.478125$ (478.125$ Dollar Value).
If we set an 80% TP, since we are selling short, the trade will be closed when
premium reaches an 80% depreciation: 0.265625 * (1 – 0.8) = 0.053125
(53.125$ Dollar Value).

2) Price Move.
In this case, the trade is closed when the option premium moves of a certain
amount expressed in price points. Let’s take the same example as before,
selling short at 0.265625: a Stop Loss of 0.2$ means that the trade will be closed
after a 0.2$ appreciation: 0.265625 + 0.2 = 0.465625$ (465.625$ Dollar Value).
A 0.2$ Take Profit would result in the trade being closed after a 0.2$
depreciation: 0.265625 – 0.2 = 0.065625$ (65.625$ Dollar Value).

3) $ Amount.
A Stop Loss or a Take Profit stated in $ Amount provides a threshold expressed
in terms of actual trade profits and losses.
A 200$ TP would result in the position being closed after the trade goes positive
of at least 200$, while a 200$ SL would close the trade after a 200$ loss.
This kind of TP and SL are size sensitive: the same amount of TP and SL, in a
trade with double number of contracts traded, would result in half available
space, because of profits and losses being built at twice the speed.

To setup a TP or a SL two inputs must be provided: Mode and Value.


To select the mode extend the drop down menu in the column TP Mode (SL Mode
for Stop Loss), in the row of the trade for which a TP or SL must be set. Then enter
a value in the cell on the right representing the entity of the TP/SL.
After the mode has been selected, and a value entered, the trade is automatically
recalculated, profit updated and a string in the Comment column will tell us if the
trade was closed because of the SL or the TP, and in case it was, when it was closed.

17
www.OptionLAB.ch
6. Automation and Defaults
Option Language
Since in some case many hundreds of trades will have to be created, the process of
manually entering all the historical trades of the backtest can be a long one.
We believe that it’s a fair cost for the information achieved, no other tool allows
the user to get this kind information so easily about Options on Futures trading, but
we nonetheless think a higher degree of automation is needed.
This is why we developed our proprietary programming language, Option
Language. For more information refer to Option language Guide.
This is what a full test looks like:
Entering all those trades is not an easy task, and it could require a couple hours of
work.

The same test, with Option Language, can be done a lot quicker.
It’s enough to enter this code block in the editor to create the strategy, and then
launch it:

18
www.OptionLAB.ch
Defaults
Now, by the way, to reduce the workload, the user can set some default
parameters. This default parameters are useful when a static logic is used to define
the exit criteria of trades.
In our example, our basic rule was to exit our trades at Maturity.
Defaults allow us to tell the program we are going to use always the same exit logic,
and thus not to wait for further input before calculating the trade outcome.
To set up a default is very easy, they are located in the lower half of the control
panel as shown in the figure:

In our case, we could have just set the Time Close default at Maturity:

By doing this, after having executed an historical trade by pressing Buy or Sell, the
program will automatically calculate the trade’s outcome based on a “wait until
maturity” logic.
Default TP and SL work just as non-default ones.
In the Defaults, as a time exit, we have as well the option to define a number of
days prior of expiration as a time limit of the trades. This is done by selecting, under
Time Close default, N Days, and by providing the number of days wanted in the
textbox on the right.
Defaults are also useful for trying different exit logics in almost no-time.
After all trades have been entered in the backtest box, to change their exit logic is
a quick and easy task.

19
www.OptionLAB.ch
Just set a new default and press the button with the two circled arrows on the right.
All trades will be recalculated using that default:

This feature allows the users, while waiting for full automation to be implemented,
to test different settings with ease.

Defaults can be set up in the Option Chain window as well, their location is in the
top panel as shown in the figure:

Once set up, after the window is closed, the defaults will be remembered when the
Option Chain is opened the next time, even if on a different contract.

20
www.OptionLAB.ch
7. The Option Chain Window
This is a full view of the Historical Option Chain:

The Option Chain Window is a very useful tool to gather extensive historical
information. For every symbol available, every maturity date, every single trading
day, an historical option chain can be displayed.
In the Windows Bar, symbol, quote date, and expiration date of the contracts are
shown.

This tool allows the user to choose which information to show and which one to
hide, this makes it easier to keep the window clean and to not overload it with data
that is not needed.

21
www.OptionLAB.ch
The Option Chain, for every contract historically available, can show:
- Price
- Delta
- Gamma
- Vega
- Theta
- Rho
- Implied Volatility

By default, when opened, the chain will show Price, Delta, Implied Volatility,
Volume and Open Interest.
Volume and Open Interest columns are coloured according to a logarithmic-scaled
quantile succession, to make information easier to access.

Price, Volume and Open Interest cannot be removed from the data table, it is at
user’s discretion to choose what else to show. Flag what is needed in the Calculate
box as shown in the figure, then press Recalculate:

After navigating the chain, which can be quite long, to go back to the At The Money
strikes press ATM button in the Calculate box.
The Dollar Value checkbox, in the upper left corner, allows the user to show option
premiums expressed in contract size instead of per unit.
Underlying Price field shows the settlement price of the underlying on the date the
chain is being calculated.

The Show box allows the user to switch between Intrinsic Value, Extrinsic Value and
Whole Value of premiums.
Defaults have been discussed in a section 6.
Group Trades allows the user to group trades opened from the Option Chain, the
grouping feature will be discussed in section 11.
The Action box allows the user to choose if to highlight a certain level of delta. We
think this feature can be useful since delta is often used as a mean to select price
levels of strike prices.

22
www.OptionLAB.ch
To highlight a certain delta level within the chain, flag Highlight Delta, and input in
the Call and Put textbox the levels needed as shown in the figure:

Follows a screenshot with corresponding output:

After closing and reopening the chain window, the Action box and Defaults box
inputs will be remembered.

As discussed in section 5 trades can be opened from the chain, by right-clicking on


the line of the contract to be traded, and selecting whether to buy or to sell it.

23
www.OptionLAB.ch
8. The Performance Report
Once all trades of a test have been executed, the Performance Report can be
opened to gather information about the results of the test.
Here, both performance statistics and charts can be found.
To open the Performance Report click on Test -> Open Performance Report:

This is how the Performance Report looks like when opened:

The chart shown is the Close-To-Close, trade-based, equity line of our strategy. The
lower chart shows profits and losses of each trade.
In this case, since we are selling naked strangles, profits are very frequent and
closely distributed around the mean, while losses are less frequent, sparser, and of
higher magnitude.

24
www.OptionLAB.ch
To switch to a daily chart, click on Options -> Chart Type -> Equity Detailed.

The chart will now show a date-based charts:

The lower charts, this time, shows profitable and non-profitable days.

The lower chart can be used to show profit/losses of the upper chart, or DrawDown.
To switch to DrawDown click on Option -> Lower Chart -> DrawDown:

As a result DrawDown will be shown:

25
www.OptionLAB.ch
The second tab, Performance, gives key statistics about the backtest:

The third tab, Test Data, shows the Test Name, the Defaults that has ben applied,
and symbols used. This helps to contestualize the performance report when more
than one will be opened at the same time.

26
www.OptionLAB.ch
9. Grouping Trades
When trading options, often, more than one of them are traded simultaneously in
some combined way. This was the case, for instance, with our short strangle
system.
Strategies can be of any degree of complexity and comprise an undefined number
of contracts at the same time. Nonetheless, these multiple trades are often
considered by traders as one.
To tackle this issue, we introduced so-called “Trading Groups”.
Trading groups allows the user to tell the program, when calculating performances,
to treat multiple trades as a single one.
Grouping trades with the Option DBE is extremely easy.
Flag the Grouping checkbox in Group Trades section as shown in the figure:

Select a group number.


All trades opened afterwards will be grouped together, to start building a new
group it’s enough to change the group number.
When calculating system performance all grouped trades will be considered as one.
It’s possible to group trades opened through the Option Chain as well, following the
same instructions as above, in the Group Trades section.

27
www.OptionLAB.ch
10. TS Code Generator for Naked Shorts Hedging
The TS Code Generator is a feature that allows the user to automatically create
TradeStation strategies that hedge Naked Short Sell option trades.

Once implemented these strategies have to be launched in TradeStation on the


appropriate underlying instrument. The outcome can then be visualized in two
ways: it can be imported in the Option Database Explorer, that will elaborate it in
conjunction with the option strategy as a portfolio (Option + Underlying), or it can
be evaluated directly within TradeStation with the performance report. Another
way would be to export both the TradeStation Report of the hedge and the
Performance Report of the Option DBE into an Excel spreadsheet, and then to
aggregate them using a macro.

To generate the TradeStation EasyLanguage code of the naked shorts covering


strategy click on Edit -> Export EL Code Future Hedging.

Once clicked on Export EL Code Future Hedging an option window will open asking
for a few information before starting the process.

Here the user can choose the name to give to the .txt file where the strategy will be
written, on which symbol of those used in the backtest to create the hedging
system, if only one symbol was used, as in most cases, only one option will be
available. You can ask the program to automatically open the .txt file straight after
code generation by flagging Open after Export.
The Code Generator will produce a strategy able to cover all and only the option
short trades on the selected symbol.
Click OK and the Option DBE will start building the code, which will be exported in
a .txt file in the installation folder at the directory Exports/EL Auto-Generated Code.
To easily access the installation folder, click on File -> Open Data Folder.

28
www.OptionLAB.ch
If you flagged the Open After Export option the .txt file will automatically open,
showing the code just generated.

To use the strategy just generated copy the whole text contained in the .txt file
(ctrl+a, ctrl+c), and paste it within a strategy appositely created in TradeStation.

Hedging Strategy Code


Let’s see now the code sections of the hedging strategy.
1. Input and Control Section

The first section, until line 33, contains variables declaration. These
variables can be used to customize the covering strategy according to
the user’s needs.
29
www.OptionLAB.ch
At Line 8 a comment reporting the location of the .txt file containing the
generated code can be found.

At line 13 the user can choose a monetary Stop Loss to be imposed to


every cover trades. It will be individually applied to all open trades, not
to the whole position, when multiple trades are floating at the same
time.

The inputs related to the long part of the cover (covering short calls) are
located at line 16, let’s discuss them one by one:
- Delay: the distance from the strike price at which the cover has to
be placed. It can assume values >, <, and = to 0. In case of a delay
equal to 0, the cover trade will be placed exactly at the strike price,
in case of a negative delay the cover order will be placed in the Out
of The Money area, in case of a positive delay it will be placed in the
In the Money area. Thus, for example, if I have a naked short call
position with strike 10$, and set a delay of 1 (also expressed in $), the
Stop Buy order will be placed at 11$.
- SizeMultiplier: this variable allows the user to cover only a fraction
(if lower than 1) or multiple times (if higher than 1) the option
position. In fact, the strategy is coded in a way that makes the cover
trades be opened with the same size of the option trade to be
covered. If we want to give double exposure to our cover trade, we
will have to set the size multiplier at 2. If we only want a half coverage
we will have to input 0.5, by default this variable is set to 1, for a ∆
neutral (at maturity) kind of hedge.
- NConIfMultZero: if instead we want to disentangle the size of the
option trades from the size of the cover trades we will have to set
the SizeMultiplier = 0, so that the proportional component of trade
size calculation is 0, and NConIfMultZero = X, where X is the number
of contract that we want our cover trades to be opened with. If
SizeMultiplier is not equal to 0, any value assigned to
NConIfMultZero will be ignored. (The name of the variable comes
from Number of Contracts to be used If Multiplier is Zero).
To better understand SizeMultiplier and NConIfMultZero variables,
think of them as related to the cover size in this way:
𝑆𝑐 = 𝑁 + 𝑀 ∙ 𝑆𝑂
Where:
𝑆𝑐 = Size of the Cover Trade on the Underlying
𝑆𝑂 = Size of the Option Trade to be covered
𝑀 = SizeMultiplier, managing proportional section of size equation
N = NConIfMultZero, managing constant section of size equation

The following constraint applies, independently by user input:


𝑀 ≠0 ⇒𝑁=0

30
www.OptionLAB.ch
- AllowSideBuy: this variable allows the user to inhibit all cover
trades for the call side.
The long part of the covering strategy will be deactivated. We’ll later
see that it is possible to create custom filters, that if set to False
would have the same effect.
The difference is that filters eliminate the chart lines of the
deactivated trades to give the user a feedback about filters
operations, while using AllowSideBuy to deactivate the whole long
side will result in the chart line to still be placed on the strike levels.

At line 17 the filter variables are declared and initialised to true. We do


not advise to interact with this variables at declaration stage, filters logic
will have to be implemented in a later section, at line 24.
At line 24, in fact, we find the same 3 variables again being set to True.
By substituting True with any expression after the “=” sign, it is possible
to build a filter that will operate on the side related to that variable.
For instance, if we write at line 26:

FilterBuy1 = Close > Close[1];

The long cover will only function if current underlying price is higher
than close price of one bar ago.
It is possible to set three filters at the same time, if we want to leave one
of the three filters inactive it will be enough to leave it set to True as by
default.
Filter 1, 2, and 3 are applied with an AND logic, thus they will have to be
all True at the same time for the cover to function. Any OR logic will have
to be implemented within the same variable, for example:

FilterBuy1 = (C > C[1]) OR (H > H[1]);

At line 20 and 21 are located the equivalent control variable for the Sell
side, at line 31 to 33 are set the custom logics of the sell side filters.

2. Internal Prelim Calculation

31
www.OptionLAB.ch
Here, internal calculation needed by the program to work correctly are
performed. For a proper functioning of the strategy we advise not to
modify the code contained in this section, from line 36 to 48.

3. Trading Core

The actual trading core of the strategy, where entry and exit conditions
for covering trades are coded, is here.
We advise not to change this section, because it would be difficult to
modify it consistently in its entirety. This section, in fact, consists of 11
code lines for every option that has been short sold, it would be
impractical to operate a change that stay consistent on every trade.

4. Stop Loss and Performance Export

In this example, this block starts at line 1314, a number that varies
depending on the number of option trades that have to be covered.
The stop loss is set up in line 1315 and 1316.
In the block from line 1319 to line 1328 the result exporter is coded.

32
www.OptionLAB.ch
The folder selected as destination for the export of the results of the
hedge is automatically set at the directory “Exports/TradeStation Equity
Export” within the installation folder of the Option DBE, to change it the
user has to modify line 1323 accordingly.
The name of the .txt file that will contain the result is chosen at line 9,
over the input block, at variable TestName (if modified make sure the
name ends with .txt).
To enable the export the block has to be uncommented, to do so the
brackets at line 1320 and 1328 have to be deleted.
The result is exported with a format that makes it comparable with the
option backtest, it consists of a daily equity.

Launching the strategy

The figure above shows what will appear on the chart after having compiled, loaded
and run the strategy on the appropriate underlying instrument.
Coloured lines will be automatically generated. Solid green lines show the strikes of
the call options sold (meaning stop buy order will be used as covers), while solid
red lines show the strike prices of put options (meaning stop sell order will be used
as covers). Dashed lines show the actual level where the stop orders are placed,
33
www.OptionLAB.ch
this level is not equal to the strike price when Delay input is not set to 0. In this
example, Delay was set to 0.5.
If more than one option has to be covered at the same time strategy properties (at
Properties for All window) have to be changed accordingly. More specifically
Position Limits have to be set as in the figure below:

This is how a two puts trade would be covered:

As shown by the solid red line, there are two puts sold, with different strike price,
at the same time. They are covered by different trades, that are managed
separately as can be seen by the fact that the stop loss exit of the first cover trade
of the lower put does not affect the previously opened trade.

34
www.OptionLAB.ch
Confronting Results
Aggregating results and analysing performance of the combined portfolio of the
Option Strategy and the hedging strategy is easy.
First of all, the hedging strategy must have been executed on the underlying, in
TradeStation, with the block containing the exportation code uncommented.
This operation will generate a result summary file, in .txt, saved in the installation
folder of the Option Database Explorer.
Then, in the Option DBE, in order to aggregate results, the .txt file has to be
imported. To do this click on Edit -> Import TS Report, as shown in the figure:

A dialog, opening automatically at the default location (Exports/TradeStation


Equity Export), will let you open the file.
Here the user will have to choose the report he wants to import.
The importing process should be fast, in the Log section the label “TSReport
Imported” tells the user that the operation was completed successfully.
Done.
Now the hedging equity line is in memory, and the Performance Report, in Detailed
mode, will look as follow:

35
www.OptionLAB.ch
The three lines represent the equity line resulted from the Hedging strategy (red),
the equity line of the Option strategy (blue), and the portfolio equity line (black).
The Close-To-Close equity line will still only show option trades because CtC equity
lines are not aggregable with sufficient precision.
In Performance tab are now available key statistics concerning the option strategy,
the hedging strategy, and the combined portfolio.
Usual CtC performance metrics are also shown.

In order to eliminate the last imported report from memory click on Edit -> Reset
TS Report.

36
www.OptionLAB.ch
11. Exporting Results
Backtests produced with the Option Database Explorer can be exported to an excel
spreadsheet for further consultation and to operate custom calculations.
To export a backtest click on Edit -> Export to Csv

By default, the location for exported backtest is within the installation folder at
Exports/Csv Exports, but a custom directory can be chosen. After selecting the
directory for the export press Save.
A .csv file will be generated, it contains information about trades, cumulative CtC
equity line, and the detailed equity line.

37
www.OptionLAB.ch
38
www.OptionLAB.ch
12. Miscellaneous
Test Name
Test Names are used to keep track of backtests in a friendly way. They can be any
sequence of characters, and, to be set, a Test Name has to be input in the Test
Name bar, as in the figure:

Once entered it will be associated with the test, and saved with it. This means that
it will be remembered once the test is closed and reloaded.
It will always be shown in the Test Name bar, so that the user can easily remember
what backtest he is working on, and it will also be shown in the Performance Report,
in the Test Data tab.
If a custom name is not entered, by default, the Test Name will be the name given
to the save file of the backtest.

Save and Open a Backtest


It is possible, when needed, to save the work done. After trades have been
executed, go to File -> Save As.
Default directory for save files is in the installation folder at /Save Files, but a
custom location can also be chosen.
Once saved, all the information contained in the backtest box will be saved, along
with Test Name and Defaults used.
To open an old backtest click on File -> Open.

Clear All
If needed, in order to cancel all trades in the backtest box and clear the working
space go to Edit -> Clear All.
Warning: all information will be lost, if then the test is saved and file overwritten
there won’t be any way to recover it.

Data Folder
All information is stored in the installation folder: the database is stored there, and
it’s the default location for save files and exports.
It happens quite often to need to go to the installation folder. To make it quicker,
we put a button in the File menu, called Open Data Folder, that allows the user to
quickly open a File Exploration window directly in the installation folder.

39
www.OptionLAB.ch

You might also like