Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/azerpas/bourso-api

Boursorama / BoursoBank unofficial API and CLI
https://github.com/azerpas/bourso-api

api banking cli dca investing rust

Last synced: 4 days ago
JSON representation

Boursorama / BoursoBank unofficial API and CLI

Awesome Lists containing this project

README

        

# Bourso CLI

[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/azerpas/bourso-api/badge)](https://securityscorecards.dev/viewer/?uri=github.com/azerpas/bourso-api)
[![codecov](https://codecov.io/gh/azerpas/bourso-api/graph/badge.svg?token=I47J55VCB3)](https://codecov.io/gh/azerpas/bourso-api)

Screenshot of Bourso CLI

This app aims to be a simple CLI powered by *[Bourso API](./src/bourso_api/)* to log in to your [BoursoBank/Boursorama](https://www.boursorama.com) account and achieve some basic tasks.

The first goal of this project was creating an automated [DCA (Dollar Cost Average)](https://www.investopedia.com/terms/d/dollarcostaveraging.asp) solution to buy [ETFs (Exchange Traded Funds)](https://www.investopedia.com/terms/e/etf.asp) on a regular basis with your Bourso account.

[Follow these instructions](#dca-dollar-cost-averaging-investing) to setup your own automated DCA.

- [Installation](#installation)
- [From releases](#from-releases)
- [Approve the app (MacOS)](#approve-the-app)
- [Verify your installation](#verify-your-installation)
- [From source](#from-source)
- [Usage](#usage)
- [Get your accounts](#get-your-accounts)
- [Place an order](#place-an-order)
- [Quote đŸĨˇ](#quote)
- [DCA](#dca-dollar-cost-averaging-investing)
- [Security](#security)
- [Disclaimer](#disclaimer)

(đŸĨˇ annoted commands require no login)

## Installation
### From releases
You can download the latest release [here](https://github.com/azerpas/bourso-api/releases).

Choose the right binary for your OS between:
- `bourso-cli-darwin.tar.gz` for MacOS
- `bourso-cli-linux.tar.gz` for Linux
- `bourso-cli.exe` for Windows

#### Approve the app (MacOS)

If you then get a `"bourso-cli" cannot be opened because the developer cannot be verified` error, go to `System Preferences > Security & Privacy > General` and click `Open Anyway`

If the above doesn't help you, make sure the file is executable:
```sh
chmod +x bourso-cli
# if it still says `Permission denied`, try
chown 777 bourso-cli
```

⚠ī¸ Signing in with a different IP address than the ones you usually use will trigger a security check from Bourso. You'll have to validate the connection from your phone. A [GitHub pull request](https://github.com/azerpas/bourso-api/pull/10) is open to handle this case.

#### Verify your installation
Bourso CLI embeds [SLSA](https://slsa.dev/) standard to verify the integrity of the binary. You can verify the signature of the binary by:
- Downloading the provenance generated by the release pipeline for your OS: https://github.com/azerpas/bourso-api/releases/latest
- Installing [slsa-verifier](https://github.com/slsa-framework/slsa-verifier?tab=readme-ov-file#installation)
- Running `slsa-verifier`. MacOS example:
```sh
slsa-verifier-darwin-arm64 verify-artifact --provenance-path provenance-id-macos-latest.intoto.jsonl --source-uri "github.com/azerpas/bourso-api" bourso-cli
```
Which should output:
```
Verifying artifact ~/bourso-cli: PASSED
```

### From source
Requires [>=Rust 1.77.2](https://www.rust-lang.org)
```sh
git clone [email protected]:azerpas/bourso-api.git
cd bourso-api
cargo build --release
# You can run any command from the built application, e.g:
./target/release/bourso-cli config
```

## Usage

### Configuration
Save your client ID with this config command:
```
./bourso-cli config
```
The password will be asked each time you run the app to avoid storing it in a file.

### Get your accounts
```
./bourso-cli accounts
```
You'll get something like this:
```
[
Account {
id: "1a2953bd1a28a37bd3fe89d32986e613",
name: "BoursoBank",
balance: 100,
bank_name: "BoursoBank",
kind: Banking,
},
Account {
id: "a583f3c5842c34fb00b408486ef493e0",
name: "PEA DOE",
balance: 1000000,
bank_name: "BoursoBank",
kind: Trading,
},
]
```

### Place an order
**Make sure to have a trading account with enough balance to place the order.** Check the previous section to see how to get your account ID.

🛍ī¸ Place a buy order for 4 shares of the ETF "1rTCW8" (AMUNDI MSCI WORLD UCITS ETF - EUR) on your account "a583f3c5842c34fb00b408486ef493e0":
```
./bourso-cli trade order new --side buy --symbol 1rTCW8 --account a583f3c5842c34fb00b408486ef493e0 --quantity 4
```

*Tip: You can get the ETF ID from the tracker URL, e.g. "AMUNDI MSCI WORLD UCITS ETF - EUR" url is https://www.boursorama.com/bourse/trackers/cours/1rTCW8/ (1rTCW8)*

### Quote
Quote an asset to retrieve its value over time, e.g:
```
➜ ~ ./bourso-cli quote --symbol 1rTCW8 average
INFO bourso_cli > Welcome to BoursoBank CLI 👋
INFO bourso_cli > ℹī¸ - Version 0.1.6. Make sure you're running the latest version: https://github.com/azerpas/bourso-api

INFO bourso_cli > Fetching quotes...
INFO bourso_cli > Average quote: 494.5348136363637
```
Subcommands available: `highest`, `lowest`, `average`, `volume`, `last`

### DCA (Dollar Cost Averaging) investing

You can use this script to do DCA investing. For example, if you want to buy 1 share of the ETF "1rTCW8" (AMUNDI MSCI WORLD UCITS ETF - EUR) every month, you can use a cron job to run the script every month.

#### With MacOS
You can use the `launchd` daemon to run the script every week. Create a file named `com.bourso-cli.plist` in `~/Library/LaunchAgents/` with the following content:
```xml

Label
com.azerpas.bourso-cli
ProgramArguments

/Users/YOUR_USER/bourso-launchd.sh

StartCalendarInterval

Weekday
1
Hour
20
Minute
00

RunAtLoad

StandardOutPath
/Users/YOUR_USER/bourso-launchd-cli-stdout.log
StandardErrorPath
/Users/YOUR_USER/bourso-launchd-cli-stderr.log

```
Replace `YOUR_USER` with your username.

Then copy the `bourso-launchd.sh` script in your home directory, modify the variables and make it executable.
```sh
chmod +x bourso-launchd.sh
chown 777 bourso-launchd.sh
```
Finally, load the agent with the following command:
```sh
launchctl load ~/Library/LaunchAgents/com.bourso-cli.plist
```
The script will now run every week at 08:00 PM on Monday. You can check the logs in `~/bourso-launchd-cli-stdout.log` and `~/bourso-launchd-cli-stderr.log`.
#### With Linux
TODO
#### With Windows
Copy/paste the following commands and replace the path with the actual location of `bourso-cli.exe`. Then paste the commands to Powershell.
```ps1
# Create a new task trigger that will run weekly on Sunday at 1:00pm
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 1:00PM
# Create a new task action that will execute the trade based on the trigger defined above
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoExit -Command `"& { `$exePath = 'C:\Path\To\bourso-cli.exe'; `$arguments = 'trade order new --side buy --symbol 1rTCW8 --account a583f3c5842c34fb00b408486ef493e0 --quantity 4'; Start-Process -FilePath `$exePath -ArgumentList `$arguments -NoNewWindow -Wait }`""
# Create a task named "Weekly Bourso CLI Task"
Register-ScheduledTask -TaskName "Weekly Bourso CLI Task" -Trigger $trigger -Action $action
```

## Security
This app runs locally. All outbound/inbound data is sent/received to/from BoursoBank servers **only**. Your password will not be saved locally and will be asked each time you run the app. Your client ID has to be configurated and will be saved into the app data for next usages.

## Disclaimer

This script is provided as is, without any warranty. I am not responsible for any loss of funds. Use at your own risk. I am not affiliated with BoursoBank or any other project mentioned in this repository. This is not financial advice.