Click here to Login




How to simulate options strategies

Updated on 2009-12-08





The advanced rules syntax introduced in the early versions of QuantShare is the perfect tool to create advanced rules and outputs that are very difficult and almost impossible to create using vector-based functions. Even using the .Net languages, implementing those rules would be too difficult and very complicated.

There are two kinds of advanced rules, the first ones are used to detect advanced patterns, while the second ones are used to create advanced outputs and simulate various strategies.

The second category, we are dealing with there, uses a syntax that starts with "SET". These rules can be created with the vector-based formulas, and are mainly used to assign a value (output) to each trading bar (or to trading bars that satisfy specific conditions).

One of the simplest output simulates a strategy that buys/shorts a security and exits it after N number of bars. This rule or output could be translated in:
Set _PERF(OPEN) WHERE _DIS(0) > 50
The syntax is: Set [output] WHERE [condition2] THEN [condition3] THEN [condition4]...
The above formula calculates the performance of a security using the open price, from the current bar (CB) to the bar number "CB + 50".

What you need to know is that advanced rules use the vector-based language functions as well as its own functions. Example:
_dis: Calculates the distance in bars, between the current condition (the bar at which the condition is met) and an older condition bar.
_perf: Calculates the return (ROC: rate of change) of the specified time-series between two condition bars.
NB: The first condition, in a "SET" rule, is the current bar.
You can get a full list of all functions in the documentation document.

How to simulate options strategies:
Let us create a more advanced output. This output simulates a strategy that is used by traders to protect their portfolios from decline using options.
The first step would be to create your rules using the "Rules Manager". After you click on "Analyze", select "Outputs", then click on "Select Outputs". In the "Output" form, select "Custom output", click on "Add", and then click on "Edit" (third column in the grid).

The type of strategy we are going to use is: Buy a security and hedge it with a put option that has the following characteristics: Expiration in 50 days, strike at -20% below the current security price and a cost of 2% (2% of the current security price).

Here are the different scenarios at the expiration:
The security return is lower or equal to -20%: The strategy maximum loss is -20%.
The security return is higher than -20%: The strategy return will be the security return minus the cost of the option (2%).

These scenarios are translated in the following formula:
_iff(_perf(open) > -20, _perf(open) - 2, -20)

In addition, since the option expires in 50 days, we should set the following function: _dis(0) >= 50 after the "WHERE" keyword.

The complete output formula is: Set _iff(_perf(open) > -20, _perf(open) - 2, -20) WHERE _dis(0) >= 50











one comment (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1461 days ago

Profile Graphs
Posted 1566 days ago

QuantShare
Previous Posts

How to simulate options strategies
Posted 5474 days ago

Organizing Trading Objects
Posted 5481 days ago

How to search for a download item
Posted 5495 days ago

Trading orders - Part 2
Posted 5502 days ago

Trading Orders - Part 1
Posted 5509 days ago

Sharpe Ratio - Part 2
Posted 5530 days ago

Sharpe Ratio - Part 1
Posted 5536 days ago

The 'inside period' function
Posted 5550 days ago


More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.