Skip to content

Smart open-source investment tracker that consolidates and monitors market performance across your different brokerages

License

Notifications You must be signed in to change notification settings

investbrainapp/investbrain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Investbrain Logo

About Investbrain

Investbrain helps you manage and track the performance of your investments.

Investbrain Screenshot

Under the hood

Investbrain is a Laravel PHP web application that leverages Livewire, Mary UI, and Tailwind for its frontend. Most databases should work, including MySQL and SQLite. Out of the box, we feature three market data providers: Yahoo Finance, Finnhub, and Alpha Vantage. But we also offer an extensible market data provider interface for intrepid developers to create their own! Finally, of course we have robust support for i18n, a11y, and dark mode.

Installation

For ease of installation, we highly recommend installing Investbrain using the provided Docker Compose file, which downloads all the necessary dependencies and seamlessly builds everything you need to get started quickly!

Before getting started, you should already have the following installed on your machine: Docker Engine, Git, and a wild sense of adventure.

Ready? Let's get started!

First, you can clone this repository:

git clone https://github.com/investbrainapp/investbrain.git && cd investbrain

Then, build the Docker image and bring up the container (this will take a few minutes):

docker compose up

In the previous step, all of the default configurations are set automatically. This includes creating a .env file and setting the required Laravel APP_KEY.

If everything worked as expected, you should now be able to access Investbrain in the browser at. You should create an account by visiting:

http://localhost:8000/register

Congrats! You've just installed Investbrain!

Market data providers

Investbrain includes an extensible market data provider interface that allows you to retrieve stock market data from multiple providers, such as Yahoo Finance, Alpha Vantage, or Finnhub. The interface includes a built-in fallback mechanism to ensure reliable data access, even if a provider fails.

Configuration

You can specify the provider you want to use in your .env file:

MARKET_DATA_PROVIDER=yahoo

You can also use Investbrain's built-in fallback mechanism to ensure reliable data access, even if a provider fails. If any provider fails, Investbrain will automatically attempt to retrieve data from the next available provider, continuing through your configured providers until one returns successfully.

Your selected providers should be listed in your .env file. Each should be separated by a comma:

MARKET_DATA_PROVIDER=yahoo,alphavantage

In the above example, Yahoo Finance will be attempted first and the Alpha Vantage provider will be used as the fallback. If Yahoo Finance fails to retrieve market data, the application will automatically try Alpha Vantage.

Custom providers

If you wish to create your own market data provider, you can create your own implementation of the MarketDataInterface. You can refer to any existing market data implementation as an examples.

Once you've created your market data implementation, be sure add your custom provider to the Investbrain configuration file, under the interfaces section:

'interfaces' => [
    //                       *  *  *
    'custom_provider' => \App\Services\CustomProviderMarketData::class,
    //                       *  *  *
],

And add your custom provider to your .env file:

MARKET_DATA_PROVIDER=yahoo,alphavantage,custom_provider

Feel free to submit a PR with any custom providers you create.

Configuration

There are several optional configurations available when installing using the recommended Docker method. These options are configurable using an environment file. Changes can be made in your .env file before installation.

Option Description Default
APP_URL The URL where your Investbrain installation will be accessible http://localhost
APP_PORT The HTTP port exposed by the NGINX container 8000
MARKET_DATA_PROVIDER The market data provider to use (either yahoo, alphavantage, or finnhub) yahoo
MARKET_DATA_REFRESH Cadence to refresh market data in minutes 30
ALPHAVANTAGE_API_KEY If using the Alpha Vantage provider null
FINNHUB_API_KEY If using the Finnhub provider null

Note: These options affect the docker-compose.yml file, so if you decide to make any changes to these default configurations, you'll have to restart the Docker containers before your changes take effect.

Updating

To update Investbrain using the recommended Docker installation method, you just need to stop the running containers:

docker compose stop

Then pull the latest updates from this repository using git:

git pull

Then bring the containers back up!

docker compose up

Easy as that!

Command line utilities

Investbrain comes bundled with several helpful command line utilities to make managing your portfolios and holdings more efficient. Keep in mind these commands are extremely powerful and can make irreversable changes to your holdings.

To run these commands, you can use docker exec like this:

docker exec -it investbrain-app php artisan <replace with command you want to run>

Just to be safe, we recommend backing up your portfolios before using these commands:

Command Description
refresh:market-data Refreshes market data with your configured market data provider.
refresh:dividend-data Refreshes dividend data with your configured market data provider. Will also re-calculate your total dividends earned for each holding.
refresh:split-data Refreshes splits data with your configured market data provider. Will also create new transactions to account for any splits.
capture:daily-change Captures a snapshot of each portfolio's daily performance.
sync:daily-change Re-calculates daily snapshots of your portfolio's daily performance. Useful to fill in gaps in your portfolio charts. (Note: this is an extremely resource intensive query.)
sync:holdings Re-calculates performance of holdings with related transactions (i.e. dividends, realized gains, etc).

Testing

Investbrain has a complete PHPUnit test suite that creates an in-memory SQLite database and runs any queued jobs synchronously using Laravel's array driver. You can run the entire Investbrain test suite from within the Docker container by running:

docker exec -it investbrain-app php artisan test

Contributing

We appreciate any contributions to Investbrain! Please open a pull request on our Github repository. Here are some ideas for first time contributors:

  • Improve our documentation
  • Create new market data providers
  • Enhance the user interface
  • Additional translations
  • Fix bugs

When you submit a contribution, don't forget to include passing tests with your PR!

Code of Conduct

We ask that you be kind and polite when interacting with the Investbrain community.

Security Vulnerabilities

If you discover a security vulnerability within Investbrain, please create an issue in the Github repository. All security vulnerabilities will be promptly addressed.

License

Investbrain is open-sourced software licensed under the CC-BY-NC 4.0.

About

Smart open-source investment tracker that consolidates and monitors market performance across your different brokerages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages