{"id":17002347,"url":"https://github.com/nix1/bye","last_synced_at":"2025-04-12T06:33:11.093Z","repository":{"id":96872829,"uuid":"576724222","full_name":"nix1/bye","owner":"nix1","description":"Backtesting Yield Estimator for Index\u0026Stock Options. A tool for testing long-term option-based trading/investment strategies.","archived":false,"fork":false,"pushed_at":"2022-12-11T19:42:18.000Z","size":30,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T01:51:09.891Z","etag":null,"topics":["backtest","backtester","backtesting","backtesting-engine","backtesting-trading-strategies","etf-investments","etfs","investing","investment-analysis","investment-simulator","investment-strategies","options","options-trading","put-option","stock-data","stock-market"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nix1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-10T19:16:43.000Z","updated_at":"2025-02-11T13:31:52.000Z","dependencies_parsed_at":"2023-03-25T13:20:29.078Z","dependency_job_id":null,"html_url":"https://github.com/nix1/bye","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix1%2Fbye","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix1%2Fbye/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix1%2Fbye/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix1%2Fbye/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nix1","download_url":"https://codeload.github.com/nix1/bye/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248529209,"owners_count":21119463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtest","backtester","backtesting","backtesting-engine","backtesting-trading-strategies","etf-investments","etfs","investing","investment-analysis","investment-simulator","investment-strategies","options","options-trading","put-option","stock-data","stock-market"],"created_at":"2024-10-14T04:27:42.146Z","updated_at":"2025-04-12T06:33:11.054Z","avatar_url":"https://github.com/nix1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backtesting Yield Estimator for Stock\u0026Index Options\n\nThe goal of the Backtesting Yield Estimator (_BYE_) is to provide\na simple Pythonic way to define and test option trading strategies.\nThis tool aims to allow investors to backtest their option strategies on historical data\nto estimate the expected yield of their strategies\n_(but see more info on its current state and limitations below)_.\n\nThe focus is on testing long-term investment strategies. Just write and HODL! 📈💰\n\n## Why?\n\nBecause I couldn't find a tool for myself,\nand I was disappointed by the state of open-source in this area.\nLet's change that!\n\n## Current Status\n\n![flake8 and pytest](https://github.com/nix1/bye/actions/workflows/python-app.yml/badge.svg)\n\n🚧 **POC / Exploration** 🚧\n\nBYE is currently in its early stages of development,\nlike a toddler learning to walk and talk. For now, it's just an experiment.\nBut if you're interested in contributing, I'd love to have your help! 🙌\nCheck if there are any recent contributions to see if the project is still active.\nIf not, it may have been abandoned. 🤷‍\n\n## Features\n### Implemented Features\nBYE currently only has limited support for SPY put-writing strategies\nbased on end-of-day historical data provided by [OptionsDX](https://www.optionsdx.com/).\nThe author is not affiliated with OptionsDX in any way, I just found\ntheir data to be the most convenient to work with.\n\n### Key Planned Features\nOne of the key planned features of BYE is the ability\nto generate semisynthetic option data based on real historical SPY and VIX values.\nThis will make it much easier to test strategies without the need\nfor actual historical option data (which might be heavy, expensive or perhaps\nlacking or even not available at all).\n\nLong-term, BYE might support the generation of purely synthetic data\nto detach itself from what happened in the past,\nand therefore hopefully better evaluate strategies for the future.\n\nThe tool will also provide additional analysis and visualization of backtesting results,\nto help users identify the most promising strategies.\n\n## Project Goals\nThe following goals are in scope for BYE:\n\n* 📈 Allow backtesting of options strategies on historical data\n  * Support for daily SPY data from OptionsDx\n  * Put-write strategies\n  * Other and more complex strategies/combinations\n  * Keeping track of available capital and enforcing position limits\n  * Reporting of results - returns, drawdowns, etc.\n  * Charts of results\n  * Reporting on metrics - volatility, Sharpe ratio, etc.\n  * The impact of commissions and fees\n  * Tax implications\n  * Margin requirements and interest\n* 🔮 Generation of semisynthetic market data based on real SPY and VIX values\n  * This is also where tickers other than SPY might be supported, because it will likely\n    be easier to generate semisynthetic data for them than to find decent historical data.\n* 🔮 Generation of purely synthetic market data to take into account very rare events (black swans)\nthat might have never occurred in the past.\n\n### Anti-Goals\nNone of the following is planned to be supported by BYE:\n* Backtesting on more frequent data. This is not a day-trading tool, it's for long-term strategies.\n* Exercise and assignment. Let's just focus on options.  \n  **Q:** Isn't this limiting?  \n  **A:** Not really. Buy the put back just before assignment,\n  and open a [synthetic long position](https://www.optionsplaybook.com/option-strategies/synthetic-long-stock/)\n  instead, if that's really what you want. Also, if your intention was to start selling covered calls,\n  notice that [they are effectively the same as selling naked puts](https://www.forbes.com/sites/baldwin/2012/07/18/options-explained-why-is-a-covered-call-equivalent-to-a-short-put/).\n\n## Usage\nTo use BYE, you will need to first initialize a virtual\nenvironment using the `requirements.txt` file provided. Like this:\n\n    python3 -m venv venv\n    source venv/bin/activate\n    pip install -r requirements.txt\n\nYou also need end-of-day data for the SPY ETF from\n[OptionsDX](https://www.optionsdx.com/).\nSave it in the `data/raw/spy_eod_raw` directory.\nEach year should be represented by a separate subdirectory,\nand each month should be saved as a separate text file.\n\nOnce you have downloaded and saved the data, run the `1_load.py` script in order to\nload and join the data. The joined data is saved as a single parquet file,\n`data/interim/spy_eod.parquet`.\n\nThen, run the `2_select.py` script to drop unnecessary columns\nand save the processed data at `data/processed/spy_eod.parquet`.\n\nFinally, run the `3_main.py` script to backtest the defined options trading strategies.\nThe script will print the progress of the backtesting process in the terminal.\nIn the future, it should generate a summary of the results for each strategy tested.\n\n## How do I define my own strategy?\nTo define your own strategy, you need to get you hands dirty with code.\nCreate a new class that inherits from any other strategy defined in `src/strategies.py`.\nNote that the crucial part is the `handle_no_open_positions` method, which defines\nthe logic for opening a new position when there are no open positions.\nEverything else is optional, because whatever position you open,\nit will eventually expire, and the basic logic for handling expiration\nis already defined in the base class.\nThen, make sure to add it to the `strategies` list in `3_main.py`.\n\n## Disclaimer\n🚨 Use at your own risk 🚨\n\nYou are responsible for any losses incurred as a result of using this tool.\nSee also the [LICENSE](LICENSE).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnix1%2Fbye","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnix1%2Fbye","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnix1%2Fbye/lists"}