Skip to content

Commit

Permalink
feat(readme)
Browse files Browse the repository at this point in the history
  • Loading branch information
emvalbuena committed May 4, 2024
1 parent 9d787fc commit c098bd5
Showing 1 changed file with 72 additions and 40 deletions.
112 changes: 72 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,11 @@ Basic reporting functionality:
Access to real-time trading.

## Setting up the environment

### Environment variables
The CLI relies on a couple of environment variables to work:
```bash
LOG_LEVEL=info
DEGIRO_FOLDER=~/.degiro/base # folder to create the filesystem to work with
INCEPTION=2024-05-04 # start date of the portfolio.
YS=2024-01-01 # workaround to indicate [Y]ear [S]tart
EDITOR=nvim # or any other editor of your choide (code, vim, emacs, etc.)
```
At the moment, the values of these variables are always printed whenever
the CLI is invoked.

- `DEGIRO_FOLDER` is instantiated to `~/.degiro/base` if it is not specified.
- `YS` is used for a workaround. To keep functionality simple, each time the positions are pulled,
they are pulled since the start of the year. Clearly, we ought to only pull the ones that we are missing,
but to keep logic to a bare minimum I preferred to skip that for now.

> [!TIP]
> I use [autoenv](https://github.com/hyperupcall/autoenv) to load them automagically every time I access to the repo folder.
### Username and password
This library only supports login with username and password.
They have to be located in `DEGIRO_FOLDER`, in a file called `.secrets.json`:
```json
{
"username": "your-username",
"password": "your-password"
}
```
This library uses some environment variables and a custom filesystem to
handle all the reporting.
More details on the "First steps (cold start)" section below.
Improvements are on my wish-list, but for now monitoring the portfolio
is a priority.

### How to install

Expand All @@ -69,31 +44,88 @@ More information can be obtained by executing them with the `--help` flag.

![degiro-cli](./degiro-cli.png)

At the moment the CLI is a bit too overcomplex (commands are split in too many little pieces),
### Why is there a Makefile?
At the moment the CLI is a bit too overcomplex
(commands are split in too many little pieces),
so until a refactor is done,
I have created a Makefile to simplify its use.

The help of the Makefile can be invoked writing `make` in the command line.

### First steps
Feel free to inspect the contents of the Makefile to learn how the CLI is used.

### First steps (cold start)

Until tech debt is payed back,
cold starting the CLI takes some steps ...

1. Define environment variables.
2. Execute `cold-start` entrypoint:
```bash
LOG_LEVEL=info
DEGIRO_FOLDER=~/.degiro/base # (default value) folder to create the filesystem to work with
INCEPTION= # start date of the portfolio, e.g. 2019-05-04
YS=2024-01-01 # workaround to indicate current [Y]ear [S]tart date
EDITOR=nvim # or any other editor of your choide (vim, code, emacs, etc.)
```
- `DEGIRO_FOLDER`: location of secrets, session credentials and raw and processed files.
Created automatically by `degiro init` command.
- `INCEPTION`: starting date of the portfolio.
Fill with a date that is reasonably *previous* to the actual starting date of your portfolio
(it can be later re-adjusted, on cold-starting better to err on the left side of the time interval).
- `YS`: used for a workaround. To keep functionality simple, each time the positions are pulled,
they are done so since the start of the year.
Clearly, we ought to only pull the ones that we are missing,
but to keep logic to a bare minimum I preferred to skip that for now.

> [!TIP]
> I use [autoenv](https://github.com/hyperupcall/autoenv) to load them automagically every time I access to the repo folder.
At the moment, the values of the environment variables are always printed whenever
the CLI is invoked.

2. Create working folder and `.secrets.json` file:
```
make init
```
3. Fill the `.secrets.json` file with your username and password.
(for now, 2FA is not supported).
They have to be located in `DEGIRO_FOLDER`, in a file called `.secrets.json`:
```json
{
"username": "your-username",
"password": "your-password"
}
```
4. Execute `cold-start` entrypoint to download for the first time raw files:
```
make cold-start
```
3. Create `portfolio.csv` file.
5. Create `portfolio.csv` file.
This command will use the `EDITOR` env var to open the file.
**Delete the cash line.**
Delete any other line you do not want to keep track of.
Save the file and continue.
**Delete all the cash lines.**
```
make portfolio
```
4. Execute [S]ince [I]nception report:
6. Execute Since Inception report:
```
make si
```
7. The CLI logs the folder where the report has been generated.

### Everyday use
Now that you have cold-started the CLI, everyday use is much simpler,
two commands barely.
You simply need to update the files and then trigger a report.
1. Update files:
```
make update
```
2. Create a report:
```
make ytd
```
```
make si
```
5. The CLI should log the folder where the report has been generated.

### Tips
#### How did you figure out the inception date?
Expand Down

0 comments on commit c098bd5

Please sign in to comment.