Skip to content

azerpas/bourso-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bourso CLI

OpenSSF Scorecard codecov

Screenshot of Bourso CLI

This app aims to be a simple CLI powered by Bourso API to log in to your BoursoBank/Boursorama account and achieve some basic tasks.

The first goal of this project was creating an automated DCA (Dollar Cost Average) solution to buy ETFs (Exchange Traded Funds) on a regular basis with your Bourso account.

Follow these instructions to setup your own automated DCA.

(🥷 annoted commands require no login)

Installation

From releases

You can download the latest release here.

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:

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 is open to handle this case.

Verify your installation

Bourso CLI embeds SLSA standard to verify the integrity of the binary. You can verify the signature of the binary by:

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

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 version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.azerpas.bourso-cli</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/YOUR_USER/bourso-launchd.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Weekday</key>
        <integer>1</integer> <!-- Run the script every Monday -->
        <key>Hour</key>
        <integer>20</integer> <!-- Run the script at 08:00 PM -->
        <key>Minute</key>
        <integer>00</integer>
    </dict>
    <key>RunAtLoad</key>
    <true/> <!-- Run the script when the agent is loaded, i.e., when the system starts -->
    <key>StandardOutPath</key>
    <string>/Users/YOUR_USER/bourso-launchd-cli-stdout.log</string>
    <key>StandardErrorPath</key>
    <string>/Users/YOUR_USER/bourso-launchd-cli-stderr.log</string>
</dict>
</plist>

Replace YOUR_USER with your username.

Then copy the bourso-launchd.sh script in your home directory, modify the variables and make it executable.

chmod +x bourso-launchd.sh
chown 777 bourso-launchd.sh

Finally, load the agent with the following command:

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.

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