Compare commits

..

115 Commits

Author SHA1 Message Date
hackerESQ bdd30c238c Merge pull request #52 from investbrainapp/optimize-dockerfile
Optimize Docker Image
2025-01-26 21:59:56 -06:00
hackerESQ 778d799113 cleanup 2025-01-26 21:56:41 -06:00
hackerESQ 47cd1b6a91 wip 2025-01-26 21:54:56 -06:00
hackerESQ 118232e906 update readme 2025-01-26 21:50:25 -06:00
hackerESQ 64c84fe708 wip 2025-01-26 21:46:59 -06:00
hackerESQ cff3c02851 wip 2025-01-26 21:45:38 -06:00
hackerESQ 60577d02c7 wip 2025-01-26 21:45:17 -06:00
hackerESQ 99749bd9c9 this is it 2025-01-26 21:42:39 -06:00
hackerESQ b3ca2e5927 wip 2025-01-26 21:38:59 -06:00
hackerESQ b71e9e2e80 make info messages pop 2025-01-26 21:33:49 -06:00
hackerESQ 72a8aacabe wip 2025-01-26 21:30:12 -06:00
hackerESQ a0e9cfb40d wip 2025-01-26 21:24:59 -06:00
hackerESQ 46707c1149 wip 2025-01-26 21:20:02 -06:00
hackerESQ 497efcfa76 wip 2025-01-26 21:08:48 -06:00
hackerESQ 1201c248ee cleanup 2025-01-26 21:06:08 -06:00
hackerESQ 395eb31801 wip 2025-01-26 20:40:44 -06:00
hackerESQ b27edd9818 wip 2025-01-26 11:36:42 -06:00
hackerESQ 51c43e9893 make sure key is set 2025-01-26 11:31:07 -06:00
hackerESQ ec2019430e ensure storage is there 2025-01-26 11:28:20 -06:00
hackerESQ 05174e93ad wip 2025-01-26 11:20:52 -06:00
hackerESQ e8ec94bfa8 add in-line docs to env 2025-01-25 23:36:33 -06:00
hackerESQ c6642e028c updat example env 2025-01-25 23:30:00 -06:00
hackerESQ 6d5a5f46b9 update readme for new install instructions 2025-01-25 23:17:21 -06:00
hackerESQ e651eb86ca bump front end 2025-01-25 22:56:22 -06:00
hackerESQ 84171da29b bump php version 2025-01-25 22:55:45 -06:00
hackerESQ d463ec689b last one 2025-01-25 22:54:10 -06:00
hackerESQ 416a82058b getting close 2025-01-25 22:52:44 -06:00
hackerESQ 6f2324ad1b wip 2025-01-25 22:37:26 -06:00
hackerESQ c19f13edc1 wip 2025-01-25 22:36:48 -06:00
hackerESQ 390b137e0b wiiiip 2025-01-25 22:33:27 -06:00
hackerESQ 0c7d4a83f1 wip 2025-01-25 22:24:51 -06:00
hackerESQ 25112cb03a wip 2025-01-25 22:22:42 -06:00
hackerESQ 5ade4b35a0 wip 2025-01-25 22:19:54 -06:00
hackerESQ 00067c56d4 wip 2025-01-25 22:08:07 -06:00
hackerESQ 620566490b wip 2025-01-25 21:57:50 -06:00
hackerESQ 7245f4cc69 wip 2025-01-25 21:53:55 -06:00
hackerESQ 575fecb163 wip 2025-01-25 21:43:58 -06:00
hackerESQ 4120b1abfa set permission in entry script 2025-01-25 21:34:18 -06:00
hackerESQ 801d3739fc wip 2025-01-25 21:21:08 -06:00
hackerESQ 92bdf14508 wip 2025-01-25 21:17:27 -06:00
hackerESQ fa25a82693 wip 2025-01-25 21:12:16 -06:00
hackerESQ 1684f3e0cb wip 2025-01-25 21:06:54 -06:00
hackerESQ a31f807da8 wip 2025-01-25 20:49:24 -06:00
hackerESQ 6d92b49f3d wip 2025-01-25 20:46:40 -06:00
hackerESQ 11cdf975bc wip 2025-01-25 20:40:26 -06:00
hackerESQ 7bacc28e3b wip 2025-01-25 20:37:50 -06:00
hackerESQ 4bbb71d434 wip 2025-01-25 20:34:03 -06:00
hackerESQ 8da153a476 wip 2025-01-25 20:31:40 -06:00
hackerESQ 1189325638 wip 2025-01-25 20:28:38 -06:00
hackerESQ e93459ae55 wip 2025-01-25 20:25:25 -06:00
hackerESQ b1fcf51546 wip 2025-01-25 20:21:38 -06:00
hackerESQ 75716368bb wip 2025-01-25 20:20:56 -06:00
hackerESQ ec15e2bb63 wip 2025-01-25 20:15:21 -06:00
hackerESQ 9a3e030ce7 wip 2025-01-25 20:13:19 -06:00
hackerESQ 4f5894ef4a wip 2025-01-25 18:41:20 -06:00
hackerESQ e0b5610d90 wip 2025-01-25 18:35:18 -06:00
hackerESQ bc34519a26 wip 2025-01-25 18:22:12 -06:00
hackerESQ dc69bfa8c7 make php extensions required 2025-01-25 18:18:31 -06:00
hackerESQ cf7c5fc23a wip 2025-01-25 18:12:55 -06:00
hackerESQ 16d5b80657 wip 2025-01-25 18:09:02 -06:00
hackerESQ 8dd153fb53 docs: added more badges 2025-01-17 12:46:29 -06:00
hackerESQ 89bfb28019 docs: add badges 2025-01-15 22:37:03 -06:00
hackerESQ 1215e47297 Merge pull request #49 from investbrainapp/upgrade-laravel
chore: upgrade composer deps
2024-12-26 12:34:53 -06:00
hackerESQ 4016899179 chore: upgrade composer deps 2024-12-26 12:34:29 -06:00
hackerESQ 1cad9b83fb Update build-and-push-images.yml 2024-12-20 23:05:05 -06:00
hackerESQ 780ee76dc3 Update build-and-push-images.yml 2024-12-20 23:02:36 -06:00
hackerESQ 4d8e17f59f Update build-and-push-images.yml 2024-12-20 22:57:02 -06:00
hackerESQ 21c27e22da Update build-and-push-images.yml 2024-12-20 22:55:56 -06:00
hackerESQ 2e978089b5 rename workflow 2024-12-20 22:25:39 -06:00
hackerESQ 803fe7147e Set up github workflow to build and push images 2024-12-20 22:24:54 -06:00
hackerESQ 6490364a5d chore: update dockerignore 2024-12-20 16:19:07 -06:00
hackerESQ 2ad773952e chore: slim down docker build 2024-12-19 21:53:50 -06:00
hackerESQ 138e71107e chore: clean up dockerfile and entrypoint script 2024-12-19 21:34:58 -06:00
hackerESQ bde399f589 chore: move dockerfile back to repo 2024-12-19 21:10:00 -06:00
hackerESQ 8a43602363 docs: clarify upsert 2024-12-18 16:03:32 -06:00
hackerESQ 5a56790fd4 docs: more refinement and word choice 2024-12-18 16:03:01 -06:00
hackerESQ 892f681174 docs: add self-hosted llm to readme intro section 2024-12-18 15:53:09 -06:00
hackerESQ 997b5420ee Merge pull request #44 from investbrainapp/create-docker-image
Use the investbrainapp/investbrain docker image
2024-12-17 18:28:03 -06:00
hackerESQ 643bbe3af2 wait for db to be ready in order to migrate 2024-12-16 21:54:59 -06:00
hackerESQ f85f0f19b9 wip 2024-12-16 21:33:45 -06:00
hackerESQ 3f9a1bafa0 Merge pull request #37 from investbrainapp/feat-use-openai-compatible-endpoints
Feat use openai compatible endpoints
2024-12-06 16:10:54 -06:00
hackerESQ 6f72a03ecf fix: specifically use factory import 2024-12-06 16:10:27 -06:00
hackerESQ 5b8e4c634e fix: remove validation which could prevent selfhosting w ollama 2024-12-06 16:09:03 -06:00
hackerESQ 70c3f7162e Merge pull request #36 from investbrainapp/feat-use-openai-compatible-endpoints
feat: adds ollama support
2024-12-06 16:02:13 -06:00
hackerESQ cb9199431a feat: adds ollama support 2024-12-06 16:01:53 -06:00
hackerESQ cba9fe1e7b feat: adds pagination to recent activity list 2024-11-29 14:22:35 -06:00
hackerESQ baa49e77eb docs: fix link to import / export section 2024-11-27 12:52:37 -06:00
hackerESQ b015462e50 docs: adds information about import / export capabilities
See #25
2024-11-27 12:51:52 -06:00
hackerESQ c9f1fc1bea feat: make the system prompt aware of current date 2024-11-14 23:44:04 -06:00
hackerESQ 1177886271 Merge pull request #32 from investbrainapp/remove-terms-checkbox-for-self-hosted
Remove terms checkbox for self hosted
2024-11-14 02:23:50 -06:00
hackerESQ 0e1c56dd18 feat: do not show terms when self hosting 2024-11-14 02:23:22 -06:00
hackerESQ eefe237dff feat: allow app debug on default install 2024-11-14 02:10:21 -06:00
hackerESQ 8d4e004177 Merge pull request #31 from investbrainapp/dev
Uses last dividend created date as start date instead of last dividend date
2024-11-14 01:30:27 -06:00
hackerESQ 1c63e2b856 fix: uses last dividend created date as start date instead of last dividend date
closes #26
2024-11-14 01:25:03 -06:00
hackerESQ 3040cbf49a chore: bump composer deps 2024-11-12 22:42:27 -06:00
hackerESQ 1a124a2571 Merge pull request #30 from investbrainapp/dev
fix: refresh dividends only once daily
2024-11-12 22:36:50 -06:00
hackerESQ 26c8c3f3b9 Merge pull request #29 from investbrainapp/dependabot/composer/laravel/framework-11.31.0
chore(deps): bump laravel/framework from 11.30.0 to 11.31.0
2024-11-12 20:56:50 -06:00
dependabot[bot] 50d814ebf6 chore(deps): bump laravel/framework from 11.30.0 to 11.31.0
Bumps [laravel/framework](https://github.com/laravel/framework) from 11.30.0 to 11.31.0.
- [Release notes](https://github.com/laravel/framework/releases)
- [Changelog](https://github.com/laravel/framework/blob/11.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/framework/compare/v11.30.0...v11.31.0)

---
updated-dependencies:
- dependency-name: laravel/framework
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-12 22:47:25 +00:00
hackerESQ 7fc20876dd fix: refresh dividends only once daily 2024-11-12 00:53:22 -06:00
hackerESQ 183108400e Merge pull request #17 from investbrainapp/dependabot/npm_and_yarn/vite-5.4.10
chore(deps-dev): bump vite from 5.3.5 to 5.4.10
2024-11-08 21:03:32 -06:00
dependabot[bot] 3055d34979 chore(deps-dev): bump vite from 5.3.5 to 5.4.10
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.3.5 to 5.4.10.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.4.10/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.10/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-09 03:01:41 +00:00
hackerESQ 747f5f5f42 Merge pull request #16 from investbrainapp/dependabot/npm_and_yarn/axios-1.7.4
chore(deps-dev): bump axios from 1.7.3 to 1.7.4
2024-11-08 21:00:30 -06:00
dependabot[bot] 4db9409b94 chore(deps-dev): bump axios from 1.7.3 to 1.7.4
Bumps [axios](https://github.com/axios/axios) from 1.7.3 to 1.7.4.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.7.3...v1.7.4)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-08 04:10:36 +00:00
hackerESQ 8693bb29ca Update README.md 2024-11-07 22:08:46 -06:00
hackerESQ 524d8ca41d Update SECURITY.md 2024-11-07 22:08:16 -06:00
hackerESQ 3c77eca689 Create SECURITY.md 2024-11-07 22:02:53 -06:00
hackerESQ 307f74b1d9 Merge pull request #14 from investbrainapp/dev
fix: adds validation for transaction date
2024-11-07 20:46:03 -06:00
hackerESQ 0c29393f3b fix: skip dividend sync if most recent dividend was less than 24 hours ago 2024-11-07 20:40:55 -06:00
hackerESQ af3726cb91 fix: sales quantity should use rounded float numbers 2024-11-07 18:20:53 -06:00
hackerESQ 0d40fd92f0 fix: adds validation for transaction date (no post-dated transactions) 2024-11-07 18:06:27 -06:00
hackerESQ 0f55d84355 Merge pull request #13 from eltociear/patch-1
docs: update README.md
2024-11-07 17:42:31 -06:00
Ikko Eltociear Ashimine eafa889827 docs: update README.md
assstant -> assistant
2024-11-08 08:39:39 +09:00
hackerESQ 60cd880c2e docs: fix formatting for TOC 2024-11-07 17:31:50 -06:00
hackerESQ ea8de69863 docs: adds table of contents to docs 2024-11-07 17:31:17 -06:00
hackerESQ 11ef26e878 docs: add troubleshooting section 2024-11-07 17:05:25 -06:00
34 changed files with 1821 additions and 1089 deletions
+16
View File
@@ -0,0 +1,16 @@
.git
.env
node_modules
packages
vendor
tests
.DS_Store
vapor.yml
.vapor
storage/app/livewire-tmp/*
storage/app/public/profile-photos/*
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/testing/*
storage/framework/views/*
storage/framework/logs/*
+25 -10
View File
@@ -1,24 +1,35 @@
APP_NAME=Investbrain
APP_ENV=production
# Generate a secure key using `openssl rand -base64 32`
APP_KEY=
APP_DEBUG=false
APP_TIMEZONE=UTC
# Port for NGINX to listen on
APP_PORT=8000
# Used internally to generate absolute links
APP_URL="http://localhost:${APP_PORT}"
SELF_HOSTED=true
# Webroot for static assets (css, js, images, etc)
ASSET_URL="${APP_URL}"
# Enables or disables new user registration
REGISTRATION_ENABLED=true
# ASSET_URL="http://localhost:8000" # (optional) webroot for static assets (css, js, images, etc)
# Enable or disable AI chat feature
AI_CHAT_ENABLED=false
# API key for OpenAI (for Llama support, see docs)
OPENAI_API_KEY=
OPENAI_ORGANIZATION=
# Market data provider to use (comma separated list)
MARKET_DATA_PROVIDER=yahoo
MARKET_DATA_REFRESH=30
ALPHAVANTAGE_API_KEY=
FINNHUB_API_KEY=
# Cadence to refresh market data (in minutes)
MARKET_DATA_REFRESH=30
DAILY_CHANGE_TIME=
#### Advanced configurations ####
ENABLED_LOGIN_PROVIDERS=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
@@ -29,9 +40,13 @@ LINKEDIN_CLIENT_SECRET=
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
APP_NAME=Investbrain
APP_TIMEZONE=UTC
APP_ENV=production
APP_DEBUG=true
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
SELF_HOSTED=true
DB_CONNECTION=mysql
DB_HOST=investbrain-mysql
@@ -52,7 +67,7 @@ QUEUE_CONNECTION=redis
CACHE_STORE=redis
REDIS_CLIENT=predis
REDIS_HOST=127.0.0.1
REDIS_HOST=investbrain-redis
REDIS_PATH=/tmp/database_server.sock
REDIS_PASSWORD=null
REDIS_PORT=6379
@@ -0,0 +1,49 @@
name: Build and push Docker images
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GIT_HUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract version from tag
id: extract-version
run: |
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
file: ./docker/Dockerfile
push: true
tags: |
investbrainapp/investbrain:latest
investbrainapp/investbrain:${{ env.version }}
ghcr.io/investbrainapp/investbrain:latest
ghcr.io/investbrainapp/investbrain:${{ env.version }}
+79 -18
View File
@@ -1,38 +1,58 @@
<p align="center"><a href="https://investbra.in" target="_blank"><img src="https://raw.githubusercontent.com/investbrainapp/investbrain/main/investbrain-logo.png" width="400" alt="Investbrain Logo"></a></p>
[![GitHub Repo Stars](https://img.shields.io/github/stars/investbrainapp/investbrain?style=for-the-badge&color=%23CCCCCC)](https://github.com/investbrainapp/investbrain/)
[![GitHub Contributors](https://img.shields.io/github/contributors/investbrainapp/investbrain?style=for-the-badge)](https://github.com/investbrainapp/investbrain/)
[![GitHub Issues](https://img.shields.io/github/issues/investbrainapp/investbrain?style=for-the-badge)](https://github.com/investbrainapp/investbrain/issues)
[![Docker Pulls](https://img.shields.io/docker/pulls/investbrainapp/investbrain?style=for-the-badge)](https://hub.docker.com/r/investbrainapp/investbrain/)
## About Investbrain
Investbrain is a smart open-source investment tracker that helps you manage, track, and make informed decisions about your investments.
<p align="center"><a href="https://investbra.in" target="_blank"><img src="https://raw.githubusercontent.com/investbrainapp/investbrain/main/screenshot.png" width="100%" alt="Investbrain Screenshot"></a></p>
## Table of contents
- [Under the hood](#under-the-hood)
- [Install (self hosting)](#self-hosting)
- [Chat with your holdings](#chat-with-your-holdings)
- [Market data providers](#market-data-providers)
- [Import / Export](#import--export)
- [Configuration](#configuration)
- [Updating](#updating)
- [Command line utilities](#command-line-utilities)
- [Troubleshooting](#troubleshooting)
- [Testing](#testing)
## Under the hood
Investbrain is a Laravel PHP web application that leverages Livewire 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](https://finance.yahoo.com/), [Finnhub](https://finnhub.io/pricing-stock-api-market-data), and [Alpha Vantage](https://www.alphavantage.co/support/). But we also offer an extensible market data provider interface for intrepid developers to create their own! We also offer an integration with OpenAI's LLMs for our ["chat with your holdings"](#chat-with-your-holdings) capability. Finally, of course we have robust support for i18n, a11y, and dark mode.
Investbrain is a Laravel PHP web application that leverages Livewire 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](https://finance.yahoo.com/), [Finnhub](https://finnhub.io/pricing-stock-api-market-data), and [Alpha Vantage](https://www.alphavantage.co/support/). But we also offer an extensible market data provider interface for intrepid developers to create their own! We also offer integrations with OpenAI and Ollama for our ["chat with your holdings"](#chat-with-your-holdings) capability. Finally, of course we have robust support for i18n, a11y, and dark mode.
## Self hosting
For ease of installation, we _highly recommend_ installing Investbrain using the provided [Docker Compose](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file, which downloads all the necessary dependencies and seamlessly builds everything you need to get started quickly!
For ease of installation, we _highly recommend_ installing Investbrain using the provided [Docker Compose](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file, which uses the official Investbrain Docker image and includes all the necessary dependencies to seamlessly build everything you need to get started quickly!
Before getting started, you should already have the following installed on your machine: [Docker Engine](https://docs.docker.com/engine/install/), [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), and a wild sense of adventure.
Before getting started, you should already have [Docker Engine](https://docs.docker.com/engine/install/) installed on your machine.
Ready? Let's get started!
First, you can clone this repository:
**1. Copy Docker Compose file**
```bash
git clone https://github.com/investbrainapp/investbrain.git && cd investbrain
```
Grab a copy of the [docker-compose.yml](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml)** file and paste the contents into the directory where you plan to install Investbrain.
Then, build the Docker image and bring up the container (this will take a few minutes):
**2. Set your environment**
```bash
docker compose up
```
Adjust the `environment` properties in the Docker Compose file to your preferences.
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`.
_Particularly_, you need to set the `APP_KEY` value to a complex random value. If you're unsure, you can run `openssl rand -base64 32` from your terminal to generate a strong application 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:
> Tip: Want to know what options are available? You can reference the [.env.example](https://github.com/investbrainapp/investbrain/blob/main/.env.example) file in this respository for available environment configurations.
**3. Run `docker compose up`**
This might take a few minutes. But if everything worked as expected, you should now be able to access Investbrain in the browser by visiting:
```bash
http://localhost:8000/register
@@ -44,9 +64,11 @@ Congrats! You've just installed Investbrain!
Investbrain offers an AI powered chat assistant that is grounded on *your* investments. This enables you to use AI as a thought partner when making investment decisions.
When self-hosting, you can enable the chat assstant by configuring your OpenAI Secret Key and Organization ID in your [.env](https://github.com/investbrainapp/investbrain/blob/main/.env.example) file. Navigate to OpenAI to [create your keys](https://platform.openai.com/api-keys).
When self-hosting, you can enable the chat assistant by configuring your OpenAI Secret Key and Organization ID in your [.env](https://github.com/investbrainapp/investbrain/blob/main/.env.example) file. Navigate to OpenAI to [create your keys](https://platform.openai.com/api-keys).
Always keep in mind the limitations of large language models. When in doubt, consult a licensed investment advisor.
If you are self-hosting your own large language models ("LLMs") that expose an OpenAI compatible API (e.g. [Ollama](https://ollama.com/blog/openai-compatibility)), you can update the `OPENAI_BASE_URI` configuration to your self-hosted instance. Ensure you also update the `OPENAI_MODEL` to an available model.
Always keep in mind the limitations of LLMs. When in doubt, consult a licensed investment advisor.
## Market data providers
@@ -93,6 +115,18 @@ MARKET_DATA_PROVIDER=yahoo,alphavantage,custom_provider
Feel free to submit a PR with any custom providers you create.
## Import / Export
Investbrain includes a convenient feature which allows you to maintain the portability of your portfolios and transaction data.
### Import
Imports are "upserted" to the database. If the record does not already exist in the database, the record will be created. However, when a portfolio or transaction exists (i.e. the record's ID matches an existing record), the record will be updated. This way, you can simultaneously create new records, but also bulk update records.
### Export
Exporting your portfolios and transactions is a convenient way to back-up your Investbrain data. It is also a convenient way to maintain portability of *your* data.
## Configuration
There are several optional configurations available when installing using the recommended [Docker method](#self-hosting). These options are configurable using an environment file. Changes can be made in your [.env](https://github.com/investbrainapp/investbrain/blob/main/.env.example) file before installation.
@@ -101,6 +135,7 @@ There are several optional configurations available when installing using the re
| ------------- | ------------- | ------------- |
| APP_URL | The URL where your Investbrain installation will be accessible | http://localhost |
| APP_PORT | The HTTP port exposed by the NGINX container | 8000 |
| APP_KEY | Must be set during install - encryption key for various security-related functions | `null` |
| MARKET_DATA_PROVIDER | The market data provider to use (either `yahoo`, `alphavantage`, or `finnhub`) | yahoo |
| ALPHAVANTAGE_API_KEY | If using the Alpha Vantage provider | `null` |
| FINNHUB_API_KEY | If using the Finnhub provider | `null` |
@@ -109,12 +144,13 @@ There are several optional configurations available when installing using the re
| AI_CHAT_ENABLED | Whether to enable AI chat features | `false` |
| OPENAI_API_KEY | OpenAI secret key (required for AI chat) | `null` |
| OPENAI_ORGANIZATION | OpenAI org id (required for AI chat) | `null` |
| OPENAI_MODEL | The selected LLM used for AI chat | gpt-4o |
| OPENAI_BASE_URI | The URI for your self-hosted LLM | api.openai.com/v1 |
| DAILY_CHANGE_TIME | The time of day to capture daily change | 23:00 |
| REGISTRATION_ENABLED | Whether to enable registration of new users | `true` |
> Note: These options affect the [docker-compose.yml](https://github.com/investbrainapp/investbrain/blob/main/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.
> Note: These options affect the [docker-compose.yml](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file and are cached during run-time. If change any .env values, you'll have to restart the containers before your changes take effect.
## Updating
@@ -159,6 +195,31 @@ Just to be safe, we recommend backing up your portfolios before using these comm
| 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). |
## Troubleshooting
If you are facing issues with Investbrain, it can be handy to monitor the application's logs:
```bash
docker exec -it investbrain-app cat storage/logs/laravel.log
```
or you can live monitor logs using `tail`:
```bash
docker exec -it investbrain-app tail -f storage/logs/laravel.log
```
### Common issues
<details>
**<summary>Market data not refreshing on fresh install</summary>**
If you're unable to refresh market data out of the box (i.e. your market data provider is set to Yahoo), there is a chance Yahoo is being blocked by a firewall or adblocker. Pihole is known to block `fc.yahoo.com` which is the domain used to query Yahoo.
Once you whitelist `fc.yahoo.com` in pihole, your market data should begin populating!
</details>
## Testing
Investbrain has a robus 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:
@@ -185,7 +246,7 @@ We ask that you be kind and polite when interacting with the Investbrain communi
## Security Vulnerabilities
If you discover a security vulnerability within Investbrain, please create an issue in the [Github repository](https://github.com/investbrainapp/investbrain). All security vulnerabilities will be promptly addressed.
If you discover a security vulnerability within Investbrain, please submit your report via [Github](https://github.com/investbrainapp/investbrain/security/advisories/new). All security vulnerabilities will be promptly addressed. We ask that you keep any suspected vulnerabilities private and confidential until they have been appropriately addressed.
## License
+12
View File
@@ -0,0 +1,12 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.0.x | :white_check_mark: |
| < 1.0.0 | :x: |
## Reporting a Vulnerability
If you discover a security vulnerability within Investbrain, please submit your report via [Github](https://github.com/investbrainapp/investbrain/security/advisories/new). All security vulnerabilities will be promptly addressed. We ask that you keep any suspected vulnerabilities private and confidential until they have been appropriately addressed.
+11 -9
View File
@@ -27,7 +27,7 @@ class Dividend extends Model
protected $casts = [
'date' => 'datetime',
'last_date' => 'datetime',
'last_dividend_update' => 'datetime',
];
public function marketData() {
@@ -50,25 +50,29 @@ class Dividend extends Model
/**
* Grab new dividend data
*
* @param string $symbol
* @return void
*/
public static function refreshDividendData(string $symbol)
public static function refreshDividendData(string $symbol): void
{
$dividends_meta = self::where(['symbol' => $symbol])
->selectRaw('COUNT(symbol) as total_dividends')
->selectRaw('MAX(date) as last_date')
->selectRaw('MAX(created_at) as last_dividend_update')
->get()
->first();
// assume we need to populate ALL dividend data
$start_date = new \DateTime('@0');
$start_date = new Carbon('@0');
$end_date = now();
// nope, refresh forward looking only
if ( $dividends_meta->total_dividends ) {
$start_date = $dividends_meta->last_dividend_update->addHours(24);
}
// skip refresh if there's already recent data
if ($start_date->greaterThan($end_date)) {
$start_date = $dividends_meta->last_date->addHours(48);
return;
}
// get some data
@@ -99,8 +103,6 @@ class Dividend extends Model
$market_data->last_dividend_amount = $dividend_data->sortByDesc('date')->first()['dividend_amount'];
$market_data->save();
}
return $dividend_data;
}
public static function syncHoldings(string $symbol): void
+1 -1
View File
@@ -125,7 +125,7 @@ class Transaction extends Model
public function scopeBeforeDate($query, $date)
{
return $query->whereDate('date', '<', $date);
return $query->whereDate('date', '<=', $date);
}
public function scopeMyTransactions()
@@ -2,7 +2,10 @@
namespace App\Providers;
use Illuminate\Support\Arr;
use Laravel\Jetstream\Features;
use App\Actions\Jetstream\DeleteUser;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
use Laravel\Jetstream\Jetstream;
@@ -26,6 +29,13 @@ class JetstreamServiceProvider extends ServiceProvider
Jetstream::deleteUsersUsing(DeleteUser::class);
if ( config('investbrain.self_hosted', false) ) {
Config::set(
'jetstream.features',
array_keys(Arr::except(array_values(config('jetstream.features')), Features::termsAndPrivacyPolicy()))
);
}
}
/**
+1 -1
View File
@@ -50,7 +50,7 @@ class QuantityValidationRule implements ValidationRule
$maxQuantity = $purchase_qty - $sales_qty;
if ($value > $maxQuantity) {
if (round($value, 3) > round($maxQuantity, 3)) {
$fail(__('The quantity must not be greater than the available quantity.'));
}
}
+6 -3
View File
@@ -5,9 +5,12 @@
"keywords": ["stocks", "dividends", "investments", "tracking"],
"license": "CC-BY-NC 4.0",
"require": {
"php": "^8.2",
"php": "^8.3",
"ext-gd": "*",
"ext-mbstring": "*",
"ext-zip": "*",
"finnhub/client": "master@dev",
"laravel/framework": "^11.9",
"laravel/framework": "^11.35",
"laravel/jetstream": "^5.1",
"laravel/sanctum": "^4.0",
"laravel/socialite": "^5.16",
@@ -16,7 +19,7 @@
"livewire/livewire": "^3.5",
"livewire/volt": "^1.6",
"maatwebsite/excel": "^3.1",
"openai-php/laravel": "^0.10.2",
"openai-php/client": "^0.10.3",
"predis/predis": "^2.2",
"robsontenorio/mary": "^1.35",
"scheb/yahoo-finance-api": "^4.11",
Generated
+881 -673
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -13,7 +13,7 @@ return [
|
*/
'name' => env('APP_NAME', 'Laravel'),
'name' => env('APP_NAME', 'Investbrain'),
/*
|--------------------------------------------------------------------------
+1 -1
View File
@@ -143,7 +143,7 @@ return [
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
+1 -1
View File
@@ -143,7 +143,7 @@ return [
|
*/
'inject_morph_markers' => true,
'inject_morph_markers' => false,
/*
|---------------------------------------------------------------------------
+1 -1
View File
@@ -110,7 +110,7 @@ return [
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
'name' => env('MAIL_FROM_NAME', 'Investbrain'),
],
];
+1
View File
@@ -27,5 +27,6 @@ return [
'request_timeout' => env('OPENAI_REQUEST_TIMEOUT', 30),
//
'base_uri' => env('OPENAI_BASE_URI', 'api.openai.com/v1'),
'model' => env('OPENAI_MODEL', 'gpt-4o'),
];
+30 -20
View File
@@ -3,34 +3,42 @@ networks:
driver: bridge
services:
app:
build:
context: .
dockerfile: docker/Dockerfile
image: investbrainapp/investbrain:latest
container_name: investbrain-app
restart: unless-stopped
tty: true
expose:
- "9000"
volumes:
- .:/var/www/app:delegated
depends_on:
- mysql
networks:
- investbrain-network
nginx:
image: nginx:alpine
container_name: investbrain-nginx
restart: unless-stopped
tty: true
ports:
- "${APP_PORT:-8000}:80"
environment:
- APP_KEY= # Generate a key using `openssl rand -base64 32`
- APP_URL="http://localhost:8000"
- ASSET_URL="http://localhost:8000"
- DB_CONNECTION=mysql
- DB_HOST=investbrain-mysql
- DB_PORT=3306
- DB_DATABASE=investbrain
- DB_USERNAME=investbrain
- DB_PASSWORD=investbrain
- SESSION_DRIVER=redis
- QUEUE_CONNECTION=redis
- CACHE_STORE=redis
- REDIS_HOST=investbrain-redis
volumes:
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
- .:/var/www/app:delegated
- ./storage:/var/www/app/storage:delegated
depends_on:
- app
- mysql
- redis
networks:
- investbrain-network
redis:
image: redis:alpine
container_name: investbrain-redis
restart: unless-stopped
tty: true
networks:
- investbrain-network
volumes:
- investbrain-redis:/data
mysql:
image: mysql:8.0
container_name: investbrain-mysql
@@ -40,10 +48,12 @@ services:
MYSQL_USER: ${DB_USERNAME:-investbrain}
MYSQL_PASSWORD: ${DB_PASSWORD:-investbrain}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-investbrain}
command:
- --cte-max-recursion-depth=25000
volumes:
- ./docker/mysql.conf:/etc/mysql/conf.d/my.cnf
- investbrain-mysql:/var/lib/mysql
networks:
- investbrain-network
volumes:
investbrain-redis:
investbrain-mysql:
-1
View File
@@ -1 +0,0 @@
dump.rdb
+47 -29
View File
@@ -1,6 +1,10 @@
FROM php:8.3-fpm
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
ENV APP_NAME=Investbrain
ENV VITE_APP_NAME=Investbrain
ENV APP_DEBUG=true
ENV SELF_HOSTED=true
# Set the working directory
COPY . /var/www/app
@@ -8,40 +12,54 @@ WORKDIR /var/www/app
# Install common php extension dependencies
RUN apt-get update && apt-get install -y \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev \
zlib1g-dev \
libzip-dev \
unzip \
libicu-dev \
git \
curl \
redis \
supervisor \
nginx \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev \
zlib1g-dev \
libzip-dev \
libicu-dev \
libpq-dev \
supervisor \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
gd \
zip \
pdo_mysql \
mysqli \
intl
gd pgsql bcmath zip pdo_mysql mysqli intl \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Node.js and npm
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest
# Set permissions
RUN chown -R www-data:www-data . \
&& chmod -R 775 ./storage \
&& chmod +x ./docker/entrypoint.sh \
&& usermod -s /bin/bash www-data
# Copy over supervisor configuration
# Install Composer and Node.js
RUN apt-get update && apt-get install -y \
curl \
unzip \
git \
nodejs \
npm \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install PHP dependencies and build front end assets
RUN composer install --no-scripts --optimize-autoloader \
&& npm install && npm run build
# Remove default nginx config
RUN rm /etc/nginx/sites-enabled/default
# Copy over configs
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Update permissions
RUN chown -R www-data:www-data . \
&& chmod -R 775 ./storage \
&& chmod +x ./docker/entrypoint.sh
# Serve on port 80
EXPOSE 80
# install composer
COPY --from=composer:2.6.5 /usr/bin/composer /usr/local/bin/composer
# Set up healthcheck
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost || exit 1
# Run everything else
CMD ["./docker/entrypoint.sh"]
ENTRYPOINT ["/bin/bash", "./docker/entrypoint.sh"]
Executable → Regular
+44 -31
View File
@@ -2,43 +2,56 @@
cd /var/www/app
echo "====================== Running entrypoint script... ====================== "
if [ ! -f ".env" ]; then
echo " > Ope, gotta create an .env file!"
echo -e "\n====================== Validating environment... ====================== "
if [[ -z "$APP_KEY" ]]; then
echo -e "\n > Oops! The required APP_KEY configuration is missing in your environment! "
echo -e "\n > Generating a key (see below) but this will NOT be persisted between container restarts. "
echo -e "\n > You should set this APP_KEY in your .env file! "
cp .env.example .env
draw_box() {
local text="$1"
local length=${#text}
local border=$(printf '%*s' "$((length + 4))" | tr ' ' '*')
echo -e "\n\n$border"
echo "* $text *"
echo "$border"
}
export APP_KEY=base64:$(openssl rand -base64 32)
draw_box $APP_KEY
fi
echo "====================== Checking for updates... ====================== "
/usr/bin/git pull
echo "====================== Installing Composer dependencies... ====================== "
/usr/local/bin/composer install
echo "====================== Validating environment... ====================== "
if [ $(stat -c '%U' .) != "www-data" ]; then
echo " > Setting correct permissions for pwd..."
chown -R www-data:www-data .
fi
if ( ! grep -q "^APP_KEY=" ".env" || grep -q "^APP_KEY=$" ".env"); then
echo " > Ah, APP_KEY is missing in .env file. Generating a new key!"
/usr/local/bin/php artisan key:generate --force
fi
for dir in storage/framework/cache storage/framework/sessions storage/framework/views; do
if [ ! -d "$dir" ]; then
echo -e "\n > $dir is missing. Creating scaffold for storage directory... "
mkdir -p storage/framework/{cache,sessions,views}
chmod -R 775 storage
chown -R www-data:www-data storage
fi
done
if [ ! -L "public/storage" ]; then
echo " > Creating symbolic link for app public storage..."
echo -e "\n > Creating symbolic link for app public storage... "
/usr/local/bin/php artisan storage:link
/usr/local/bin/php /var/www/app/artisan storage:link
fi
echo "====================== Installing NPM dependencies and building frontend... ====================== "
/usr/bin/npm install
/usr/bin/npm run build
echo -e "\n====================== Running migrations... ====================== "
run_migrations() {
/usr/local/bin/php /var/www/app/artisan migrate --force
}
RETRIES=10
DELAY=5
until run_migrations; do
RETRIES=$((RETRIES-1))
if [ $RETRIES -le 0 ]; then
echo -e "\n > Database is not ready after $RETRIES attempts. Exiting... "
exit 1
fi
echo -e "\n > Waiting for database to be ready... retrying in $DELAY seconds. "
sleep $DELAY
done
echo "====================== Running migrations... ====================== "
/usr/local/bin/php artisan migrate --force
echo "====================== Spinning up Supervisor daemon... ====================== "
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
echo -e "\n====================== Spinning up Supervisor daemon... ====================== \n"
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
-2
View File
@@ -1,2 +0,0 @@
[mysqld]
cte_max_recursion_depth = 25000
+1 -1
View File
@@ -14,7 +14,7 @@ server {
fastcgi_param HTTPS $http_x_forwarded_proto;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass investbrain-app:9000;
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
-2
View File
@@ -1,2 +0,0 @@
# Redis RDB and AOF file location
dir /var/www/app/docker
+11 -18
View File
@@ -1,41 +1,34 @@
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
[program:nginx]
command=nginx -g 'daemon off;'
autostart=true
autorestart=true
redirect_stderr=true
redirect_stdout=true
[program:php]
command=php-fpm -F
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/php.log
stderr_logfile=/var/log/supervisor/php_error.log
[program:redis]
command=redis-server /var/www/app/docker/redis.conf
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/redis.log
stderr_logfile=/var/log/supervisor/redis_error.log
redirect_stderr=true
redirect_stdout=true
[program:scheduler]
command=php artisan schedule:work
autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
redirect_stdout=true
[program:queue-worker]
command=php artisan queue:work --sleep=3 --tries=1 --memory=256 --timeout=3600
process_name=%(program_name)s_%(process_num)02d
autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
redirect_stdout=true
numprocs=2
[supervisorctl]
+494 -253
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -9,12 +9,12 @@
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"autoprefixer": "^10.4.19",
"axios": "^1.6.4",
"axios": "^1.7.4",
"daisyui": "^4.12.10",
"laravel-vite-plugin": "^1.0",
"postcss": "^8.4.40",
"tailwindcss": "^3.4.7",
"vite": "^5.0"
"vite": "^5.4"
},
"dependencies": {
"apexcharts": "^3.51.0"
+3 -1
View File
@@ -63,7 +63,9 @@
<x-ib-card title="{{ __('Recent activity') }}" class="md:col-span-3">
@livewire('transactions-list', [
'transactions' => $user->transactions
'transactions' => $user->transactions,
'showPortfolio' => true,
'paginate' => false
])
</x-ib-card>
+1 -1
View File
@@ -207,7 +207,7 @@
* 52 week high: {$holding->market_data->fifty_two_week_high}
* Dividend yield: {$holding->market_data->dividend_yield}
Based on this current market data, quantity owned, and average cost basis, you should determine if the {$holding->symbol} holding is making or losing money.
This data is current as of today's date: " . now()->format('Y-m-d') . ". Based on this current market data, quantity owned, and average cost basis, you should determine if the {$holding->symbol} holding is making or losing money.
Below is the question from the investor. Considering these facts, provide a concise response to the following question (give a direct response). Limit your response to no more than 75 words and consider using a common decision framework. Use github style markdown for any formatting:"
])
@@ -5,7 +5,7 @@ use App\Models\AiChat;
use App\Models\Holding;
use Illuminate\Database\Eloquent\Model;
use Livewire\Volt\Component;
use OpenAI\Laravel\Facades\OpenAI;
use OpenAI\Factory;
use OpenAI\Responses\StreamResponse;
new class extends Component {
@@ -67,7 +67,9 @@ new class extends Component {
{
try {
$stream = OpenAI::chat()->createStreamed([
$client = $this->createOpenAiClient();
$stream = $client->chat()->createStreamed([
'model' => config('openai.model'),
'messages' => [
['role' => 'system', 'content' => "Today's date is "
@@ -104,7 +106,9 @@ new class extends Component {
public function generateSuggestedPrompts(): void
{
try {
$suggested_prompts = OpenAI::chat()->create([
$client = $this->createOpenAiClient();
$suggested_prompts = $client->chat()->create([
'model' => config('openai.model'),
'response_format' => [
'type' => 'json_schema',
@@ -192,6 +196,21 @@ new class extends Component {
return false;
}
private function createOpenAiClient()
{
$apiKey = config('openai.api_key');
$organization = config('openai.organization');
$baseUri = config('openai.base_uri');
return OpenAI::factory()
->withApiKey($apiKey)
->withOrganization($organization)
->withHttpHeader('OpenAI-Beta', 'assistants=v2')
->withHttpClient(new \GuzzleHttp\Client(['timeout' => config('openai.request_timeout', 30)]))
->withBaseUri($baseUri)
->make();
}
}; ?>
<div
@@ -36,7 +36,7 @@ new class extends Component {
'symbol' => ['required', 'string', new SymbolValidationRule],
'transaction_type' => 'required|string|in:BUY,SELL',
'portfolio_id' => 'required|exists:portfolios,id',
'date' => 'required|date_format:Y-m-d',
'date' => ['required', 'date_format:Y-m-d', 'before_or_equal:' . now()->format('Y-m-d')],
'quantity' => [
'required',
'numeric',
@@ -15,6 +15,10 @@ new class extends Component {
public ?Portfolio $portfolio;
public ?Transaction $editingTransaction;
public Bool $shouldGoToHolding = true;
public Bool $showPortfolio = false;
public Bool $paginate = true;
public Int $perPage = 5;
public Int $offset = 0;
protected $listeners = [
'transaction-updated' => '$refresh',
@@ -38,17 +42,23 @@ new class extends Component {
return $this->redirect(route('holding.show', ['portfolio' => $holding['portfolio_id'], 'symbol' => $holding['symbol']]));
}
public function updateOffset($amount = 0)
{
$this->offset = $this->offset + $amount;
}
}; ?>
<div class="">
@foreach($transactions->sortByDesc('date')->take(10) as $transaction)
@foreach($transactions->sortByDesc('date')->slice($offset)->take($perPage) as $transaction)
<x-list-item
no-separator
:item="$transaction"
class="cursor-pointer"
x-data="{ loading: false, timeout: null }"
:key="$transaction->id"
@click="
if ($wire.shouldGoToHolding) {
@@ -83,12 +93,44 @@ new class extends Component {
<x-loading x-show="loading" x-cloak class="text-gray-400 ml-2" />
</x-slot:value>
<x-slot:sub-value>
@if($showPortfolio)
<span title="{{ __('Portfolio') }}">{{ $transaction->portfolio->title }} </span>
&middot;
@endif
<span title="{{ __('Transaction Date') }}">{{ $transaction->date->format('F j, Y') }} </span>
</x-slot:sub-value>
</x-list-item>
@endforeach
@if ($paginate && count($transactions) > $perPage)
<div class="flex justify-between">
<span>
@if($offset > 0)
<x-button
class="btn btn-sm btn-ghost text-secondary"
wire:click="updateOffset(-{{ $perPage }})"
>
{!! __('pagination.previous') !!}
</x-button>
@endif
</span>
<span>
@if(count($transactions) - $offset > $offset)
<x-button
class="btn btn-sm btn-ghost text-secondary"
wire:click="updateOffset({{ $perPage }})"
>
{!! __('pagination.next') !!}
</x-button>
@endif
</span>
</div>
@endif
<x-ib-alpine-modal
key="manage-transaction"
title="{{ __('Manage Transaction') }}"
@@ -96,7 +138,7 @@ new class extends Component {
@livewire('manage-transaction-form', [
'portfolio' => $portfolio,
'transaction' => $editingTransaction,
], key($editingTransaction->id ?? 'new'))
], key($editingTransaction?->id.rand()))
</x-ib-alpine-modal>
</div>
+1 -1
View File
@@ -173,7 +173,7 @@
{$formattedHoldings}
Based on the current market data, quantity owned, and average cost basis, you can determine the performance of any holding.
This data is current as of today's date: " . now()->format('Y-m-d') . ". Based on the current market data, quantity owned, and average cost basis, you can determine the performance of any holding.
Below is the question from the investor. Considering these facts, provide a concise response to the following question (give a direct response). Limit your response to no more than 75 words and consider using a common decision framework. Use github style markdown for any formatting:"
])
+2 -2
View File
@@ -8,7 +8,7 @@ use App\Console\Commands\{RefreshMarketData, CaptureDailyChange, RefreshDividend
* This scheduled job refreshes market data from your selected data provider
* Update the cadence with the MARKET_DATA_REFRESH key in your env file
*/
Schedule::command(RefreshMarketData::class)->everyMinute()->weekdays();
Schedule::command(RefreshMarketData::class)->weekdays()->everyMinute();
/**
*
@@ -20,7 +20,7 @@ Schedule::command(CaptureDailyChange::class)->dailyAt(config('investbrain.daily_
*
* Refreshes dividend data for your holdings (and syncs new dividends to holdings)
*/
Schedule::command(RefreshDividendData::class)->days([1, 3, 5])->weekdays();
Schedule::command(RefreshDividendData::class)->daily()->days([1, 3, 5]);
/**
*
+22
View File
@@ -61,4 +61,26 @@ class DividendsTest extends TestCase
$this->assertCount(3, $transactions);
$this->assertEqualsWithDelta(4.95, $dividendsReinvested * $market_data->market_value, 0.01);
}
/**
*/
public function test_do_not_duplicate_recent_dividends(): void
{
$this->actingAs($user = User::factory()->create());
$portfolio = Portfolio::factory()->create();
Transaction::factory()->buy()->yearsAgo()->portfolio($portfolio->id)->symbol('ACME')->create();
$holding = Holding::query()->portfolio($portfolio->id)->symbol('ACME')->first();
Dividend::create([
'symbol' => 'ACME',
'date' => now()->subDay(2),
'dividend_amount' => .01
]);
Dividend::refreshDividendData('ACME');
$this->assertCount(1, $holding->dividends);
}
}