NelsonDane / auto-rsa

A Discord bot and CLI for automating Reverse Split Arbitrage stock trading!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

✨ 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 🐳

  1. Create a .env file for your brokerage variables using .env.example as a template, and add your bot using DISCORD_TOKEN and DISCORD_CHANNEL
  2. Using the provided docker-compose.yml file, run the command docker compose up -d inside the project directory.
  3. The bot should appear online (You can also do !ping to check).

🏃‍♂️ Always Running Python Script 🏃‍♀️

Make sure python3-pip is installed

  1. Clone this repository and cd into it
  2. Run pip install -r requirements.txt
  3. Create a .env file for your brokerage variables using .env.example as a template, and add your bot using DISCORD_TOKEN and DISCORD_CHANNEL
  4. 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 💻

  1. Clone this repository and cd into it
  2. Run pip install -r requirements.txt
  3. Create a .env file for your brokerage variables using .env.example as a template.
  4. Run the script using python autoRSA.py plus 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 proceeding not, What brokerages to exclude from command. Separate multiple brokerages with commas and no spaces.
  • <dry>: boolean, Whether to run in dry mode (in which no transactions are made. Useful for testing). Set to True, False, or just write dry forTrue. Defaults to True, so if you want to run a real transaction, you must set this explicitly.

🗺️ Guides 🗺️

More detailed guides for some of the difficult setups:

🤝 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!

Sponsor 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.

Some brokerages require Playwright to run. On Windows, the playwright install command might not be recognized. If this is the case, run python -m playwright install instead.

Chase

Made by MaxxRK using the chaseinvest-api. Go give them a ⭐

  • CHASE_USERNAME
  • CHASE_PASSWORD
  • CELL_PHONE_LAST_FOUR

.env file format:

  • CHASE=CHASE_USERNAME:CHASE_PASSWORD:CELL_PHONE_LAST_FOUR

Fidelity

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

Firstrade

Made by MaxxRK using the firstrade-api. Go give them a ⭐

Required .env variables:

  • FIRSTRADE_USERNAME
  • FIRSTRADE_PASSWORD
  • FIRSTRADE_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_USERNAME
  • PUBLIC_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_USERNAME
  • ROBINHOOD_PASSWORD
  • ROBINHOOD_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

Configuring 2fa can be tricky, so follow this guide.

Schwab

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.

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.

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_USERNAME
  • TASTYTRADE_PASSWORD

.env file format:

  • TASTYTRADE=TASTYTRADE_USERNAME:TASTYTRADE_PASSWORD

Webull

Made using the webull library. Go give them a ⭐

Required .env variables:

  • WEBULL_USERNAME
  • WEBULL_PASSWORD
  • WEBULL_DID
  • WEBULL_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.

Vanguard

Will be added using Selenium or Playwright.

SoFi

Will be added using Selenium or Playwright.

👎 Never working brokerages 👎

Stash

Why.

About

A Discord bot and CLI for automating Reverse Split Arbitrage stock trading!

License:GNU General Public License v3.0


Languages

Language:Python 99.2%Language:Dockerfile 0.6%Language:Shell 0.2%