Compare commits
75 Commits
Author | SHA1 | Date | |
---|---|---|---|
420f331be9 | |||
e0068c4d5d | |||
85661884a6 | |||
8f6203d296 | |||
2fa723dc3c | |||
a500fb72c5 | |||
02db0db733 | |||
c87b08ca8b | |||
fcc2ab1a48 | |||
7efda2f890 | |||
3794a61d2d | |||
c1d1ea9dde | |||
0d676a46c8 | |||
97db144e01 | |||
cec55127c8 | |||
f3f359bcfb | |||
601e6f4147 | |||
e228b4925c | |||
62e3ffe413 | |||
6af885fde0 | |||
dd15bba359 | |||
43fca7ff43 | |||
faa6af5694 | |||
d2ea7a0bfb | |||
3f6319e00b | |||
5601299648 | |||
6060c7cfe0 | |||
ba78c2783d | |||
48eee5f865 | |||
f4a8acdb46 | |||
1d6ba22598 | |||
e38be8d710 | |||
da5be3fb57 | |||
b5317a7f95 | |||
43afb16808 | |||
d5c56fb16c | |||
b94c1f280b | |||
acc59866a3 | |||
c9fc3e402d | |||
6c1317f978 | |||
89be438e66 | |||
9d6214e93a | |||
0640b24290 | |||
6eb9d9d973 | |||
9ecc3176a5 | |||
96434c5a54 | |||
4063c62a17 | |||
890c5b986c | |||
423bd92b89 | |||
5dc331e386 | |||
744dc51dcd | |||
b0c53d050a | |||
830569b38e | |||
35b4aef06f | |||
bc2fd9c970 | |||
c42a8aebed | |||
fad1adb91b | |||
9cd37f8de0 | |||
d49b90d7a5 | |||
130a9ea062 | |||
ffc6309850 | |||
976cc7f243 | |||
7067aca04b | |||
1c9805bb96 | |||
8227a2d91a | |||
194aee97db | |||
0f77169952 | |||
0f8dc62c53 | |||
554136cdcd | |||
83b5cfff1f | |||
dcec3accf0 | |||
f08b0b570b | |||
8386fec98a | |||
4d3dff3e5b | |||
76890e63fa |
12
.github/workflows/build-code.yml
vendored
12
.github/workflows/build-code.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node_version:
|
node_version:
|
||||||
- 18
|
- 20
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -24,16 +24,16 @@ jobs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node_version }}
|
node-version: ${{ matrix.node_version }}
|
||||||
cache: 'yarn'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --frozen-lockfile
|
run: npm ci
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: yarn format:check
|
run: npm run format:check
|
||||||
|
|
||||||
- name: Execute tests
|
- name: Execute tests
|
||||||
run: yarn test
|
run: npm test
|
||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
run: yarn build:production
|
run: npm run build:production
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,8 +5,8 @@
|
|||||||
/tmp
|
/tmp
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/.yarn
|
|
||||||
/node_modules
|
/node_modules
|
||||||
|
npm-debug.log
|
||||||
|
|
||||||
# IDEs and editors
|
# IDEs and editors
|
||||||
/.idea
|
/.idea
|
||||||
@ -34,10 +34,8 @@
|
|||||||
/coverage
|
/coverage
|
||||||
/dist
|
/dist
|
||||||
/libpeerconnection.log
|
/libpeerconnection.log
|
||||||
npm-debug.log
|
|
||||||
testem.log
|
testem.log
|
||||||
/typings
|
/typings
|
||||||
yarn-error.log
|
|
||||||
|
|
||||||
# System Files
|
# System Files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
134
CHANGELOG.md
134
CHANGELOG.md
@ -5,6 +5,138 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## 2.101.0 - 2024-08-03
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Hardened container security by switching to a non-root user, setting the filesystem to read-only, and dropping unnecessary capabilities
|
||||||
|
|
||||||
|
## 2.100.0 - 2024-08-03
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added support to manage tags of holdings in the holding detail dialog
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the color assignment in the chart of the holdings tab on the home page (experimental)
|
||||||
|
- Persisted the view mode of the holdings tab on the home page (experimental)
|
||||||
|
- Improved the language localization for Catalan (`ca`)
|
||||||
|
- Improved the language localization for Spanish (`es`)
|
||||||
|
|
||||||
|
## 2.99.0 - 2024-07-29
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Migrated the usage of `yarn` to `npm`
|
||||||
|
- Upgraded `storybook` from version `7.0.9` to `8.2.5`
|
||||||
|
- Downgraded `marked` from version `13.0.0` to `12.0.2`
|
||||||
|
|
||||||
|
## 2.98.0 - 2024-07-27
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Set up the language localization for Catalan (`ca`)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the account selector of the create or update activity dialog
|
||||||
|
- Improved the handling of the numerical precision in the value component
|
||||||
|
- Skipped derived currencies in the get quotes functionality of the data provider service
|
||||||
|
- Improved the language localization for Spanish (`es`)
|
||||||
|
- Upgraded `angular` from version `18.0.4` to `18.1.1`
|
||||||
|
- Upgraded `Nx` from version `19.4.3` to `19.5.1`
|
||||||
|
- Upgraded `prisma` from version `5.16.1` to `5.17.0`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the dividend import from a data provider for holdings without an account
|
||||||
|
- Fixed an issue in the public page related to a non-existent access
|
||||||
|
|
||||||
|
## 2.97.0 - 2024-07-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added _selfh.st_ to the _As seen in_ section on the landing page
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the numerical precision in the holding detail dialog
|
||||||
|
- Improved the handling of the numerical precision in the value component
|
||||||
|
- Optimized the 7d data gathering by prioritizing the currencies
|
||||||
|
- Improved the language localization for German (`de`)
|
||||||
|
- Upgraded `Node.js` from version `18` to `20` (`Dockerfile`)
|
||||||
|
- Upgraded `Nx` from version `19.4.0` to `19.4.3`
|
||||||
|
- Upgraded `prettier` from version `3.3.1` to `3.3.3`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the table sorting of the holdings tab on the home page
|
||||||
|
|
||||||
|
## 2.96.0 - 2024-07-13
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the chart of the holdings tab on the home page (experimental)
|
||||||
|
- Separated the icon purposes in the `site.webmanifest`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue in the portfolio summary with the currency conversion of fees
|
||||||
|
- Fixed an issue in the the search for a holding
|
||||||
|
- Removed the show condition of the experimental features setting in the user settings
|
||||||
|
|
||||||
|
## 2.95.0 - 2024-07-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a chart to the holdings tab of the home page (experimental)
|
||||||
|
|
||||||
|
## 2.94.0 - 2024-07-09
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the language localization for German (`de`)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed a pagination issue in the activities endpoint by adding `id` as a secondary sort criterion to `date` to ensure consistent ordering
|
||||||
|
|
||||||
|
## 2.93.0 - 2024-07-07
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added the _Crypto Coins Heatmap_ to the resources section
|
||||||
|
- Added the _Stock Heatmap_ to the resources section
|
||||||
|
- Extended the content of the _Self-Hosting_ section by the platforms concept on the Frequently Asked Questions (FAQ) page
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the allocations by ETF holding on the allocations page for the impersonation mode (experimental)
|
||||||
|
- Improved the detection of REST APIs (`JSON`) used via the scraper configuration
|
||||||
|
- Improved the usability to delete an asset profile of type currency in the historical market data table and the asset profile details dialog of the admin control
|
||||||
|
- Refreshed the cryptocurrencies list
|
||||||
|
- Refactored the thresholds of the rules in the _X-ray_ section
|
||||||
|
- Removed the obsolete `version` from the `docker-compose` files
|
||||||
|
- Upgraded `Nx` from version `19.2.2` to `19.4.0`
|
||||||
|
|
||||||
|
## 2.92.0 - 2024-06-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added support for bulk deletion of asset profiles from the market data table in the admin control panel
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Added support for derived currencies in the currency validation
|
||||||
|
- Added support for automatic deletion of unused asset profiles when deleting activities
|
||||||
|
- Improved the caching of the benchmarks in the markets overview (only cache if needed)
|
||||||
|
- Upgraded `prisma` from version `5.15.0` to `5.16.1`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue with the all time high in the benchmarks of the markets overview
|
||||||
|
|
||||||
## 2.91.0 - 2024-06-26
|
## 2.91.0 - 2024-06-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -4748,7 +4880,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Added the attribute `precision` in the value component
|
- Added the attribute `precision` to the value component
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Remove permission in `UserService` using `without()`
|
|||||||
|
|
||||||
### Frontend
|
### Frontend
|
||||||
|
|
||||||
Use `*ngIf="user?.settings?.isExperimentalFeatures"` in HTML template
|
Use `@if (user?.settings?.isExperimentalFeatures) {}` in HTML template
|
||||||
|
|
||||||
## Git
|
## Git
|
||||||
|
|
||||||
@ -30,26 +30,26 @@ Use `*ngIf="user?.settings?.isExperimentalFeatures"` in HTML template
|
|||||||
|
|
||||||
#### Upgrade
|
#### Upgrade
|
||||||
|
|
||||||
1. Run `yarn nx migrate latest`
|
1. Run `npx nx migrate latest`
|
||||||
1. Make sure `package.json` changes make sense and then run `yarn install`
|
1. Make sure `package.json` changes make sense and then run `npm install`
|
||||||
1. Run `yarn nx migrate --run-migrations` (Run `YARN_NODE_LINKER="node-modules" NX_MIGRATE_SKIP_INSTALL=1 yarn nx migrate --run-migrations` due to https://github.com/nrwl/nx/issues/16338)
|
1. Run `npx nx migrate --run-migrations`
|
||||||
|
|
||||||
### Prisma
|
### Prisma
|
||||||
|
|
||||||
#### Access database via GUI
|
#### Access database via GUI
|
||||||
|
|
||||||
Run `yarn database:gui`
|
Run `npm run database:gui`
|
||||||
|
|
||||||
https://www.prisma.io/studio
|
https://www.prisma.io/studio
|
||||||
|
|
||||||
#### Synchronize schema with database for prototyping
|
#### Synchronize schema with database for prototyping
|
||||||
|
|
||||||
Run `yarn database:push`
|
Run `npm run database:push`
|
||||||
|
|
||||||
https://www.prisma.io/docs/concepts/components/prisma-migrate/db-push
|
https://www.prisma.io/docs/concepts/components/prisma-migrate/db-push
|
||||||
|
|
||||||
#### Create schema migration
|
#### Create schema migration
|
||||||
|
|
||||||
Run `yarn prisma migrate dev --name added_job_title`
|
Run `npm run prisma migrate dev --name added_job_title`
|
||||||
|
|
||||||
https://www.prisma.io/docs/concepts/components/prisma-migrate#getting-started-with-prisma-migrate
|
https://www.prisma.io/docs/concepts/components/prisma-migrate#getting-started-with-prisma-migrate
|
||||||
|
45
Dockerfile
45
Dockerfile
@ -1,4 +1,4 @@
|
|||||||
FROM --platform=$BUILDPLATFORM node:18-slim as builder
|
FROM --platform=$BUILDPLATFORM node:20-slim AS builder
|
||||||
|
|
||||||
# Build application and add additional files
|
# Build application and add additional files
|
||||||
WORKDIR /ghostfolio
|
WORKDIR /ghostfolio
|
||||||
@ -8,18 +8,17 @@ WORKDIR /ghostfolio
|
|||||||
COPY ./CHANGELOG.md CHANGELOG.md
|
COPY ./CHANGELOG.md CHANGELOG.md
|
||||||
COPY ./LICENSE LICENSE
|
COPY ./LICENSE LICENSE
|
||||||
COPY ./package.json package.json
|
COPY ./package.json package.json
|
||||||
COPY ./yarn.lock yarn.lock
|
COPY ./package-lock.json package-lock.json
|
||||||
COPY ./.yarnrc .yarnrc
|
|
||||||
COPY ./prisma/schema.prisma prisma/schema.prisma
|
COPY ./prisma/schema.prisma prisma/schema.prisma
|
||||||
|
|
||||||
RUN apt update && apt install -y \
|
RUN apt-get update && apt-get install -y --no-install-suggests \
|
||||||
g++ \
|
g++ \
|
||||||
git \
|
git \
|
||||||
make \
|
make \
|
||||||
openssl \
|
openssl \
|
||||||
python3 \
|
python3 \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
RUN yarn install
|
RUN npm install
|
||||||
|
|
||||||
# See https://github.com/nrwl/nx/issues/6586 for further details
|
# See https://github.com/nrwl/nx/issues/6586 for further details
|
||||||
COPY ./decorate-angular-cli.js decorate-angular-cli.js
|
COPY ./decorate-angular-cli.js decorate-angular-cli.js
|
||||||
@ -33,34 +32,36 @@ COPY ./tsconfig.base.json tsconfig.base.json
|
|||||||
COPY ./libs libs
|
COPY ./libs libs
|
||||||
COPY ./apps apps
|
COPY ./apps apps
|
||||||
|
|
||||||
RUN yarn build:production
|
RUN npm run build:production
|
||||||
|
|
||||||
# Prepare the dist image with additional node_modules
|
# Prepare the dist image with additional node_modules
|
||||||
WORKDIR /ghostfolio/dist/apps/api
|
WORKDIR /ghostfolio/dist/apps/api
|
||||||
# package.json was generated by the build process, however the original
|
# package.json was generated by the build process, however the original
|
||||||
# yarn.lock needs to be used to ensure the same versions
|
# package-lock.json needs to be used to ensure the same versions
|
||||||
COPY ./yarn.lock /ghostfolio/dist/apps/api/yarn.lock
|
COPY ./package-lock.json /ghostfolio/dist/apps/api/package-lock.json
|
||||||
|
|
||||||
RUN yarn
|
RUN npm install
|
||||||
COPY prisma /ghostfolio/dist/apps/api/prisma
|
COPY prisma /ghostfolio/dist/apps/api/prisma
|
||||||
|
|
||||||
# Overwrite the generated package.json with the original one to ensure having
|
# Overwrite the generated package.json with the original one to ensure having
|
||||||
# all the scripts
|
# all the scripts
|
||||||
COPY package.json /ghostfolio/dist/apps/api
|
COPY package.json /ghostfolio/dist/apps/api
|
||||||
RUN yarn database:generate-typings
|
RUN npm run database:generate-typings
|
||||||
|
|
||||||
# Image to run, copy everything needed from builder
|
# Image to run, copy everything needed from builder
|
||||||
FROM node:18-slim
|
FROM node:20-slim
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/ghostfolio/ghostfolio"
|
LABEL org.opencontainers.image.source="https://github.com/ghostfolio/ghostfolio"
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
RUN apt update && apt install -y \
|
RUN apt-get update && apt-get install -y --no-install-suggests \
|
||||||
curl \
|
curl \
|
||||||
openssl \
|
openssl \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY --from=builder /ghostfolio/dist/apps /ghostfolio/apps
|
COPY --from=builder /ghostfolio/dist/apps /ghostfolio/apps
|
||||||
COPY ./docker/entrypoint.sh /ghostfolio/entrypoint.sh
|
COPY ./docker/entrypoint.sh /ghostfolio/entrypoint.sh
|
||||||
|
RUN chown -R node:node /ghostfolio
|
||||||
WORKDIR /ghostfolio/apps/api
|
WORKDIR /ghostfolio/apps/api
|
||||||
EXPOSE ${PORT:-3333}
|
EXPOSE ${PORT:-3333}
|
||||||
|
USER node
|
||||||
CMD [ "/ghostfolio/entrypoint.sh" ]
|
CMD [ "/ghostfolio/entrypoint.sh" ]
|
||||||
|
79
README.md
79
README.md
@ -7,7 +7,7 @@
|
|||||||
**Open Source Wealth Management Software**
|
**Open Source Wealth Management Software**
|
||||||
|
|
||||||
[**Ghostfol.io**](https://ghostfol.io) | [**Live Demo**](https://ghostfol.io/en/demo) | [**Ghostfolio Premium**](https://ghostfol.io/en/pricing) | [**FAQ**](https://ghostfol.io/en/faq) |
|
[**Ghostfol.io**](https://ghostfol.io) | [**Live Demo**](https://ghostfol.io/en/demo) | [**Ghostfolio Premium**](https://ghostfol.io/en/pricing) | [**FAQ**](https://ghostfol.io/en/faq) |
|
||||||
[**Blog**](https://ghostfol.io/en/blog) | [**Slack**](https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg) | [**X**](https://twitter.com/ghostfolio_)
|
[**Blog**](https://ghostfol.io/en/blog) | [**Slack**](https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg) | [**X**](https://x.com/ghostfolio_)
|
||||||
|
|
||||||
[](https://www.buymeacoffee.com/ghostfolio)
|
[](https://www.buymeacoffee.com/ghostfolio)
|
||||||
[](#contributing)
|
[](#contributing)
|
||||||
@ -47,7 +47,7 @@ Ghostfolio is for you if you are...
|
|||||||
|
|
||||||
- ✅ Create, update and delete transactions
|
- ✅ Create, update and delete transactions
|
||||||
- ✅ Multi account management
|
- ✅ Multi account management
|
||||||
- ✅ Portfolio performance: Time-weighted rate of return (TWR) for `Today`, `YTD`, `1Y`, `5Y`, `Max`
|
- ✅ Portfolio performance: Time-weighted rate of return (TWR) for `Today`, `WTD`, `MTD`, `YTD`, `1Y`, `5Y`, `Max`
|
||||||
- ✅ Various charts
|
- ✅ Various charts
|
||||||
- ✅ Static analysis to identify potential risks in your portfolio
|
- ✅ Static analysis to identify potential risks in your portfolio
|
||||||
- ✅ Import and export transactions
|
- ✅ Import and export transactions
|
||||||
@ -87,21 +87,21 @@ We provide official container images hosted on [Docker Hub](https://hub.docker.c
|
|||||||
|
|
||||||
| Name | Type | Default Value | Description |
|
| Name | Type | Default Value | Description |
|
||||||
| ------------------------ | ------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------ | ------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `ACCESS_TOKEN_SALT` | string | | A random string used as salt for access tokens |
|
| `ACCESS_TOKEN_SALT` | `string` | | A random string used as salt for access tokens |
|
||||||
| `API_KEY_COINGECKO_DEMO` | string (`optional`) | | The _CoinGecko_ Demo API key |
|
| `API_KEY_COINGECKO_DEMO` | `string` (optional) | | The _CoinGecko_ Demo API key |
|
||||||
| `API_KEY_COINGECKO_PRO` | string (`optional`) | | The _CoinGecko_ Pro API |
|
| `API_KEY_COINGECKO_PRO` | `string` (optional) | | The _CoinGecko_ Pro API key |
|
||||||
| `DATABASE_URL` | string | | The database connection URL, e.g. `postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?sslmode=prefer` |
|
| `DATABASE_URL` | `string` | | The database connection URL, e.g. `postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?sslmode=prefer` |
|
||||||
| `HOST` | string (`optional`) | `0.0.0.0` | The host where the Ghostfolio application will run on |
|
| `HOST` | `string` (optional) | `0.0.0.0` | The host where the Ghostfolio application will run on |
|
||||||
| `JWT_SECRET_KEY` | string | | A random string used for _JSON Web Tokens_ (JWT) |
|
| `JWT_SECRET_KEY` | `string` | | A random string used for _JSON Web Tokens_ (JWT) |
|
||||||
| `PORT` | number (`optional`) | `3333` | The port where the Ghostfolio application will run on |
|
| `PORT` | `number` (optional) | `3333` | The port where the Ghostfolio application will run on |
|
||||||
| `POSTGRES_DB` | string | | The name of the _PostgreSQL_ database |
|
| `POSTGRES_DB` | `string` | | The name of the _PostgreSQL_ database |
|
||||||
| `POSTGRES_PASSWORD` | string | | The password of the _PostgreSQL_ database |
|
| `POSTGRES_PASSWORD` | `string` | | The password of the _PostgreSQL_ database |
|
||||||
| `POSTGRES_USER` | string | | The user of the _PostgreSQL_ database |
|
| `POSTGRES_USER` | `string` | | The user of the _PostgreSQL_ database |
|
||||||
| `REDIS_DB` | number (`optional`) | `0` | The database index of _Redis_ |
|
| `REDIS_DB` | `number` (optional) | `0` | The database index of _Redis_ |
|
||||||
| `REDIS_HOST` | string | | The host where _Redis_ is running |
|
| `REDIS_HOST` | `string` | | The host where _Redis_ is running |
|
||||||
| `REDIS_PASSWORD` | string | | The password of _Redis_ |
|
| `REDIS_PASSWORD` | `string` | | The password of _Redis_ |
|
||||||
| `REDIS_PORT` | number | | The port where _Redis_ is running |
|
| `REDIS_PORT` | `number` | | The port where _Redis_ is running |
|
||||||
| `REQUEST_TIMEOUT` | number (`optional`) | `2000` | The timeout of network requests to data providers in milliseconds |
|
| `REQUEST_TIMEOUT` | `number` (optional) | `2000` | The timeout of network requests to data providers in milliseconds |
|
||||||
|
|
||||||
### Run with Docker Compose
|
### Run with Docker Compose
|
||||||
|
|
||||||
@ -149,16 +149,15 @@ Ghostfolio is available for various home server systems, including [CasaOS](http
|
|||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- [Docker](https://www.docker.com/products/docker-desktop)
|
- [Docker](https://www.docker.com/products/docker-desktop)
|
||||||
- [Node.js](https://nodejs.org/en/download) (version 18+)
|
- [Node.js](https://nodejs.org/en/download) (version 20+)
|
||||||
- [Yarn](https://yarnpkg.com/en/docs/install)
|
|
||||||
- Create a local copy of this Git repository (clone)
|
- Create a local copy of this Git repository (clone)
|
||||||
- Copy the file `.env.dev` to `.env` and populate it with your data (`cp .env.dev .env`)
|
- Copy the file `.env.dev` to `.env` and populate it with your data (`cp .env.dev .env`)
|
||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
|
|
||||||
1. Run `yarn install`
|
1. Run `npm install`
|
||||||
1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)
|
1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)
|
||||||
1. Run `yarn database:setup` to initialize the database schema
|
1. Run `npm run database:setup` to initialize the database schema
|
||||||
1. Run `git config core.hooksPath ./git-hooks/` to setup git hooks
|
1. Run `git config core.hooksPath ./git-hooks/` to setup git hooks
|
||||||
1. Start the server and the client (see [_Development_](#Development))
|
1. Start the server and the client (see [_Development_](#Development))
|
||||||
1. Open https://localhost:4200/en in your browser
|
1. Open https://localhost:4200/en in your browser
|
||||||
@ -168,31 +167,31 @@ Ghostfolio is available for various home server systems, including [CasaOS](http
|
|||||||
|
|
||||||
#### Debug
|
#### Debug
|
||||||
|
|
||||||
Run `yarn watch:server` and click _Debug API_ in [Visual Studio Code](https://code.visualstudio.com)
|
Run `npm run watch:server` and click _Debug API_ in [Visual Studio Code](https://code.visualstudio.com)
|
||||||
|
|
||||||
#### Serve
|
#### Serve
|
||||||
|
|
||||||
Run `yarn start:server`
|
Run `npm run start:server`
|
||||||
|
|
||||||
### Start Client
|
### Start Client
|
||||||
|
|
||||||
Run `yarn start:client` and open https://localhost:4200/en in your browser
|
Run `npm run start:client` and open https://localhost:4200/en in your browser
|
||||||
|
|
||||||
### Start _Storybook_
|
### Start _Storybook_
|
||||||
|
|
||||||
Run `yarn start:storybook`
|
Run `npm run start:storybook`
|
||||||
|
|
||||||
### Migrate Database
|
### Migrate Database
|
||||||
|
|
||||||
With the following command you can keep your database schema in sync:
|
With the following command you can keep your database schema in sync:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn database:push
|
npm run database:push
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Run `yarn test`
|
Run `npm test`
|
||||||
|
|
||||||
## Public API
|
## Public API
|
||||||
|
|
||||||
@ -233,18 +232,18 @@ Deprecated: `GET http://localhost:3333/api/v1/auth/anonymous/<INSERT_SECURITY_TO
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| Field | Type | Description |
|
| Field | Type | Description |
|
||||||
| ---------- | ------------------- | ----------------------------------------------------------------------------- |
|
| ------------ | ------------------- | ----------------------------------------------------------------------------- |
|
||||||
| accountId | string (`optional`) | Id of the account |
|
| `accountId` | `string` (optional) | Id of the account |
|
||||||
| comment | string (`optional`) | Comment of the activity |
|
| `comment` | `string` (optional) | Comment of the activity |
|
||||||
| currency | string | `CHF` \| `EUR` \| `USD` etc. |
|
| `currency` | `string` | `CHF` \| `EUR` \| `USD` etc. |
|
||||||
| dataSource | string | `COINGECKO` \| `MANUAL` (for type `ITEM`) \| `YAHOO` |
|
| `dataSource` | `string` | `COINGECKO` \| `MANUAL` (for type `ITEM`) \| `YAHOO` |
|
||||||
| date | string | Date in the format `ISO-8601` |
|
| `date` | `string` | Date in the format `ISO-8601` |
|
||||||
| fee | number | Fee of the activity |
|
| `fee` | `number` | Fee of the activity |
|
||||||
| quantity | number | Quantity of the activity |
|
| `quantity` | `number` | Quantity of the activity |
|
||||||
| symbol | string | Symbol of the activity (suitable for `dataSource`) |
|
| `symbol` | `string` | Symbol of the activity (suitable for `dataSource`) |
|
||||||
| type | string | `BUY` \| `DIVIDEND` \| `FEE` \| `INTEREST` \| `ITEM` \| `LIABILITY` \| `SELL` |
|
| `type` | `string` | `BUY` \| `DIVIDEND` \| `FEE` \| `INTEREST` \| `ITEM` \| `LIABILITY` \| `SELL` |
|
||||||
| unitPrice | number | Price per unit of the activity |
|
| `unitPrice` | `number` | Price per unit of the activity |
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
@ -275,7 +274,7 @@ Are you building your own project? Add the `ghostfolio` topic to your _GitHub_ r
|
|||||||
|
|
||||||
Ghostfolio is **100% free** and **open source**. We encourage and support an active and healthy community that accepts contributions from the public - including you.
|
Ghostfolio is **100% free** and **open source**. We encourage and support an active and healthy community that accepts contributions from the public - including you.
|
||||||
|
|
||||||
Not sure what to work on? We have [some ideas](https://github.com/ghostfolio/ghostfolio/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22), even for [newcomers](https://github.com/ghostfolio/ghostfolio/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). Please join the Ghostfolio [Slack](https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg) channel or post to [@ghostfolio\_](https://twitter.com/ghostfolio_) on _X_. We would love to hear from you.
|
Not sure what to work on? We have [some ideas](https://github.com/ghostfolio/ghostfolio/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22), even for [newcomers](https://github.com/ghostfolio/ghostfolio/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). Please join the Ghostfolio [Slack](https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg) channel or post to [@ghostfolio\_](https://x.com/ghostfolio_) on _X_. We would love to hear from you.
|
||||||
|
|
||||||
If you like to support this project, get [**Ghostfolio Premium**](https://ghostfol.io/en/pricing) or [**Buy me a coffee**](https://www.buymeacoffee.com/ghostfolio).
|
If you like to support this project, get [**Ghostfolio Premium**](https://ghostfol.io/en/pricing) or [**Buy me a coffee**](https://www.buymeacoffee.com/ghostfolio).
|
||||||
|
|
||||||
|
@ -174,8 +174,8 @@ export class AccountService {
|
|||||||
ACCOUNT: filtersByAccount,
|
ACCOUNT: filtersByAccount,
|
||||||
ASSET_CLASS: filtersByAssetClass,
|
ASSET_CLASS: filtersByAssetClass,
|
||||||
TAG: filtersByTag
|
TAG: filtersByTag
|
||||||
} = groupBy(filters, (filter) => {
|
} = groupBy(filters, ({ type }) => {
|
||||||
return filter.type;
|
return type;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (filtersByAccount?.length > 0) {
|
if (filtersByAccount?.length > 0) {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code';
|
||||||
|
|
||||||
import { Transform, TransformFnParams } from 'class-transformer';
|
import { Transform, TransformFnParams } from 'class-transformer';
|
||||||
import {
|
import {
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsISO4217CurrencyCode,
|
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
@ -20,7 +21,7 @@ export class CreateAccountDto {
|
|||||||
)
|
)
|
||||||
comment?: string;
|
comment?: string;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
currency: string;
|
currency: string;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code';
|
||||||
|
|
||||||
import { Transform, TransformFnParams } from 'class-transformer';
|
import { Transform, TransformFnParams } from 'class-transformer';
|
||||||
import {
|
import {
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsISO4217CurrencyCode,
|
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
@ -20,7 +21,7 @@ export class UpdateAccountDto {
|
|||||||
)
|
)
|
||||||
comment?: string;
|
comment?: string;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
currency: string;
|
currency: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
|
@ -81,10 +81,11 @@ export class AdminController {
|
|||||||
@Post('gather/max')
|
@Post('gather/max')
|
||||||
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
||||||
public async gatherMax(): Promise<void> {
|
public async gatherMax(): Promise<void> {
|
||||||
const uniqueAssets = await this.dataGatheringService.getUniqueAssets();
|
const assetProfileIdentifiers =
|
||||||
|
await this.dataGatheringService.getAllAssetProfileIdentifiers();
|
||||||
|
|
||||||
await this.dataGatheringService.addJobsToQueue(
|
await this.dataGatheringService.addJobsToQueue(
|
||||||
uniqueAssets.map(({ dataSource, symbol }) => {
|
assetProfileIdentifiers.map(({ dataSource, symbol }) => {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
dataSource,
|
dataSource,
|
||||||
@ -107,10 +108,11 @@ export class AdminController {
|
|||||||
@Post('gather/profile-data')
|
@Post('gather/profile-data')
|
||||||
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
||||||
public async gatherProfileData(): Promise<void> {
|
public async gatherProfileData(): Promise<void> {
|
||||||
const uniqueAssets = await this.dataGatheringService.getUniqueAssets();
|
const assetProfileIdentifiers =
|
||||||
|
await this.dataGatheringService.getAllAssetProfileIdentifiers();
|
||||||
|
|
||||||
await this.dataGatheringService.addJobsToQueue(
|
await this.dataGatheringService.addJobsToQueue(
|
||||||
uniqueAssets.map(({ dataSource, symbol }) => {
|
assetProfileIdentifiers.map(({ dataSource, symbol }) => {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
dataSource,
|
dataSource,
|
||||||
|
@ -27,12 +27,13 @@ import {
|
|||||||
} from '@ghostfolio/common/interfaces';
|
} from '@ghostfolio/common/interfaces';
|
||||||
import { MarketDataPreset } from '@ghostfolio/common/types';
|
import { MarketDataPreset } from '@ghostfolio/common/types';
|
||||||
|
|
||||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
AssetClass,
|
AssetClass,
|
||||||
AssetSubClass,
|
AssetSubClass,
|
||||||
DataSource,
|
DataSource,
|
||||||
Prisma,
|
Prisma,
|
||||||
|
PrismaClient,
|
||||||
Property,
|
Property,
|
||||||
SymbolProfile
|
SymbolProfile
|
||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
@ -212,98 +213,113 @@ export class AdminService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let [assetProfiles, count] = await Promise.all([
|
const extendedPrismaClient = this.getExtendedPrismaClient();
|
||||||
this.prismaService.symbolProfile.findMany({
|
|
||||||
orderBy,
|
try {
|
||||||
skip,
|
let [assetProfiles, count] = await Promise.all([
|
||||||
take,
|
extendedPrismaClient.symbolProfile.findMany({
|
||||||
where,
|
orderBy,
|
||||||
select: {
|
skip,
|
||||||
_count: {
|
take,
|
||||||
select: { Order: true }
|
where,
|
||||||
},
|
select: {
|
||||||
assetClass: true,
|
_count: {
|
||||||
assetSubClass: true,
|
select: { Order: true }
|
||||||
comment: true,
|
},
|
||||||
countries: true,
|
assetClass: true,
|
||||||
currency: true,
|
assetSubClass: true,
|
||||||
dataSource: true,
|
comment: true,
|
||||||
id: true,
|
countries: true,
|
||||||
name: true,
|
currency: true,
|
||||||
Order: {
|
dataSource: true,
|
||||||
orderBy: [{ date: 'asc' }],
|
id: true,
|
||||||
select: { date: true },
|
isUsedByUsersWithSubscription: true,
|
||||||
take: 1
|
name: true,
|
||||||
},
|
Order: {
|
||||||
scraperConfiguration: true,
|
orderBy: [{ date: 'asc' }],
|
||||||
sectors: true,
|
select: { date: true },
|
||||||
symbol: true
|
take: 1
|
||||||
|
},
|
||||||
|
scraperConfiguration: true,
|
||||||
|
sectors: true,
|
||||||
|
symbol: true
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
this.prismaService.symbolProfile.count({ where })
|
||||||
|
]);
|
||||||
|
|
||||||
|
let marketData: AdminMarketDataItem[] = await Promise.all(
|
||||||
|
assetProfiles.map(
|
||||||
|
async ({
|
||||||
|
_count,
|
||||||
|
assetClass,
|
||||||
|
assetSubClass,
|
||||||
|
comment,
|
||||||
|
countries,
|
||||||
|
currency,
|
||||||
|
dataSource,
|
||||||
|
id,
|
||||||
|
isUsedByUsersWithSubscription,
|
||||||
|
name,
|
||||||
|
Order,
|
||||||
|
sectors,
|
||||||
|
symbol
|
||||||
|
}) => {
|
||||||
|
const countriesCount = countries
|
||||||
|
? Object.keys(countries).length
|
||||||
|
: 0;
|
||||||
|
const marketDataItemCount =
|
||||||
|
marketDataItems.find((marketDataItem) => {
|
||||||
|
return (
|
||||||
|
marketDataItem.dataSource === dataSource &&
|
||||||
|
marketDataItem.symbol === symbol
|
||||||
|
);
|
||||||
|
})?._count ?? 0;
|
||||||
|
const sectorsCount = sectors ? Object.keys(sectors).length : 0;
|
||||||
|
|
||||||
|
return {
|
||||||
|
assetClass,
|
||||||
|
assetSubClass,
|
||||||
|
comment,
|
||||||
|
currency,
|
||||||
|
countriesCount,
|
||||||
|
dataSource,
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
symbol,
|
||||||
|
marketDataItemCount,
|
||||||
|
sectorsCount,
|
||||||
|
activitiesCount: _count.Order,
|
||||||
|
date: Order?.[0]?.date,
|
||||||
|
isUsedByUsersWithSubscription: await isUsedByUsersWithSubscription
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (presetId) {
|
||||||
|
if (presetId === 'ETF_WITHOUT_COUNTRIES') {
|
||||||
|
marketData = marketData.filter(({ countriesCount }) => {
|
||||||
|
return countriesCount === 0;
|
||||||
|
});
|
||||||
|
} else if (presetId === 'ETF_WITHOUT_SECTORS') {
|
||||||
|
marketData = marketData.filter(({ sectorsCount }) => {
|
||||||
|
return sectorsCount === 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}),
|
|
||||||
this.prismaService.symbolProfile.count({ where })
|
|
||||||
]);
|
|
||||||
|
|
||||||
let marketData: AdminMarketDataItem[] = assetProfiles.map(
|
count = marketData.length;
|
||||||
({
|
|
||||||
_count,
|
|
||||||
assetClass,
|
|
||||||
assetSubClass,
|
|
||||||
comment,
|
|
||||||
countries,
|
|
||||||
currency,
|
|
||||||
dataSource,
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
Order,
|
|
||||||
sectors,
|
|
||||||
symbol
|
|
||||||
}) => {
|
|
||||||
const countriesCount = countries ? Object.keys(countries).length : 0;
|
|
||||||
const marketDataItemCount =
|
|
||||||
marketDataItems.find((marketDataItem) => {
|
|
||||||
return (
|
|
||||||
marketDataItem.dataSource === dataSource &&
|
|
||||||
marketDataItem.symbol === symbol
|
|
||||||
);
|
|
||||||
})?._count ?? 0;
|
|
||||||
const sectorsCount = sectors ? Object.keys(sectors).length : 0;
|
|
||||||
|
|
||||||
return {
|
|
||||||
assetClass,
|
|
||||||
assetSubClass,
|
|
||||||
comment,
|
|
||||||
currency,
|
|
||||||
countriesCount,
|
|
||||||
dataSource,
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
symbol,
|
|
||||||
marketDataItemCount,
|
|
||||||
sectorsCount,
|
|
||||||
activitiesCount: _count.Order,
|
|
||||||
date: Order?.[0]?.date
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (presetId) {
|
|
||||||
if (presetId === 'ETF_WITHOUT_COUNTRIES') {
|
|
||||||
marketData = marketData.filter(({ countriesCount }) => {
|
|
||||||
return countriesCount === 0;
|
|
||||||
});
|
|
||||||
} else if (presetId === 'ETF_WITHOUT_SECTORS') {
|
|
||||||
marketData = marketData.filter(({ sectorsCount }) => {
|
|
||||||
return sectorsCount === 0;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count = marketData.length;
|
return {
|
||||||
|
count,
|
||||||
|
marketData
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
await extendedPrismaClient.$disconnect();
|
||||||
|
|
||||||
|
Logger.debug('Disconnect extended prisma client', 'AdminService');
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
count,
|
|
||||||
marketData
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getMarketDataBySymbol({
|
public async getMarketDataBySymbol({
|
||||||
@ -431,6 +447,52 @@ export class AdminService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getExtendedPrismaClient() {
|
||||||
|
Logger.debug('Connect extended prisma client', 'AdminService');
|
||||||
|
|
||||||
|
const symbolProfileExtension = Prisma.defineExtension((client) => {
|
||||||
|
return client.$extends({
|
||||||
|
result: {
|
||||||
|
symbolProfile: {
|
||||||
|
isUsedByUsersWithSubscription: {
|
||||||
|
compute: async ({ id }) => {
|
||||||
|
const { _count } =
|
||||||
|
await this.prismaService.symbolProfile.findUnique({
|
||||||
|
select: {
|
||||||
|
_count: {
|
||||||
|
select: {
|
||||||
|
Order: {
|
||||||
|
where: {
|
||||||
|
User: {
|
||||||
|
Subscription: {
|
||||||
|
some: {
|
||||||
|
expiresAt: {
|
||||||
|
gt: new Date()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return _count.Order > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return new PrismaClient().$extends(symbolProfileExtension);
|
||||||
|
}
|
||||||
|
|
||||||
private async getMarketDataForCurrencies(): Promise<AdminMarketData> {
|
private async getMarketDataForCurrencies(): Promise<AdminMarketData> {
|
||||||
const marketDataItems = await this.prismaService.marketData.groupBy({
|
const marketDataItems = await this.prismaService.marketData.groupBy({
|
||||||
_count: true,
|
_count: true,
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code';
|
||||||
|
|
||||||
import { AssetClass, AssetSubClass, Prisma } from '@prisma/client';
|
import { AssetClass, AssetSubClass, Prisma } from '@prisma/client';
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsISO4217CurrencyCode,
|
|
||||||
IsObject,
|
IsObject,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
@ -26,7 +27,7 @@ export class UpdateAssetProfileDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
countries?: Prisma.InputJsonArray;
|
countries?: Prisma.InputJsonArray;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
currency?: string;
|
currency?: string;
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ export class BenchmarkService {
|
|||||||
Promise.all(promisesAllTimeHighs),
|
Promise.all(promisesAllTimeHighs),
|
||||||
Promise.all(promisesBenchmarkTrends)
|
Promise.all(promisesBenchmarkTrends)
|
||||||
]);
|
]);
|
||||||
let storeInCache = true;
|
let storeInCache = useCache;
|
||||||
|
|
||||||
benchmarks = allTimeHighs.map((allTimeHigh, index) => {
|
benchmarks = allTimeHighs.map((allTimeHigh, index) => {
|
||||||
const { marketPrice } =
|
const { marketPrice } =
|
||||||
@ -161,7 +161,10 @@ export class BenchmarkService {
|
|||||||
performances: {
|
performances: {
|
||||||
allTimeHigh: {
|
allTimeHigh: {
|
||||||
date: allTimeHigh?.date,
|
date: allTimeHigh?.date,
|
||||||
performancePercent: performancePercentFromAllTimeHigh
|
performancePercent:
|
||||||
|
performancePercentFromAllTimeHigh >= 0
|
||||||
|
? 0
|
||||||
|
: performancePercentFromAllTimeHigh
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
symbol: benchmarkAssetProfiles[index].symbol,
|
symbol: benchmarkAssetProfiles[index].symbol,
|
||||||
@ -419,7 +422,7 @@ export class BenchmarkService {
|
|||||||
private getMarketCondition(
|
private getMarketCondition(
|
||||||
aPerformanceInPercent: number
|
aPerformanceInPercent: number
|
||||||
): Benchmark['marketCondition'] {
|
): Benchmark['marketCondition'] {
|
||||||
if (aPerformanceInPercent === 0) {
|
if (aPerformanceInPercent >= 0) {
|
||||||
return 'ALL_TIME_HIGH';
|
return 'ALL_TIME_HIGH';
|
||||||
} else if (aPerformanceInPercent <= -0.2) {
|
} else if (aPerformanceInPercent <= -0.2) {
|
||||||
return 'BEAR_MARKET';
|
return 'BEAR_MARKET';
|
||||||
|
@ -72,9 +72,13 @@ export class ImportService {
|
|||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const accounts = orders.map((order) => {
|
const accounts = orders
|
||||||
return order.Account;
|
.filter(({ Account }) => {
|
||||||
});
|
return !!Account;
|
||||||
|
})
|
||||||
|
.map(({ Account }) => {
|
||||||
|
return Account;
|
||||||
|
});
|
||||||
|
|
||||||
const Account = this.isUniqueAccount(accounts) ? accounts[0] : undefined;
|
const Account = this.isUniqueAccount(accounts) ? accounts[0] : undefined;
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code';
|
||||||
import { IsAfter1970Constraint } from '@ghostfolio/common/validator-constraints/is-after-1970';
|
import { IsAfter1970Constraint } from '@ghostfolio/common/validator-constraints/is-after-1970';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -12,7 +13,6 @@ import {
|
|||||||
IsArray,
|
IsArray,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsISO4217CurrencyCode,
|
|
||||||
IsISO8601,
|
IsISO8601,
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
@ -42,10 +42,10 @@ export class CreateOrderDto {
|
|||||||
)
|
)
|
||||||
comment?: string;
|
comment?: string;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
currency: string;
|
currency: string;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
customCurrency?: string;
|
customCurrency?: string;
|
||||||
|
|
||||||
|
@ -66,7 +66,6 @@ export class OrderController {
|
|||||||
|
|
||||||
return this.orderService.deleteOrders({
|
return this.orderService.deleteOrders({
|
||||||
filters,
|
filters,
|
||||||
userCurrency: this.request.user.Settings.settings.baseCurrency,
|
|
||||||
userId: this.request.user.id
|
userId: this.request.user.id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,39 @@ export class OrderService {
|
|||||||
private readonly symbolProfileService: SymbolProfileService
|
private readonly symbolProfileService: SymbolProfileService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public async assignTags({
|
||||||
|
dataSource,
|
||||||
|
symbol,
|
||||||
|
tags,
|
||||||
|
userId
|
||||||
|
}: { tags: Tag[]; userId: string } & UniqueAsset) {
|
||||||
|
const orders = await this.prismaService.order.findMany({
|
||||||
|
where: {
|
||||||
|
userId,
|
||||||
|
SymbolProfile: {
|
||||||
|
dataSource,
|
||||||
|
symbol
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise.all(
|
||||||
|
orders.map(({ id }) =>
|
||||||
|
this.prismaService.order.update({
|
||||||
|
data: {
|
||||||
|
tags: {
|
||||||
|
// The set operation replaces all existing connections with the provided ones
|
||||||
|
set: tags.map(({ id }) => {
|
||||||
|
return { id };
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
where: { id }
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public async createOrder(
|
public async createOrder(
|
||||||
data: Prisma.OrderCreateInput & {
|
data: Prisma.OrderCreateInput & {
|
||||||
accountId?: string;
|
accountId?: string;
|
||||||
@ -184,7 +217,15 @@ export class OrderService {
|
|||||||
where
|
where
|
||||||
});
|
});
|
||||||
|
|
||||||
if (['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(order.type)) {
|
const [symbolProfile] =
|
||||||
|
await this.symbolProfileService.getSymbolProfilesByIds([
|
||||||
|
order.symbolProfileId
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (
|
||||||
|
['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(order.type) ||
|
||||||
|
symbolProfile.activitiesCount === 0
|
||||||
|
) {
|
||||||
await this.symbolProfileService.deleteById(order.symbolProfileId);
|
await this.symbolProfileService.deleteById(order.symbolProfileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,18 +241,16 @@ export class OrderService {
|
|||||||
|
|
||||||
public async deleteOrders({
|
public async deleteOrders({
|
||||||
filters,
|
filters,
|
||||||
userCurrency,
|
|
||||||
userId
|
userId
|
||||||
}: {
|
}: {
|
||||||
filters?: Filter[];
|
filters?: Filter[];
|
||||||
userCurrency: string;
|
|
||||||
userId: string;
|
userId: string;
|
||||||
}): Promise<number> {
|
}): Promise<number> {
|
||||||
const { activities } = await this.getOrders({
|
const { activities } = await this.getOrders({
|
||||||
filters,
|
filters,
|
||||||
userId,
|
userId,
|
||||||
userCurrency,
|
|
||||||
includeDrafts: true,
|
includeDrafts: true,
|
||||||
|
userCurrency: undefined,
|
||||||
withExcludedAccounts: true
|
withExcludedAccounts: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -225,6 +264,19 @@ export class OrderService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const symbolProfiles =
|
||||||
|
await this.symbolProfileService.getSymbolProfilesByIds(
|
||||||
|
activities.map(({ symbolProfileId }) => {
|
||||||
|
return symbolProfileId;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const { activitiesCount, id } of symbolProfiles) {
|
||||||
|
if (activitiesCount === 0) {
|
||||||
|
await this.symbolProfileService.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.eventEmitter.emit(
|
this.eventEmitter.emit(
|
||||||
PortfolioChangedEvent.getName(),
|
PortfolioChangedEvent.getName(),
|
||||||
new PortfolioChangedEvent({ userId })
|
new PortfolioChangedEvent({ userId })
|
||||||
@ -272,7 +324,8 @@ export class OrderService {
|
|||||||
withExcludedAccounts?: boolean;
|
withExcludedAccounts?: boolean;
|
||||||
}): Promise<Activities> {
|
}): Promise<Activities> {
|
||||||
let orderBy: Prisma.Enumerable<Prisma.OrderOrderByWithRelationInput> = [
|
let orderBy: Prisma.Enumerable<Prisma.OrderOrderByWithRelationInput> = [
|
||||||
{ date: 'asc' }
|
{ date: 'asc' },
|
||||||
|
{ id: 'asc' }
|
||||||
];
|
];
|
||||||
const where: Prisma.OrderWhereInput = { userId };
|
const where: Prisma.OrderWhereInput = { userId };
|
||||||
|
|
||||||
@ -292,10 +345,14 @@ export class OrderService {
|
|||||||
ACCOUNT: filtersByAccount,
|
ACCOUNT: filtersByAccount,
|
||||||
ASSET_CLASS: filtersByAssetClass,
|
ASSET_CLASS: filtersByAssetClass,
|
||||||
TAG: filtersByTag
|
TAG: filtersByTag
|
||||||
} = groupBy(filters, (filter) => {
|
} = groupBy(filters, ({ type }) => {
|
||||||
return filter.type;
|
return type;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const searchQuery = filters?.find(({ type }) => {
|
||||||
|
return type === 'SEARCH_QUERY';
|
||||||
|
})?.id;
|
||||||
|
|
||||||
if (filtersByAccount?.length > 0) {
|
if (filtersByAccount?.length > 0) {
|
||||||
where.accountId = {
|
where.accountId = {
|
||||||
in: filtersByAccount.map(({ id }) => {
|
in: filtersByAccount.map(({ id }) => {
|
||||||
@ -337,6 +394,30 @@ export class OrderService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (searchQuery) {
|
||||||
|
const searchQueryWhereInput: Prisma.SymbolProfileWhereInput[] = [
|
||||||
|
{ id: { mode: 'insensitive', startsWith: searchQuery } },
|
||||||
|
{ isin: { mode: 'insensitive', startsWith: searchQuery } },
|
||||||
|
{ name: { mode: 'insensitive', startsWith: searchQuery } },
|
||||||
|
{ symbol: { mode: 'insensitive', startsWith: searchQuery } }
|
||||||
|
];
|
||||||
|
|
||||||
|
if (where.SymbolProfile) {
|
||||||
|
where.SymbolProfile = {
|
||||||
|
AND: [
|
||||||
|
where.SymbolProfile,
|
||||||
|
{
|
||||||
|
OR: searchQueryWhereInput
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
where.SymbolProfile = {
|
||||||
|
OR: searchQueryWhereInput
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (filtersByTag?.length > 0) {
|
if (filtersByTag?.length > 0) {
|
||||||
where.tags = {
|
where.tags = {
|
||||||
some: {
|
some: {
|
||||||
@ -348,7 +429,7 @@ export class OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sortColumn) {
|
if (sortColumn) {
|
||||||
orderBy = [{ [sortColumn]: sortDirection }];
|
orderBy = [{ [sortColumn]: sortDirection }, { id: sortDirection }];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (types) {
|
if (types) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code';
|
||||||
import { IsAfter1970Constraint } from '@ghostfolio/common/validator-constraints/is-after-1970';
|
import { IsAfter1970Constraint } from '@ghostfolio/common/validator-constraints/is-after-1970';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -11,7 +12,6 @@ import { Transform, TransformFnParams } from 'class-transformer';
|
|||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsISO4217CurrencyCode,
|
|
||||||
IsISO8601,
|
IsISO8601,
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
@ -41,10 +41,10 @@ export class UpdateOrderDto {
|
|||||||
)
|
)
|
||||||
comment?: string;
|
comment?: string;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
currency: string;
|
currency: string;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
customCurrency?: string;
|
customCurrency?: string;
|
||||||
|
|
||||||
|
@ -300,6 +300,12 @@ export abstract class PortfolioCalculator {
|
|||||||
const errors: ResponseError['errors'] = [];
|
const errors: ResponseError['errors'] = [];
|
||||||
|
|
||||||
for (const item of lastTransactionPoint.items) {
|
for (const item of lastTransactionPoint.items) {
|
||||||
|
const feeInBaseCurrency = item.fee.mul(
|
||||||
|
exchangeRatesByCurrency[`${item.currency}${this.currency}`]?.[
|
||||||
|
lastTransactionPoint.date
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
const marketPriceInBaseCurrency = (
|
const marketPriceInBaseCurrency = (
|
||||||
marketSymbolMap[endDateString]?.[item.symbol] ?? item.averagePrice
|
marketSymbolMap[endDateString]?.[item.symbol] ?? item.averagePrice
|
||||||
).mul(
|
).mul(
|
||||||
@ -340,10 +346,11 @@ export abstract class PortfolioCalculator {
|
|||||||
hasAnySymbolMetricsErrors = hasAnySymbolMetricsErrors || hasErrors;
|
hasAnySymbolMetricsErrors = hasAnySymbolMetricsErrors || hasErrors;
|
||||||
|
|
||||||
positions.push({
|
positions.push({
|
||||||
dividend: totalDividend,
|
feeInBaseCurrency,
|
||||||
dividendInBaseCurrency: totalDividendInBaseCurrency,
|
|
||||||
timeWeightedInvestment,
|
timeWeightedInvestment,
|
||||||
timeWeightedInvestmentWithCurrencyEffect,
|
timeWeightedInvestmentWithCurrencyEffect,
|
||||||
|
dividend: totalDividend,
|
||||||
|
dividendInBaseCurrency: totalDividendInBaseCurrency,
|
||||||
averagePrice: item.averagePrice,
|
averagePrice: item.averagePrice,
|
||||||
currency: item.currency,
|
currency: item.currency,
|
||||||
dataSource: item.dataSource,
|
dataSource: item.dataSource,
|
||||||
|
@ -168,6 +168,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('3.2'),
|
fee: new Big('3.2'),
|
||||||
|
feeInBaseCurrency: new Big('3.2'),
|
||||||
firstBuyDate: '2021-11-22',
|
firstBuyDate: '2021-11-22',
|
||||||
grossPerformance: new Big('-12.6'),
|
grossPerformance: new Big('-12.6'),
|
||||||
grossPerformancePercentage: new Big('-0.04408677396780965649'),
|
grossPerformancePercentage: new Big('-0.04408677396780965649'),
|
||||||
|
@ -153,6 +153,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('3.2'),
|
fee: new Big('3.2'),
|
||||||
|
feeInBaseCurrency: new Big('3.2'),
|
||||||
firstBuyDate: '2021-11-22',
|
firstBuyDate: '2021-11-22',
|
||||||
grossPerformance: new Big('-12.6'),
|
grossPerformance: new Big('-12.6'),
|
||||||
grossPerformancePercentage: new Big('-0.0440867739678096571'),
|
grossPerformancePercentage: new Big('-0.0440867739678096571'),
|
||||||
|
@ -138,6 +138,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('1.55'),
|
fee: new Big('1.55'),
|
||||||
|
feeInBaseCurrency: new Big('1.55'),
|
||||||
firstBuyDate: '2021-11-30',
|
firstBuyDate: '2021-11-30',
|
||||||
grossPerformance: new Big('24.6'),
|
grossPerformance: new Big('24.6'),
|
||||||
grossPerformancePercentage: new Big('0.09004392386530014641'),
|
grossPerformancePercentage: new Big('0.09004392386530014641'),
|
||||||
|
@ -166,6 +166,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('0'),
|
fee: new Big('0'),
|
||||||
|
feeInBaseCurrency: new Big('0'),
|
||||||
firstBuyDate: '2015-01-01',
|
firstBuyDate: '2015-01-01',
|
||||||
grossPerformance: new Big('27172.74'),
|
grossPerformance: new Big('27172.74'),
|
||||||
grossPerformancePercentage: new Big('42.41978276196153750666'),
|
grossPerformancePercentage: new Big('42.41978276196153750666'),
|
||||||
|
@ -123,6 +123,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('49'),
|
fee: new Big('49'),
|
||||||
|
feeInBaseCurrency: new Big('49'),
|
||||||
firstBuyDate: '2021-09-01',
|
firstBuyDate: '2021-09-01',
|
||||||
grossPerformance: null,
|
grossPerformance: null,
|
||||||
grossPerformancePercentage: null,
|
grossPerformancePercentage: null,
|
||||||
|
@ -151,6 +151,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('1'),
|
fee: new Big('1'),
|
||||||
|
feeInBaseCurrency: new Big('0.9238'),
|
||||||
firstBuyDate: '2023-01-03',
|
firstBuyDate: '2023-01-03',
|
||||||
grossPerformance: new Big('27.33'),
|
grossPerformance: new Big('27.33'),
|
||||||
grossPerformancePercentage: new Big('0.3066651705565529623'),
|
grossPerformancePercentage: new Big('0.3066651705565529623'),
|
||||||
@ -177,7 +178,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
valueInBaseCurrency: new Big('103.10483')
|
valueInBaseCurrency: new Big('103.10483')
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
totalFeesWithCurrencyEffect: new Big('1'),
|
totalFeesWithCurrencyEffect: new Big('0.9238'),
|
||||||
totalInterestWithCurrencyEffect: new Big('0'),
|
totalInterestWithCurrencyEffect: new Big('0'),
|
||||||
totalInvestment: new Big('89.12'),
|
totalInvestment: new Big('89.12'),
|
||||||
totalInvestmentWithCurrencyEffect: new Big('82.329056'),
|
totalInvestmentWithCurrencyEffect: new Big('82.329056'),
|
||||||
|
@ -123,6 +123,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('0'),
|
fee: new Big('0'),
|
||||||
|
feeInBaseCurrency: new Big('0'),
|
||||||
firstBuyDate: '2022-01-01',
|
firstBuyDate: '2022-01-01',
|
||||||
grossPerformance: null,
|
grossPerformance: null,
|
||||||
grossPerformancePercentage: null,
|
grossPerformancePercentage: null,
|
||||||
|
@ -153,6 +153,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('4.25'),
|
fee: new Big('4.25'),
|
||||||
|
feeInBaseCurrency: new Big('4.25'),
|
||||||
firstBuyDate: '2022-03-07',
|
firstBuyDate: '2022-03-07',
|
||||||
grossPerformance: new Big('21.93'),
|
grossPerformance: new Big('21.93'),
|
||||||
grossPerformancePercentage: new Big('0.15113417083448194384'),
|
grossPerformancePercentage: new Big('0.15113417083448194384'),
|
||||||
|
@ -183,6 +183,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('0'),
|
fee: new Big('0'),
|
||||||
|
feeInBaseCurrency: new Big('0'),
|
||||||
firstBuyDate: '2022-03-07',
|
firstBuyDate: '2022-03-07',
|
||||||
grossPerformance: new Big('19.86'),
|
grossPerformance: new Big('19.86'),
|
||||||
grossPerformancePercentage: new Big('0.13100263852242744063'),
|
grossPerformancePercentage: new Big('0.13100263852242744063'),
|
||||||
|
@ -34,9 +34,9 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
|
|||||||
let totalTimeWeightedInvestmentWithCurrencyEffect = new Big(0);
|
let totalTimeWeightedInvestmentWithCurrencyEffect = new Big(0);
|
||||||
|
|
||||||
for (const currentPosition of positions) {
|
for (const currentPosition of positions) {
|
||||||
if (currentPosition.fee) {
|
if (currentPosition.feeInBaseCurrency) {
|
||||||
totalFeesWithCurrencyEffect = totalFeesWithCurrencyEffect.plus(
|
totalFeesWithCurrencyEffect = totalFeesWithCurrencyEffect.plus(
|
||||||
currentPosition.fee
|
currentPosition.feeInBaseCurrency
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { AccessService } from '@ghostfolio/api/app/access/access.service';
|
import { AccessService } from '@ghostfolio/api/app/access/access.service';
|
||||||
import { OrderService } from '@ghostfolio/api/app/order/order.service';
|
import { OrderService } from '@ghostfolio/api/app/order/order.service';
|
||||||
import { UserService } from '@ghostfolio/api/app/user/user.service';
|
import { UserService } from '@ghostfolio/api/app/user/user.service';
|
||||||
|
import { HasPermission } from '@ghostfolio/api/decorators/has-permission.decorator';
|
||||||
import { HasPermissionGuard } from '@ghostfolio/api/guards/has-permission.guard';
|
import { HasPermissionGuard } from '@ghostfolio/api/guards/has-permission.guard';
|
||||||
import {
|
import {
|
||||||
hasNotDefinedValuesInObject,
|
hasNotDefinedValuesInObject,
|
||||||
@ -29,7 +30,8 @@ import {
|
|||||||
} from '@ghostfolio/common/interfaces';
|
} from '@ghostfolio/common/interfaces';
|
||||||
import {
|
import {
|
||||||
hasReadRestrictedAccessPermission,
|
hasReadRestrictedAccessPermission,
|
||||||
isRestrictedView
|
isRestrictedView,
|
||||||
|
permissions
|
||||||
} from '@ghostfolio/common/permissions';
|
} from '@ghostfolio/common/permissions';
|
||||||
import type {
|
import type {
|
||||||
DateRange,
|
DateRange,
|
||||||
@ -38,12 +40,14 @@ import type {
|
|||||||
} from '@ghostfolio/common/types';
|
} from '@ghostfolio/common/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
Headers,
|
Headers,
|
||||||
HttpException,
|
HttpException,
|
||||||
Inject,
|
Inject,
|
||||||
Param,
|
Param,
|
||||||
|
Put,
|
||||||
Query,
|
Query,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
UseInterceptors,
|
UseInterceptors,
|
||||||
@ -51,12 +55,13 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { AssetClass, AssetSubClass } from '@prisma/client';
|
import { AssetClass, AssetSubClass, DataSource } from '@prisma/client';
|
||||||
import { Big } from 'big.js';
|
import { Big } from 'big.js';
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
|
|
||||||
import { PortfolioHoldingDetail } from './interfaces/portfolio-holding-detail.interface';
|
import { PortfolioHoldingDetail } from './interfaces/portfolio-holding-detail.interface';
|
||||||
import { PortfolioService } from './portfolio.service';
|
import { PortfolioService } from './portfolio.service';
|
||||||
|
import { UpdateHoldingTagsDto } from './update-holding-tags.dto';
|
||||||
|
|
||||||
@Controller('portfolio')
|
@Controller('portfolio')
|
||||||
export class PortfolioController {
|
export class PortfolioController {
|
||||||
@ -496,9 +501,6 @@ export class PortfolioController {
|
|||||||
@Param('accessId') accessId
|
@Param('accessId') accessId
|
||||||
): Promise<PortfolioPublicDetails> {
|
): Promise<PortfolioPublicDetails> {
|
||||||
const access = await this.accessService.access({ id: accessId });
|
const access = await this.accessService.access({ id: accessId });
|
||||||
const user = await this.userService.user({
|
|
||||||
id: access.userId
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!access) {
|
if (!access) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
@ -508,6 +510,11 @@ export class PortfolioController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let hasDetails = true;
|
let hasDetails = true;
|
||||||
|
|
||||||
|
const user = await this.userService.user({
|
||||||
|
id: access.userId
|
||||||
|
});
|
||||||
|
|
||||||
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
|
||||||
hasDetails = user.subscription.type === 'Premium';
|
hasDetails = user.subscription.type === 'Premium';
|
||||||
}
|
}
|
||||||
@ -564,23 +571,23 @@ export class PortfolioController {
|
|||||||
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
||||||
public async getPosition(
|
public async getPosition(
|
||||||
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
|
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
|
||||||
@Param('dataSource') dataSource,
|
@Param('dataSource') dataSource: DataSource,
|
||||||
@Param('symbol') symbol
|
@Param('symbol') symbol: string
|
||||||
): Promise<PortfolioHoldingDetail> {
|
): Promise<PortfolioHoldingDetail> {
|
||||||
const position = await this.portfolioService.getPosition(
|
const holding = await this.portfolioService.getPosition(
|
||||||
dataSource,
|
dataSource,
|
||||||
impersonationId,
|
impersonationId,
|
||||||
symbol
|
symbol
|
||||||
);
|
);
|
||||||
|
|
||||||
if (position) {
|
if (!holding) {
|
||||||
return position;
|
throw new HttpException(
|
||||||
|
getReasonPhrase(StatusCodes.NOT_FOUND),
|
||||||
|
StatusCodes.NOT_FOUND
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new HttpException(
|
return holding;
|
||||||
getReasonPhrase(StatusCodes.NOT_FOUND),
|
|
||||||
StatusCodes.NOT_FOUND
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('report')
|
@Get('report')
|
||||||
@ -603,4 +610,36 @@ export class PortfolioController {
|
|||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@HasPermission(permissions.updateOrder)
|
||||||
|
@Put('position/:dataSource/:symbol/tags')
|
||||||
|
@UseInterceptors(TransformDataSourceInRequestInterceptor)
|
||||||
|
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
||||||
|
public async updateHoldingTags(
|
||||||
|
@Body() data: UpdateHoldingTagsDto,
|
||||||
|
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
|
||||||
|
@Param('dataSource') dataSource: DataSource,
|
||||||
|
@Param('symbol') symbol: string
|
||||||
|
): Promise<void> {
|
||||||
|
const holding = await this.portfolioService.getPosition(
|
||||||
|
dataSource,
|
||||||
|
impersonationId,
|
||||||
|
symbol
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!holding) {
|
||||||
|
throw new HttpException(
|
||||||
|
getReasonPhrase(StatusCodes.NOT_FOUND),
|
||||||
|
StatusCodes.NOT_FOUND
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.portfolioService.updateTags({
|
||||||
|
dataSource,
|
||||||
|
impersonationId,
|
||||||
|
symbol,
|
||||||
|
tags: data.tags,
|
||||||
|
userId: this.request.user.id
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
import { Big } from 'big.js';
|
|
||||||
|
|
||||||
import { PortfolioService } from './portfolio.service';
|
|
||||||
|
|
||||||
describe('PortfolioService', () => {
|
|
||||||
let portfolioService: PortfolioService;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
portfolioService = new PortfolioService(
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('annualized performance percentage', () => {
|
|
||||||
it('Get annualized performance', async () => {
|
|
||||||
expect(
|
|
||||||
portfolioService
|
|
||||||
.getAnnualizedPerformancePercent({
|
|
||||||
daysInMarket: NaN, // differenceInDays of date-fns returns NaN for the same day
|
|
||||||
netPerformancePercentage: new Big(0)
|
|
||||||
})
|
|
||||||
.toNumber()
|
|
||||||
).toEqual(0);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
portfolioService
|
|
||||||
.getAnnualizedPerformancePercent({
|
|
||||||
daysInMarket: 0,
|
|
||||||
netPerformancePercentage: new Big(0)
|
|
||||||
})
|
|
||||||
.toNumber()
|
|
||||||
).toEqual(0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Source: https://www.readyratios.com/reference/analysis/annualized_rate.html
|
|
||||||
*/
|
|
||||||
expect(
|
|
||||||
portfolioService
|
|
||||||
.getAnnualizedPerformancePercent({
|
|
||||||
daysInMarket: 65, // < 1 year
|
|
||||||
netPerformancePercentage: new Big(0.1025)
|
|
||||||
})
|
|
||||||
.toNumber()
|
|
||||||
).toBeCloseTo(0.729705);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
portfolioService
|
|
||||||
.getAnnualizedPerformancePercent({
|
|
||||||
daysInMarket: 365, // 1 year
|
|
||||||
netPerformancePercentage: new Big(0.05)
|
|
||||||
})
|
|
||||||
.toNumber()
|
|
||||||
).toBeCloseTo(0.05);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Source: https://www.investopedia.com/terms/a/annualized-total-return.asp#annualized-return-formula-and-calculation
|
|
||||||
*/
|
|
||||||
expect(
|
|
||||||
portfolioService
|
|
||||||
.getAnnualizedPerformancePercent({
|
|
||||||
daysInMarket: 575, // > 1 year
|
|
||||||
netPerformancePercentage: new Big(0.2374)
|
|
||||||
})
|
|
||||||
.toNumber()
|
|
||||||
).toBeCloseTo(0.145);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -18,6 +18,7 @@ import { DataProviderService } from '@ghostfolio/api/services/data-provider/data
|
|||||||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service';
|
||||||
import { ImpersonationService } from '@ghostfolio/api/services/impersonation/impersonation.service';
|
import { ImpersonationService } from '@ghostfolio/api/services/impersonation/impersonation.service';
|
||||||
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service';
|
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service';
|
||||||
|
import { getAnnualizedPerformancePercent } from '@ghostfolio/common/calculation-helper';
|
||||||
import {
|
import {
|
||||||
DEFAULT_CURRENCY,
|
DEFAULT_CURRENCY,
|
||||||
EMERGENCY_FUND_TAG_ID,
|
EMERGENCY_FUND_TAG_ID,
|
||||||
@ -58,7 +59,8 @@ import {
|
|||||||
DataSource,
|
DataSource,
|
||||||
Order,
|
Order,
|
||||||
Platform,
|
Platform,
|
||||||
Prisma
|
Prisma,
|
||||||
|
Tag
|
||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
import { Big } from 'big.js';
|
import { Big } from 'big.js';
|
||||||
import {
|
import {
|
||||||
@ -70,7 +72,7 @@ import {
|
|||||||
parseISO,
|
parseISO,
|
||||||
set
|
set
|
||||||
} from 'date-fns';
|
} from 'date-fns';
|
||||||
import { isEmpty, isNumber, last, uniq, uniqBy } from 'lodash';
|
import { isEmpty, uniq, uniqBy } from 'lodash';
|
||||||
|
|
||||||
import { PortfolioCalculator } from './calculator/portfolio-calculator';
|
import { PortfolioCalculator } from './calculator/portfolio-calculator';
|
||||||
import {
|
import {
|
||||||
@ -206,24 +208,6 @@ export class PortfolioService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAnnualizedPerformancePercent({
|
|
||||||
daysInMarket,
|
|
||||||
netPerformancePercentage
|
|
||||||
}: {
|
|
||||||
daysInMarket: number;
|
|
||||||
netPerformancePercentage: Big;
|
|
||||||
}): Big {
|
|
||||||
if (isNumber(daysInMarket) && daysInMarket > 0) {
|
|
||||||
const exponent = new Big(365).div(daysInMarket).toNumber();
|
|
||||||
|
|
||||||
return new Big(
|
|
||||||
Math.pow(netPerformancePercentage.plus(1).toNumber(), exponent)
|
|
||||||
).minus(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Big(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getDividends({
|
public async getDividends({
|
||||||
activities,
|
activities,
|
||||||
groupBy
|
groupBy
|
||||||
@ -499,7 +483,17 @@ export class PortfolioService {
|
|||||||
grossPerformancePercentageWithCurrencyEffect?.toNumber() ?? 0,
|
grossPerformancePercentageWithCurrencyEffect?.toNumber() ?? 0,
|
||||||
grossPerformanceWithCurrencyEffect:
|
grossPerformanceWithCurrencyEffect:
|
||||||
grossPerformanceWithCurrencyEffect?.toNumber() ?? 0,
|
grossPerformanceWithCurrencyEffect?.toNumber() ?? 0,
|
||||||
holdings: assetProfile.holdings,
|
holdings: assetProfile.holdings.map(
|
||||||
|
({ allocationInPercentage, name }) => {
|
||||||
|
return {
|
||||||
|
allocationInPercentage,
|
||||||
|
name,
|
||||||
|
valueInBaseCurrency: valueInBaseCurrency
|
||||||
|
.mul(allocationInPercentage)
|
||||||
|
.toNumber()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
),
|
||||||
investment: investment.toNumber(),
|
investment: investment.toNumber(),
|
||||||
marketState: dataProviderResponse?.marketState ?? 'delayed',
|
marketState: dataProviderResponse?.marketState ?? 'delayed',
|
||||||
name: assetProfile.name,
|
name: assetProfile.name,
|
||||||
@ -703,7 +697,7 @@ export class PortfolioService {
|
|||||||
return Account;
|
return Account;
|
||||||
});
|
});
|
||||||
|
|
||||||
const dividendYieldPercent = this.getAnnualizedPerformancePercent({
|
const dividendYieldPercent = getAnnualizedPerformancePercent({
|
||||||
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
||||||
netPerformancePercentage: timeWeightedInvestment.eq(0)
|
netPerformancePercentage: timeWeightedInvestment.eq(0)
|
||||||
? new Big(0)
|
? new Big(0)
|
||||||
@ -711,7 +705,7 @@ export class PortfolioService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const dividendYieldPercentWithCurrencyEffect =
|
const dividendYieldPercentWithCurrencyEffect =
|
||||||
this.getAnnualizedPerformancePercent({
|
getAnnualizedPerformancePercent({
|
||||||
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
||||||
netPerformancePercentage: timeWeightedInvestmentWithCurrencyEffect.eq(
|
netPerformancePercentage: timeWeightedInvestmentWithCurrencyEffect.eq(
|
||||||
0
|
0
|
||||||
@ -1311,6 +1305,24 @@ export class PortfolioService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updateTags({
|
||||||
|
dataSource,
|
||||||
|
impersonationId,
|
||||||
|
symbol,
|
||||||
|
tags,
|
||||||
|
userId
|
||||||
|
}: {
|
||||||
|
dataSource: DataSource;
|
||||||
|
impersonationId: string;
|
||||||
|
symbol: string;
|
||||||
|
tags: Tag[];
|
||||||
|
userId: string;
|
||||||
|
}) {
|
||||||
|
userId = await this.getUserId(impersonationId, userId);
|
||||||
|
|
||||||
|
await this.orderService.assignTags({ dataSource, symbol, tags, userId });
|
||||||
|
}
|
||||||
|
|
||||||
private async getCashPositions({
|
private async getCashPositions({
|
||||||
cashDetails,
|
cashDetails,
|
||||||
userCurrency,
|
userCurrency,
|
||||||
@ -1714,13 +1726,13 @@ export class PortfolioService {
|
|||||||
|
|
||||||
const daysInMarket = differenceInDays(new Date(), firstOrderDate);
|
const daysInMarket = differenceInDays(new Date(), firstOrderDate);
|
||||||
|
|
||||||
const annualizedPerformancePercent = this.getAnnualizedPerformancePercent({
|
const annualizedPerformancePercent = getAnnualizedPerformancePercent({
|
||||||
daysInMarket,
|
daysInMarket,
|
||||||
netPerformancePercentage: new Big(netPerformancePercentage)
|
netPerformancePercentage: new Big(netPerformancePercentage)
|
||||||
})?.toNumber();
|
})?.toNumber();
|
||||||
|
|
||||||
const annualizedPerformancePercentWithCurrencyEffect =
|
const annualizedPerformancePercentWithCurrencyEffect =
|
||||||
this.getAnnualizedPerformancePercent({
|
getAnnualizedPerformancePercent({
|
||||||
daysInMarket,
|
daysInMarket,
|
||||||
netPerformancePercentage: new Big(
|
netPerformancePercentage: new Big(
|
||||||
netPerformancePercentageWithCurrencyEffect
|
netPerformancePercentageWithCurrencyEffect
|
||||||
|
7
apps/api/src/app/portfolio/update-holding-tags.dto.ts
Normal file
7
apps/api/src/app/portfolio/update-holding-tags.dto.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { Tag } from '@prisma/client';
|
||||||
|
import { IsArray } from 'class-validator';
|
||||||
|
|
||||||
|
export class UpdateHoldingTagsDto {
|
||||||
|
@IsArray()
|
||||||
|
tags: Tag[];
|
||||||
|
}
|
@ -1,13 +1,14 @@
|
|||||||
|
import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code';
|
||||||
import type {
|
import type {
|
||||||
ColorScheme,
|
ColorScheme,
|
||||||
DateRange,
|
DateRange,
|
||||||
|
HoldingsViewMode,
|
||||||
ViewMode
|
ViewMode
|
||||||
} from '@ghostfolio/common/types';
|
} from '@ghostfolio/common/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsISO4217CurrencyCode,
|
|
||||||
IsISO8601,
|
IsISO8601,
|
||||||
IsIn,
|
IsIn,
|
||||||
IsNumber,
|
IsNumber,
|
||||||
@ -21,7 +22,7 @@ export class UpdateUserSettingDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
annualInterestRate?: number;
|
annualInterestRate?: number;
|
||||||
|
|
||||||
@IsISO4217CurrencyCode()
|
@IsCurrencyCode()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
baseCurrency?: string;
|
baseCurrency?: string;
|
||||||
|
|
||||||
@ -66,6 +67,10 @@ export class UpdateUserSettingDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
'filters.tags'?: string[];
|
'filters.tags'?: string[];
|
||||||
|
|
||||||
|
@IsIn(<HoldingsViewMode[]>['CHART', 'TABLE'])
|
||||||
|
@IsOptional()
|
||||||
|
holdingsViewMode?: HoldingsViewMode;
|
||||||
|
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
isExperimentalFeatures?: boolean;
|
isExperimentalFeatures?: boolean;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { OrderModule } from '@ghostfolio/api/app/order/order.module';
|
||||||
import { SubscriptionModule } from '@ghostfolio/api/app/subscription/subscription.module';
|
import { SubscriptionModule } from '@ghostfolio/api/app/subscription/subscription.module';
|
||||||
import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module';
|
import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module';
|
||||||
import { PrismaModule } from '@ghostfolio/api/services/prisma/prisma.module';
|
import { PrismaModule } from '@ghostfolio/api/services/prisma/prisma.module';
|
||||||
@ -19,6 +20,7 @@ import { UserService } from './user.service';
|
|||||||
secret: process.env.JWT_SECRET_KEY,
|
secret: process.env.JWT_SECRET_KEY,
|
||||||
signOptions: { expiresIn: '30 days' }
|
signOptions: { expiresIn: '30 days' }
|
||||||
}),
|
}),
|
||||||
|
OrderModule,
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
PropertyModule,
|
PropertyModule,
|
||||||
SubscriptionModule,
|
SubscriptionModule,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { OrderService } from '@ghostfolio/api/app/order/order.service';
|
||||||
import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service';
|
import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service';
|
||||||
import { environment } from '@ghostfolio/api/environments/environment';
|
import { environment } from '@ghostfolio/api/environments/environment';
|
||||||
import { PortfolioChangedEvent } from '@ghostfolio/api/events/portfolio-changed.event';
|
import { PortfolioChangedEvent } from '@ghostfolio/api/events/portfolio-changed.event';
|
||||||
@ -40,6 +41,7 @@ export class UserService {
|
|||||||
public constructor(
|
public constructor(
|
||||||
private readonly configurationService: ConfigurationService,
|
private readonly configurationService: ConfigurationService,
|
||||||
private readonly eventEmitter: EventEmitter2,
|
private readonly eventEmitter: EventEmitter2,
|
||||||
|
private readonly orderService: OrderService,
|
||||||
private readonly prismaService: PrismaService,
|
private readonly prismaService: PrismaService,
|
||||||
private readonly propertyService: PropertyService,
|
private readonly propertyService: PropertyService,
|
||||||
private readonly subscriptionService: SubscriptionService,
|
private readonly subscriptionService: SubscriptionService,
|
||||||
@ -188,7 +190,7 @@ export class UserService {
|
|||||||
(user.Settings.settings as UserSettings).dateRange =
|
(user.Settings.settings as UserSettings).dateRange =
|
||||||
(user.Settings.settings as UserSettings).viewMode === 'ZEN'
|
(user.Settings.settings as UserSettings).viewMode === 'ZEN'
|
||||||
? 'max'
|
? 'max'
|
||||||
: (user.Settings.settings as UserSettings)?.dateRange ?? 'max';
|
: ((user.Settings.settings as UserSettings)?.dateRange ?? 'max');
|
||||||
|
|
||||||
// Set default value for view mode
|
// Set default value for view mode
|
||||||
if (!(user.Settings.settings as UserSettings).viewMode) {
|
if (!(user.Settings.settings as UserSettings).viewMode) {
|
||||||
@ -235,11 +237,15 @@ export class UserService {
|
|||||||
|
|
||||||
currentPermissions = without(
|
currentPermissions = without(
|
||||||
currentPermissions,
|
currentPermissions,
|
||||||
|
permissions.accessHoldingsChart,
|
||||||
permissions.createAccess
|
permissions.createAccess
|
||||||
);
|
);
|
||||||
|
|
||||||
// Reset benchmark
|
// Reset benchmark
|
||||||
user.Settings.settings.benchmark = undefined;
|
user.Settings.settings.benchmark = undefined;
|
||||||
|
|
||||||
|
// Reset holdings view mode
|
||||||
|
user.Settings.settings.holdingsViewMode = undefined;
|
||||||
} else if (user.subscription?.type === 'Premium') {
|
} else if (user.subscription?.type === 'Premium') {
|
||||||
currentPermissions.push(permissions.reportDataGlitch);
|
currentPermissions.push(permissions.reportDataGlitch);
|
||||||
|
|
||||||
@ -398,8 +404,8 @@ export class UserService {
|
|||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.prismaService.order.deleteMany({
|
await this.orderService.deleteOrders({
|
||||||
where: { userId: where.id }
|
userId: where.id
|
||||||
});
|
});
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,12 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
||||||
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
||||||
|
<!--
|
||||||
|
<url>
|
||||||
|
<loc>https://ghostfol.io/ca</loc>
|
||||||
|
<lastmod>${currentDate}T00:00:00+00:00</lastmod>
|
||||||
|
</url>
|
||||||
|
-->
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/de</loc>
|
<loc>https://ghostfol.io/de</loc>
|
||||||
<lastmod>${currentDate}T00:00:00+00:00</lastmod>
|
<lastmod>${currentDate}T00:00:00+00:00</lastmod>
|
||||||
@ -441,10 +447,10 @@
|
|||||||
<lastmod>${currentDate}T00:00:00+00:00</lastmod>
|
<lastmod>${currentDate}T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<!--
|
<!--
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/pl</loc>
|
<loc>https://ghostfol.io/pl</loc>
|
||||||
<lastmod>${currentDate}T00:00:00+00:00</lastmod>
|
<lastmod>${currentDate}T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
-->
|
-->
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/pt</loc>
|
<loc>https://ghostfol.io/pt</loc>
|
||||||
|
@ -55,10 +55,10 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
|
|
||||||
const maxInvestmentRatio = maxItem?.investment / totalInvestment || 0;
|
const maxInvestmentRatio = maxItem?.investment / totalInvestment || 0;
|
||||||
|
|
||||||
if (maxInvestmentRatio > ruleSettings.threshold) {
|
if (maxInvestmentRatio > ruleSettings.thresholdMax) {
|
||||||
return {
|
return {
|
||||||
evaluation: `Over ${
|
evaluation: `Over ${
|
||||||
ruleSettings.threshold * 100
|
ruleSettings.thresholdMax * 100
|
||||||
}% of your current investment is at ${maxItem.name} (${(
|
}% of your current investment is at ${maxItem.name} (${(
|
||||||
maxInvestmentRatio * 100
|
maxInvestmentRatio * 100
|
||||||
).toPrecision(3)}%)`,
|
).toPrecision(3)}%)`,
|
||||||
@ -70,7 +70,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
evaluation: `The major part of your current investment is at ${
|
evaluation: `The major part of your current investment is at ${
|
||||||
maxItem.name
|
maxItem.name
|
||||||
} (${(maxInvestmentRatio * 100).toPrecision(3)}%) and does not exceed ${
|
} (${(maxInvestmentRatio * 100).toPrecision(3)}%) and does not exceed ${
|
||||||
ruleSettings.threshold * 100
|
ruleSettings.thresholdMax * 100
|
||||||
}%`,
|
}%`,
|
||||||
value: true
|
value: true
|
||||||
};
|
};
|
||||||
@ -80,12 +80,12 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
return {
|
return {
|
||||||
baseCurrency: aUserSettings.baseCurrency,
|
baseCurrency: aUserSettings.baseCurrency,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
threshold: 0.5
|
thresholdMax: 0.5
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Settings extends RuleSettings {
|
interface Settings extends RuleSettings {
|
||||||
baseCurrency: string;
|
baseCurrency: string;
|
||||||
threshold: number;
|
thresholdMax: number;
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
|
|
||||||
const maxValueRatio = maxItem?.value / totalValue || 0;
|
const maxValueRatio = maxItem?.value / totalValue || 0;
|
||||||
|
|
||||||
if (maxValueRatio > ruleSettings.threshold) {
|
if (maxValueRatio > ruleSettings.thresholdMax) {
|
||||||
return {
|
return {
|
||||||
evaluation: `Over ${
|
evaluation: `Over ${
|
||||||
ruleSettings.threshold * 100
|
ruleSettings.thresholdMax * 100
|
||||||
}% of your current investment is in ${maxItem.groupKey} (${(
|
}% of your current investment is in ${maxItem.groupKey} (${(
|
||||||
maxValueRatio * 100
|
maxValueRatio * 100
|
||||||
).toPrecision(3)}%)`,
|
).toPrecision(3)}%)`,
|
||||||
@ -56,7 +56,7 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
evaluation: `The major part of your current investment is in ${
|
evaluation: `The major part of your current investment is in ${
|
||||||
maxItem?.groupKey ?? ruleSettings.baseCurrency
|
maxItem?.groupKey ?? ruleSettings.baseCurrency
|
||||||
} (${(maxValueRatio * 100).toPrecision(3)}%) and does not exceed ${
|
} (${(maxValueRatio * 100).toPrecision(3)}%) and does not exceed ${
|
||||||
ruleSettings.threshold * 100
|
ruleSettings.thresholdMax * 100
|
||||||
}%`,
|
}%`,
|
||||||
value: true
|
value: true
|
||||||
};
|
};
|
||||||
@ -66,12 +66,12 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
return {
|
return {
|
||||||
baseCurrency: aUserSettings.baseCurrency,
|
baseCurrency: aUserSettings.baseCurrency,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
threshold: 0.5
|
thresholdMax: 0.5
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Settings extends RuleSettings {
|
interface Settings extends RuleSettings {
|
||||||
baseCurrency: string;
|
baseCurrency: string;
|
||||||
threshold: number;
|
thresholdMax: number;
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,16 @@ export class EmergencyFundSetup extends Rule<Settings> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public evaluate(ruleSettings: Settings) {
|
public evaluate(ruleSettings: Settings) {
|
||||||
if (this.emergencyFund > ruleSettings.threshold) {
|
if (this.emergencyFund < ruleSettings.thresholdMin) {
|
||||||
return {
|
return {
|
||||||
evaluation: 'An emergency fund has been set up',
|
evaluation: 'No emergency fund has been set up',
|
||||||
value: true
|
value: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
evaluation: 'No emergency fund has been set up',
|
evaluation: 'An emergency fund has been set up',
|
||||||
value: false
|
value: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,12 +36,12 @@ export class EmergencyFundSetup extends Rule<Settings> {
|
|||||||
return {
|
return {
|
||||||
baseCurrency: aUserSettings.baseCurrency,
|
baseCurrency: aUserSettings.baseCurrency,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
threshold: 0
|
thresholdMin: 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Settings extends RuleSettings {
|
interface Settings extends RuleSettings {
|
||||||
baseCurrency: string;
|
baseCurrency: string;
|
||||||
threshold: number;
|
thresholdMin: number;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ export class FeeRatioInitialInvestment extends Rule<Settings> {
|
|||||||
? this.fees / this.totalInvestment
|
? this.fees / this.totalInvestment
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
if (feeRatio > ruleSettings.threshold) {
|
if (feeRatio > ruleSettings.thresholdMax) {
|
||||||
return {
|
return {
|
||||||
evaluation: `The fees do exceed ${
|
evaluation: `The fees do exceed ${
|
||||||
ruleSettings.threshold * 100
|
ruleSettings.thresholdMax * 100
|
||||||
}% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`,
|
}% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`,
|
||||||
value: false
|
value: false
|
||||||
};
|
};
|
||||||
@ -37,7 +37,7 @@ export class FeeRatioInitialInvestment extends Rule<Settings> {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
evaluation: `The fees do not exceed ${
|
evaluation: `The fees do not exceed ${
|
||||||
ruleSettings.threshold * 100
|
ruleSettings.thresholdMax * 100
|
||||||
}% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`,
|
}% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`,
|
||||||
value: true
|
value: true
|
||||||
};
|
};
|
||||||
@ -47,12 +47,12 @@ export class FeeRatioInitialInvestment extends Rule<Settings> {
|
|||||||
return {
|
return {
|
||||||
baseCurrency: aUserSettings.baseCurrency,
|
baseCurrency: aUserSettings.baseCurrency,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
threshold: 0.01
|
thresholdMax: 0.01
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Settings extends RuleSettings {
|
interface Settings extends RuleSettings {
|
||||||
baseCurrency: string;
|
baseCurrency: string;
|
||||||
threshold: number;
|
thresholdMax: number;
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,11 @@ export class CronService {
|
|||||||
@Cron(CronService.EVERY_SUNDAY_AT_LUNCH_TIME)
|
@Cron(CronService.EVERY_SUNDAY_AT_LUNCH_TIME)
|
||||||
public async runEverySundayAtTwelvePm() {
|
public async runEverySundayAtTwelvePm() {
|
||||||
if (await this.isDataGatheringEnabled()) {
|
if (await this.isDataGatheringEnabled()) {
|
||||||
const uniqueAssets = await this.dataGatheringService.getUniqueAssets();
|
const assetProfileIdentifiers =
|
||||||
|
await this.dataGatheringService.getAllAssetProfileIdentifiers();
|
||||||
|
|
||||||
await this.dataGatheringService.addJobsToQueue(
|
await this.dataGatheringService.addJobsToQueue(
|
||||||
uniqueAssets.map(({ dataSource, symbol }) => {
|
assetProfileIdentifiers.map(({ dataSource, symbol }) => {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
dataSource,
|
dataSource,
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
DATA_GATHERING_QUEUE,
|
DATA_GATHERING_QUEUE,
|
||||||
DATA_GATHERING_QUEUE_PRIORITY_HIGH,
|
DATA_GATHERING_QUEUE_PRIORITY_HIGH,
|
||||||
DATA_GATHERING_QUEUE_PRIORITY_LOW,
|
DATA_GATHERING_QUEUE_PRIORITY_LOW,
|
||||||
|
DATA_GATHERING_QUEUE_PRIORITY_MEDIUM,
|
||||||
GATHER_HISTORICAL_MARKET_DATA_PROCESS,
|
GATHER_HISTORICAL_MARKET_DATA_PROCESS,
|
||||||
GATHER_HISTORICAL_MARKET_DATA_PROCESS_OPTIONS,
|
GATHER_HISTORICAL_MARKET_DATA_PROCESS_OPTIONS,
|
||||||
PROPERTY_BENCHMARKS
|
PROPERTY_BENCHMARKS
|
||||||
@ -62,9 +63,22 @@ export class DataGatheringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async gather7Days() {
|
public async gather7Days() {
|
||||||
const dataGatheringItems = await this.getSymbols7D();
|
|
||||||
await this.gatherSymbols({
|
await this.gatherSymbols({
|
||||||
dataGatheringItems,
|
dataGatheringItems: await this.getCurrencies7D(),
|
||||||
|
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.gatherSymbols({
|
||||||
|
dataGatheringItems: await this.getSymbols7D({
|
||||||
|
withUserSubscription: true
|
||||||
|
}),
|
||||||
|
priority: DATA_GATHERING_QUEUE_PRIORITY_MEDIUM
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.gatherSymbols({
|
||||||
|
dataGatheringItems: await this.getSymbols7D({
|
||||||
|
withUserSubscription: false
|
||||||
|
}),
|
||||||
priority: DATA_GATHERING_QUEUE_PRIORITY_LOW
|
priority: DATA_GATHERING_QUEUE_PRIORITY_LOW
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -138,7 +152,7 @@ export class DataGatheringService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!uniqueAssets) {
|
if (!uniqueAssets) {
|
||||||
uniqueAssets = await this.getUniqueAssets();
|
uniqueAssets = await this.getAllAssetProfileIdentifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uniqueAssets.length <= 0) {
|
if (uniqueAssets.length <= 0) {
|
||||||
@ -270,7 +284,7 @@ export class DataGatheringService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getUniqueAssets(): Promise<UniqueAsset[]> {
|
public async getAllAssetProfileIdentifiers(): Promise<UniqueAsset[]> {
|
||||||
const symbolProfiles = await this.prismaService.symbolProfile.findMany({
|
const symbolProfiles = await this.prismaService.symbolProfile.findMany({
|
||||||
orderBy: [{ symbol: 'asc' }]
|
orderBy: [{ symbol: 'asc' }]
|
||||||
});
|
});
|
||||||
@ -290,73 +304,83 @@ export class DataGatheringService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private getEarliestDate(aStartDate: Date) {
|
private async getAssetProfileIdentifiersWithCompleteMarketData(): Promise<
|
||||||
return min([aStartDate, subYears(new Date(), 10)]);
|
UniqueAsset[]
|
||||||
}
|
> {
|
||||||
|
return (
|
||||||
private async getSymbols7D(): Promise<IDataGatheringItem[]> {
|
|
||||||
const startDate = subDays(resetHours(new Date()), 7);
|
|
||||||
|
|
||||||
const symbolProfiles = await this.prismaService.symbolProfile.findMany({
|
|
||||||
orderBy: [{ symbol: 'asc' }],
|
|
||||||
select: {
|
|
||||||
dataSource: true,
|
|
||||||
scraperConfiguration: true,
|
|
||||||
symbol: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Only consider symbols with incomplete market data for the last
|
|
||||||
// 7 days
|
|
||||||
const symbolsWithCompleteMarketData = (
|
|
||||||
await this.prismaService.marketData.groupBy({
|
await this.prismaService.marketData.groupBy({
|
||||||
_count: true,
|
_count: true,
|
||||||
by: ['symbol'],
|
by: ['dataSource', 'symbol'],
|
||||||
orderBy: [{ symbol: 'asc' }],
|
orderBy: [{ symbol: 'asc' }],
|
||||||
where: {
|
where: {
|
||||||
date: { gt: startDate },
|
date: { gt: subDays(resetHours(new Date()), 7) },
|
||||||
state: 'CLOSE'
|
state: 'CLOSE'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.filter((group) => {
|
.filter(({ _count }) => {
|
||||||
return group._count >= 6;
|
return _count >= 6;
|
||||||
})
|
})
|
||||||
.map((group) => {
|
.map(({ dataSource, symbol }) => {
|
||||||
return group.symbol;
|
return { dataSource, symbol };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getCurrencies7D(): Promise<IDataGatheringItem[]> {
|
||||||
|
const assetProfileIdentifiersWithCompleteMarketData =
|
||||||
|
await this.getAssetProfileIdentifiersWithCompleteMarketData();
|
||||||
|
|
||||||
|
return this.exchangeRateDataService
|
||||||
|
.getCurrencyPairs()
|
||||||
|
.filter(({ dataSource, symbol }) => {
|
||||||
|
return !assetProfileIdentifiersWithCompleteMarketData.some((item) => {
|
||||||
|
return item.dataSource === dataSource && item.symbol === symbol;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.map(({ dataSource, symbol }) => {
|
||||||
|
return {
|
||||||
|
dataSource,
|
||||||
|
symbol,
|
||||||
|
date: subDays(resetHours(new Date()), 7)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getEarliestDate(aStartDate: Date) {
|
||||||
|
return min([aStartDate, subYears(new Date(), 10)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getSymbols7D({
|
||||||
|
withUserSubscription = false
|
||||||
|
}: {
|
||||||
|
withUserSubscription?: boolean;
|
||||||
|
}): Promise<IDataGatheringItem[]> {
|
||||||
|
const symbolProfiles =
|
||||||
|
await this.symbolProfileService.getSymbolProfilesByUserSubscription({
|
||||||
|
withUserSubscription
|
||||||
});
|
});
|
||||||
|
|
||||||
const symbolProfilesToGather = symbolProfiles
|
const assetProfileIdentifiersWithCompleteMarketData =
|
||||||
|
await this.getAssetProfileIdentifiersWithCompleteMarketData();
|
||||||
|
|
||||||
|
return symbolProfiles
|
||||||
.filter(({ dataSource, scraperConfiguration, symbol }) => {
|
.filter(({ dataSource, scraperConfiguration, symbol }) => {
|
||||||
const manualDataSourceWithScraperConfiguration =
|
const manualDataSourceWithScraperConfiguration =
|
||||||
dataSource === 'MANUAL' && !isEmpty(scraperConfiguration);
|
dataSource === 'MANUAL' && !isEmpty(scraperConfiguration);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!symbolsWithCompleteMarketData.includes(symbol) &&
|
!assetProfileIdentifiersWithCompleteMarketData.some((item) => {
|
||||||
|
return item.dataSource === dataSource && item.symbol === symbol;
|
||||||
|
}) &&
|
||||||
(dataSource !== 'MANUAL' || manualDataSourceWithScraperConfiguration)
|
(dataSource !== 'MANUAL' || manualDataSourceWithScraperConfiguration)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.map((symbolProfile) => {
|
.map((symbolProfile) => {
|
||||||
return {
|
return {
|
||||||
...symbolProfile,
|
...symbolProfile,
|
||||||
date: startDate
|
date: subDays(resetHours(new Date()), 7)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const currencyPairsToGather = this.exchangeRateDataService
|
|
||||||
.getCurrencyPairs()
|
|
||||||
.filter(({ symbol }) => {
|
|
||||||
return !symbolsWithCompleteMarketData.includes(symbol);
|
|
||||||
})
|
|
||||||
.map(({ dataSource, symbol }) => {
|
|
||||||
return {
|
|
||||||
dataSource,
|
|
||||||
symbol,
|
|
||||||
date: startDate
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return [...currencyPairsToGather, ...symbolProfilesToGather];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getSymbolsMax(): Promise<IDataGatheringItem[]> {
|
private async getSymbolsMax(): Promise<IDataGatheringItem[]> {
|
||||||
|
@ -14,7 +14,12 @@ import {
|
|||||||
DERIVED_CURRENCIES,
|
DERIVED_CURRENCIES,
|
||||||
PROPERTY_DATA_SOURCE_MAPPING
|
PROPERTY_DATA_SOURCE_MAPPING
|
||||||
} from '@ghostfolio/common/config';
|
} from '@ghostfolio/common/config';
|
||||||
import { DATE_FORMAT, getStartOfUtcDate } from '@ghostfolio/common/helper';
|
import {
|
||||||
|
DATE_FORMAT,
|
||||||
|
getCurrencyFromSymbol,
|
||||||
|
getStartOfUtcDate,
|
||||||
|
isDerivedCurrency
|
||||||
|
} from '@ghostfolio/common/helper';
|
||||||
import { UniqueAsset } from '@ghostfolio/common/interfaces';
|
import { UniqueAsset } from '@ghostfolio/common/interfaces';
|
||||||
import type { Granularity, UserWithSettings } from '@ghostfolio/common/types';
|
import type { Granularity, UserWithSettings } from '@ghostfolio/common/types';
|
||||||
|
|
||||||
@ -423,13 +428,18 @@ export class DataProviderService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const symbols = dataGatheringItems.map((dataGatheringItem) => {
|
const symbols = dataGatheringItems
|
||||||
return dataGatheringItem.symbol;
|
.filter(({ symbol }) => {
|
||||||
});
|
return !isDerivedCurrency(getCurrencyFromSymbol(symbol));
|
||||||
|
})
|
||||||
|
.map(({ symbol }) => {
|
||||||
|
return symbol;
|
||||||
|
});
|
||||||
|
|
||||||
const maximumNumberOfSymbolsPerRequest =
|
const maximumNumberOfSymbolsPerRequest =
|
||||||
dataProvider.getMaxNumberOfSymbolsPerRequest?.() ??
|
dataProvider.getMaxNumberOfSymbolsPerRequest?.() ??
|
||||||
Number.MAX_SAFE_INTEGER;
|
Number.MAX_SAFE_INTEGER;
|
||||||
|
|
||||||
for (
|
for (
|
||||||
let i = 0;
|
let i = 0;
|
||||||
i < symbols.length;
|
i < symbols.length;
|
||||||
|
@ -246,7 +246,7 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
for (const { close, code, timestamp } of quotes) {
|
for (const { close, code, timestamp } of quotes) {
|
||||||
let currency: string;
|
let currency: string;
|
||||||
|
|
||||||
if (code.endsWith('.FOREX')) {
|
if (this.isForex(code)) {
|
||||||
currency = this.convertFromEodSymbol(code)?.replace(
|
currency = this.convertFromEodSymbol(code)?.replace(
|
||||||
DEFAULT_CURRENCY,
|
DEFAULT_CURRENCY,
|
||||||
''
|
''
|
||||||
@ -272,7 +272,10 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
currency,
|
currency,
|
||||||
dataSource: this.getName(),
|
dataSource: this.getName(),
|
||||||
marketPrice: close,
|
marketPrice: close,
|
||||||
marketState: isToday(new Date(timestamp * 1000)) ? 'open' : 'closed'
|
marketState:
|
||||||
|
this.isForex(code) || isToday(new Date(timestamp * 1000))
|
||||||
|
? 'open'
|
||||||
|
: 'closed'
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
Logger.error(
|
Logger.error(
|
||||||
@ -311,7 +314,7 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
items: searchResult
|
items: searchResult
|
||||||
.filter(({ currency, symbol }) => {
|
.filter(({ currency, symbol }) => {
|
||||||
// Remove 'NA' currency and exchange rates
|
// Remove 'NA' currency and exchange rates
|
||||||
return currency?.length === 3 && !symbol.endsWith('.FOREX');
|
return currency?.length === 3 && !this.isForex(symbol);
|
||||||
})
|
})
|
||||||
.map(
|
.map(
|
||||||
({
|
({
|
||||||
@ -349,7 +352,7 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
private convertFromEodSymbol(aEodSymbol: string) {
|
private convertFromEodSymbol(aEodSymbol: string) {
|
||||||
let symbol = aEodSymbol;
|
let symbol = aEodSymbol;
|
||||||
|
|
||||||
if (symbol.endsWith('.FOREX')) {
|
if (this.isForex(symbol)) {
|
||||||
symbol = symbol.replace('GBX', 'GBp');
|
symbol = symbol.replace('GBX', 'GBp');
|
||||||
symbol = symbol.replace('.FOREX', '');
|
symbol = symbol.replace('.FOREX', '');
|
||||||
}
|
}
|
||||||
@ -451,6 +454,10 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
return searchResult;
|
return searchResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isForex(aCode: string) {
|
||||||
|
return aCode?.endsWith('.FOREX') || false;
|
||||||
|
}
|
||||||
|
|
||||||
private parseAssetClass({
|
private parseAssetClass({
|
||||||
Exchange,
|
Exchange,
|
||||||
Type
|
Type
|
||||||
|
@ -257,7 +257,7 @@ export class ManualService implements DataProviderInterface {
|
|||||||
signal: abortController.signal
|
signal: abortController.signal
|
||||||
});
|
});
|
||||||
|
|
||||||
if (headers['content-type'] === 'application/json') {
|
if (headers['content-type'].includes('application/json')) {
|
||||||
const data = JSON.parse(body);
|
const data = JSON.parse(body);
|
||||||
const value = String(
|
const value = String(
|
||||||
jsonpath.query(data, scraperConfiguration.selector)[0]
|
jsonpath.query(data, scraperConfiguration.selector)[0]
|
||||||
|
@ -91,6 +91,40 @@ export class SymbolProfileService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getSymbolProfilesByUserSubscription({
|
||||||
|
withUserSubscription = false
|
||||||
|
}: {
|
||||||
|
withUserSubscription?: boolean;
|
||||||
|
}) {
|
||||||
|
return this.prismaService.symbolProfile.findMany({
|
||||||
|
include: {
|
||||||
|
Order: {
|
||||||
|
include: {
|
||||||
|
User: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
orderBy: [{ symbol: 'asc' }],
|
||||||
|
where: {
|
||||||
|
Order: withUserSubscription
|
||||||
|
? {
|
||||||
|
some: {
|
||||||
|
User: {
|
||||||
|
Subscription: { some: { expiresAt: { gt: new Date() } } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
every: {
|
||||||
|
User: {
|
||||||
|
Subscription: { none: { expiresAt: { gt: new Date() } } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public updateSymbolProfile({
|
public updateSymbolProfile({
|
||||||
assetClass,
|
assetClass,
|
||||||
assetSubClass,
|
assetSubClass,
|
||||||
@ -221,8 +255,9 @@ export class SymbolProfileService {
|
|||||||
const { name, weight } = holding as Prisma.JsonObject;
|
const { name, weight } = holding as Prisma.JsonObject;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
allocationInPercentage: weight as number,
|
||||||
name: (name as string) ?? UNKNOWN_KEY,
|
name: (name as string) ?? UNKNOWN_KEY,
|
||||||
valueInBaseCurrency: weight as number
|
valueInBaseCurrency: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -70,7 +70,7 @@ export class TwitterBotService {
|
|||||||
await this.twitterClient.v2.tweet(status);
|
await this.twitterClient.v2.tweet(status);
|
||||||
|
|
||||||
Logger.log(
|
Logger.log(
|
||||||
`Fear & Greed Index has been tweeted: https://twitter.com/ghostfolio_/status/${createdTweet.id}`,
|
`Fear & Greed Index has been posted: https://x.com/ghostfolio_/status/${createdTweet.id}`,
|
||||||
'TwitterBotService'
|
'TwitterBotService'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
44
apps/api/src/validators/is-currency-code.ts
Normal file
44
apps/api/src/validators/is-currency-code.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { DERIVED_CURRENCIES } from '@ghostfolio/common/config';
|
||||||
|
|
||||||
|
import {
|
||||||
|
registerDecorator,
|
||||||
|
ValidationOptions,
|
||||||
|
ValidatorConstraint,
|
||||||
|
ValidatorConstraintInterface,
|
||||||
|
ValidationArguments
|
||||||
|
} from 'class-validator';
|
||||||
|
import { isISO4217CurrencyCode } from 'class-validator';
|
||||||
|
|
||||||
|
export function IsCurrencyCode(validationOptions?: ValidationOptions) {
|
||||||
|
return function (object: Object, propertyName: string) {
|
||||||
|
registerDecorator({
|
||||||
|
propertyName,
|
||||||
|
constraints: [],
|
||||||
|
options: validationOptions,
|
||||||
|
target: object.constructor,
|
||||||
|
validator: IsExtendedCurrencyConstraint
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@ValidatorConstraint({ async: false })
|
||||||
|
export class IsExtendedCurrencyConstraint
|
||||||
|
implements ValidatorConstraintInterface
|
||||||
|
{
|
||||||
|
public defaultMessage(args: ValidationArguments) {
|
||||||
|
return '$value must be a valid ISO4217 currency code';
|
||||||
|
}
|
||||||
|
|
||||||
|
public validate(currency: any) {
|
||||||
|
// Return true if currency is a standard ISO 4217 code or a derived currency
|
||||||
|
return (
|
||||||
|
isISO4217CurrencyCode(currency) ||
|
||||||
|
[
|
||||||
|
...DERIVED_CURRENCIES.map((derivedCurrency) => {
|
||||||
|
return derivedCurrency.currency;
|
||||||
|
}),
|
||||||
|
'USX'
|
||||||
|
].includes(currency)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -36,6 +36,10 @@
|
|||||||
"ngswConfigPath": "apps/client/ngsw-config.json"
|
"ngswConfigPath": "apps/client/ngsw-config.json"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
|
"development-ca": {
|
||||||
|
"baseHref": "/ca/",
|
||||||
|
"localize": ["ca"]
|
||||||
|
},
|
||||||
"development-de": {
|
"development-de": {
|
||||||
"baseHref": "/de/",
|
"baseHref": "/de/",
|
||||||
"localize": ["de"]
|
"localize": ["de"]
|
||||||
@ -212,6 +216,7 @@
|
|||||||
"includeContext": true,
|
"includeContext": true,
|
||||||
"outputPath": "src/locales",
|
"outputPath": "src/locales",
|
||||||
"targetFiles": [
|
"targetFiles": [
|
||||||
|
"messages.ca.xlf",
|
||||||
"messages.de.xlf",
|
"messages.de.xlf",
|
||||||
"messages.es.xlf",
|
"messages.es.xlf",
|
||||||
"messages.fr.xlf",
|
"messages.fr.xlf",
|
||||||
@ -240,6 +245,10 @@
|
|||||||
},
|
},
|
||||||
"i18n": {
|
"i18n": {
|
||||||
"locales": {
|
"locales": {
|
||||||
|
"ca": {
|
||||||
|
"baseHref": "/ca/",
|
||||||
|
"translation": "apps/client/src/locales/messages.ca.xlf"
|
||||||
|
},
|
||||||
"de": {
|
"de": {
|
||||||
"baseHref": "/de/",
|
"baseHref": "/de/",
|
||||||
"translation": "apps/client/src/locales/messages.de.xlf"
|
"translation": "apps/client/src/locales/messages.de.xlf"
|
||||||
|
@ -138,13 +138,18 @@
|
|||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
class="align-items-baseline d-flex"
|
class="align-items-baseline d-flex"
|
||||||
href="https://twitter.com/ghostfolio_"
|
href="https://x.com/ghostfolio_"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
title="Follow Ghostfolio on X (formerly Twitter)"
|
title="Follow Ghostfolio on X (formerly Twitter)"
|
||||||
>X (formerly Twitter)<ion-icon class="ml-1" name="open-outline"
|
>X (formerly Twitter)<ion-icon class="ml-1" name="open-outline"
|
||||||
/></a>
|
/></a>
|
||||||
</li>
|
</li>
|
||||||
<li> </li>
|
<li> </li>
|
||||||
|
<!--
|
||||||
|
<li>
|
||||||
|
<a href="../ca" title="Ghostfolio en català">Català</a>
|
||||||
|
</li>
|
||||||
|
-->
|
||||||
<li>
|
<li>
|
||||||
<a href="../de" title="Ghostfolio in Deutsch">Deutsch</a>
|
<a href="../de" title="Ghostfolio in Deutsch">Deutsch</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -259,6 +259,10 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
this.user?.permissions,
|
this.user?.permissions,
|
||||||
permissions.reportDataGlitch
|
permissions.reportDataGlitch
|
||||||
),
|
),
|
||||||
|
hasPermissionToUpdateOrder:
|
||||||
|
!this.hasImpersonationId &&
|
||||||
|
hasPermission(this.user?.permissions, permissions.updateOrder) &&
|
||||||
|
!user?.settings?.isRestrictedView,
|
||||||
locale: this.user?.settings?.locale
|
locale: this.user?.settings?.locale
|
||||||
},
|
},
|
||||||
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
|
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
|
||||||
|
@ -6,10 +6,17 @@ import {
|
|||||||
ghostfolioScraperApiSymbolPrefix
|
ghostfolioScraperApiSymbolPrefix
|
||||||
} from '@ghostfolio/common/config';
|
} from '@ghostfolio/common/config';
|
||||||
import { getDateFormatString } from '@ghostfolio/common/helper';
|
import { getDateFormatString } from '@ghostfolio/common/helper';
|
||||||
import { Filter, UniqueAsset, User } from '@ghostfolio/common/interfaces';
|
import {
|
||||||
|
Filter,
|
||||||
|
InfoItem,
|
||||||
|
UniqueAsset,
|
||||||
|
User
|
||||||
|
} from '@ghostfolio/common/interfaces';
|
||||||
import { AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface';
|
import { AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface';
|
||||||
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||||
import { translate } from '@ghostfolio/ui/i18n';
|
import { translate } from '@ghostfolio/ui/i18n';
|
||||||
|
|
||||||
|
import { SelectionModel } from '@angular/cdk/collections';
|
||||||
import {
|
import {
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
@ -96,32 +103,23 @@ export class AdminMarketDataComponent
|
|||||||
new MatTableDataSource();
|
new MatTableDataSource();
|
||||||
public defaultDateFormat: string;
|
public defaultDateFormat: string;
|
||||||
public deviceType: string;
|
public deviceType: string;
|
||||||
public displayedColumns = [
|
public displayedColumns: string[] = [];
|
||||||
'nameWithSymbol',
|
|
||||||
'dataSource',
|
|
||||||
'assetClass',
|
|
||||||
'assetSubClass',
|
|
||||||
'date',
|
|
||||||
'activitiesCount',
|
|
||||||
'marketDataItemCount',
|
|
||||||
'sectorsCount',
|
|
||||||
'countriesCount',
|
|
||||||
'comment',
|
|
||||||
'actions'
|
|
||||||
];
|
|
||||||
public filters$ = new Subject<Filter[]>();
|
public filters$ = new Subject<Filter[]>();
|
||||||
public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix;
|
public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix;
|
||||||
|
public hasPermissionForSubscription: boolean;
|
||||||
|
public info: InfoItem;
|
||||||
public isLoading = false;
|
public isLoading = false;
|
||||||
public isUUID = isUUID;
|
public isUUID = isUUID;
|
||||||
public placeholder = '';
|
public placeholder = '';
|
||||||
public pageSize = DEFAULT_PAGE_SIZE;
|
public pageSize = DEFAULT_PAGE_SIZE;
|
||||||
|
public selection: SelectionModel<Partial<SymbolProfile>>;
|
||||||
public totalItems = 0;
|
public totalItems = 0;
|
||||||
public user: User;
|
public user: User;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private adminMarketDataService: AdminMarketDataService,
|
public adminMarketDataService: AdminMarketDataService,
|
||||||
private adminService: AdminService,
|
private adminService: AdminService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private dataService: DataService,
|
private dataService: DataService,
|
||||||
@ -131,6 +129,33 @@ export class AdminMarketDataComponent
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private userService: UserService
|
private userService: UserService
|
||||||
) {
|
) {
|
||||||
|
this.info = this.dataService.fetchInfo();
|
||||||
|
|
||||||
|
this.hasPermissionForSubscription = hasPermission(
|
||||||
|
this.info?.globalPermissions,
|
||||||
|
permissions.enableSubscription
|
||||||
|
);
|
||||||
|
|
||||||
|
this.displayedColumns = [
|
||||||
|
'select',
|
||||||
|
'nameWithSymbol',
|
||||||
|
'dataSource',
|
||||||
|
'assetClass',
|
||||||
|
'assetSubClass',
|
||||||
|
'date',
|
||||||
|
'activitiesCount',
|
||||||
|
'marketDataItemCount',
|
||||||
|
'sectorsCount',
|
||||||
|
'countriesCount'
|
||||||
|
];
|
||||||
|
|
||||||
|
if (this.hasPermissionForSubscription) {
|
||||||
|
this.displayedColumns.push('isUsedByUsersWithSubscription');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.displayedColumns.push('comment');
|
||||||
|
this.displayedColumns.push('actions');
|
||||||
|
|
||||||
this.route.queryParams
|
this.route.queryParams
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe((params) => {
|
.subscribe((params) => {
|
||||||
@ -188,6 +213,8 @@ export class AdminMarketDataComponent
|
|||||||
|
|
||||||
this.benchmarks = benchmarks;
|
this.benchmarks = benchmarks;
|
||||||
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
||||||
|
|
||||||
|
this.selection = new SelectionModel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public onChangePage(page: PageEvent) {
|
public onChangePage(page: PageEvent) {
|
||||||
@ -198,8 +225,16 @@ export class AdminMarketDataComponent
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onDeleteProfileData({ dataSource, symbol }: UniqueAsset) {
|
public onDeleteAssetProfile({ dataSource, symbol }: UniqueAsset) {
|
||||||
this.adminMarketDataService.deleteProfileData({ dataSource, symbol });
|
this.adminMarketDataService.deleteAssetProfile({ dataSource, symbol });
|
||||||
|
}
|
||||||
|
|
||||||
|
public onDeleteAssetProfiles() {
|
||||||
|
this.adminMarketDataService.deleteAssetProfiles(
|
||||||
|
this.selection.selected.map(({ dataSource, symbol }) => {
|
||||||
|
return { dataSource, symbol };
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public onGather7Days() {
|
public onGather7Days() {
|
||||||
@ -286,6 +321,8 @@ export class AdminMarketDataComponent
|
|||||||
this.placeholder =
|
this.placeholder =
|
||||||
this.activeFilters.length <= 0 ? $localize`Filter by...` : '';
|
this.activeFilters.length <= 0 ? $localize`Filter by...` : '';
|
||||||
|
|
||||||
|
this.selection.clear();
|
||||||
|
|
||||||
this.adminService
|
this.adminService
|
||||||
.fetchAdminMarketData({
|
.fetchAdminMarketData({
|
||||||
sortColumn,
|
sortColumn,
|
||||||
|
@ -20,6 +20,27 @@
|
|||||||
matSortDirection="asc"
|
matSortDirection="asc"
|
||||||
[dataSource]="dataSource"
|
[dataSource]="dataSource"
|
||||||
>
|
>
|
||||||
|
<ng-container matColumnDef="select">
|
||||||
|
<th *matHeaderCellDef class="px-1" mat-header-cell></th>
|
||||||
|
<td *matCellDef="let element" class="px-1" mat-cell>
|
||||||
|
@if (
|
||||||
|
adminMarketDataService.hasPermissionToDeleteAssetProfile({
|
||||||
|
activitiesCount: element.activitiesCount,
|
||||||
|
isBenchmark: element.isBenchmark,
|
||||||
|
symbol: element.symbol
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
<mat-checkbox
|
||||||
|
color="primary"
|
||||||
|
[checked]="selection.isSelected(element)"
|
||||||
|
(change)="$event ? selection.toggle(element) : null"
|
||||||
|
(click)="$event.stopPropagation()"
|
||||||
|
>
|
||||||
|
</mat-checkbox>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="symbol">
|
<ng-container matColumnDef="symbol">
|
||||||
<th *matHeaderCellDef class="px-1" mat-header-cell mat-sort-header>
|
<th *matHeaderCellDef class="px-1" mat-header-cell mat-sort-header>
|
||||||
<ng-container i18n>Symbol</ng-container>
|
<ng-container i18n>Symbol</ng-container>
|
||||||
@ -123,6 +144,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="isUsedByUsersWithSubscription">
|
||||||
|
<th *matHeaderCellDef class="px-1" mat-header-cell></th>
|
||||||
|
<td *matCellDef="let element" class="px-1" mat-cell>
|
||||||
|
@if (element.isUsedByUsersWithSubscription) {
|
||||||
|
<gf-premium-indicator [enableLink]="false" />
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="comment">
|
<ng-container matColumnDef="comment">
|
||||||
<th *matHeaderCellDef class="px-1" mat-header-cell></th>
|
<th *matHeaderCellDef class="px-1" mat-header-cell></th>
|
||||||
<td *matCellDef="let element" class="px-1" mat-cell>
|
<td *matCellDef="let element" class="px-1" mat-cell>
|
||||||
@ -152,6 +182,13 @@
|
|||||||
<button mat-menu-item (click)="onGatherProfileData()">
|
<button mat-menu-item (click)="onGatherProfileData()">
|
||||||
<ng-container i18n>Gather Profile Data</ng-container>
|
<ng-container i18n>Gather Profile Data</ng-container>
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
mat-menu-item
|
||||||
|
[disabled]="!selection.hasValue()"
|
||||||
|
(click)="onDeleteAssetProfiles()"
|
||||||
|
>
|
||||||
|
<ng-container i18n>Delete Profiles</ng-container>
|
||||||
|
</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
</th>
|
</th>
|
||||||
<td *matCellDef="let element" class="px-1 text-center" mat-cell>
|
<td *matCellDef="let element" class="px-1 text-center" mat-cell>
|
||||||
@ -181,12 +218,14 @@
|
|||||||
<button
|
<button
|
||||||
mat-menu-item
|
mat-menu-item
|
||||||
[disabled]="
|
[disabled]="
|
||||||
element.activitiesCount !== 0 ||
|
!adminMarketDataService.hasPermissionToDeleteAssetProfile({
|
||||||
element.isBenchmark ||
|
activitiesCount: element.activitiesCount,
|
||||||
element.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
|
isBenchmark: element.isBenchmark,
|
||||||
|
symbol: element.symbol
|
||||||
|
})
|
||||||
"
|
"
|
||||||
(click)="
|
(click)="
|
||||||
onDeleteProfileData({
|
onDeleteAssetProfile({
|
||||||
dataSource: element.dataSource,
|
dataSource: element.dataSource,
|
||||||
symbol: element.symbol
|
symbol: element.symbol
|
||||||
})
|
})
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module';
|
import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module';
|
||||||
import { GfActivitiesFilterComponent } from '@ghostfolio/ui/activities-filter';
|
import { GfActivitiesFilterComponent } from '@ghostfolio/ui/activities-filter';
|
||||||
|
import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator';
|
||||||
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||||
import { MatSortModule } from '@angular/material/sort';
|
import { MatSortModule } from '@angular/material/sort';
|
||||||
@ -23,8 +25,10 @@ import { GfCreateAssetProfileDialogModule } from './create-asset-profile-dialog/
|
|||||||
GfActivitiesFilterComponent,
|
GfActivitiesFilterComponent,
|
||||||
GfAssetProfileDialogModule,
|
GfAssetProfileDialogModule,
|
||||||
GfCreateAssetProfileDialogModule,
|
GfCreateAssetProfileDialogModule,
|
||||||
|
GfPremiumIndicatorComponent,
|
||||||
GfSymbolModule,
|
GfSymbolModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
|
MatCheckboxModule,
|
||||||
MatMenuModule,
|
MatMenuModule,
|
||||||
MatPaginatorModule,
|
MatPaginatorModule,
|
||||||
MatSortModule,
|
MatSortModule,
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
import { AdminService } from '@ghostfolio/client/services/admin.service';
|
import { AdminService } from '@ghostfolio/client/services/admin.service';
|
||||||
import { UniqueAsset } from '@ghostfolio/common/interfaces';
|
import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config';
|
||||||
|
import { getCurrencyFromSymbol, isCurrency } from '@ghostfolio/common/helper';
|
||||||
|
import {
|
||||||
|
AdminMarketDataItem,
|
||||||
|
UniqueAsset
|
||||||
|
} from '@ghostfolio/common/interfaces';
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { takeUntil } from 'rxjs';
|
import { EMPTY, catchError, finalize, forkJoin, takeUntil } from 'rxjs';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminMarketDataService {
|
export class AdminMarketDataService {
|
||||||
public constructor(private adminService: AdminService) {}
|
public constructor(private adminService: AdminService) {}
|
||||||
|
|
||||||
public deleteProfileData({ dataSource, symbol }: UniqueAsset) {
|
public deleteAssetProfile({ dataSource, symbol }: UniqueAsset) {
|
||||||
const confirmation = confirm(
|
const confirmation = confirm(
|
||||||
$localize`Do you really want to delete this asset profile?`
|
$localize`Do you really want to delete this asset profile?`
|
||||||
);
|
);
|
||||||
@ -23,4 +28,44 @@ export class AdminMarketDataService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public deleteAssetProfiles(uniqueAssets: UniqueAsset[]) {
|
||||||
|
const confirmation = confirm(
|
||||||
|
$localize`Do you really want to delete these profiles?`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (confirmation) {
|
||||||
|
const deleteRequests = uniqueAssets.map(({ dataSource, symbol }) => {
|
||||||
|
return this.adminService.deleteProfileData({ dataSource, symbol });
|
||||||
|
});
|
||||||
|
|
||||||
|
forkJoin(deleteRequests)
|
||||||
|
.pipe(
|
||||||
|
catchError(() => {
|
||||||
|
alert($localize`Oops! Could not delete profiles.`);
|
||||||
|
|
||||||
|
return EMPTY;
|
||||||
|
}),
|
||||||
|
finalize(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 300);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public hasPermissionToDeleteAssetProfile({
|
||||||
|
activitiesCount,
|
||||||
|
isBenchmark,
|
||||||
|
symbol
|
||||||
|
}: Pick<AdminMarketDataItem, 'activitiesCount' | 'isBenchmark' | 'symbol'>) {
|
||||||
|
return (
|
||||||
|
activitiesCount === 0 &&
|
||||||
|
!isBenchmark &&
|
||||||
|
!isCurrency(getCurrencyFromSymbol(symbol)) &&
|
||||||
|
!symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
|
|||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private adminMarketDataService: AdminMarketDataService,
|
public adminMarketDataService: AdminMarketDataService,
|
||||||
private adminService: AdminService,
|
private adminService: AdminService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: AssetProfileDialogParams,
|
@Inject(MAT_DIALOG_DATA) public data: AssetProfileDialogParams,
|
||||||
@ -176,7 +176,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onDeleteProfileData({ dataSource, symbol }: UniqueAsset) {
|
public onDeleteProfileData({ dataSource, symbol }: UniqueAsset) {
|
||||||
this.adminMarketDataService.deleteProfileData({ dataSource, symbol });
|
this.adminMarketDataService.deleteAssetProfile({ dataSource, symbol });
|
||||||
|
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,11 @@
|
|||||||
mat-menu-item
|
mat-menu-item
|
||||||
type="button"
|
type="button"
|
||||||
[disabled]="
|
[disabled]="
|
||||||
assetProfile?.activitiesCount !== 0 ||
|
!adminMarketDataService.hasPermissionToDeleteAssetProfile({
|
||||||
isBenchmark ||
|
activitiesCount: assetProfile?.activitiesCount,
|
||||||
data.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
|
isBenchmark: isBenchmark,
|
||||||
|
symbol: data.symbol
|
||||||
|
})
|
||||||
"
|
"
|
||||||
(click)="
|
(click)="
|
||||||
onDeleteProfileData({
|
onDeleteProfileData({
|
||||||
|
@ -12,11 +12,7 @@
|
|||||||
<div class="d-flex my-3">
|
<div class="d-flex my-3">
|
||||||
<div class="w-50" i18n>User Count</div>
|
<div class="w-50" i18n>User Count</div>
|
||||||
<div class="w-50">
|
<div class="w-50">
|
||||||
<gf-value
|
<gf-value [locale]="user?.settings?.locale" [value]="userCount" />
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[precision]="0"
|
|
||||||
[value]="userCount"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex my-3">
|
<div class="d-flex my-3">
|
||||||
@ -24,7 +20,6 @@
|
|||||||
<div class="w-50">
|
<div class="w-50">
|
||||||
<gf-value
|
<gf-value
|
||||||
[locale]="user?.settings?.locale"
|
[locale]="user?.settings?.locale"
|
||||||
[precision]="0"
|
|
||||||
[value]="transactionCount"
|
[value]="transactionCount"
|
||||||
/>
|
/>
|
||||||
@if (transactionCount && userCount) {
|
@if (transactionCount && userCount) {
|
||||||
|
@ -4,6 +4,7 @@ import { GfDialogFooterModule } from '@ghostfolio/client/components/dialog-foote
|
|||||||
import { GfDialogHeaderModule } from '@ghostfolio/client/components/dialog-header/dialog-header.module';
|
import { GfDialogHeaderModule } from '@ghostfolio/client/components/dialog-header/dialog-header.module';
|
||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config';
|
||||||
import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper';
|
import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper';
|
||||||
import {
|
import {
|
||||||
DataProviderInfo,
|
DataProviderInfo,
|
||||||
@ -18,16 +19,24 @@ import { GfLineChartComponent } from '@ghostfolio/ui/line-chart';
|
|||||||
import { GfPortfolioProportionChartComponent } from '@ghostfolio/ui/portfolio-proportion-chart';
|
import { GfPortfolioProportionChartComponent } from '@ghostfolio/ui/portfolio-proportion-chart';
|
||||||
import { GfValueComponent } from '@ghostfolio/ui/value';
|
import { GfValueComponent } from '@ghostfolio/ui/value';
|
||||||
|
|
||||||
|
import { COMMA, ENTER } from '@angular/cdk/keycodes';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
CUSTOM_ELEMENTS_SCHEMA,
|
CUSTOM_ELEMENTS_SCHEMA,
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
|
ElementRef,
|
||||||
Inject,
|
Inject,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit
|
OnInit,
|
||||||
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
import {
|
||||||
|
MatAutocompleteModule,
|
||||||
|
MatAutocompleteSelectedEvent
|
||||||
|
} from '@angular/material/autocomplete';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatChipsModule } from '@angular/material/chips';
|
import { MatChipsModule } from '@angular/material/chips';
|
||||||
import {
|
import {
|
||||||
@ -35,14 +44,15 @@ import {
|
|||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
MatDialogRef
|
MatDialogRef
|
||||||
} from '@angular/material/dialog';
|
} from '@angular/material/dialog';
|
||||||
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
import { SortDirection } from '@angular/material/sort';
|
import { SortDirection } from '@angular/material/sort';
|
||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
import { MatTabsModule } from '@angular/material/tabs';
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
import { Account, Tag } from '@prisma/client';
|
import { Account, Tag } from '@prisma/client';
|
||||||
import { format, isSameMonth, isToday, parseISO } from 'date-fns';
|
import { format, isSameMonth, isToday, parseISO } from 'date-fns';
|
||||||
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
|
||||||
import { Subject } from 'rxjs';
|
import { Observable, of, Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { map, startWith, takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
import { HoldingDetailDialogParams } from './interfaces/interfaces';
|
import { HoldingDetailDialogParams } from './interfaces/interfaces';
|
||||||
|
|
||||||
@ -59,9 +69,11 @@ import { HoldingDetailDialogParams } from './interfaces/interfaces';
|
|||||||
GfLineChartComponent,
|
GfLineChartComponent,
|
||||||
GfPortfolioProportionChartComponent,
|
GfPortfolioProportionChartComponent,
|
||||||
GfValueComponent,
|
GfValueComponent,
|
||||||
|
MatAutocompleteModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatChipsModule,
|
MatChipsModule,
|
||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
|
MatFormFieldModule,
|
||||||
MatTabsModule,
|
MatTabsModule,
|
||||||
NgxSkeletonLoaderModule
|
NgxSkeletonLoaderModule
|
||||||
],
|
],
|
||||||
@ -72,6 +84,9 @@ import { HoldingDetailDialogParams } from './interfaces/interfaces';
|
|||||||
templateUrl: 'holding-detail-dialog.html'
|
templateUrl: 'holding-detail-dialog.html'
|
||||||
})
|
})
|
||||||
export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
||||||
|
@ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>;
|
||||||
|
|
||||||
|
public activityForm: FormGroup;
|
||||||
public accounts: Account[];
|
public accounts: Account[];
|
||||||
public activities: Activity[];
|
public activities: Activity[];
|
||||||
public assetClass: string;
|
public assetClass: string;
|
||||||
@ -84,28 +99,35 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
public dataProviderInfo: DataProviderInfo;
|
public dataProviderInfo: DataProviderInfo;
|
||||||
public dataSource: MatTableDataSource<Activity>;
|
public dataSource: MatTableDataSource<Activity>;
|
||||||
public dividendInBaseCurrency: number;
|
public dividendInBaseCurrency: number;
|
||||||
|
public dividendInBaseCurrencyPrecision = 2;
|
||||||
public dividendYieldPercentWithCurrencyEffect: number;
|
public dividendYieldPercentWithCurrencyEffect: number;
|
||||||
public feeInBaseCurrency: number;
|
public feeInBaseCurrency: number;
|
||||||
|
public filteredTagsObservable: Observable<Tag[]> = of([]);
|
||||||
public firstBuyDate: string;
|
public firstBuyDate: string;
|
||||||
public historicalDataItems: LineChartItem[];
|
public historicalDataItems: LineChartItem[];
|
||||||
public investment: number;
|
public investment: number;
|
||||||
|
public investmentPrecision = 2;
|
||||||
public marketPrice: number;
|
public marketPrice: number;
|
||||||
public maxPrice: number;
|
public maxPrice: number;
|
||||||
public minPrice: number;
|
public minPrice: number;
|
||||||
public netPerformance: number;
|
public netPerformance: number;
|
||||||
|
public netPerformancePrecision = 2;
|
||||||
public netPerformancePercent: number;
|
public netPerformancePercent: number;
|
||||||
public netPerformancePercentWithCurrencyEffect: number;
|
public netPerformancePercentWithCurrencyEffect: number;
|
||||||
public netPerformanceWithCurrencyEffect: number;
|
public netPerformanceWithCurrencyEffect: number;
|
||||||
|
public netPerformanceWithCurrencyEffectPrecision = 2;
|
||||||
public quantity: number;
|
public quantity: number;
|
||||||
public quantityPrecision = 2;
|
public quantityPrecision = 2;
|
||||||
public reportDataGlitchMail: string;
|
public reportDataGlitchMail: string;
|
||||||
public sectors: {
|
public sectors: {
|
||||||
[name: string]: { name: string; value: number };
|
[name: string]: { name: string; value: number };
|
||||||
};
|
};
|
||||||
|
public separatorKeysCodes: number[] = [COMMA, ENTER];
|
||||||
public sortColumn = 'date';
|
public sortColumn = 'date';
|
||||||
public sortDirection: SortDirection = 'desc';
|
public sortDirection: SortDirection = 'desc';
|
||||||
public SymbolProfile: EnhancedSymbolProfile;
|
public SymbolProfile: EnhancedSymbolProfile;
|
||||||
public tags: Tag[];
|
public tags: Tag[];
|
||||||
|
public tagsAvailable: Tag[];
|
||||||
public totalItems: number;
|
public totalItems: number;
|
||||||
public transactionCount: number;
|
public transactionCount: number;
|
||||||
public user: User;
|
public user: User;
|
||||||
@ -118,10 +140,38 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
private dataService: DataService,
|
private dataService: DataService,
|
||||||
public dialogRef: MatDialogRef<GfHoldingDetailDialogComponent>,
|
public dialogRef: MatDialogRef<GfHoldingDetailDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: HoldingDetailDialogParams,
|
@Inject(MAT_DIALOG_DATA) public data: HoldingDetailDialogParams,
|
||||||
|
private formBuilder: FormBuilder,
|
||||||
private userService: UserService
|
private userService: UserService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
const { tags } = this.dataService.fetchInfo();
|
||||||
|
|
||||||
|
this.activityForm = this.formBuilder.group({
|
||||||
|
tags: <string[]>[]
|
||||||
|
});
|
||||||
|
|
||||||
|
this.tagsAvailable = tags.map(({ id, name }) => {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
name: translate(name)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activityForm
|
||||||
|
.get('tags')
|
||||||
|
.valueChanges.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((tags) => {
|
||||||
|
this.dataService
|
||||||
|
.putHoldingTags({
|
||||||
|
tags,
|
||||||
|
dataSource: this.data.dataSource,
|
||||||
|
symbol: this.data.symbol
|
||||||
|
})
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe();
|
||||||
|
});
|
||||||
|
|
||||||
this.dataService
|
this.dataService
|
||||||
.fetchHoldingDetail({
|
.fetchHoldingDetail({
|
||||||
dataSource: this.data.dataSource,
|
dataSource: this.data.dataSource,
|
||||||
@ -161,10 +211,20 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
this.dataProviderInfo = dataProviderInfo;
|
this.dataProviderInfo = dataProviderInfo;
|
||||||
this.dataSource = new MatTableDataSource(orders.reverse());
|
this.dataSource = new MatTableDataSource(orders.reverse());
|
||||||
this.dividendInBaseCurrency = dividendInBaseCurrency;
|
this.dividendInBaseCurrency = dividendInBaseCurrency;
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.data.deviceType === 'mobile' &&
|
||||||
|
this.dividendInBaseCurrency >= NUMERICAL_PRECISION_THRESHOLD
|
||||||
|
) {
|
||||||
|
this.dividendInBaseCurrencyPrecision = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.dividendYieldPercentWithCurrencyEffect =
|
this.dividendYieldPercentWithCurrencyEffect =
|
||||||
dividendYieldPercentWithCurrencyEffect;
|
dividendYieldPercentWithCurrencyEffect;
|
||||||
|
|
||||||
this.feeInBaseCurrency = feeInBaseCurrency;
|
this.feeInBaseCurrency = feeInBaseCurrency;
|
||||||
this.firstBuyDate = firstBuyDate;
|
this.firstBuyDate = firstBuyDate;
|
||||||
|
|
||||||
this.historicalDataItems = historicalData.map(
|
this.historicalDataItems = historicalData.map(
|
||||||
({ averagePrice, date, marketPrice }) => {
|
({ averagePrice, date, marketPrice }) => {
|
||||||
this.benchmarkDataItems.push({
|
this.benchmarkDataItems.push({
|
||||||
@ -178,26 +238,82 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.investment = investment;
|
this.investment = investment;
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.data.deviceType === 'mobile' &&
|
||||||
|
this.investment >= NUMERICAL_PRECISION_THRESHOLD
|
||||||
|
) {
|
||||||
|
this.investmentPrecision = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.marketPrice = marketPrice;
|
this.marketPrice = marketPrice;
|
||||||
this.maxPrice = maxPrice;
|
this.maxPrice = maxPrice;
|
||||||
this.minPrice = minPrice;
|
this.minPrice = minPrice;
|
||||||
this.netPerformance = netPerformance;
|
this.netPerformance = netPerformance;
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.data.deviceType === 'mobile' &&
|
||||||
|
this.netPerformance >= NUMERICAL_PRECISION_THRESHOLD
|
||||||
|
) {
|
||||||
|
this.netPerformancePrecision = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.netPerformancePercent = netPerformancePercent;
|
this.netPerformancePercent = netPerformancePercent;
|
||||||
|
|
||||||
this.netPerformancePercentWithCurrencyEffect =
|
this.netPerformancePercentWithCurrencyEffect =
|
||||||
netPerformancePercentWithCurrencyEffect;
|
netPerformancePercentWithCurrencyEffect;
|
||||||
|
|
||||||
this.netPerformanceWithCurrencyEffect =
|
this.netPerformanceWithCurrencyEffect =
|
||||||
netPerformanceWithCurrencyEffect;
|
netPerformanceWithCurrencyEffect;
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.data.deviceType === 'mobile' &&
|
||||||
|
this.netPerformanceWithCurrencyEffect >=
|
||||||
|
NUMERICAL_PRECISION_THRESHOLD
|
||||||
|
) {
|
||||||
|
this.netPerformanceWithCurrencyEffectPrecision = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
|
|
||||||
|
if (Number.isInteger(this.quantity)) {
|
||||||
|
this.quantityPrecision = 0;
|
||||||
|
} else if (this.SymbolProfile?.assetSubClass === 'CRYPTOCURRENCY') {
|
||||||
|
if (this.quantity < 1) {
|
||||||
|
this.quantityPrecision = 7;
|
||||||
|
} else if (this.quantity < 1000) {
|
||||||
|
this.quantityPrecision = 5;
|
||||||
|
} else if (this.quantity >= 10000000) {
|
||||||
|
this.quantityPrecision = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.reportDataGlitchMail = `mailto:hi@ghostfol.io?Subject=Ghostfolio Data Glitch Report&body=Hello%0D%0DI would like to report a data glitch for%0D%0DSymbol: ${SymbolProfile?.symbol}%0DData Source: ${SymbolProfile?.dataSource}%0D%0DAdditional notes:%0D%0DCan you please take a look?%0D%0DKind regards`;
|
this.reportDataGlitchMail = `mailto:hi@ghostfol.io?Subject=Ghostfolio Data Glitch Report&body=Hello%0D%0DI would like to report a data glitch for%0D%0DSymbol: ${SymbolProfile?.symbol}%0DData Source: ${SymbolProfile?.dataSource}%0D%0DAdditional notes:%0D%0DCan you please take a look?%0D%0DKind regards`;
|
||||||
this.sectors = {};
|
this.sectors = {};
|
||||||
this.SymbolProfile = SymbolProfile;
|
this.SymbolProfile = SymbolProfile;
|
||||||
|
|
||||||
this.tags = tags.map(({ id, name }) => {
|
this.tags = tags.map(({ id, name }) => {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
name: translate(name)
|
name: translate(name)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.activityForm.setValue({ tags: this.tags }, { emitEvent: false });
|
||||||
|
|
||||||
|
this.filteredTagsObservable = this.activityForm.controls[
|
||||||
|
'tags'
|
||||||
|
].valueChanges.pipe(
|
||||||
|
startWith(this.activityForm.get('tags').value),
|
||||||
|
map((aTags: Tag[] | null) => {
|
||||||
|
return aTags
|
||||||
|
? this.filterTags(aTags)
|
||||||
|
: this.tagsAvailable.slice();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
this.transactionCount = transactionCount;
|
this.transactionCount = transactionCount;
|
||||||
this.totalItems = transactionCount;
|
this.totalItems = transactionCount;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -282,18 +398,6 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Number.isInteger(this.quantity)) {
|
|
||||||
this.quantityPrecision = 0;
|
|
||||||
} else if (this.SymbolProfile?.assetSubClass === 'CRYPTOCURRENCY') {
|
|
||||||
if (this.quantity < 1) {
|
|
||||||
this.quantityPrecision = 7;
|
|
||||||
} else if (this.quantity < 1000) {
|
|
||||||
this.quantityPrecision = 5;
|
|
||||||
} else if (this.quantity > 10000000) {
|
|
||||||
this.quantityPrecision = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -309,6 +413,17 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onAddTag(event: MatAutocompleteSelectedEvent) {
|
||||||
|
this.activityForm.get('tags').setValue([
|
||||||
|
...(this.activityForm.get('tags').value ?? []),
|
||||||
|
this.tagsAvailable.find(({ id }) => {
|
||||||
|
return id === event.option.value;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.tagInput.nativeElement.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
public onClose() {
|
public onClose() {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
@ -333,8 +448,26 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onRemoveTag(aTag: Tag) {
|
||||||
|
this.activityForm.get('tags').setValue(
|
||||||
|
this.activityForm.get('tags').value.filter(({ id }) => {
|
||||||
|
return id !== aTag.id;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
this.unsubscribeSubject.next();
|
this.unsubscribeSubject.next();
|
||||||
this.unsubscribeSubject.complete();
|
this.unsubscribeSubject.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private filterTags(aTags: Tag[]) {
|
||||||
|
const tagIds = aTags.map(({ id }) => {
|
||||||
|
return id;
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.tagsAvailable.filter(({ id }) => {
|
||||||
|
return !tagIds.includes(id);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
[colorizeSign]="true"
|
[colorizeSign]="true"
|
||||||
[isCurrency]="true"
|
[isCurrency]="true"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
|
[precision]="netPerformanceWithCurrencyEffectPrecision"
|
||||||
[unit]="data.baseCurrency"
|
[unit]="data.baseCurrency"
|
||||||
[value]="netPerformanceWithCurrencyEffect"
|
[value]="netPerformanceWithCurrencyEffect"
|
||||||
>Change with currency effect</gf-value
|
>Change with currency effect</gf-value
|
||||||
@ -58,6 +59,7 @@
|
|||||||
[colorizeSign]="true"
|
[colorizeSign]="true"
|
||||||
[isCurrency]="true"
|
[isCurrency]="true"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
|
[precision]="netPerformancePrecision"
|
||||||
[unit]="data.baseCurrency"
|
[unit]="data.baseCurrency"
|
||||||
[value]="netPerformance"
|
[value]="netPerformance"
|
||||||
>Change</gf-value
|
>Change</gf-value
|
||||||
@ -160,6 +162,7 @@
|
|||||||
size="medium"
|
size="medium"
|
||||||
[isCurrency]="true"
|
[isCurrency]="true"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
|
[precision]="investmentPrecision"
|
||||||
[unit]="data.baseCurrency"
|
[unit]="data.baseCurrency"
|
||||||
[value]="investment"
|
[value]="investment"
|
||||||
>Investment</gf-value
|
>Investment</gf-value
|
||||||
@ -172,6 +175,7 @@
|
|||||||
size="medium"
|
size="medium"
|
||||||
[isCurrency]="true"
|
[isCurrency]="true"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
|
[precision]="dividendInBaseCurrencyPrecision"
|
||||||
[unit]="data.baseCurrency"
|
[unit]="data.baseCurrency"
|
||||||
[value]="dividendInBaseCurrency"
|
[value]="dividendInBaseCurrency"
|
||||||
>Dividend</gf-value
|
>Dividend</gf-value
|
||||||
@ -321,7 +325,7 @@
|
|||||||
|
|
||||||
<mat-tab-group
|
<mat-tab-group
|
||||||
animationDuration="0"
|
animationDuration="0"
|
||||||
class="mb-3"
|
class="mb-5"
|
||||||
[mat-stretch-tabs]="false"
|
[mat-stretch-tabs]="false"
|
||||||
[ngClass]="{ 'd-none': !activities?.length }"
|
[ngClass]="{ 'd-none': !activities?.length }"
|
||||||
>
|
>
|
||||||
@ -371,7 +375,49 @@
|
|||||||
</mat-tab>
|
</mat-tab>
|
||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
|
|
||||||
@if (tags?.length > 0) {
|
<div
|
||||||
|
class="row"
|
||||||
|
[ngClass]="{
|
||||||
|
'd-none': !data.hasPermissionToUpdateOrder
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<div class="col">
|
||||||
|
<mat-form-field appearance="outline" class="w-100 without-hint">
|
||||||
|
<mat-label i18n>Tags</mat-label>
|
||||||
|
<mat-chip-grid #tagsChipList>
|
||||||
|
@for (tag of activityForm.get('tags')?.value; track tag.id) {
|
||||||
|
<mat-chip-row
|
||||||
|
matChipRemove
|
||||||
|
[removable]="true"
|
||||||
|
(removed)="onRemoveTag(tag)"
|
||||||
|
>
|
||||||
|
{{ tag.name }}
|
||||||
|
<ion-icon class="ml-2" matPrefix name="close-outline" />
|
||||||
|
</mat-chip-row>
|
||||||
|
}
|
||||||
|
<input
|
||||||
|
#tagInput
|
||||||
|
name="close-outline"
|
||||||
|
[matAutocomplete]="autocompleteTags"
|
||||||
|
[matChipInputFor]="tagsChipList"
|
||||||
|
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
|
||||||
|
/>
|
||||||
|
</mat-chip-grid>
|
||||||
|
<mat-autocomplete
|
||||||
|
#autocompleteTags="matAutocomplete"
|
||||||
|
(optionSelected)="onAddTag($event)"
|
||||||
|
>
|
||||||
|
@for (tag of filteredTagsObservable | async; track tag.id) {
|
||||||
|
<mat-option [value]="tag.id">
|
||||||
|
{{ tag.name }}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
|
</mat-autocomplete>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (!data.hasPermissionToUpdateOrder && tagsAvailable?.length > 0) {
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="h5" i18n>Tags</div>
|
<div class="h5" i18n>Tags</div>
|
||||||
|
@ -9,6 +9,7 @@ export interface HoldingDetailDialogParams {
|
|||||||
deviceType: string;
|
deviceType: string;
|
||||||
hasImpersonationId: boolean;
|
hasImpersonationId: boolean;
|
||||||
hasPermissionToReportDataGlitch: boolean;
|
hasPermissionToReportDataGlitch: boolean;
|
||||||
|
hasPermissionToUpdateOrder: boolean;
|
||||||
locale: string;
|
locale: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
||||||
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
import { PortfolioPosition, User } from '@ghostfolio/common/interfaces';
|
import {
|
||||||
|
PortfolioPosition,
|
||||||
|
UniqueAsset,
|
||||||
|
User
|
||||||
|
} from '@ghostfolio/common/interfaces';
|
||||||
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||||
import { HoldingType, ToggleOption } from '@ghostfolio/common/types';
|
import {
|
||||||
|
HoldingType,
|
||||||
|
HoldingsViewMode,
|
||||||
|
ToggleOption
|
||||||
|
} from '@ghostfolio/common/types';
|
||||||
|
|
||||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { FormControl } from '@angular/forms';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { skip, takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-home-holdings',
|
selector: 'gf-home-holdings',
|
||||||
@ -16,8 +26,11 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
templateUrl: './home-holdings.html'
|
templateUrl: './home-holdings.html'
|
||||||
})
|
})
|
||||||
export class HomeHoldingsComponent implements OnDestroy, OnInit {
|
export class HomeHoldingsComponent implements OnDestroy, OnInit {
|
||||||
|
public static DEFAULT_HOLDINGS_VIEW_MODE: HoldingsViewMode = 'TABLE';
|
||||||
|
|
||||||
public deviceType: string;
|
public deviceType: string;
|
||||||
public hasImpersonationId: boolean;
|
public hasImpersonationId: boolean;
|
||||||
|
public hasPermissionToAccessHoldingsChart: boolean;
|
||||||
public hasPermissionToCreateOrder: boolean;
|
public hasPermissionToCreateOrder: boolean;
|
||||||
public holdings: PortfolioPosition[];
|
public holdings: PortfolioPosition[];
|
||||||
public holdingType: HoldingType = 'ACTIVE';
|
public holdingType: HoldingType = 'ACTIVE';
|
||||||
@ -26,6 +39,9 @@ export class HomeHoldingsComponent implements OnDestroy, OnInit {
|
|||||||
{ label: $localize`Closed`, value: 'CLOSED' }
|
{ label: $localize`Closed`, value: 'CLOSED' }
|
||||||
];
|
];
|
||||||
public user: User;
|
public user: User;
|
||||||
|
public viewModeFormControl = new FormControl<HoldingsViewMode>(
|
||||||
|
HomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE
|
||||||
|
);
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
@ -34,6 +50,7 @@ export class HomeHoldingsComponent implements OnDestroy, OnInit {
|
|||||||
private dataService: DataService,
|
private dataService: DataService,
|
||||||
private deviceService: DeviceDetectorService,
|
private deviceService: DeviceDetectorService,
|
||||||
private impersonationStorageService: ImpersonationStorageService,
|
private impersonationStorageService: ImpersonationStorageService,
|
||||||
|
private router: Router,
|
||||||
private userService: UserService
|
private userService: UserService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -53,38 +70,50 @@ export class HomeHoldingsComponent implements OnDestroy, OnInit {
|
|||||||
if (state?.user) {
|
if (state?.user) {
|
||||||
this.user = state.user;
|
this.user = state.user;
|
||||||
|
|
||||||
|
this.hasPermissionToAccessHoldingsChart = hasPermission(
|
||||||
|
this.user.permissions,
|
||||||
|
permissions.accessHoldingsChart
|
||||||
|
);
|
||||||
|
|
||||||
this.hasPermissionToCreateOrder = hasPermission(
|
this.hasPermissionToCreateOrder = hasPermission(
|
||||||
this.user.permissions,
|
this.user.permissions,
|
||||||
permissions.createOrder
|
permissions.createOrder
|
||||||
);
|
);
|
||||||
|
|
||||||
this.holdings = undefined;
|
this.initialize();
|
||||||
|
|
||||||
this.fetchHoldings()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe(({ holdings }) => {
|
|
||||||
this.holdings = holdings;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.viewModeFormControl.valueChanges
|
||||||
|
.pipe(
|
||||||
|
// Skip inizialization: "new FormControl"
|
||||||
|
skip(1),
|
||||||
|
takeUntil(this.unsubscribeSubject)
|
||||||
|
)
|
||||||
|
.subscribe((holdingsViewMode) => {
|
||||||
|
this.dataService
|
||||||
|
.putUserSetting({ holdingsViewMode })
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(() => {
|
||||||
|
this.userService.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onChangeHoldingType(aHoldingType: HoldingType) {
|
public onChangeHoldingType(aHoldingType: HoldingType) {
|
||||||
this.holdingType = aHoldingType;
|
this.holdingType = aHoldingType;
|
||||||
|
|
||||||
this.holdings = undefined;
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchHoldings()
|
public onSymbolClicked({ dataSource, symbol }: UniqueAsset) {
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
if (dataSource && symbol) {
|
||||||
.subscribe(({ holdings }) => {
|
this.router.navigate([], {
|
||||||
this.holdings = holdings;
|
queryParams: { dataSource, symbol, holdingDetailDialog: true }
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
@ -104,4 +133,38 @@ export class HomeHoldingsComponent implements OnDestroy, OnInit {
|
|||||||
range: this.user?.settings?.dateRange
|
range: this.user?.settings?.dateRange
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private initialize() {
|
||||||
|
this.viewModeFormControl.disable();
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.hasPermissionToAccessHoldingsChart &&
|
||||||
|
this.holdingType === 'ACTIVE'
|
||||||
|
) {
|
||||||
|
this.viewModeFormControl.enable({ emitEvent: false });
|
||||||
|
|
||||||
|
this.viewModeFormControl.setValue(
|
||||||
|
this.deviceType === 'mobile'
|
||||||
|
? HomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE
|
||||||
|
: this.user?.settings?.holdingsViewMode ||
|
||||||
|
HomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE,
|
||||||
|
{ emitEvent: false }
|
||||||
|
);
|
||||||
|
} else if (this.holdingType === 'CLOSED') {
|
||||||
|
this.viewModeFormControl.setValue(
|
||||||
|
HomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE,
|
||||||
|
{ emitEvent: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.holdings = undefined;
|
||||||
|
|
||||||
|
this.fetchHoldings()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(({ holdings }) => {
|
||||||
|
this.holdings = holdings;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,33 +6,62 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg">
|
<div class="col-lg">
|
||||||
<div class="d-flex justify-content-end">
|
<div class="d-flex">
|
||||||
<gf-toggle
|
@if (user?.settings?.isExperimentalFeatures) {
|
||||||
class="d-none d-lg-block"
|
<div class="d-flex">
|
||||||
[defaultValue]="holdingType"
|
<div class="d-none d-lg-block">
|
||||||
[isLoading]="false"
|
<mat-button-toggle-group
|
||||||
[options]="holdingTypeOptions"
|
[formControl]="viewModeFormControl"
|
||||||
(change)="onChangeHoldingType($event.value)"
|
[hideSingleSelectionIndicator]="true"
|
||||||
/>
|
>
|
||||||
</div>
|
<mat-button-toggle i18n-title title="Table" value="TABLE">
|
||||||
<gf-holdings-table
|
<ion-icon name="reorder-four-outline" />
|
||||||
[baseCurrency]="user?.settings?.baseCurrency"
|
</mat-button-toggle>
|
||||||
[deviceType]="deviceType"
|
<mat-button-toggle i18n-title title="Chart" value="CHART">
|
||||||
[hasPermissionToCreateActivity]="hasPermissionToCreateOrder"
|
<ion-icon name="grid-outline" />
|
||||||
[holdings]="holdings"
|
</mat-button-toggle>
|
||||||
[locale]="user?.settings?.locale"
|
</mat-button-toggle-group>
|
||||||
/>
|
</div>
|
||||||
@if (hasPermissionToCreateOrder && holdings?.length > 0) {
|
</div>
|
||||||
<div class="text-center">
|
}
|
||||||
<a
|
<div class="align-items-center d-flex flex-grow-1 justify-content-end">
|
||||||
class="mt-3"
|
<gf-toggle
|
||||||
i18n
|
class="d-none d-lg-block"
|
||||||
mat-stroked-button
|
[defaultValue]="holdingType"
|
||||||
[routerLink]="['/portfolio', 'activities']"
|
[isLoading]="false"
|
||||||
>Manage Activities</a
|
[options]="holdingTypeOptions"
|
||||||
>
|
(change)="onChangeHoldingType($event.value)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (viewModeFormControl.value === 'CHART') {
|
||||||
|
<gf-treemap-chart
|
||||||
|
class="mt-3"
|
||||||
|
cursor="pointer"
|
||||||
|
[holdings]="holdings"
|
||||||
|
(treemapChartClicked)="onSymbolClicked($event)"
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
<div [ngClass]="{ 'd-none': viewModeFormControl.value !== 'TABLE' }">
|
||||||
|
<gf-holdings-table
|
||||||
|
[baseCurrency]="user?.settings?.baseCurrency"
|
||||||
|
[deviceType]="deviceType"
|
||||||
|
[hasPermissionToCreateActivity]="hasPermissionToCreateOrder"
|
||||||
|
[holdings]="holdings"
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
/>
|
||||||
|
@if (hasPermissionToCreateOrder && holdings?.length > 0) {
|
||||||
|
<div class="text-center">
|
||||||
|
<a
|
||||||
|
class="mt-3"
|
||||||
|
i18n
|
||||||
|
mat-stroked-button
|
||||||
|
[routerLink]="['/portfolio', 'activities']"
|
||||||
|
>Manage Activities</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { GfToggleModule } from '@ghostfolio/client/components/toggle/toggle.module';
|
import { GfToggleModule } from '@ghostfolio/client/components/toggle/toggle.module';
|
||||||
import { GfHoldingsTableComponent } from '@ghostfolio/ui/holdings-table';
|
import { GfHoldingsTableComponent } from '@ghostfolio/ui/holdings-table';
|
||||||
|
import { GfTreemapChartComponent } from '@ghostfolio/ui/treemap-chart';
|
||||||
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
import { HomeHoldingsComponent } from './home-holdings.component';
|
import { HomeHoldingsComponent } from './home-holdings.component';
|
||||||
@ -12,9 +15,13 @@ import { HomeHoldingsComponent } from './home-holdings.component';
|
|||||||
declarations: [HomeHoldingsComponent],
|
declarations: [HomeHoldingsComponent],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
FormsModule,
|
||||||
GfHoldingsTableComponent,
|
GfHoldingsTableComponent,
|
||||||
GfToggleModule,
|
GfToggleModule,
|
||||||
|
GfTreemapChartComponent,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
|
MatButtonToggleModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
||||||
|
.mat-button-toggle-group {
|
||||||
|
.mat-button-toggle-appearance-standard {
|
||||||
|
--mat-standard-button-toggle-height: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { LayoutService } from '@ghostfolio/client/core/layout.service';
|
|||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
||||||
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config';
|
||||||
import {
|
import {
|
||||||
LineChartItem,
|
LineChartItem,
|
||||||
PortfolioPerformance,
|
PortfolioPerformance,
|
||||||
@ -34,6 +35,7 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
|
|||||||
public isAllTimeLow: boolean;
|
public isAllTimeLow: boolean;
|
||||||
public isLoadingPerformance = true;
|
public isLoadingPerformance = true;
|
||||||
public performance: PortfolioPerformance;
|
public performance: PortfolioPerformance;
|
||||||
|
public precision = 2;
|
||||||
public showDetails = false;
|
public showDetails = false;
|
||||||
public unit: string;
|
public unit: string;
|
||||||
public user: User;
|
public user: User;
|
||||||
@ -67,6 +69,12 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
|
|||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
||||||
|
|
||||||
|
this.showDetails =
|
||||||
|
!this.user.settings.isRestrictedView &&
|
||||||
|
this.user.settings.viewMode !== 'ZEN';
|
||||||
|
|
||||||
|
this.unit = this.showDetails ? this.user.settings.baseCurrency : '%';
|
||||||
|
|
||||||
this.impersonationStorageService
|
this.impersonationStorageService
|
||||||
.onChangeHasImpersonation()
|
.onChangeHasImpersonation()
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
@ -81,12 +89,6 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
|
|||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.update();
|
this.update();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.showDetails =
|
|
||||||
!this.user.settings.isRestrictedView &&
|
|
||||||
this.user.settings.viewMode !== 'ZEN';
|
|
||||||
|
|
||||||
this.unit = this.showDetails ? this.user.settings.baseCurrency : '%';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onChangeDateRange(dateRange: DateRange) {
|
public onChangeDateRange(dateRange: DateRange) {
|
||||||
@ -134,6 +136,14 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.deviceType === 'mobile' &&
|
||||||
|
this.performance.currentValueInBaseCurrency >=
|
||||||
|
NUMERICAL_PRECISION_THRESHOLD
|
||||||
|
) {
|
||||||
|
this.precision = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.isLoadingPerformance = false;
|
this.isLoadingPerformance = false;
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
|
@ -88,6 +88,7 @@
|
|||||||
[isLoading]="isLoadingPerformance"
|
[isLoading]="isLoadingPerformance"
|
||||||
[locale]="user?.settings?.locale"
|
[locale]="user?.settings?.locale"
|
||||||
[performance]="performance"
|
[performance]="performance"
|
||||||
|
[precision]="precision"
|
||||||
[showDetails]="showDetails"
|
[showDetails]="showDetails"
|
||||||
[unit]="unit"
|
[unit]="unit"
|
||||||
/>
|
/>
|
||||||
|
@ -14,7 +14,6 @@ import {
|
|||||||
ElementRef,
|
ElementRef,
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
OnInit,
|
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { CountUp } from 'countup.js';
|
import { CountUp } from 'countup.js';
|
||||||
@ -26,7 +25,7 @@ import { isNumber } from 'lodash';
|
|||||||
templateUrl: './portfolio-performance.component.html',
|
templateUrl: './portfolio-performance.component.html',
|
||||||
styleUrls: ['./portfolio-performance.component.scss']
|
styleUrls: ['./portfolio-performance.component.scss']
|
||||||
})
|
})
|
||||||
export class PortfolioPerformanceComponent implements OnChanges, OnInit {
|
export class PortfolioPerformanceComponent implements OnChanges {
|
||||||
@Input() deviceType: string;
|
@Input() deviceType: string;
|
||||||
@Input() errors: ResponseError['errors'];
|
@Input() errors: ResponseError['errors'];
|
||||||
@Input() isAllTimeHigh: boolean;
|
@Input() isAllTimeHigh: boolean;
|
||||||
@ -34,6 +33,7 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit {
|
|||||||
@Input() isLoading: boolean;
|
@Input() isLoading: boolean;
|
||||||
@Input() locale = getLocale();
|
@Input() locale = getLocale();
|
||||||
@Input() performance: PortfolioPerformance;
|
@Input() performance: PortfolioPerformance;
|
||||||
|
@Input() precision: number;
|
||||||
@Input() showDetails: boolean;
|
@Input() showDetails: boolean;
|
||||||
@Input() unit: string;
|
@Input() unit: string;
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
public constructor() {}
|
public constructor() {}
|
||||||
|
|
||||||
public ngOnInit() {}
|
|
||||||
|
|
||||||
public ngOnChanges() {
|
public ngOnChanges() {
|
||||||
|
this.precision = this.precision >= 0 ? this.precision : 2;
|
||||||
|
|
||||||
if (this.isLoading) {
|
if (this.isLoading) {
|
||||||
if (this.value?.nativeElement) {
|
if (this.value?.nativeElement) {
|
||||||
this.value.nativeElement.innerHTML = '';
|
this.value.nativeElement.innerHTML = '';
|
||||||
@ -52,11 +52,7 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit {
|
|||||||
if (isNumber(this.performance?.currentValueInBaseCurrency)) {
|
if (isNumber(this.performance?.currentValueInBaseCurrency)) {
|
||||||
new CountUp('value', this.performance?.currentValueInBaseCurrency, {
|
new CountUp('value', this.performance?.currentValueInBaseCurrency, {
|
||||||
decimal: getNumberFormatDecimal(this.locale),
|
decimal: getNumberFormatDecimal(this.locale),
|
||||||
decimalPlaces:
|
decimalPlaces: this.precision,
|
||||||
this.deviceType === 'mobile' &&
|
|
||||||
this.performance?.currentValueInBaseCurrency >= 100000
|
|
||||||
? 0
|
|
||||||
: 2,
|
|
||||||
duration: 1,
|
duration: 1,
|
||||||
separator: getNumberFormatGroup(this.locale)
|
separator: getNumberFormatGroup(this.locale)
|
||||||
}).start();
|
}).start();
|
||||||
|
@ -47,6 +47,7 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit {
|
|||||||
public isWebAuthnEnabled: boolean;
|
public isWebAuthnEnabled: boolean;
|
||||||
public language = document.documentElement.lang;
|
public language = document.documentElement.lang;
|
||||||
public locales = [
|
public locales = [
|
||||||
|
'ca',
|
||||||
'de',
|
'de',
|
||||||
'de-CH',
|
'de-CH',
|
||||||
'en-GB',
|
'en-GB',
|
||||||
|
@ -72,6 +72,14 @@
|
|||||||
<mat-option [value]="null" />
|
<mat-option [value]="null" />
|
||||||
<mat-option value="de">Deutsch</mat-option>
|
<mat-option value="de">Deutsch</mat-option>
|
||||||
<mat-option value="en">English</mat-option>
|
<mat-option value="en">English</mat-option>
|
||||||
|
@if (user?.settings?.isExperimentalFeatures) {
|
||||||
|
<!--
|
||||||
|
<mat-option value="ca"
|
||||||
|
>Català (<ng-container i18n>Community</ng-container
|
||||||
|
>)</mat-option
|
||||||
|
>
|
||||||
|
-->
|
||||||
|
}
|
||||||
@if (user?.settings?.isExperimentalFeatures) {
|
@if (user?.settings?.isExperimentalFeatures) {
|
||||||
<mat-option value="zh"
|
<mat-option value="zh"
|
||||||
>Chinese (<ng-container i18n>Community</ng-container
|
>Chinese (<ng-container i18n>Community</ng-container
|
||||||
@ -95,10 +103,12 @@
|
|||||||
>)</mat-option
|
>)</mat-option
|
||||||
>
|
>
|
||||||
@if (user?.settings?.isExperimentalFeatures) {
|
@if (user?.settings?.isExperimentalFeatures) {
|
||||||
<mat-option value="pl"
|
<!--
|
||||||
>Polski (<ng-container i18n>Community</ng-container
|
<mat-option value="pl"
|
||||||
>)</mat-option
|
>Polski (<ng-container i18n>Community</ng-container
|
||||||
>
|
>)</mat-option
|
||||||
|
>
|
||||||
|
-->
|
||||||
}
|
}
|
||||||
<mat-option value="pt"
|
<mat-option value="pt"
|
||||||
>Português (<ng-container i18n>Community</ng-container
|
>Português (<ng-container i18n>Community</ng-container
|
||||||
@ -196,25 +206,23 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if (hasPermissionToUpdateUserSettings) {
|
<div class="align-items-center d-flex mt-4 py-1">
|
||||||
<div class="align-items-center d-flex mt-4 py-1">
|
<div class="pr-1 w-50">
|
||||||
<div class="pr-1 w-50">
|
<div i18n>Experimental Features</div>
|
||||||
<div i18n>Experimental Features</div>
|
<div class="hint-text text-muted" i18n>
|
||||||
<div class="hint-text text-muted" i18n>
|
Sneak peek at upcoming functionality
|
||||||
Sneak peek at upcoming functionality
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="pl-1 w-50">
|
|
||||||
<mat-slide-toggle
|
|
||||||
color="primary"
|
|
||||||
hideIcon="true"
|
|
||||||
[checked]="user.settings.isExperimentalFeatures"
|
|
||||||
[disabled]="!hasPermissionToUpdateUserSettings"
|
|
||||||
(change)="onExperimentalFeaturesChange($event)"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
<div class="pl-1 w-50">
|
||||||
|
<mat-slide-toggle
|
||||||
|
color="primary"
|
||||||
|
hideIcon="true"
|
||||||
|
[checked]="user.settings.isExperimentalFeatures"
|
||||||
|
[disabled]="!hasPermissionToUpdateUserSettings"
|
||||||
|
(change)="onExperimentalFeaturesChange($event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="align-items-center d-flex mt-4 py-1">
|
<div class="align-items-center d-flex mt-4 py-1">
|
||||||
<div class="pr-1 w-50">
|
<div class="pr-1 w-50">
|
||||||
Ghostfolio <ng-container i18n>User ID</ng-container>
|
Ghostfolio <ng-container i18n>User ID</ng-container>
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
>
|
>
|
||||||
community, post to
|
community, post to
|
||||||
<a
|
<a
|
||||||
href="https://twitter.com/ghostfolio_"
|
href="https://x.com/ghostfolio_"
|
||||||
title="Post to Ghostfolio on X (formerly Twitter)"
|
title="Post to Ghostfolio on X (formerly Twitter)"
|
||||||
>@ghostfolio_</a
|
>@ghostfolio_</a
|
||||||
>
|
>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
<p class="align-items-center d-flex justify-content-center">
|
<p class="align-items-center d-flex justify-content-center">
|
||||||
<a
|
<a
|
||||||
class="mx-2"
|
class="mx-2"
|
||||||
href="https://twitter.com/ghostfolio_"
|
href="https://x.com/ghostfolio_"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
title="Follow Ghostfolio on X (formerly Twitter)"
|
title="Follow Ghostfolio on X (formerly Twitter)"
|
||||||
>
|
>
|
||||||
|
@ -131,9 +131,9 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Du erreichst mich per E-Mail unter
|
Du erreichst mich per E-Mail unter
|
||||||
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> oder auf
|
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> oder auf X
|
||||||
Twitter
|
(ehemals Twitter)
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a>.
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Ich freue mich, von dir zu hören.<br />
|
Ich freue mich, von dir zu hören.<br />
|
||||||
|
@ -126,8 +126,9 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
You can reach me by e-mail at
|
You can reach me by e-mail at
|
||||||
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on Twitter
|
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on X
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a>.
|
(formerly Twitter)
|
||||||
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
I look forward to hearing from you.<br />
|
I look forward to hearing from you.<br />
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
At the end of 2021, Ghostfolio reached an important milestone:
|
At the end of 2021, Ghostfolio reached an important milestone:
|
||||||
<a href="https://twitter.com/ghostfolio_/status/1470075774640218121"
|
<a href="https://x.com/ghostfolio_/status/1470075774640218121"
|
||||||
>100 stars</a
|
>100 stars</a
|
||||||
>
|
>
|
||||||
on GitHub. This is really exciting with almost no marketing. I am a
|
on GitHub. This is really exciting with almost no marketing. I am a
|
||||||
@ -100,9 +100,10 @@
|
|||||||
of users. In the future, I would like to involve more contributors
|
of users. In the future, I would like to involve more contributors
|
||||||
to further extend the functionality of Ghostfolio (e.g. with new
|
to further extend the functionality of Ghostfolio (e.g. with new
|
||||||
reports). Get in touch with me by e-mail at
|
reports). Get in touch with me by e-mail at
|
||||||
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on Twitter
|
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on X
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a> if
|
(formerly Twitter)
|
||||||
you are interested, I’m happy to discuss ideas.
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a> if you are
|
||||||
|
interested, I’m happy to discuss ideas.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
I would like to say thank you for all your feedback and support
|
I would like to say thank you for all your feedback and support
|
||||||
|
@ -90,8 +90,9 @@
|
|||||||
<p>
|
<p>
|
||||||
If you would like to provide feedback or get involved in further
|
If you would like to provide feedback or get involved in further
|
||||||
development of Ghostfolio, please get in touch by e-mail via
|
development of Ghostfolio, please get in touch by e-mail via
|
||||||
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on Twitter
|
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on X
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a>.
|
(formerly Twitter)
|
||||||
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
I look forward to hearing from you.<br />
|
I look forward to hearing from you.<br />
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
>Slack</a
|
>Slack</a
|
||||||
>
|
>
|
||||||
as well as 100 followers on
|
as well as 100 followers on
|
||||||
<a href="https://twitter.com/ghostfolio_">Twitter</a>. If you have
|
<a href="https://x.com/ghostfolio_">Twitter</a>. If you have not
|
||||||
not joined yet, this is a good time to make sure you do not miss out
|
joined yet, this is a good time to make sure you do not miss out on
|
||||||
on any future updates.
|
any future updates.
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
<section class="mb-4">
|
<section class="mb-4">
|
||||||
@ -91,9 +91,10 @@
|
|||||||
engineering to realize the full potential of open source software.
|
engineering to realize the full potential of open source software.
|
||||||
If you are a web developer and interested in personal finance,
|
If you are a web developer and interested in personal finance,
|
||||||
please get in touch by e-mail via
|
please get in touch by e-mail via
|
||||||
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on Twitter
|
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or on X
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a>. We
|
(formerly Twitter)
|
||||||
are happy to discuss ideas.
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a>. We are
|
||||||
|
happy to discuss ideas.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
We would like to say thank you for all your feedback and support
|
We would like to say thank you for all your feedback and support
|
||||||
|
@ -84,8 +84,8 @@
|
|||||||
href="https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg"
|
href="https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg"
|
||||||
>Slack</a
|
>Slack</a
|
||||||
>
|
>
|
||||||
community or get in touch on Twitter
|
community or get in touch on X (formerly Twitter)
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a> or by
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a> or by
|
||||||
e-mail via <a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a>.
|
e-mail via <a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -90,8 +90,8 @@
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
>Slack</a
|
>Slack</a
|
||||||
>
|
>
|
||||||
community or via Twitter
|
community or via X (formerly Twitter)
|
||||||
<a href="https://twitter.com/ghostfolio_" target="_blank"
|
<a href="https://x.com/ghostfolio_" target="_blank"
|
||||||
>@ghostfolio_</a
|
>@ghostfolio_</a
|
||||||
>. We look forward to hearing from you!
|
>. We look forward to hearing from you!
|
||||||
</p>
|
</p>
|
||||||
|
@ -122,8 +122,9 @@
|
|||||||
>Slack</a
|
>Slack</a
|
||||||
>
|
>
|
||||||
community or connect with
|
community or connect with
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a> on
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a> on X
|
||||||
Twitter. We are happy to discuss ideas and get you involved.
|
(formerly Twitter). We are happy to discuss ideas and get you
|
||||||
|
involved.
|
||||||
</p>
|
</p>
|
||||||
<p>Thank you for all your feedback and support.</p>
|
<p>Thank you for all your feedback and support.</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<p>
|
<p>
|
||||||
OSS Friends started as a simple
|
OSS Friends started as a simple
|
||||||
<a
|
<a
|
||||||
href="https://twitter.com/formbricks/status/1660735970281508878"
|
href="https://x.com/formbricks/status/1660735970281508878"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>post</a
|
>post</a
|
||||||
>
|
>
|
||||||
|
@ -123,7 +123,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
On
|
On
|
||||||
<a href="https://twitter.com/ghostfolio_" target="_blank">X</a>
|
<a href="https://x.com/ghostfolio_" target="_blank">X</a>
|
||||||
(formerly Twitter), over
|
(formerly Twitter), over
|
||||||
<strong>300 investors and personal finance enthusiasts</strong>
|
<strong>300 investors and personal finance enthusiasts</strong>
|
||||||
follow Ghostfolio, keen to stay updated on the latest
|
follow Ghostfolio, keen to stay updated on the latest
|
||||||
@ -151,7 +151,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<strong>Follow us on X</strong>: For release updates and market
|
<strong>Follow us on X</strong>: For release updates and market
|
||||||
insights, follow
|
insights, follow
|
||||||
<a href="https://twitter.com/ghostfolio_" target="_blank"
|
<a href="https://x.com/ghostfolio_" target="_blank"
|
||||||
>Ghostfolio on X</a
|
>Ghostfolio on X</a
|
||||||
>. It is the perfect place to stay informed and connect with our
|
>. It is the perfect place to stay informed and connect with our
|
||||||
team.
|
team.
|
||||||
|
@ -89,7 +89,7 @@
|
|||||||
>Slack</a
|
>Slack</a
|
||||||
>
|
>
|
||||||
community or get in touch on X
|
community or get in touch on X
|
||||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a>.
|
<a href="https://x.com/ghostfolio_">@ghostfolio_</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
We look forward to hearing from you.<br />
|
We look forward to hearing from you.<br />
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
>
|
>
|
||||||
community,
|
community,
|
||||||
<a
|
<a
|
||||||
href="https://twitter.com/ghostfolio_"
|
href="https://x.com/ghostfolio_"
|
||||||
title="Post to Ghostfolio on X (formerly Twitter)"
|
title="Post to Ghostfolio on X (formerly Twitter)"
|
||||||
>@ghostfolio_</a
|
>@ghostfolio_</a
|
||||||
>
|
>
|
||||||
@ -152,7 +152,7 @@
|
|||||||
>Slack </a
|
>Slack </a
|
||||||
>community, post to
|
>community, post to
|
||||||
<a
|
<a
|
||||||
href="https://twitter.com/ghostfolio_"
|
href="https://x.com/ghostfolio_"
|
||||||
title="Post to Ghostfolio on X (formerly Twitter)"
|
title="Post to Ghostfolio on X (formerly Twitter)"
|
||||||
>@ghostfolio_</a
|
>@ghostfolio_</a
|
||||||
>
|
>
|
||||||
|
@ -151,7 +151,7 @@
|
|||||||
>Slack </a
|
>Slack </a
|
||||||
>community, post to
|
>community, post to
|
||||||
<a
|
<a
|
||||||
href="https://twitter.com/ghostfolio_"
|
href="https://x.com/ghostfolio_"
|
||||||
title="Post to Ghostfolio on X (formerly Twitter)"
|
title="Post to Ghostfolio on X (formerly Twitter)"
|
||||||
>@ghostfolio_</a
|
>@ghostfolio_</a
|
||||||
>
|
>
|
||||||
|
@ -86,6 +86,17 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
<mat-card appearance="outlined" class="mb-3">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>What is the concept of platforms?</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
Platforms are used to group multiple accounts, such as a savings
|
||||||
|
account and a trading account at the same bank. By assigning accounts
|
||||||
|
to the same platform, they are displayed with a unified icon and you
|
||||||
|
gain insights into platform-specific risks.
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
<mat-card appearance="outlined" class="mb-3">
|
<mat-card appearance="outlined" class="mb-3">
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<mat-card-title>How do I add a new platform?</mat-card-title>
|
<mat-card-title>How do I add a new platform?</mat-card-title>
|
||||||
@ -186,7 +197,7 @@
|
|||||||
>Slack </a
|
>Slack </a
|
||||||
>community, post to
|
>community, post to
|
||||||
<a
|
<a
|
||||||
href="https://twitter.com/ghostfolio_"
|
href="https://x.com/ghostfolio_"
|
||||||
title="Post to Ghostfolio on X (formerly Twitter)"
|
title="Post to Ghostfolio on X (formerly Twitter)"
|
||||||
>@ghostfolio_</a
|
>@ghostfolio_</a
|
||||||
>
|
>
|
||||||
|
@ -145,8 +145,9 @@
|
|||||||
</h4>
|
</h4>
|
||||||
<p class="m-0">
|
<p class="m-0">
|
||||||
Check the rate of return of your portfolio for
|
Check the rate of return of your portfolio for
|
||||||
<code>Today</code>, <code>YTD</code>, <code>1Y</code>,
|
<code>Today</code>, <code>WTD</code>, <code>MTD</code>,
|
||||||
<code>5Y</code>, and <code>Max</code>.
|
<code>YTD</code>, <code>1Y</code>, <code>5Y</code>, and
|
||||||
|
<code>Max</code>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
@ -241,9 +242,11 @@
|
|||||||
<h4 i18n>Multi-Language</h4>
|
<h4 i18n>Multi-Language</h4>
|
||||||
<p class="m-0">
|
<p class="m-0">
|
||||||
Use Ghostfolio in multiple languages: English,
|
Use Ghostfolio in multiple languages: English,
|
||||||
<!-- Chinese, -->Dutch, French, German, Italian,
|
<!--Català, -->
|
||||||
<!-- Polish, -->Portuguese, Spanish and Turkish are currently
|
<!-- Chinese, -->
|
||||||
supported.
|
Dutch, French, German, Italian,
|
||||||
|
<!-- Polish, -->
|
||||||
|
Portuguese, Spanish and Turkish are currently supported.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
@ -186,6 +186,14 @@
|
|||||||
title="Sackgeld.com – Apps für ein höheres Sackgeld"
|
title="Sackgeld.com – Apps für ein höheres Sackgeld"
|
||||||
></a>
|
></a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="align-items-center col-md-3 d-flex justify-content-center my-1">
|
||||||
|
<a
|
||||||
|
class="d-block logo logo-selfh-st mask"
|
||||||
|
href="https://selfh.st"
|
||||||
|
target="_blank"
|
||||||
|
title="selfh.st — Self-hosted content and software"
|
||||||
|
></a>
|
||||||
|
</div>
|
||||||
<div class="col-md-3 d-flex justify-content-center my-1">
|
<div class="col-md-3 d-flex justify-content-center my-1">
|
||||||
<a
|
<a
|
||||||
class="d-block logo logo-sourceforge mask"
|
class="d-block logo logo-sourceforge mask"
|
||||||
|
@ -80,6 +80,11 @@
|
|||||||
mask-image: url('/assets/images/logo-sackgeld.png');
|
mask-image: url('/assets/images/logo-sackgeld.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.logo-selfh-st {
|
||||||
|
mask-image: url('/assets/images/logo-selfh-st.svg');
|
||||||
|
max-height: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
&.logo-sourceforge {
|
&.logo-sourceforge {
|
||||||
mask-image: url('/assets/images/logo-sourceforge.svg');
|
mask-image: url('/assets/images/logo-sourceforge.svg');
|
||||||
}
|
}
|
||||||
@ -131,6 +136,7 @@
|
|||||||
&.logo-privacy-tools,
|
&.logo-privacy-tools,
|
||||||
&.logo-reddit,
|
&.logo-reddit,
|
||||||
&.logo-sackgeld,
|
&.logo-sackgeld,
|
||||||
|
&.logo-selfh-st,
|
||||||
&.logo-sourceforge,
|
&.logo-sourceforge,
|
||||||
&.logo-umbrel,
|
&.logo-umbrel,
|
||||||
&.logo-unraid {
|
&.logo-unraid {
|
||||||
|
@ -51,9 +51,10 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
public filteredTagsObservable: Observable<Tag[]> = of([]);
|
public filteredTagsObservable: Observable<Tag[]> = of([]);
|
||||||
public isLoading = false;
|
public isLoading = false;
|
||||||
public isToday = isToday;
|
public isToday = isToday;
|
||||||
|
public mode: 'create' | 'update';
|
||||||
public platforms: { id: string; name: string }[];
|
public platforms: { id: string; name: string }[];
|
||||||
public separatorKeysCodes: number[] = [ENTER, COMMA];
|
public separatorKeysCodes: number[] = [COMMA, ENTER];
|
||||||
public tags: Tag[] = [];
|
public tagsAvailable: Tag[] = [];
|
||||||
public total = 0;
|
public total = 0;
|
||||||
public typesTranslationMap = new Map<Type, string>();
|
public typesTranslationMap = new Map<Type, string>();
|
||||||
public Validators = Validators;
|
public Validators = Validators;
|
||||||
@ -71,6 +72,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
this.mode = this.data.activity.id ? 'update' : 'create';
|
||||||
this.locale = this.data.user?.settings?.locale;
|
this.locale = this.data.user?.settings?.locale;
|
||||||
this.dateAdapter.setLocale(this.locale);
|
this.dateAdapter.setLocale(this.locale);
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
this.currencies = currencies;
|
this.currencies = currencies;
|
||||||
this.defaultDateFormat = getDateFormatString(this.locale);
|
this.defaultDateFormat = getDateFormatString(this.locale);
|
||||||
this.platforms = platforms;
|
this.platforms = platforms;
|
||||||
this.tags = tags.map(({ id, name }) => {
|
this.tagsAvailable = tags.map(({ id, name }) => {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
name: translate(name)
|
name: translate(name)
|
||||||
@ -92,7 +94,9 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
|
|
||||||
this.activityForm = this.formBuilder.group({
|
this.activityForm = this.formBuilder.group({
|
||||||
accountId: [
|
accountId: [
|
||||||
this.data.accounts.length === 1 && !this.data.activity?.accountId
|
this.data.accounts.length === 1 &&
|
||||||
|
!this.data.activity?.accountId &&
|
||||||
|
this.mode === 'create'
|
||||||
? this.data.accounts[0].id
|
? this.data.accounts[0].id
|
||||||
: this.data.activity?.accountId,
|
: this.data.activity?.accountId,
|
||||||
Validators.required
|
Validators.required
|
||||||
@ -283,7 +287,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
].valueChanges.pipe(
|
].valueChanges.pipe(
|
||||||
startWith(this.activityForm.get('tags').value),
|
startWith(this.activityForm.get('tags').value),
|
||||||
map((aTags: Tag[] | null) => {
|
map((aTags: Tag[] | null) => {
|
||||||
return aTags ? this.filterTags(aTags) : this.tags.slice();
|
return aTags ? this.filterTags(aTags) : this.tagsAvailable.slice();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -437,10 +441,11 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
public onAddTag(event: MatAutocompleteSelectedEvent) {
|
public onAddTag(event: MatAutocompleteSelectedEvent) {
|
||||||
this.activityForm.get('tags').setValue([
|
this.activityForm.get('tags').setValue([
|
||||||
...(this.activityForm.get('tags').value ?? []),
|
...(this.activityForm.get('tags').value ?? []),
|
||||||
this.tags.find(({ id }) => {
|
this.tagsAvailable.find(({ id }) => {
|
||||||
return id === event.option.value;
|
return id === event.option.value;
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.tagInput.nativeElement.value = '';
|
this.tagInput.nativeElement.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,18 +484,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.data.activity.id) {
|
if (this.mode === 'create') {
|
||||||
(activity as UpdateOrderDto).id = this.data.activity.id;
|
|
||||||
|
|
||||||
await validateObjectForForm({
|
|
||||||
classDto: UpdateOrderDto,
|
|
||||||
form: this.activityForm,
|
|
||||||
ignoreFields: ['dataSource', 'date'],
|
|
||||||
object: activity as UpdateOrderDto
|
|
||||||
});
|
|
||||||
|
|
||||||
this.dialogRef.close(activity as UpdateOrderDto);
|
|
||||||
} else {
|
|
||||||
(activity as CreateOrderDto).updateAccountBalance =
|
(activity as CreateOrderDto).updateAccountBalance =
|
||||||
this.activityForm.get('updateAccountBalance').value;
|
this.activityForm.get('updateAccountBalance').value;
|
||||||
|
|
||||||
@ -502,6 +496,17 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.dialogRef.close(activity as CreateOrderDto);
|
this.dialogRef.close(activity as CreateOrderDto);
|
||||||
|
} else {
|
||||||
|
(activity as UpdateOrderDto).id = this.data.activity.id;
|
||||||
|
|
||||||
|
await validateObjectForForm({
|
||||||
|
classDto: UpdateOrderDto,
|
||||||
|
form: this.activityForm,
|
||||||
|
ignoreFields: ['dataSource', 'date'],
|
||||||
|
object: activity as UpdateOrderDto
|
||||||
|
});
|
||||||
|
|
||||||
|
this.dialogRef.close(activity as UpdateOrderDto);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -514,12 +519,12 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private filterTags(aTags: Tag[]) {
|
private filterTags(aTags: Tag[]) {
|
||||||
const tagIds = aTags.map((tag) => {
|
const tagIds = aTags.map(({ id }) => {
|
||||||
return tag.id;
|
return id;
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.tags.filter((tag) => {
|
return this.tagsAvailable.filter(({ id }) => {
|
||||||
return !tagIds.includes(tag.id);
|
return !tagIds.includes(id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
(keyup.enter)="activityForm.valid && onSubmit()"
|
(keyup.enter)="activityForm.valid && onSubmit()"
|
||||||
(ngSubmit)="onSubmit()"
|
(ngSubmit)="onSubmit()"
|
||||||
>
|
>
|
||||||
@if (data.activity.id) {
|
@if (mode === 'create') {
|
||||||
<h1 i18n mat-dialog-title>Update activity</h1>
|
|
||||||
} @else {
|
|
||||||
<h1 i18n mat-dialog-title>Add activity</h1>
|
<h1 i18n mat-dialog-title>Add activity</h1>
|
||||||
|
} @else {
|
||||||
|
<h1 i18n mat-dialog-title>Update activity</h1>
|
||||||
}
|
}
|
||||||
<div class="flex-grow-1 py-3" mat-dialog-content>
|
<div class="flex-grow-1 py-3" mat-dialog-content>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
@ -76,16 +76,17 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div [ngClass]="{ 'mb-3': data.activity.id }">
|
<div [ngClass]="{ 'mb-3': mode === 'update' }">
|
||||||
<mat-form-field
|
<mat-form-field
|
||||||
appearance="outline"
|
appearance="outline"
|
||||||
class="w-100"
|
class="w-100"
|
||||||
[ngClass]="{ 'mb-1 without-hint': !data.activity.id }"
|
[ngClass]="{ 'mb-1 without-hint': mode === 'create' }"
|
||||||
>
|
>
|
||||||
<mat-label i18n>Account</mat-label>
|
<mat-label i18n>Account</mat-label>
|
||||||
<mat-select formControlName="accountId">
|
<mat-select formControlName="accountId">
|
||||||
@if (
|
@if (
|
||||||
!activityForm.get('accountId').hasValidator(Validators.required)
|
!activityForm.get('accountId').hasValidator(Validators.required) ||
|
||||||
|
(!activityForm.get('accountId').value && mode === 'update')
|
||||||
) {
|
) {
|
||||||
<mat-option [value]="null" />
|
<mat-option [value]="null" />
|
||||||
}
|
}
|
||||||
@ -106,7 +107,7 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3" [ngClass]="{ 'd-none': data.activity.id }">
|
<div class="mb-3" [ngClass]="{ 'd-none': mode === 'update' }">
|
||||||
<mat-checkbox color="primary" formControlName="updateAccountBalance" i18n
|
<mat-checkbox color="primary" formControlName="updateAccountBalance" i18n
|
||||||
>Update Cash Balance</mat-checkbox
|
>Update Cash Balance</mat-checkbox
|
||||||
>
|
>
|
||||||
@ -377,11 +378,11 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3" [ngClass]="{ 'd-none': tags?.length < 1 }">
|
<div class="mb-3" [ngClass]="{ 'd-none': tagsAvailable?.length < 1 }">
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Tags</mat-label>
|
<mat-label i18n>Tags</mat-label>
|
||||||
<mat-chip-grid #tagsChipList>
|
<mat-chip-grid #tagsChipList>
|
||||||
@for (tag of activityForm.get('tags')?.value; track tag) {
|
@for (tag of activityForm.get('tags')?.value; track tag.id) {
|
||||||
<mat-chip-row
|
<mat-chip-row
|
||||||
matChipRemove
|
matChipRemove
|
||||||
[removable]="true"
|
[removable]="true"
|
||||||
@ -403,7 +404,7 @@
|
|||||||
#autocompleteTags="matAutocomplete"
|
#autocompleteTags="matAutocomplete"
|
||||||
(optionSelected)="onAddTag($event)"
|
(optionSelected)="onAddTag($event)"
|
||||||
>
|
>
|
||||||
@for (tag of filteredTagsObservable | async; track tag) {
|
@for (tag of filteredTagsObservable | async; track tag.id) {
|
||||||
<mat-option [value]="tag.id">
|
<mat-option [value]="tag.id">
|
||||||
{{ tag.name }}
|
{{ tag.name }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -454,30 +454,22 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
|
|||||||
|
|
||||||
if (position.holdings.length > 0) {
|
if (position.holdings.length > 0) {
|
||||||
for (const holding of position.holdings) {
|
for (const holding of position.holdings) {
|
||||||
const { name, valueInBaseCurrency } = holding;
|
const { allocationInPercentage, name, valueInBaseCurrency } =
|
||||||
|
holding;
|
||||||
|
|
||||||
if (
|
if (this.topHoldingsMap[name]?.value) {
|
||||||
!this.hasImpersonationId &&
|
this.topHoldingsMap[name].value += isNumber(valueInBaseCurrency)
|
||||||
!this.user.settings.isRestrictedView
|
? valueInBaseCurrency
|
||||||
) {
|
: allocationInPercentage *
|
||||||
if (this.topHoldingsMap[name]?.value) {
|
this.portfolioDetails.holdings[symbol].valueInPercentage;
|
||||||
this.topHoldingsMap[name].value +=
|
} else {
|
||||||
valueInBaseCurrency *
|
this.topHoldingsMap[name] = {
|
||||||
(isNumber(position.valueInBaseCurrency)
|
name,
|
||||||
? position.valueInBaseCurrency
|
value: isNumber(valueInBaseCurrency)
|
||||||
: position.valueInPercentage);
|
? valueInBaseCurrency
|
||||||
} else {
|
: allocationInPercentage *
|
||||||
this.topHoldingsMap[name] = {
|
this.portfolioDetails.holdings[symbol].valueInPercentage
|
||||||
name,
|
};
|
||||||
value:
|
|
||||||
valueInBaseCurrency *
|
|
||||||
(isNumber(position.valueInBaseCurrency)
|
|
||||||
? this.portfolioDetails.holdings[symbol]
|
|
||||||
.valueInBaseCurrency
|
|
||||||
: this.portfolioDetails.holdings[symbol]
|
|
||||||
.valueInPercentage)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -562,6 +554,14 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
|
|||||||
|
|
||||||
this.topHoldings = Object.values(this.topHoldingsMap)
|
this.topHoldings = Object.values(this.topHoldingsMap)
|
||||||
.map(({ name, value }) => {
|
.map(({ name, value }) => {
|
||||||
|
if (this.hasImpersonationId || this.user.settings.isRestrictedView) {
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
allocationInPercentage: value,
|
||||||
|
valueInBaseCurrency: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
allocationInPercentage:
|
allocationInPercentage:
|
||||||
@ -570,7 +570,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return b.valueInBaseCurrency - a.valueInBaseCurrency;
|
return b.allocationInPercentage - a.allocationInPercentage;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.topHoldings.length > MAX_TOP_HOLDINGS) {
|
if (this.topHoldings.length > MAX_TOP_HOLDINGS) {
|
||||||
|
@ -253,7 +253,8 @@
|
|||||||
} @else {
|
} @else {
|
||||||
{{ baseCurrency }} <strong>{{ price }}</strong>
|
{{ baseCurrency }} <strong>{{ price }}</strong>
|
||||||
}
|
}
|
||||||
<span i18n>per year</span></span
|
<span> </span>
|
||||||
|
<span i18n>per year</span></span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
@if (
|
@if (
|
||||||
|
@ -152,7 +152,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row my-5">
|
<div class="row my-5">
|
||||||
<div class="col-md-10 offset-md-1">
|
<div class="col-md-10 offset-md-1">
|
||||||
<h2 class="h4 mb-1 text-center">
|
<h2 class="h4 mb-1 text-center" i18n>
|
||||||
Would you like to <strong>refine</strong> your
|
Would you like to <strong>refine</strong> your
|
||||||
<strong>personal investment strategy</strong>?
|
<strong>personal investment strategy</strong>?
|
||||||
</h2>
|
</h2>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { Product } from '@ghostfolio/common/interfaces';
|
import { Product } from '@ghostfolio/common/interfaces';
|
||||||
import { personalFinanceTools } from '@ghostfolio/common/personal-finance-tools';
|
import { personalFinanceTools } from '@ghostfolio/common/personal-finance-tools';
|
||||||
|
import { translate } from '@ghostfolio/ui/i18n';
|
||||||
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
@ -26,6 +27,7 @@ export class GfProductPageComponent implements OnInit {
|
|||||||
'/' + $localize`resources`,
|
'/' + $localize`resources`,
|
||||||
'personal-finance-tools'
|
'personal-finance-tools'
|
||||||
];
|
];
|
||||||
|
public tags: string[];
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private dataService: DataService,
|
private dataService: DataService,
|
||||||
@ -56,7 +58,7 @@ export class GfProductPageComponent implements OnInit {
|
|||||||
],
|
],
|
||||||
name: 'Ghostfolio',
|
name: 'Ghostfolio',
|
||||||
origin: $localize`Switzerland`,
|
origin: $localize`Switzerland`,
|
||||||
region: $localize`Global`,
|
regions: [$localize`Global`],
|
||||||
slogan: 'Open Source Wealth Management',
|
slogan: 'Open Source Wealth Management',
|
||||||
useAnonymously: true
|
useAnonymously: true
|
||||||
};
|
};
|
||||||
@ -64,5 +66,41 @@ export class GfProductPageComponent implements OnInit {
|
|||||||
this.product2 = personalFinanceTools.find(({ key }) => {
|
this.product2 = personalFinanceTools.find(({ key }) => {
|
||||||
return key === this.route.snapshot.data['key'];
|
return key === this.route.snapshot.data['key'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.product2.origin) {
|
||||||
|
this.product2.origin = translate(this.product2.origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.product2.regions) {
|
||||||
|
this.product2.regions = this.product2.regions.map((region) => {
|
||||||
|
return translate(region);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tags = [
|
||||||
|
this.product1.name,
|
||||||
|
this.product2.name,
|
||||||
|
$localize`Alternative`,
|
||||||
|
$localize`App`,
|
||||||
|
$localize`Budgeting`,
|
||||||
|
$localize`Community`,
|
||||||
|
$localize`Family Office`,
|
||||||
|
`Fintech`,
|
||||||
|
$localize`Investment`,
|
||||||
|
$localize`Investor`,
|
||||||
|
$localize`Open Source`,
|
||||||
|
`OSS`,
|
||||||
|
$localize`Personal Finance`,
|
||||||
|
$localize`Privacy`,
|
||||||
|
$localize`Portfolio`,
|
||||||
|
$localize`Software`,
|
||||||
|
$localize`Tool`,
|
||||||
|
$localize`User Experience`,
|
||||||
|
$localize`Wealth`,
|
||||||
|
$localize`Wealth Management`,
|
||||||
|
`WealthTech`
|
||||||
|
].sort((a, b) => {
|
||||||
|
return a.localeCompare(b, undefined, { sensitivity: 'base' });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,24 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="mat-mdc-row">
|
<tr class="mat-mdc-row">
|
||||||
<td class="mat-mdc-cell px-3 py-2 text-right" i18n>Region</td>
|
<td class="mat-mdc-cell px-3 py-2 text-right" i18n>Region</td>
|
||||||
<td class="mat-mdc-cell px-1 py-2">{{ product1.region }}</td>
|
<td class="mat-mdc-cell px-1 py-2">
|
||||||
<td class="mat-mdc-cell px-1 py-2">{{ product2.region }}</td>
|
@for (
|
||||||
|
region of product1.regions;
|
||||||
|
track region;
|
||||||
|
let isLast = $last
|
||||||
|
) {
|
||||||
|
{{ region }}{{ isLast ? '' : ', ' }}
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
<td class="mat-mdc-cell px-1 py-2">
|
||||||
|
@for (
|
||||||
|
region of product2.regions;
|
||||||
|
track region;
|
||||||
|
let isLast = $last
|
||||||
|
) {
|
||||||
|
{{ region }}{{ isLast ? '' : ', ' }}
|
||||||
|
}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="mat-mdc-row">
|
<tr class="mat-mdc-row">
|
||||||
<td class="mat-mdc-cell px-3 py-2 text-right" i18n>
|
<td class="mat-mdc-cell px-3 py-2 text-right" i18n>
|
||||||
@ -236,69 +252,11 @@
|
|||||||
</section>
|
</section>
|
||||||
<section class="mb-4">
|
<section class="mb-4">
|
||||||
<ul class="list-inline">
|
<ul class="list-inline">
|
||||||
<li class="list-inline-item">
|
@for (tag of tags; track tag) {
|
||||||
<span class="badge badge-light">Alternative</span>
|
<li class="list-inline-item">
|
||||||
</li>
|
<span class="badge badge-light">{{ tag }}</span>
|
||||||
<li class="list-inline-item">
|
</li>
|
||||||
<span class="badge badge-light">App</span>
|
}
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Budgeting</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Community</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Family Office</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Fintech</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">{{ product1.name }}</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Investment</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Investor</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Open Source</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">OSS</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Personal Finance</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Privacy</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Portfolio</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Software</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Tool</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">User Experience</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Wealth</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">WealthTech</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">Wealth Management</span>
|
|
||||||
</li>
|
|
||||||
<li class="list-inline-item">
|
|
||||||
<span class="badge badge-light">{{ product2.name }}</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
|
@ -55,6 +55,22 @@
|
|||||||
</div>
|
</div>
|
||||||
<h2 class="h4 mb-3" i18n>Markets</h2>
|
<h2 class="h4 mb-3" i18n>Markets</h2>
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
|
<div class="mb-4 media">
|
||||||
|
<div class="media-body">
|
||||||
|
<h3 class="h5 mt-0">Crypto Coins Heatmap</h3>
|
||||||
|
<div class="mb-1">
|
||||||
|
With the <i>Crypto Coins Heatmap</i> you can track the daily
|
||||||
|
market movements of cryptocurrencies as a visual snapshot.
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a
|
||||||
|
href="https://www.tradingview.com/heatmap/crypto"
|
||||||
|
target="_blank"
|
||||||
|
>Crypto Coins Heatmap →</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="mb-4 media">
|
<div class="mb-4 media">
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<h3 class="h5 mt-0">Fear & Greed Index</h3>
|
<h3 class="h5 mt-0">Fear & Greed Index</h3>
|
||||||
@ -73,10 +89,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media-body">
|
<div class="mb-4 media">
|
||||||
<h3 class="h5 mt-0">Inflation Chart</h3>
|
<h3 class="h5 mt-0">Inflation Chart</h3>
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
Inflation Chart helps you find the intrinsic value of stock
|
<i>Inflation Chart</i> helps you find the intrinsic value of stock
|
||||||
markets, stock prices, goods and services by adjusting them to the
|
markets, stock prices, goods and services by adjusting them to the
|
||||||
amount of the money supply (M0, M1, M2) or price of other goods
|
amount of the money supply (M0, M1, M2) or price of other goods
|
||||||
(food or oil).
|
(food or oil).
|
||||||
@ -88,6 +104,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="media">
|
||||||
|
<div class="media-body">
|
||||||
|
<h3 class="h5 mt-0">Stock Heatmap</h3>
|
||||||
|
<div class="mb-1">
|
||||||
|
With the <i>Stock Heatmap</i> you can track the daily market
|
||||||
|
movements of stocks as a visual snapshot.
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a
|
||||||
|
href="https://www.tradingview.com/heatmap/stock"
|
||||||
|
target="_blank"
|
||||||
|
>Stock Heatmap →</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="h4 mb-3" i18n>Glossary</h2>
|
<h2 class="h4 mb-3" i18n>Glossary</h2>
|
||||||
<div>
|
<div>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user