REDIPlus API Complex Options Trading Example
Introduction
With REDIPlus’s powerful options capabilities, users can easily trade single and complex spread strategies globally through multiple brokers. The options trade can be sent via REDIPlus UI or REDIPlus API. The example in this article demonstrates how to trade complex option via REDIPlus API with C# and Visual Studio 2017. REDIPlus and the tutorial example run on the same machine, side by side. The example supports the following strategies for complex options orders.
- Buy-Write
- Vertical
- Ratio
- Butterfly
The valid parameters of the example are:
By default, the order will be sent to a broker simulator server. If the account (-a, --account) is not specified, the application will use the first available account returned from the OPTIONORDER.GetAccountAt method.
The complete project code is available for download at OptionsStrategyExample.
For the detailed steps for sending a complex options order, please refer to the Trading Complex Options in C#.
Buy-Write
Buy-write is an options trading strategy in which the investor is buying shares and simultaneously selling call options against those shares to generate income from option premiums. It can limit the loss because the options position is covered by the underlying stocks.
With REDIPlus API, this strategy requires two legs. The first leg is for the option order and the second leg is for the underlying stocks.
The above code sells one Nov '18 110 Call on the first leg and buys the 100 shares of IBM on the second leg with the market order price type. The order will be sent to a broker simulator server.
You can also use the following parameters with the example to send a buy-write complex option order.
The output is:
The order can be verified from the Message Monitor.
Buy-Write
Vertical
In options trading, a vertical spread is an options strategy constructed by simultaneously buying a certain number of options and selling an equal number of options of the same type, same underlying security, same expiration date, but at different strike prices. They can be created with either all calls or all puts. This strategy limits the risk involved in the options trade but at the same time, it also reduces the profit potential.
With REDIPlus API, this strategy requires two legs. The option type and expiration date can only be specified on the first leg. Then, REDIPlus API will use these values for the second leg.
The above code buys IBM Nov '18 120 Call on the first leg and sells IBM Nov '18 130 Call on the second. The spread entry price is $5.5. The order will be sent to a broker simulator server.
You can also use the following parameters with the example to send a vertical complex option order.
The output is:
The order can be verified from the Message Monitor.
Vertical
Ratio
A ratio spread is a variation of the vertical spread. Typically, it involves buying and selling options on the same underlying security and the same expiration date but with different strike prices. However, a number of option contracts and a number of contracts sold are in ratio. The most common ratio is 2:1 with 2 options sold to 1 option bought. This strategy provides a limited profit and has a chance of incurring unlimited risks if the underlying stock is too volatile.
With REDIPlus API, this strategy requires two legs. The option type and expiration date between the first and second legs can be different. The ratio of each leg is set through the COMPLEXORDER.SetQuantity method.
The above code buys one IBM Nov '18 120 Call contract on the first leg and sells two IBM Dec '18 130 Call contracts on the second with the market order price type. The order will be sent to a broker simulator server.
You can also use the following parameters with the example to send a vertical complex option order.
The output is:
The order can be verified from the Message Monitor.
Ratio
Butterfly
The butterfly spread is a neutral strategy that is a combination of the vertical spread trades. It relates to four option contracts with the same expiration and option type but three different strike prices. For example, the trader sells two option contracts at the middle strike price, buys one option contract at a lower strike price, and buys another option contract at a higher strike price. It can be constructed using calls or puts. This strategy provides a limited profit and risk. It is used when the trader believes the price of the underlying stock will not deviate much from the current price.
With REDIPlus API, this strategy requires three legs. The option type and expiration date can only be specified on the first leg. Then, REDIPlus API will use these values for other legs. The first and third legs have the same side (Buy or Sell) and each relates to one option contract. The second leg has the opposite side (Buy or Sell) and it relates to two option contracts.
The above code uses the butterfly strategy to buy and sell the following IBM option contracts with the market order price type.
- Buy one IBM Dec '18 110 Call contract on the first leg
- Sell two IBM Dec '18 120 Call contracts on the second leg
- Buy one IBM Dec '18 130 Call contract on the third leg
The order will be sent to a broker simulator server.
You can also use the following parameters with the example to send a butterfly complex option order.
The output is:
The order can be verified from the Message Monitor.
Butterfly
Summary
The complex options trade can be sent via REDIPlus UI or REDIPlus API. With REDIPlus API, RediLib.COMPLEXORDER class is used to populate and submit an order. This article demonstrates the ways to use REDIPlus API to send complex options orders with the Buy-Write, Vertical, Ratio, and Butterfly strategies.