A CLI tool and Discord bot to buy and sell the same amount of stocks across multiple accounts!
RSA stands for "Reverse Split Arbitrage." This is a strategy where you buy the same amount of stocks in multiple accounts across multiple brokers right before a stock performs a reverse split. Once the stock splits and your fractional share is rounded up to a full share, you profit!
This project will allow you to maximize your profits by being able to easily manage multiple accounts across different brokerages, buying and selling as needed.
To create your Discord bot and get your DISCORD_TOKEN
, follow this guide.
- Create a
.env
file for your brokerage variables using .env.example as a template, and add your bot usingDISCORD_TOKEN
andDISCORD_CHANNEL
- Using the provided docker-compose.yml file, run
docker compose up -d
- The bot should appear online (You can also do
!ping
to check).
Make sure python3-pip is installed
- Clone this repository and cd into it
- Run
pip install -r requirements.txt
- Create a
.env
file for your brokerage variables using .env.example as a template, and add your bot usingDISCORD_TOKEN
andDISCORD_CHANNEL
- Run
python autoRSA.py
(See below for more command explanations)
- Clone this repository and cd into it
- Run
pip install -r requirements.txt
- Create a
.env
file for your brokerage variables using .env.example as a template. - Run the script using
python pythonRSA.py
plus the command you want to run (See below for more command explanations)
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 STAF in all accounts:
buy 1 STAF all false
For a dry run of the above command in Robinhood only:
buy 1 STAF robinhood true
For a real run on Ally and Robinhood, but not Schwab:
buy 1 STAF ally,robinhood not schwab false
For a real run on Ally and Robinhood but not Schwab buying both STAF and AREB:
buy 1 STAF,AREB ally,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
)
<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 indry
mode (in which no transactions are made. Useful for testing). Set toTrue
,False
, or just writedry
forTrue
. Defaults toTrue
, so if you want to run a real transaction, you must set this explicitly.
To test your login credentials, run python testLogin.py
. This will print all your .env
variables and attempt to log in to each brokerage. If you get an error, check your .env
variables and try again. This prints everything in plain text, so don't share the output with anyone!
More detailed guides for some of the difficult setups:
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!
Is someone selling a ripoff of this bot? (Looking at you OSU freshmen). Get it from here and contribute to open source!
Like what you see? Feel free to support me on Ko-Fi!
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.
All brokers: separate account credentials with a colon (":"). For example, ALLY_USERNAME:ALLY_PASSWORD
. Separate multiple logins with the same broker with a comma (","). For example, ALLY_USERNAME:ALLY_PASSWORD,ALLY_USERNAME2:ALLY_PASSWORD2
.
For Selenium-based brokers, you can optionally set the webdriver version by setting WEBDRIVER_VERSION
in your .env
file. For example, WEBDRIVER_VERSION=114.0.5735.90
. This only applies to the CLI tool, not the Discord bot.
Made using PyAlly. Go give them a ⭐
Required .env
variables:
ALLY_CONSUMER_KEY
ALLY_CONSUMER_SECRET
ALLY_OAUTH_TOKEN
ALLY_OAUTH_SECRET
ALLY_ACCOUNT_NUMBERS
.env
file format:
ALLY=ALLY_CONSUMER_KEY:ALLY_CONSUMER_SECRET:ALLY_OAUTH_TOKEN:ALLY_OAUTH_SECRET
ALLY_ACCOUNT_NUMBERS=ALLY_ACCOUNT_NUMBER1:ALLY_ACCOUNT_NUMBER2
To get these, follow these instructions.
Made by yours truly using Selenium (and many hours of web scraping).
Required .env
variables:
FIDELITY_USERNAME
FIDELITY_PASSWORD
.env
file format:
FIDELITY=FIDELITY_USERNAME:FIDELITY_PASSWORD
Made using robin_stocks. Go give them a ⭐
Required .env
variables:
ROBINHOOD_USERNAME
ROBINHOOD_PASSWORD
ROBINHOOD_TOTP
(If 2fa enabled, else NA)ROBINHOOD_IRA_NUMBERS
(If you want to use your IRA account, else NA. Separate multiple IRA numbers with colons.)
.env
file format:
- With 2fa:
ROBINHOOD=ROBINHOOD_USERNAME:ROBINHOOD_PASSWORD:ROBINHOOD_TOTP:ROBINHOOD_IRA_1:ROBINHOOD_IRA_2
- Without 2fa:
ROBINHOOD=ROBINHOOD_USERNAME:ROBINHOOD_PASSWORD:NA:ROBINHOOD_IRA_1:ROBINHOOD_IRA_2
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.
To get your IRA numbers, check your monthly statement, or tap the menu button in the Robinhood app and go to Investing
. Or click the Retirement
tab on the desktop website, then the settings
button on the top right of the graph. Then click Account numbers
.
Made using the schwab-api. Go give them a ⭐
Required .env
variables:
SCHWAB_USERNAME
SCHWAB_PASSWORD
SCHWAB_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.
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.
Made by MaxxRK using the tastytrade-api. Go give them a ⭐
Required .env
variables:
TASTYTRADE_USERNAME
TASTYTRADE_PASSWORD
.env
file format:
TASTYTRADE=TASTYTRADE_USERNAME:TASTYTRADE_PASSWORD
I will be signing up for a Chase account soon, and I have heard that it is possible, so I will be looking into it soon.
Will be added using Selenium just like Fidelity. I found this vanguard-api, but it failed when I ran it.
Login requires SMS 2fa, and I'm not sure how to do that automatically.
In progress on develop-webull. Stay tuned.
Same as Webull and SoFi.
Why.