Options Trading

Author: Kwabena Aduse-Poku

Motivation

The core of the SIF infrastructure is built around developing testable portfolio-based trading strategies for the stock market that rebalance holdings daily. Over the past few semesters, we have been experimenting with intra-day trading and different financial products. This project takes some of the ideas developed in these explorations and applies them to options trading in order to create an infrastructure that makes creating and testing new strategies easy and flexible for researchers.

Overview

The first major concern was selecting a market data provider and broker for execution. The Tradier API proved to fill all of our needs well. Tradier has both data and execution services with acceptable liveness guarantees. Additionally, it has the option to create paper trading accounts, allowing researchers to test trading strategies without using real money. It provides current price data for options and their underlyings, as well as greeks and other information. Tradier also has forgiving rate limits, which made it an ideal choice for live trading application.

We took an object oriented approach to defining the strategy platform.

OptionsClient

The OptionsClient is the object that interacts with the Tradier API. It holds the OptionsStrategy object and passes market data to it on every trading interval. The OptionsClient takes trades generated by the OptionsStrategy and sends them to Tradier for execution. It also handles logging of all trading events including opening and closing positions and market data updates.

OptionsStrategy

The OptionsStrategy is an abstract class which handles how the option will be traded. There is one method that must be defined in its API: generate_trade. This method takes in market data from Tradier and returns an OptionsTrade object to be executed. This method is called on every trading interval. The researcher has a lot of flexibility in how the OptionsStrategy is defined, including creating new data structures within the object to hold previous market data or perform additional calculations. This openness allows a plethora of trading styles to be emulated with just one abstract class.

OptionsTrade

This object represents an open option trade. It can contain up to four legs, or individual option contracts. Thus, it can represent most common discrete options strategies such as spreads, straddles, strangles, condors and butterflies. Each OptionsTrade also contains exit conditions, a dictionary mapping market data fields to lambdas. Each lambda evaluates to a boolean to determine whether the current trade should remain open on this interval or be closed. This allows researchers to define trading strategies as a set of conditions: the conditions under which a trade should be entered paired with the conditions under which the trade should be closed. This opens the door for a lot of creativity in strategy creation while keeping the trade generation loop computationally light on average.

The Future

The bones of this options strategy framework have a lot of room to be fleshed out. For example, support for different market data sources and brokerages can be added. Connections can even be made to the existing historical securities data and alternative data collected for other SIF projects. In order to make analyzing strategy performance easier, the existing logging can be extended to create visual representations of strategy performance. All of these additions can help researchers to build better strategies. We look forward to seeing the strategies that SIF researchers will build with this new infrastructure.

Previous
Previous

SIFSearch Progress & Developments

Next
Next

Fall 2023 Recap