Skip to content

Commit

Permalink
Merge pull request #93 from NelsonDane/develop
Browse files Browse the repository at this point in the history
Merge Develop into Main
  • Loading branch information
NelsonDane authored Oct 23, 2023
2 parents 98391d2 + 28bfd52 commit a19411f
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 596 deletions.
6 changes: 0 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ DANGER_MODE="false"
# at the same brokerage with a comma, then separate account credentials with a colon
# BROKER=BROKER_USERNAME:BROKER_PASSWORD,OTHER_BROKER_USERNAME:OTHER_BROKER_PASSWORD

# Ally (CURRENTLY DISABLED)
# ALLY=ALLY_CONSUMER_KEY:ALLY_CONSUMER_SECRET:ALLY_OAUTH_TOKEN:ALLY_OAUTH_SECRET
# ALLY_ACCOUNT_NUMBERS=ALLY_ACCOUNT_NUMBER_1:ALLY_ACCOUNT_NUMBER_2
ALLY=
ALLY_ACCOUNT_NUMBERS=

# Fidelity
# FIDELITY=FIDELITY_USERNAME:FIDELITY_PASSWORD
FIDELITY=
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ RUN playwright install && \

# Grab needed files
COPY ./autoRSA.py .
COPY ./allyAPI.py .
COPY ./fidelityAPI.py .
COPY ./robinhoodAPI.py .
COPY ./schwabAPI.py .
Expand Down
86 changes: 39 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,61 @@
# AutoRSA Discord Bot and CLI Tool
A CLI tool and Discord bot to buy and sell the same amount of stocks across multiple accounts!
# ✨ AutoRSA ✨
## Discord Bot and CLI Tool
A CLI tool and Discord bot to buy, sell, and monitor holdings across multiple accounts!

## What is RSA?
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!
<img src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54"/>
<img src="https://img.shields.io/badge/-selenium-%43B02A?style=for-the-badge&logo=selenium&logoColor=white"/>
<img src="https://img.shields.io/badge/-discord.py-%232c2f33?style=for-the-badge&logo=discord&logoColor=white"/>
<img src="https://img.shields.io/badge/-docker-%232c2f33?style=for-the-badge&logo=docker&logoColor=white"/>

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.
## ❓ 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...

## Discord Bot Installation
## 🤔 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](guides/discordBot.md).
### Docker
### 🐳 Docker 🐳
1. Create a `.env` file for your brokerage variables using [.env.example](.env.example) as a template, and add your bot using `DISCORD_TOKEN` and `DISCORD_CHANNEL`
2. Using the provided [docker-compose.yml](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
### 🏃‍♂️ 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](.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)

## CLI Tool Installation
## 💻 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](.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)

## Usage
## 👀 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 STAF in all accounts:
For example, to buy 1 AAPL in all accounts:

`buy 1 STAF all false`
`buy 1 AAPL all false`

For a dry run of the above command in Robinhood only:

`buy 1 STAF robinhood true`
`buy 1 AAPL robinhood true`

For a real run on Ally and Robinhood, but not Schwab:
For a real run on Fidelity and Robinhood, but not Schwab:

`buy 1 STAF ally,robinhood not schwab false`
`buy 1 AAPL fidelity,robinhood not schwab false`

For a real run on Ally and Robinhood but not Schwab buying both STAF and AREB:
For a real run on Fidelity and Robinhood but not Schwab buying both AAPL and GOOG:

`buy 1 STAF,AREB ally,robinhood not schwab false`
`buy 1 AAPL,GOOG fidelity,robinhood not schwab false`

To check your account holdings:

Expand All @@ -62,23 +69,22 @@ For help:

`!help` (without appending `!rsa`)

### Parameters
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` for`True`. Defaults to `True`, so if you want to run a real transaction, you must set this explicitly.

### Testing your Login Credentials
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!

### Guides
### 🗺️ Guides 🗺️
More detailed guides for some of the difficult setups:
- [Discord Bot Setup](guides/discordBot.md)
- [Schwab 2FA Setup](guides/schwabSetup.md)

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

Is someone selling a ripoff of this bot? (Looking at you OSU freshmen). Get it from here and contribute to open source!
Expand All @@ -87,30 +93,12 @@ Like what you see? Feel free to support me on Ko-Fi!

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/X8X6LFCI0)

## DISCLAIMER
## 😳 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, `ALLY_USERNAME:ALLY_PASSWORD`. Separate multiple logins with the same broker with a comma (","). For example, `ALLY_USERNAME:ALLY_PASSWORD,ALLY_USERNAME2:ALLY_PASSWORD2`.

### Ally
**Ally has disabled their API, so Ally is currently unsupported.**

Made using [PyAlly](https://github.com/alienbrett/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`
## 👍 Supported brokerages 👍

To get these, follow [these instructions](https://alienbrett.github.io/PyAlly/installing.html#get-the-library).
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).
Expand Down Expand Up @@ -176,9 +164,13 @@ Required `.env` variables:
`.env` file format:
- `TASTYTRADE=TASTYTRADE_USERNAME:TASTYTRADE_PASSWORD`

### Maybe future brokerages
### 🤷‍♂️ Maybe future brokerages 🤷‍♀️
#### Ally
Ally disabled their official API, so all Ally packages don't work. I am attempting to reverse engineer their API, which you can track [here](https://github.com/NelsonDane/ally-api). Once I get it working, I will add it to this project.
#### Chase
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.
Chase doesn't have an official API, so it would have to be added using Selenium.
#### Firstrade
In progress on the `develop-firstrade` branch. Stay tuned.
#### Vanguard
Will be added using Selenium just like Fidelity. I found this [vanguard-api](https://github.com/rikonor/vanguard-api), but it failed when I ran it.
#### SoFi
Expand All @@ -187,6 +179,6 @@ Login requires SMS 2fa, and I'm not sure how to do that automatically.
In progress on [develop-webull](https://github.com/NelsonDane/auto-rsa/pull/61). Stay tuned.
#### Public
Same as Webull and SoFi.
### Never working brokerages
### 👎 Never working brokerages 👎
#### Stash
Why.
Loading

0 comments on commit a19411f

Please sign in to comment.