GithubHelp home page GithubHelp logo

s2j1968 / opi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukasno1/opi

0.0 0.0 1.0 113 KB

OPI - Option passive income bot - Automated selling of covered calls

License: MIT License

Python 100.00%

opi's Introduction

OPI - Option passive income bot

The DIY alternative to covered call ETF's

This bot is meant for my own personal use, the strategy behind it is subject to change.

That said, you are free to use this bot in any way you see fit, as long as you understand what's written here and what the code of this bot does.

If you don't understand everything 100%, then don't use it!

Requirements

  • A TD Ameritrade account with options privileges
  • All python packages from requirements.txt installed
  • General understanding of the stock market and options

Setup instructions

  1. Register and create an app on developer.tdameritrade.com to get an api key
  2. copy configuration.example.py to configuration.py and adjust it to your needs
  3. Run setupApi.py to get an api token
  4. Run main.py

Factsheet

This bot seeks to generate passive income from option premiums through writing covered calls on stocks and ETF's

The bot will sell a covered call each month on the assets you select

The covered call will be the first OTM call per default (current asset price + 1$, adjustable in the configuration for more growth)

The bot buys back (rolls) the option contract each month, one day before expiration

The bot will try to roll contracts for credit first, but can fall back to pay for rollups if the last sold option ended up deep ITM

(Paying for rollups can be prevented in the config settings)


You need to own at least 100 of the underlying asset you want the bot to sell the covered calls on

Alternatively you can also hold an ITM call option (preferably deep ITM LEAP) representing said asset

The bot will check if you actually have enough shares or options in the account to cover the cc's


Configuration

# how many cc's to write
'amountOfHundreds': 1,

# write cc's at or over current asset price + this value
'minGapToATM': 1,

# If our strike is below current asset price - this value, we consider it deep ITM and want to rollup for debit
'deepITMLimit': 10,

# How much do we want to rollup the strike from last month if we are Deep ITM?
# (If this is set to 0 the bot will roll to the highest contract with credit, ignoring deepITMLimit)
'maxRollupGap': 0,

# How much are we allowed to reduce the strike from last month? (flash crash protection)
# If the underlying f.ex. drops by 30 in value, this is the max we are gonna drop our cc strike
'maxDrawdownGap': 10,

# don't write cc's with strikes below this value (set this f.ex. to breakeven)
'minStrike': 0

The bot will inform you about important events either directly in the console or over email.

(For emails you need to add credentials for a smtp server in configuration.py and set the 'botAlert' setting to "email")

CC expiration date

The bot will try to write a cc which expires on the third friday of next month. If that date is not available because it falls on a holiday f.ex., it will write a cc with expiration on the thursday preceding said friday

If you are running the bot the first time on an asset and there is enough time left, it will write the cc's on the third friday of the current month

Rollups: Further explanation

A 'rollup' is the process of rolling to a higher strike price than the current one.

If you set maxRollupGap, you should have some spare cash in the account to pay for rollup costs, because the new contract can have less premium than the current one, if the asset price went up.

Risks

Volatility risk - Less volatility, more spread, less option premium

Do not use this bot with assets that have low volatility or too few options

Options - Covered calls are the least risky options, nonetheless, if you don't know what you're doing or fuck up the configuration above, you can lose a lot or even all of your money

Early assignment - If your cc's end up being significantly ITM before expiration, there is a low chance that you get assigned and your brokerage automatically closes the cc's and sells the according amount of shares.

If this happens, the bot will fail and notify you, but you will need to manually buy everything back, before restarting the bot.

opi's People

Contributors

lukasno1 avatar

Forkers

aubds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.