Skip to content
forked from michaelchu/optopsy

Python Backtesting library for options trading strategies

License

Notifications You must be signed in to change notification settings

foxbupt/optopsy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Development Update (June 1, 2018)

Codacy Badge Build Status codecov

This library is currently being redeveloped to be better optimized for options backtesting.

The new version will provide predefined filters to act as building blocks for your option trading strategies. No need to extend classes to implement custom trade configurations such as position sizing and commissions. These settings can now be defined using existing filters.

Filters will include (but not limited to):

Entry rules:

  • Days to expiration
  • Entry Days (Stagger trades)
  • Absolute Delta
  • Percentage out-of-the-money
  • Contract size

Exit rules:

  • Days to expiration
  • Hold days
  • Profit/Stop loss percent
  • Spread delta
  • Spread price

Development changes will be made on the development branch. The backtester branch will be retained for historical purposes and will be removed at a later time.

Optopsy

Optopsy is a flexible backtesting framework used to test complex options trading strategies written in Python. Backtesting is the process of testing a strategy over a given data set. This framework allows you to mix and match different 'filters' to create a 'Strategy', and allow multiple strategies to form an overall more complex trading algorithms. The modular nature of this framework aims to foster the creation of easily testable, re-usable and flexible blocks of strategy logic to facilitate the rapid development of complex options trading strategies.

Features

  • Open source - Feel free to make requests or contribute to the code base! Help out a fellow trader!
  • BYOD - "Bring your own Data" source by using the built-in data adapters or write your own. (Currently supports csv files)
  • Modular Design - Facilitates the construction and composition of complex algorithmic trading strategies that are modular and re-usable.
  • Optimization support - Define ranges for your strategy parameters and the system will optimize the strategy

Planned Features

  • Indicator Support - Create entry and exit rules based on indicators
  • Optimizer - Allows users to run multiple backtests with different combinations of parameters
  • Option strategy support:
    • Single Calls/Puts
    • Vertical Spreads
    • Iron Condors (Iron Butterflies)
    • Covered Stock
    • Combos (Synthetics/Collars)
    • Diagonal Spreads
    • Calendar Spreads
    • Custom Spreads
    • Strangles
    • Straddles
  • Stock Price Distribution Generator - Analyze historical stock price movements patterns to discover potential trade ideas.
  • Trade Scanner - Used to recommend trades based on stock price distributions

Dependencies

You will need Python 3.6.x. It is recommended to install Miniconda3. See requirements.txt for full details.

Installation

pip install optopsy

Usage

python strategies/sample_strategy.py

The sample strategy can be used with Level 3 Historical CSV Data Sample from historicaloptiondata.com.

In order to use it, you will need to define the struct variable to map the column names to the numerical index as per the file format.

About

Python Backtesting library for options trading strategies

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%