Skip to main content

Option Strategy Backtesting Library

Project description

This is a basic trading strategy backtesting library. It can be used to backtest option strategies.

Three files are needed to backtest the option strategies. One file with the futures data. Another file with the call option data. Third file with the put option data.

Ensure the below format for the files and the files should be of the csv format.

Futures file : Order of Columns : yyyy-mm-dd, date, month, year, expiry_date(of the format dd-(first three characters of month)-yy example : 26-May-22), open, high, low, close Call Option File : Order of Columns : datetime year month Date expiry_date Time strike_price open high low close (example : 2022-01-03 9:15:00 2022 1 3 27-Jan-22 9:15:00 15500 1961.55 2010 1961.55 2004.45) Put Option File : Order of Columns : datetime year month date expiry_date time strike_price open high low close (example : 2022-04-01 9:15:00 2022 4 1 28-Apr-22 9:15:00 15500 25.1 25.55 19.95 20.1)

Argument list for ironCondorStrategy : self, putFile, callFile, spotFile, sellPut, sellCall, buyCall, buyPut, entry, exit, lotSize

example of code

from AlgoAshutosh import *

object = ironCondor() object.ironCondorStrategy(“/Users/username/Desktop/putOptionsFile.csv”,”/Users/username/Desktop/callOptionsFile.csv”,”/Users/username/Desktop/futuresFile.csv”,100,100,200,200,1,10,50) This means if spot price is 15000 then call sold at strike price 15000+100, call bought at 15000+200, put sold at strike price 15000-100, put bought at 15000-200, would be backtested. The entry would be at the first day of the month and exit at expiry date - 10 days before. So for example to exit position at expiry date pass that argument as 0. 50 represents the lot size.

Argument list for shortStraddleStrategy : self, putFile, callFile, spotFile, entry, exit, lotSize

Argument list for shortStrangleStrategy : self, putFile, callFile, spotFile, sellPut, sellCall, entry,exit, lotSize

CHANGELOG

0.0.1 (09/07/2022)

-First Release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AlgoAshutosh-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file AlgoAshutosh-0.0.1.tar.gz.

File metadata

  • Download URL: AlgoAshutosh-0.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for AlgoAshutosh-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c1acb41569fcffef88e0f2cbd74865d6f4b1bb3fdf6fd1604e37060e296c06f2
MD5 de28973ffbf84711f41564e9d14f5bfc
BLAKE2b-256 d877b36c1c631d40ed78827fe8f166c0c5da3bfd270a3db163506e34f7fc18c8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page