AlgoTraderAlgoTrader Documentation
The purpose of this Strategy is to demonstrate capabilities of AlgoTrader. Do not use it with a Live Trading Account and real Money! The strategy might lead to large losses. Even when modifying or extending the Strategy use caution before trading it Live.
A short strangle is an options strategy comprised of selling both a call option and a put option with the same strike price and expiration date. It is used when the trader believes the underlying asset will not move significantly higher or lower over the lives of the options contracts. The maximum profit is the amount of premium collected by writing the options. The potential loss can be unlimited, so it is typically a strategy for more advanced traders.
Short strangles allow traders to profit from the lack of movement in the underlying asset, rather than having to place directional bets hoping for a big move either higher or lower. Premiums are collected when the trade is opened with the goal to let both the put and call expire worthless. However, chances that the underlying asset closes exactly at the strike price at the expiration is low, and that leaves the short strangle owner at risk for assignment. However, as long as the difference between asset price and strike price is less than the premiums collected, the trader will still make a profit.
Advanced traders might run this strategy to take advantage of a possible decrease in implied volatility. If implied volatility is unusually high without an obvious reason for it being that way, the call and put may be overvalued. In this case, the goal would be to wait for volatility to drop and then close the position for a profit without waiting for expiration.
This example strategy demonstrates a typical options trading strategy where the subscribed instruments change throughout the simulation process (i.e. when options expire new options need to be subscribed).
On startup the strategy will subscribe to the underlying S&P Index. Then on
the first tick of the S&P Index the strategy will determine Put and Call options
with a minimum remaining time to expiration of
daysToExpirationOnOpen
.
A standard Strangle strategy will use Put and Call options with the same strike
(the current market price). By setting the strategy parameter
moneyness
to a non-zero amount the Put Option will have a
strike of moneyness
below the current market price and the Call
option will have a strike of moneyness
above the current market
price. By setting moneyness
to a non-zero amount the strategy
becomes a Short Strangle strategy.
After subscribing to the newly established Put and Call Option the strategy will
wait for the first tick of each options and then place corresponding
SELL
orders.
The strategy parameter daysToExpirationOnClose
then defines the
number of days prior to expiration of the options the strategy will close open
positions. Upon closing positions the strategy will unsubscribe the current option
market data subscriptions and establish a new set of options to enter positions
into.
The following list will give an overview of the specific artifacts implemented by the Short Strangle Strategy. Most of the functionality is documented via comments:
/src/main/java/ch/algotrader/strategy/shortstrangle/ShortStrangleService.java
The strategy service class providing the all the logic.
/src/main/resources/conf-shortstrangle.properties
Contains parameters used by the strategy
/src/main/resources/META-INF/applicationContext-client-shortstrangle.xml
Contains the Spring Bean definitions for
shortstrangleConfigParams
,
shortstrangleEngine
,
shortstrangleService
/src/main/resources/META-INF/esper-shortstrangle.cfg.xml
Esper config file (no strategy specific config needed)
/src/main/resources/db/influx/influx-shortstrangle.gz
Contains the end-of-day historical data for all SPX Options for July 2011 to January 2013
To setup the strategy for live trading on a development workstation please execute the following steps:
If you have used the Section 2.1, “Windows Installer” to setup AlgoTrader, this project is already setup in the AlgoTrader IntelliJ IDEA and you can skip this step.
Download the Examples project zip file and unpack it in a directory of your choosing: https://www.algotrader.com/downloads/latest-examples
user name and password will be provided when signing up for an AlgoTrader license
If you need an older AlgoTrader version, login to our maven repository
(https://repo.algotrader.com/nexus)
and click on Browse
on the left and select code-general
.
Then select the AlgoTrader version you want and download:
Import the project short-strangle
into your
IDE.
load the InfluxDB historical data file into InfluxDB:
/short-strangle/src/main/resources/db/influx/influx-shortstrangle.gz
by issuing the following
command
influx -import -compressed -path influx-shortstrangle.gz
invoke the Run Configuration:
SimulationStarter-simulate-shortstrangle