Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Nohealz committed Jul 25, 2024
2 parents b39084d + dcf81cc commit ba2f4c1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:

jobs:
call-workflow-dockerhub-build-push:
uses: NelsonDane/Custom-GitHub-Actions/.github/workflows/dockerhub-build-push.yml@e3876788a573bfb35bac32593c4075b87c37e774
uses: NelsonDane/Custom-GitHub-Actions/.github/workflows/docker-registry-build-push.yml@6729a5a9fba311fabe014c6b75ab58717efdbb17
with:
image_name: auto-rsa
image_tag: ${{ github.ref_name == 'main' && 'latest' || startsWith(github.ref_name, 'develop') && github.ref_name }}
should_push: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'develop') }}
platforms: linux/amd64,linux/arm64
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ A CLI tool and Discord bot to buy, sell, and monitor holdings across multiple br
<img src="https://img.shields.io/badge/-docker-%232c2f33?style=for-the-badge&logo=docker&logoColor=white"/>
</p>

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

## 📝 Installation 📝
## 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.

## Having an Issue? 🤔
I am not responding to issues on this repository. If you have an issue, please Sponsor me below and I will help you directly on Discord (for Sponsors and Contributors only).

[![Sponsor](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#white)](https://github.com/sponsors/NelsonDane)
[![ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white
)](https://ko-fi.com/X8X6LFCI0)

However, if you fix the issue yourself, please submit a pull request and I will review it.

## Installation 📝
There are two ways to use this program: as a Discord bot or as a CLI tool. The setup instructions will be a little different depending on which method you choose. However, both methods require the same pre-setup steps, and the same `.env` file format.

### 🛠️ Pre-Setup 🛠️
### Pre-Setup 🛠️
1. Install `git` for your operating system.
2. Clone this repository and cd into it:
```bash
Expand All @@ -30,12 +41,12 @@ cp .env.example .env

Now follow the instructions for either the Discord Bot or CLI Tool. Once setup is complete, see the [Usage](#-usage-) section for how to use the program.

### 🤖 Discord Bot Installation 🤖
### Discord Bot Installation 🤖
To create your Discord bot and get your `DISCORD_TOKEN` for your `.env`, follow this [guide](guides/discordBot.md).

There are two ways to run the Discord bot: using Docker or running the Python script. When running the bot using the Python script, the bot will only be online when the script is running. With Docker, the bot will run in the background, restarting and updating automatically.

### 🐳 Discord Bot: Docker 🐳
### Discord Bot: Docker 🐳
1. Add `DISCORD_TOKEN` and `DISCORD_CHANNEL` to your `.env` file.
2. Create the container using the provided [docker-compose.yml](docker-compose.yml) file:
```bash
Expand All @@ -45,7 +56,7 @@ docker compose up -d

Docker Note: If you make any changes to your `.env` file, you will need to restart the container by running `docker-compose up -d` again. The bot will also automatically stay up to date thanks to the included [Watchtower](https://containrrr.dev/watchtower/).

### 🏃‍♂️ Discord Bot: Python Script 🏃‍♀️
### Discord Bot: Python Script 🏃‍♀️
1. Install Python 3.10 or higher
2. Install the required packages:
```bash
Expand All @@ -58,7 +69,7 @@ python autoRSA.py discord
```
5. The bot should appear online in Discord (You can also do `!ping` to check).

### 💻 CLI Tool Installation 💻
### CLI Tool Installation 💻
To run the CLI tool, follow these steps:
1. Install Python 3.10 or higher
2. Install the required packages:
Expand All @@ -67,7 +78,7 @@ pip install -r requirements.txt
```
4. Run the script using `python autoRSA.py`. It should say that no arguments were given, then exit. This is expected, and means everything was installed and set up correctly.

## 👀 Usage 👀
## Usage 👀

To buy and sell stocks, use this command:

Expand Down Expand Up @@ -95,6 +106,10 @@ To check your account holdings:

`<prefix> holdings <accounts>`

For example, to check your account holdings on Chase and Vanguard, but not Robinhood:

`<prefix> holdings chase,vanguard not robinhood`

To restart the Discord bot (only for the Docker Discord bot):

`!restart` (without appending `!rsa` or prefix)
Expand All @@ -103,7 +118,7 @@ For help:

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

### ⚙️ Parameters Explanation ⚙️
### Parameters Explanation ⚙️
- `<prefix>`: string, The prefix for the command. For the Discord bot, this is `!rsa`. For the CLI tool, this is `python autoRSA.py`.
- `<action>`: string, "buy" or "sell"
- `<amount>`: integer, Amount to buy or sell.
Expand Down Expand Up @@ -133,19 +148,7 @@ More detailed guides for some of the difficult setups:
- [Robinhood 2FA Setup](guides/robinhoodSetup.md)
- [Schwab 2FA Setup](guides/schwabSetup.md)

## 🤝 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](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#white)](https://github.com/sponsors/NelsonDane)
[![ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white
)](https://ko-fi.com/X8X6LFCI0)

## 😳 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 👍
## 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`.

Expand Down Expand Up @@ -288,9 +291,9 @@ Optional `.env` variables:
- `VANGUARD=VANGUARD_USERNAME:VANGUARD_PASSWORD:PHONE_LAST_FOUR:DEBUG`


### 🤷‍♂️ Maybe future brokerages 🤷‍♀️
### Maybe future brokerages 🤷‍♀️
#### SoFi
In progress [here](https://github.com/NelsonDane/auto-rsa/pull/237).
### 👎 Never working brokerages 👎
### Never working brokerages 👎
#### Stash
Why.
10 changes: 7 additions & 3 deletions autoRSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ def fun_run(orderObj: stockOrder, command, botObj=None, loop=None):
print(f"Error in {fun_name} with {broker}: {ex}")
print(orderObj)
print()
if not orderObj.get_holdings():
printAndDiscord("All transactions complete in all brokers", loop)
printAndDiscord("All commands complete in all brokers", loop)
else:
print(f"Error: {command} is not a valid command")

Expand All @@ -185,6 +184,11 @@ def argParser(args: list) -> stockOrder:
else:
for broker in args[1].split(","):
orderObj.set_brokers(nicknames(broker))
# If next argument is not, set not broker
if len(args) > 3 and args[2] == "not":
for broker in args[3].split(","):
if nicknames(broker) in SUPPORTED_BROKERS:
orderObj.set_notbrokers(nicknames(broker))
return orderObj
# Otherwise: action, amount, stock, broker, (optional) not broker, (optional) dry
orderObj.set_action(args[0])
Expand Down Expand Up @@ -321,7 +325,7 @@ async def help(ctx):
"Available RSA commands:\n"
"!ping\n"
"!help\n"
"!rsa holdings [all|<broker1>,<broker2>,...]\n"
"!rsa holdings [all|<broker1>,<broker2>,...] [not broker1,broker2,...]\n"
"!rsa [buy|sell] [amount] [stock1|stock1,stock2] [all|<broker1>,<broker2>,...] [not broker1,broker2,...] [DRY: true|false]\n"
"!restart"
)
Expand Down
9 changes: 5 additions & 4 deletions helperAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ async def getOTPCodeDiscord(
f"Please enter OTP code or type cancel within {timeout} seconds", loop
)
# Get OTP code from Discord
otp_code = None
while otp_code is None:
while True:
try:
code = await botObj.wait_for(
"message",
Expand All @@ -606,14 +605,16 @@ async def getOTPCodeDiscord(
printAndDiscord(f"Cancelling OTP code for {brokerName}", loop)
return None
try:
otp_code = int(code.content)
# Check if code is numbers only
int(code.content)
except ValueError:
printAndDiscord("OTP code must be numbers only", loop)
continue
# Check if code is correct length
if len(code.content) != code_len:
printAndDiscord(f"OTP code must be {code_len} digits", loop)
continue
return otp_code
return code.content


def maskString(string):
Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
asyncio==3.4.3
chaseinvest-api==0.1.9
chaseinvest-api==0.2.3
discord.py==2.4.0
fennel-invest-api==1.0.9.2
firstrade==0.0.19
firstrade==0.0.21
GitPython==3.1.43
public-invest-api==1.0.4
pyotp==2.9.0
python-dotenv==1.0.1
requests==2.32.3
robin-stocks==3.1.0
schwab-api==0.4.2
selenium==4.22.0
setuptools==70.2.0
schwab-api==0.4.3
selenium==4.23.1
setuptools==71.1.0
tastytrade==8.0
vanguard-api==0.1.9
-e git+https://github.com/NelsonDane/webull.git@ef14ae63f9e1436fbea77fe864df54847cf2f730#egg=webull

0 comments on commit ba2f4c1

Please sign in to comment.