Created by: Camilo Rojas - @camilo_rojas
Python based robot trader on naked put strategy for selected accounts.
The strategy selected for this bot is to sell puts for a selected number of stocks. The selection of the stock list is currently manual.
The robot searches for opportunities in selling naked puts (sell to open), looking for days with a -4.5% daily price change, which normally increases volatility in the options for the stock. With the increase in vega we will evaluate the option chain for opportunities that offer a yield of 1% monthly or more. If we find an opportunity we will generate a prospect that will be managed. The amount of contracts and the R are all defined in a config file.
RobotRay will manage the trade and monitor the following conditions: 1) Risk Loss management will close (BTC) if losses are 2x the amount of premium collected, 2) we are at 21 days to expiration, 3) we reach 50% target of total premium.
The idea is to sell between 3 and 8 month Put options, and close (buy to close) to gain advantage of vega crush and short term volatility. Worst case scenario of being assigned the contract, bot will confirm buying power.
This is a high risk bot. For academic purposes only, not for real world implementation.
It connects info from Interactive Brokers for real market data and trading. Also leverages information from other public data sources to build an analytics model to select trades.
All package requirements are included in the requirements.txt file in the project
- Interactive Brokers automated trading
- Report / Statistics of operation with full P&L reporting
- Backtrading to review strategy for selected stocks
- Automated stock selection and rejection based on portfolio and risk
- Auto evaluate between open positions and new prospects to maximize % of success
The project architecture is the following:
- rrServer - scheduling, threading
- rrTelegram - communications through Telegram
- rrController
- rrDataFetcher - invoked by rrDB controls data fetching mechanism routing to public or IB
- rrDB - Handles DB manager for Stocks, Option Data and Intraday data
- rrThinker - Handles DB manager for Prospects and its lifecycle
- rrDFIB - Interactive Brokers data fetching
- rrDFPublic - Finviz and Yahoo data fetching
- rrOptions - Support lib for Option formating and management
- rrLogger - Logging
- robotRay.ini - File with operational parameters and general configuration
In a Python shell invoke the python3 rrlib/rrServer.py command to start the bot trading program. Currently no command line parameters are supported, but operation can be configured from the ini file in the rrlib directory.
- Generate your userid for robotRay, need sudo (wheel) group for TA-lib and sqlite3 if it needs to be installed, useradd, passwd, usermod -aG wheel
- Yum update python (3.8+), sqlite, ta-lib (https://mrjbq7.github.io/ta-lib/install.html), [tar, xz-devel, gcc, make for ta-lib install]. Or compile/install if not already
- Create your robotRay directory and git fetch https://github.com/camilo-rojas/robotRay
- Create your venv for python if required. python3 -m venv venv. Activate the environment source venv/bin/activate
- Pip upgrade environment and install all requirements.txt
- Adjust robotRay.ini based from robotRay.sample.ini with your parameters and stock
- If you have problems installing pip install pysqlite3 with errors or problems be sure to install sudo yum install sqlite-devel