auto-rsa
auto-rsa copied to clipboard
A Discord bot and CLI for automating Reverse Split Arbitrage stock trading!
✨ AutoRSA ✨
Discord Bot and CLI Tool
A CLI tool and Discord bot to buy, sell, and monitor holdings across multiple accounts!
❓ What is RSA? ❓
You already know what Reverse Split Arbitrage is, that's not why you're here. If you do know what it is, then you know why a tool like this would be valuable. If you're a big player, even more so...
🤔 How Does It Work? 🤔
This program uses APIs to interface with your brokerages. When available, official APIs are always used. If an official API is not available, then a third-party API is used. As a last resort, Selenium or Playwright Stealth are used to automate the browser.
🤖 Discord Bot Installation 🤖
To create your Discord bot and get your DISCORD_TOKEN, follow this guide.
🐳 Docker 🐳
- Create a
.envfile for your brokerage variables using .env.example as a template, and add your bot usingDISCORD_TOKENandDISCORD_CHANNEL - Using the provided docker-compose.yml file, run the command
docker compose up -dinside the project directory. - The bot should appear online (You can also do
!pingto check).
🏃♂️ Always Running Python Script 🏃♀️
Make sure python3-pip is installed
- Clone this repository and cd into it
- Run
pip install -r requirements.txt - Create a
.envfile for your brokerage variables using .env.example as a template, and add your bot usingDISCORD_TOKENandDISCORD_CHANNEL - Run
python autoRSA.py(See below for more command explanations)
Note: If you are using Windows, you will need to install playwright manually. See this guide for more information.
💻 CLI Tool Installation 💻
- Clone this repository and cd into it
- Run
pip install -r requirements.txt - Create a
.envfile for your brokerage variables using .env.example as a template. - Run the script using
python autoRSA.pyplus the command you want to run (See below for more command explanations)
Note: If you are using Windows, you will need to install playwright manually. See this guide for more information.
👀 Usage 👀
If running as a Discord bot, append !rsa to the beginning of each command.
If running from the CLI Tool, append python autoRSA.py to the beginning of each command.
To buy and sell stocks, use this command:
<action> <amount> <ticker> <accounts> <dry>
For example, to buy 1 AAPL in all accounts:
buy 1 AAPL all false
For a dry run of the above command in Robinhood only:
buy 1 AAPL robinhood true
For a real run on Fidelity and Robinhood, but not Schwab:
buy 1 AAPL fidelity,robinhood not schwab false
For a real run on Fidelity and Robinhood but not Schwab buying both AAPL and GOOG:
buy 1 AAPL,GOOG fidelity,robinhood not schwab false
To check your account holdings:
holdings <accounts>
To restart the Discord bot:
!restart (without appending !rsa)
For help:
!help (without appending !rsa)
Note: There are two special keywords you can use when specifying accounts: all and day1. all will use every account that you have set up. day1 will use "day 1" brokers, which are Robinhood, Schwab, Tastytrade, and Tradier. This is useful for brokers that provide quick turnaround times, hence the nickname "day 1".
⚙️ Parameters ⚙️
<action>: string, "buy" or "sell"<amount>: integer, Amount to buy or sell.<ticker>: string, The stock ticker to buy or sell. Separate multiple tickers with commas and no spaces.<accounts>: string, What brokerage to run command in (robinhood, schwab, etc, or all). Separate multiple brokerages with commas and no spaces.<not accounts>: string proceedingnot, What brokerages to exclude from command. Separate multiple brokerages with commas and no spaces.<dry>: boolean, Whether to run indrymode (in which no transactions are made. Useful for testing). Set toTrue,False, or just writedryforTrue. Defaults toTrue, so if you want to run a real transaction, you must set this explicitly.
🗺️ Guides 🗺️
More detailed guides for some of the difficult setups:
- Discord Bot Setup
- Schwab 2FA Setup
🤝 Contributing 🤝
Found or fixed a bug? Have a feature request? Want to add support for a new brokerage? Feel free to open an issue or pull request!
Enjoying the project? Feel free to Sponsor me on GitHub or Ko-fi!
😳 DISCLAIMER 😳
DISCLAIMER: I am not a financial advisor and not affiliated with any of the brokerages listed below. Use this tool at your own risk. I am not responsible for any losses or damages you may incur by using this project. This tool is provided as-is with no warranty.
👍 Supported brokerages 👍
All brokers: separate account credentials with a colon (":"). For example, SCHWAB_USERNAME:SCHWAB_PASSWORD. Separate multiple logins with the same broker with a comma (","). For example, SCHWAB_USERNAME:SCHWAB_PASSWORD,SCHWAB_USERNAME2:SCHWAB_PASSWORD2.
Fidelity
Made by yours truly using Selenium (and many hours of web scraping).
Required .env variables:
FIDELITY_USERNAMEFIDELITY_PASSWORD
.env file format:
FIDELITY=FIDELITY_USERNAME:FIDELITY_PASSWORD
Firstrade
Made by MaxxRK using the firstrade-api. Go give them a ⭐
Required .env variables:
FIRSTRADE_USERNAMEFIRSTRADE_PASSWORDFIRSTRADE_PIN
.env file format:
FIRSTRADE=FIRSTRADE_USERNAME:FIRSTRADE_PASSWORD:FIRSTRADE_PIN
Public
Made by yours truly using using public-invest-api. Consider giving me a ⭐
Required .env variables:
PUBLIC_USERNAMEPUBLIC_PASSWORD
.env file format:
PUBLIC_BROKER=PUBLIC_USERNAME:PUBLIC_PASSWORD
Note: Because Windows already has a PUBLIC environment variable, you will need to use PUBLIC_BROKER instead.
Robinhood
Made using robin_stocks. Go give them a ⭐
Required .env variables:
ROBINHOOD_USERNAMEROBINHOOD_PASSWORDROBINHOOD_TOTP(If 2fa enabled, else NA)
.env file format:
- With 2fa:
ROBINHOOD=ROBINHOOD_USERNAME:ROBINHOOD_PASSWORD:ROBINHOOD_TOTP - Without 2fa:
ROBINHOOD=ROBINHOOD_USERNAME:ROBINHOOD_PASSWORD:NA
If you don't have an IRA account or only have one, then you can omit the last field or set it to NA.
Configuring 2fa can be tricky, read the TOTP section here.
Schwab
Made using the schwab-api. Go give them a ⭐
Required .env variables:
SCHWAB_USERNAMESCHWAB_PASSWORDSCHWAB_TOTP_SECRET(If 2fa is enabled, else NA)
.env file format:
- With 2fa:
SCHWAB=SCHWAB_USERNAME:SCHWAB_PASSWORD:SCHWAB_TOTP_SECRET - Without 2fa:
SCHWAB=SCHWAB_USERNAME:SCHWAB_PASSWORD:NA
To get your TOTP secret, follow this guide.
Note 1: Think or Swim must be enabled on all accounts. To enable, go to Trade > Trading Platforms > Learn how to enable thinkorswim. Then press Continue and expand the thinkorswim Access Agreement and accept it. Then press Continue again. Then select the checkbox for all available accounts and press Submit. It may take a day or two for the accounts to be enabled.
Note 2: If you are using Windows, you may need to install playwright manually. See this guide for more information.
Tradier
Made by yours truly using the official Tradier API. Consider giving me a ⭐
Required .env variables:
TRADIER_ACCESS_TOKEN
.env file format:
TRADIER=TRADIER_ACCESS_TOKEN
To get your access token, go to your Tradier API settings.
Tastytrade
Made by MaxxRK using the tastytrade-api. Go give them a ⭐
Required .env variables:
TASTYTRADE_USERNAMETASTYTRADE_PASSWORD
.env file format:
TASTYTRADE=TASTYTRADE_USERNAME:TASTYTRADE_PASSWORD
Webull
Made using the webull library. Go give them a ⭐
Required .env variables:
WEBULL_USERNAMEWEBULL_PASSWORDWEBULL_DIDWEBULL_TRADING_PIN
.env file format:
WEBULL=WEBULL_USERNAME:WEBULL_PASSWORD:WEBULL_DID:WEBULL_TRADING_PIN
Your WEBULL_USERNAME can be your email or phone number. If using a phone number, it must be formatted as: +1-XXXXXXXXXX or +86-XXXXXXXXXXX.
To get your Webull DID, follow this guide.
🤷♂️ Maybe future brokerages 🤷♀️
Ally
Ally disabled their official API, so all Ally packages don't work. I am attempting to reverse engineer their API, and will add it if I get it working. Otherwise, I will use Selenium or Playwright.
Chase
In progress on develop-chase. Stay tuned.
Vanguard
Will be added using Selenium or Playwright.
SoFi
Will be added using Selenium or Playwright.
👎 Never working brokerages 👎
Stash
Why.