• Stars
    star
    480
  • Rank 91,562 (Top 2 %)
  • Language
    Rust
  • Created about 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Helps you with managing your investments

Test status

Investments

Helps you with managing your investments:

  • Portfolio rebalancing: instructs you which orders you have to submit to make your portfolio in order with your asset allocation.
  • Stock selling simulation: calculates revenue, profit, taxes and real profit percent which considers taxes into account.
  • Automatic tax statement generation: reads broker statements and alters *.dcX file (created by Russian tax program named Декларация) by adding all required information about income from stock selling, paid dividends and idle cash interest.
  • Analysis: calculates average rate of return from cash investments by comparing portfolio performance to performance of a bank deposit in USD and RUB currency with exactly the same investments and monthly capitalization. Considers taxes, commissions, dividends and tax deductions when calculates portfolio performance.
  • Bank deposits control: view opened bank deposits all in one place and get notified about upcoming deposit closures.

Targeted for Russian investors who use Interactive Brokers, Открытие Брокер, Тинькофф, Firstrade or БКС.

Installation

See installation instructions.

Configuration

Create ~/.investments/config.yaml configuration file. See example which contains typical configuration for each broker, tax exemptions that are applicable to the account and more. Don't forget to obtain API token for FCS API and Finnhub (see stock and forex quotes providers for details).

Usage

Stocks

Investments is designed to work with your broker statements — there is no need to enter all trades and transactions manually, but it requires you to have all broker statements starting from account opening day. It may be either one broker statement or many — it doesn't matter, but what matters is that the first statement must be with zero starting assets and statements' periods mustn't overlap or have missing days in between.

For now the following brokers are supported:

Investments keeps some data in local database located at ~/.investments/db.sqlite and supports a number of commands which can be grouped as:

Performance analysis

investments analyse command calculates average rate of return from cash investments by comparing portfolio performance to performance of a bank deposit in USD and RUB currency with exactly the same investments and monthly capitalization. Considers taxes, commissions, dividends and tax deductions when calculates portfolio performance.

investments analyse

Portfolio rebalancing

See instructions for portfolio rebalancing.

investments rebalance

Tax statement generation

See instructions for tax statement generation and recommendations for interacting with Russian Federal Tax Service.

investments tax-statement

Sell simulation

investments simulate-sell command simulates closing of the specified positions by current market price and allows you to estimate your profits, taxes and tax exemption applicability.

investments simulate-sell

Prometheus metrics

investments metrics command allows you to export analysis results in Prometheus format to be collected by Node exporter's Textfile Collector.

Here is an example of Grafana dashboard which displays aggregated statistics and investment results for multiple portfolios opened in different brokers:

Investments Grafana dashboard

Deposits

You can also view opened bank deposits all in one place and get notified about upcoming deposit closures. Register your opened deposits in the configuration file and then execute:

$ investments deposits

                            Open deposits

 Open date   Close date    Name     Amount   Interest  Current amount
 19.06.2019  19.03.2020  Тинькофф  465,000₽         7     473,343.49₽
 21.06.2019  21.06.2020  Тинькофф  200,000₽       7.5     203,763.08₽
                                   665,000₽               677,106.57₽

This command has a cron mode (investments deposits --cron) which you can use in combination with notify_deposit_closing_days configuration option. For example, if you create a cron job and configure it to send the command output to your email, then on 11.06.2020 having notify_deposit_closing_days: 10 you get an email with the following contents:

The following deposits are about to close:
* 21.06.2020 Тинькофф: 200,000₽ -> 215,570.51₽

The following deposits are closed:
* 19.03.2020 Тинькофф: 465,000₽ -> 490,013.27₽

Unsupported features

The program is focused on passive investing use cases and supports only those cases which I saw in my broker statements or statements sent to me by other people, which I assured to be handled properly and wrote regression tests for. For example, the following aren't supported yet:

Denial of responsibility

Any automation is imperfect and the author is a software developer, not a tax lawyer, so always be critical to all program's calculation results.

The project is developed as a pet project, mainly for my personal use. The code is written in a way that if it finds something unusual in broker statement it returns an error and doesn't try to pass through the error to avoid the case when it will get you to misleading results, so there may be many cases that it's not able to handle yet and I can't guarantee that I'll find a free time to support your specific case.

Contacts

Issues and Discussions are the preferred way for requests and questions. Please use email only for privacy reasons.

More Repositories

1

vkfeed

Generates RSS feed for vk.com public wall posts
HTML
112
star
2

psh

Process management library
Python
18
star
3

social-rss

Allows you to receive updates from your social network accounts via RSS
Python
16
star
4

flush

GTK-based BitTorrent client
Shell
15
star
5

investment-tools

Scripts which help me with managing my investments
Python
7
star
6

pysd

Small Python script for automatic TV show subtitles downloading which can also be used as a separate Python module
Python
7
star
7

rutracker.rss

RSS for RuTracker.org with filtering by TV show name
Python
4
star
8

binup

Automated app installation from GitHub releases
Rust
4
star
9

rsspipes

RSS processor inspired by Yahoo! Pipes
Go
3
star
10

object-validator

Python object validation module
Python
3
star
11

qemu-kvm

Mirror of the official git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git with my fixes
C
3
star
12

ansible-vagrant

Ansible role for Vagrant provisioning
Shell
3
star
13

transmission-controller

Сontrols Transmission daemon to save user from routine operations
Rust
2
star
14

python-config

A simple module for reading Python configuration files
Python
2
star
15

go-rss

Simple RSS parser and generator for Go
Go
2
star
16

psys

A Python module with a set of basic tools for writing system utilities
Python
2
star
17

mkdevelvirtualenv

Very easy way of creating development virtual environments for python projects
Shell
2
star
18

pycl

Just a small set of some useful classes which I'm going to use in all my Python projects
Python
2
star
19

git-backup

Script for backing up GitHub repositories
Python
1
star
20

gosquashimports

Go
1
star
21

pytee

Video player for watching movies with subtitles
Python
1
star
22

rust-easy-logging

An easy way to get logging working in your CLI tool
Rust
1
star
23

pyvsb

Very simple in configuring but powerful backup tool
Shell
1
star
24

flatmon

Indoor air quality monitoring using Arduino
C++
1
star
25

nanokernel

Playing with https://539kernel.com/ book
Assembly
1
star
26

credit-calculator

A simple credit calculator which helps you in managing your credits
Python
1
star
27

dotfiles

Configuration files and scripts
Shell
1
star