d-lopes / options-advisor

Lightweight Robo-Advisor for Stock Options
Mozilla Public License 2.0
2 stars 0 forks source link

Options Advisor

Quality Gate Status Coverage Known Vulnerabilities License

Lightweight Robo-Advisor for Stock Options

The following use case is currently supported: scan all available options for one or more stocks in a time frame

Information about stock options for the underlyings are loaded in bulk based on your watchlist (example), filtered based on the given criteria and either printed on screen or stored on your file system.

Highlighted criteria which you can filter on:

As result, you can generate a CSV or XLSX file with similar content to this:

example result

The raw information about stock options and market prices is loaded from Yahoo Finance and extended with additional calculations or hints.

Getting Started

prerequisites

Usage

Command line

To run this command from command line, you have the following options:

usage: run.py [-h] -i INPUT_FILE [-mode MODE] [-ms MAX_STRIKE] [-mp MIN_PUTS] [-mc MIN_CALLS]
              [-mv MIN_VOLUME] [-my MIN_YIELD] [-mn MONEYNESS] [-swo START_WEEK_OFFSET]
              [-ewo END_WEEK_OFFSET] [-o OUTPUT_PATH] [-f OUTPUT_FORMAT]

gathers data about stock options

options:
  -h, --help            show this help message and exit
  -i INPUT_FILE         an input file defining the settings to scan for options
  -ds DATASOURCE        yahoofin (default) or yoptions
  -mode MODE            PUT (default) or CALL
  -ms MAX_STRIKE        filter for maximum acceptable strike (Default = 60)
  -mp MIN_PUTS          filter for minium available interest in PUTs (Default = 1000)
  -mc MIN_CALLS         filter for minium available interest in CALLs (Default = 1000)
  -mv MIN_VOLUME        filter for minium available volume (Default = 100)
  -my MIN_YIELD         filter for minimum acceptable yield (Default = 10)
  -mn MONEYNESS         filter for the moneyness: OTM (default), ITM or ATM
  -swo START_WEEK_OFFSET
                        offset from current week to start searching for expiry dates (Default = 3)
  -ewo END_WEEK_OFFSET  offset from current week to end searching for expiry dates (Default = 7)
  -o OUTPUT_PATH        destination to write the result to. If empty, then no data is written to disk. Instead it is printed on screen (Default = None)
  -f OUTPUT_FORMAT      CSV (default) or XLSX (requires python module openpyxl)

For example, you can execute the program in your console as follows:

python3 -m src.run -i ./resources/samples/settings.example.json -ms 35 -o ./out/results.csv

After execution, the program will end with a summary similar to this:

searching for PUT options between calendar weeks 52/2023 - 4/2024
|████████████████████████████████████████| 8/8 [100%] in 9.8s (0.77/s)

-------- SUMMARY ---------
finished run on: 04/12/2023, 19:45:41
started scan at: 9 seconds ago (took 9.80 seconds overall)
scanned 2 underlyings: ['AMZN', 'BAC']
applied filter: Filter(min_puts=1000, min_calls=1000, min_volume=100, min_yield=10, max_strike=35.0, moneyness=OTM)
found options: 4
results written to disk: ./out/results.csv

Web interface

will be provided in the future

Docker

will be provided in the future

How to test?

simply run coverage run -m pytest from the root directory to see an overview of successful and failing tests.

If you want to run a specific test, just invoke pytest -k "DataSourceAggregatorTest" whereas "DataSourceAggregatorTest" is the name of your test class and/or method.

see answer to following stack overflow article for further info: https://stackoverflow.com/questions/1896918/running-unittest-with-typical-test-directory-structure