Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a869a90da | |||
280030ae7f | |||
52e4504de9 | |||
20356f6931 | |||
e0bb2b1c78 | |||
ec806be45f | |||
809ee97f6f | |||
893ca83d3a | |||
23da1bd293 | |||
fa66cd5bce | |||
9344dcd26e | |||
90ad22cccf | |||
dcc7ef89fe | |||
e355847f40 | |||
76f70598e2 | |||
7af5cd244a | |||
86943a5f5b | |||
6eb4eae4a9 | |||
6ac693dd39 | |||
e29f7f8976 | |||
82069da4e2 |
62
CHANGELOG.md
62
CHANGELOG.md
@ -5,6 +5,68 @@ 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).
|
||||||
|
|
||||||
|
## 1.116.0 - 16.02.2022
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a service to tweet the current _Fear & Greed Index_ (market mood)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the mobile layout of the position detail dialog (countries and sectors charts)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the `maxItems` attribute of the portfolio proportion chart component
|
||||||
|
- Fixed the time in market display of the portfolio summary tab on the home page
|
||||||
|
|
||||||
|
## 1.115.0 - 13.02.2022
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a feature overview page
|
||||||
|
- Added the asset and asset sub class to the position detail dialog
|
||||||
|
- Added the countries and sectors to the position detail dialog
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Upgraded `angular` from version `13.1.2` to `13.2.3`
|
||||||
|
- Upgraded `Nx` from version `13.4.1` to `13.8.1`
|
||||||
|
- Upgraded `storybook` from version `6.4.9` to `6.4.18`
|
||||||
|
|
||||||
|
## 1.114.1 - 10.02.2022
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the creation of (wealth) items
|
||||||
|
|
||||||
|
## 1.114.0 - 10.02.2022
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added support for (wealth) items
|
||||||
|
|
||||||
|
### Todo
|
||||||
|
|
||||||
|
- Apply data migration (`yarn database:migrate`)
|
||||||
|
|
||||||
|
## 1.113.0 - 09.02.2022
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the position of the currency column in the accounts table
|
||||||
|
- Improved the position of the currency column in the activities table
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue with the performance calculation in connection with fees in the new calculation engine
|
||||||
|
|
||||||
|
## 1.112.1 - 06.02.2022
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the creation of the user account (missing access token)
|
||||||
|
|
||||||
## 1.112.0 - 06.02.2022
|
## 1.112.0 - 06.02.2022
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
13
README.md
13
README.md
@ -41,21 +41,13 @@ If you prefer to run Ghostfolio on your own infrastructure (self-hosting), pleas
|
|||||||
Ghostfolio is for you if you are...
|
Ghostfolio is for you if you are...
|
||||||
|
|
||||||
- 💼 trading stocks, ETFs or cryptocurrencies on multiple platforms
|
- 💼 trading stocks, ETFs or cryptocurrencies on multiple platforms
|
||||||
|
|
||||||
- 🏦 pursuing a buy & hold strategy
|
- 🏦 pursuing a buy & hold strategy
|
||||||
|
|
||||||
- 🎯 interested in getting insights of your portfolio composition
|
- 🎯 interested in getting insights of your portfolio composition
|
||||||
|
|
||||||
- 👻 valuing privacy and data ownership
|
- 👻 valuing privacy and data ownership
|
||||||
|
|
||||||
- 🧘 into minimalism
|
- 🧘 into minimalism
|
||||||
|
|
||||||
- 🧺 caring about diversifying your financial resources
|
- 🧺 caring about diversifying your financial resources
|
||||||
|
|
||||||
- 🆓 interested in financial independence
|
- 🆓 interested in financial independence
|
||||||
|
|
||||||
- 🙅 saying no to spreadsheets in 2021
|
- 🙅 saying no to spreadsheets in 2021
|
||||||
|
|
||||||
- 😎 still reading this list
|
- 😎 still reading this list
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@ -65,6 +57,7 @@ Ghostfolio is for you if you are...
|
|||||||
- ✅ Portfolio performance: Time-weighted rate of return (TWR) for `Today`, `YTD`, `1Y`, `5Y`, `Max`
|
- ✅ Portfolio performance: Time-weighted rate of return (TWR) for `Today`, `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
|
||||||
- ✅ Dark Mode
|
- ✅ Dark Mode
|
||||||
- ✅ Zen Mode
|
- ✅ Zen Mode
|
||||||
- ✅ Mobile-first design
|
- ✅ Mobile-first design
|
||||||
@ -92,7 +85,7 @@ The frontend is built with [Angular](https://angular.io) and uses [Angular Mater
|
|||||||
Run the following command to start the Docker images from [Docker Hub](https://hub.docker.com/r/ghostfolio/ghostfolio):
|
Run the following command to start the Docker images from [Docker Hub](https://hub.docker.com/r/ghostfolio/ghostfolio):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose -f docker/docker-compose.yml up
|
docker-compose -f docker/docker-compose.yml up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Setup Database
|
#### Setup Database
|
||||||
@ -109,7 +102,7 @@ Run the following commands to build and start the Docker images:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose -f docker/docker-compose.build.yml build
|
docker-compose -f docker/docker-compose.build.yml build
|
||||||
docker-compose -f docker/docker-compose.build.yml up
|
docker-compose -f docker/docker-compose.build.yml up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Setup Database
|
#### Setup Database
|
||||||
|
@ -264,7 +264,8 @@
|
|||||||
"port": 4400,
|
"port": 4400,
|
||||||
"config": {
|
"config": {
|
||||||
"configFolder": "libs/ui/.storybook"
|
"configFolder": "libs/ui/.storybook"
|
||||||
}
|
},
|
||||||
|
"projectBuildConfig": "ui:build-storybook"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"ci": {
|
"ci": {
|
||||||
@ -280,7 +281,8 @@
|
|||||||
"outputPath": "dist/storybook/ui",
|
"outputPath": "dist/storybook/ui",
|
||||||
"config": {
|
"config": {
|
||||||
"configFolder": "libs/ui/.storybook"
|
"configFolder": "libs/ui/.storybook"
|
||||||
}
|
},
|
||||||
|
"projectBuildConfig": "ui:build-storybook"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"ci": {
|
"ci": {
|
||||||
|
@ -8,6 +8,7 @@ import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering.mod
|
|||||||
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
|
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
|
||||||
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
||||||
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
||||||
|
import { TwitterBotModule } from '@ghostfolio/api/services/twitter-bot/twitter-bot.module';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { ScheduleModule } from '@nestjs/schedule';
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
@ -65,6 +66,7 @@ import { UserModule } from './user/user.module';
|
|||||||
}),
|
}),
|
||||||
SubscriptionModule,
|
SubscriptionModule,
|
||||||
SymbolModule,
|
SymbolModule,
|
||||||
|
TwitterBotModule,
|
||||||
UserModule
|
UserModule
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
|
@ -59,7 +59,7 @@ export class ExportService {
|
|||||||
type,
|
type,
|
||||||
unitPrice,
|
unitPrice,
|
||||||
dataSource: SymbolProfile.dataSource,
|
dataSource: SymbolProfile.dataSource,
|
||||||
symbol: SymbolProfile.symbol
|
symbol: type === 'ITEM' ? SymbolProfile.name : SymbolProfile.symbol
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -21,8 +21,13 @@ export class ImportService {
|
|||||||
userId: string;
|
userId: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
for (const order of orders) {
|
for (const order of orders) {
|
||||||
order.dataSource =
|
if (!order.dataSource) {
|
||||||
order.dataSource ?? this.dataProviderService.getPrimaryDataSource();
|
if (order.type === 'ITEM') {
|
||||||
|
order.dataSource = 'MANUAL';
|
||||||
|
} else {
|
||||||
|
order.dataSource = this.dataProviderService.getPrimaryDataSource();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.validateOrders({ orders, userId });
|
await this.validateOrders({ orders, userId });
|
||||||
@ -111,20 +116,22 @@ export class ImportService {
|
|||||||
throw new Error(`orders.${index} is a duplicate transaction`);
|
throw new Error(`orders.${index} is a duplicate transaction`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.dataProviderService.get([
|
if (dataSource !== 'MANUAL') {
|
||||||
{ dataSource, symbol }
|
const result = await this.dataProviderService.get([
|
||||||
]);
|
{ dataSource, symbol }
|
||||||
|
]);
|
||||||
|
|
||||||
if (result[symbol] === undefined) {
|
if (result[symbol] === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`orders.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")`
|
`orders.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result[symbol].currency !== currency) {
|
if (result[symbol].currency !== currency) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`orders.${index}.currency ("${currency}") does not match with "${result[symbol].currency}"`
|
`orders.${index}.currency ("${currency}") does not match with "${result[symbol].currency}"`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@ import {
|
|||||||
PROPERTY_IS_READ_ONLY_MODE,
|
PROPERTY_IS_READ_ONLY_MODE,
|
||||||
PROPERTY_SLACK_COMMUNITY_USERS,
|
PROPERTY_SLACK_COMMUNITY_USERS,
|
||||||
PROPERTY_STRIPE_CONFIG,
|
PROPERTY_STRIPE_CONFIG,
|
||||||
PROPERTY_SYSTEM_MESSAGE
|
PROPERTY_SYSTEM_MESSAGE,
|
||||||
|
ghostfolioFearAndGreedIndexDataSource
|
||||||
} from '@ghostfolio/common/config';
|
} from '@ghostfolio/common/config';
|
||||||
import { encodeDataSource } from '@ghostfolio/common/helper';
|
import { encodeDataSource } from '@ghostfolio/common/helper';
|
||||||
import { InfoItem } from '@ghostfolio/common/interfaces';
|
import { InfoItem } from '@ghostfolio/common/interfaces';
|
||||||
@ -18,7 +19,6 @@ import { Subscription } from '@ghostfolio/common/interfaces/subscription.interfa
|
|||||||
import { permissions } from '@ghostfolio/common/permissions';
|
import { permissions } from '@ghostfolio/common/permissions';
|
||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { DataSource } from '@prisma/client';
|
|
||||||
import * as bent from 'bent';
|
import * as bent from 'bent';
|
||||||
import { subDays } from 'date-fns';
|
import { subDays } from 'date-fns';
|
||||||
|
|
||||||
@ -52,7 +52,9 @@ export class InfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||||
info.fearAndGreedDataSource = encodeDataSource(DataSource.RAKUTEN);
|
info.fearAndGreedDataSource = encodeDataSource(
|
||||||
|
ghostfolioFearAndGreedIndexDataSource
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.configurationService.get('ENABLE_FEATURE_IMPORT')) {
|
if (this.configurationService.get('ENABLE_FEATURE_IMPORT')) {
|
||||||
|
@ -8,6 +8,7 @@ import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-
|
|||||||
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
||||||
import { ImpersonationModule } from '@ghostfolio/api/services/impersonation.module';
|
import { ImpersonationModule } from '@ghostfolio/api/services/impersonation.module';
|
||||||
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
||||||
|
import { SymbolProfileModule } from '@ghostfolio/api/services/symbol-profile.module';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { OrderController } from './order.controller';
|
import { OrderController } from './order.controller';
|
||||||
@ -22,6 +23,7 @@ import { OrderService } from './order.service';
|
|||||||
ImpersonationModule,
|
ImpersonationModule,
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
RedisCacheModule,
|
RedisCacheModule,
|
||||||
|
SymbolProfileModule,
|
||||||
UserModule
|
UserModule
|
||||||
],
|
],
|
||||||
controllers: [OrderController],
|
controllers: [OrderController],
|
||||||
|
@ -3,11 +3,13 @@ import { CacheService } from '@ghostfolio/api/app/cache/cache.service';
|
|||||||
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
|
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile.service';
|
||||||
import { OrderWithAccount } from '@ghostfolio/common/types';
|
import { OrderWithAccount } from '@ghostfolio/common/types';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { DataSource, Order, Prisma, Type as TypeOfOrder } from '@prisma/client';
|
import { DataSource, Order, Prisma, Type as TypeOfOrder } from '@prisma/client';
|
||||||
import Big from 'big.js';
|
import Big from 'big.js';
|
||||||
import { endOfToday, isAfter } from 'date-fns';
|
import { endOfToday, isAfter } from 'date-fns';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { Activity } from './interfaces/activities.interface';
|
import { Activity } from './interfaces/activities.interface';
|
||||||
|
|
||||||
@ -18,7 +20,8 @@ export class OrderService {
|
|||||||
private readonly cacheService: CacheService,
|
private readonly cacheService: CacheService,
|
||||||
private readonly exchangeRateDataService: ExchangeRateDataService,
|
private readonly exchangeRateDataService: ExchangeRateDataService,
|
||||||
private readonly dataGatheringService: DataGatheringService,
|
private readonly dataGatheringService: DataGatheringService,
|
||||||
private readonly prismaService: PrismaService
|
private readonly prismaService: PrismaService,
|
||||||
|
private readonly symbolProfileService: SymbolProfileService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async order(
|
public async order(
|
||||||
@ -58,7 +61,7 @@ export class OrderService {
|
|||||||
return account.isDefault === true;
|
return account.isDefault === true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const Account = {
|
let Account = {
|
||||||
connect: {
|
connect: {
|
||||||
id_userId: {
|
id_userId: {
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
@ -67,24 +70,47 @@ export class OrderService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDraft = isAfter(data.date as Date, endOfToday());
|
if (data.type === 'ITEM') {
|
||||||
|
const currency = data.currency;
|
||||||
|
const dataSource: DataSource = 'MANUAL';
|
||||||
|
const id = uuidv4();
|
||||||
|
const name = data.SymbolProfile.connectOrCreate.create.symbol;
|
||||||
|
|
||||||
// Convert the symbol to uppercase to avoid case-sensitive duplicates
|
Account = undefined;
|
||||||
const symbol = data.symbol.toUpperCase();
|
data.dataSource = dataSource;
|
||||||
|
data.id = id;
|
||||||
|
data.symbol = null;
|
||||||
|
data.SymbolProfile.connectOrCreate.create.currency = currency;
|
||||||
|
data.SymbolProfile.connectOrCreate.create.dataSource = dataSource;
|
||||||
|
data.SymbolProfile.connectOrCreate.create.name = name;
|
||||||
|
data.SymbolProfile.connectOrCreate.create.symbol = id;
|
||||||
|
data.SymbolProfile.connectOrCreate.where.dataSource_symbol = {
|
||||||
|
dataSource,
|
||||||
|
symbol: id
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
data.SymbolProfile.connectOrCreate.create.symbol =
|
||||||
|
data.SymbolProfile.connectOrCreate.create.symbol.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
const isDraft = isAfter(data.date as Date, endOfToday());
|
||||||
|
|
||||||
if (!isDraft) {
|
if (!isDraft) {
|
||||||
// Gather symbol data of order in the background, if not draft
|
// Gather symbol data of order in the background, if not draft
|
||||||
this.dataGatheringService.gatherSymbols([
|
this.dataGatheringService.gatherSymbols([
|
||||||
{
|
{
|
||||||
symbol,
|
|
||||||
dataSource: data.dataSource,
|
dataSource: data.dataSource,
|
||||||
date: <Date>data.date
|
date: <Date>data.date,
|
||||||
|
symbol: data.SymbolProfile.connectOrCreate.create.symbol
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dataGatheringService.gatherProfileData([
|
this.dataGatheringService.gatherProfileData([
|
||||||
{ symbol, dataSource: data.dataSource }
|
{
|
||||||
|
dataSource: data.dataSource,
|
||||||
|
symbol: data.SymbolProfile.connectOrCreate.create.symbol
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await this.cacheService.flush();
|
await this.cacheService.flush();
|
||||||
@ -98,8 +124,7 @@ export class OrderService {
|
|||||||
data: {
|
data: {
|
||||||
...orderData,
|
...orderData,
|
||||||
Account,
|
Account,
|
||||||
isDraft,
|
isDraft
|
||||||
symbol
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -107,9 +132,15 @@ export class OrderService {
|
|||||||
public async deleteOrder(
|
public async deleteOrder(
|
||||||
where: Prisma.OrderWhereUniqueInput
|
where: Prisma.OrderWhereUniqueInput
|
||||||
): Promise<Order> {
|
): Promise<Order> {
|
||||||
return this.prismaService.order.delete({
|
const order = await this.prismaService.order.delete({
|
||||||
where
|
where
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (order.type === 'ITEM') {
|
||||||
|
await this.symbolProfileService.deleteById(order.symbolProfileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getOrders({
|
public async getOrders({
|
||||||
@ -180,6 +211,17 @@ export class OrderService {
|
|||||||
}): Promise<Order> {
|
}): Promise<Order> {
|
||||||
const { data, where } = params;
|
const { data, where } = params;
|
||||||
|
|
||||||
|
if (data.Account.connect.id_userId.id === null) {
|
||||||
|
delete data.Account;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.type === 'ITEM') {
|
||||||
|
const name = data.symbol;
|
||||||
|
|
||||||
|
data.symbol = null;
|
||||||
|
data.SymbolProfile = { update: { name } };
|
||||||
|
}
|
||||||
|
|
||||||
const isDraft = isAfter(data.date as Date, endOfToday());
|
const isDraft = isAfter(data.date as Date, endOfToday());
|
||||||
|
|
||||||
if (!isDraft) {
|
if (!isDraft) {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { DataSource, Type } from '@prisma/client';
|
import { DataSource, Type } from '@prisma/client';
|
||||||
import { IsISO8601, IsNumber, IsString } from 'class-validator';
|
import { IsISO8601, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class UpdateOrderDto {
|
export class UpdateOrderDto {
|
||||||
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
accountId: string;
|
accountId: string;
|
||||||
|
|
||||||
|
60
apps/api/src/app/portfolio/current-rate.service.mock.ts
Normal file
60
apps/api/src/app/portfolio/current-rate.service.mock.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { parseDate, resetHours } from '@ghostfolio/common/helper';
|
||||||
|
import { addDays, endOfDay, isBefore, isSameDay } from 'date-fns';
|
||||||
|
|
||||||
|
import { GetValuesParams } from './interfaces/get-values-params.interface';
|
||||||
|
|
||||||
|
function mockGetValue(symbol: string, date: Date) {
|
||||||
|
switch (symbol) {
|
||||||
|
case 'BALN.SW':
|
||||||
|
if (isSameDay(parseDate('2021-11-12'), date)) {
|
||||||
|
return { marketPrice: 146 };
|
||||||
|
} else if (isSameDay(parseDate('2021-11-22'), date)) {
|
||||||
|
return { marketPrice: 142.9 };
|
||||||
|
} else if (isSameDay(parseDate('2021-11-26'), date)) {
|
||||||
|
return { marketPrice: 139.9 };
|
||||||
|
} else if (isSameDay(parseDate('2021-11-30'), date)) {
|
||||||
|
return { marketPrice: 136.6 };
|
||||||
|
} else if (isSameDay(parseDate('2021-12-18'), date)) {
|
||||||
|
return { marketPrice: 148.9 };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { marketPrice: 0 };
|
||||||
|
|
||||||
|
default:
|
||||||
|
return { marketPrice: 0 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CurrentRateServiceMock = {
|
||||||
|
getValues: ({ dataGatheringItems, dateQuery }: GetValuesParams) => {
|
||||||
|
const result = [];
|
||||||
|
if (dateQuery.lt) {
|
||||||
|
for (
|
||||||
|
let date = resetHours(dateQuery.gte);
|
||||||
|
isBefore(date, endOfDay(dateQuery.lt));
|
||||||
|
date = addDays(date, 1)
|
||||||
|
) {
|
||||||
|
for (const dataGatheringItem of dataGatheringItems) {
|
||||||
|
result.push({
|
||||||
|
date,
|
||||||
|
marketPrice: mockGetValue(dataGatheringItem.symbol, date)
|
||||||
|
.marketPrice,
|
||||||
|
symbol: dataGatheringItem.symbol
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const date of dateQuery.in) {
|
||||||
|
for (const dataGatheringItem of dataGatheringItems) {
|
||||||
|
result.push({
|
||||||
|
date,
|
||||||
|
marketPrice: mockGetValue(dataGatheringItem.symbol, date)
|
||||||
|
.marketPrice,
|
||||||
|
symbol: dataGatheringItem.symbol
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.resolve(result);
|
||||||
|
}
|
||||||
|
};
|
@ -1,11 +1,8 @@
|
|||||||
|
import { EnhancedSymbolProfile } from '@ghostfolio/api/services/interfaces/symbol-profile.interface';
|
||||||
import { OrderWithAccount } from '@ghostfolio/common/types';
|
import { OrderWithAccount } from '@ghostfolio/common/types';
|
||||||
import { AssetClass, AssetSubClass } from '@prisma/client';
|
|
||||||
|
|
||||||
export interface PortfolioPositionDetail {
|
export interface PortfolioPositionDetail {
|
||||||
assetClass?: AssetClass;
|
|
||||||
assetSubClass?: AssetSubClass;
|
|
||||||
averagePrice: number;
|
averagePrice: number;
|
||||||
currency: string;
|
|
||||||
firstBuyDate: string;
|
firstBuyDate: string;
|
||||||
grossPerformance: number;
|
grossPerformance: number;
|
||||||
grossPerformancePercent: number;
|
grossPerformancePercent: number;
|
||||||
@ -14,12 +11,11 @@ export interface PortfolioPositionDetail {
|
|||||||
marketPrice: number;
|
marketPrice: number;
|
||||||
maxPrice: number;
|
maxPrice: number;
|
||||||
minPrice: number;
|
minPrice: number;
|
||||||
name: string;
|
|
||||||
netPerformance: number;
|
netPerformance: number;
|
||||||
netPerformancePercent: number;
|
netPerformancePercent: number;
|
||||||
orders: OrderWithAccount[];
|
orders: OrderWithAccount[];
|
||||||
quantity: number;
|
quantity: number;
|
||||||
symbol: string;
|
SymbolProfile: EnhancedSymbolProfile;
|
||||||
transactionCount: number;
|
transactionCount: number;
|
||||||
value: number;
|
value: number;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
import { CurrentRateService } from '@ghostfolio/api/app/portfolio/current-rate.service';
|
||||||
|
import { parseDate } from '@ghostfolio/common/helper';
|
||||||
|
import Big from 'big.js';
|
||||||
|
|
||||||
|
import { CurrentRateServiceMock } from './current-rate.service.mock';
|
||||||
|
import { PortfolioCalculatorNew } from './portfolio-calculator-new';
|
||||||
|
|
||||||
|
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
|
||||||
|
return {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
|
CurrentRateService: jest.fn().mockImplementation(() => {
|
||||||
|
return CurrentRateServiceMock;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PortfolioCalculatorNew', () => {
|
||||||
|
let currentRateService: CurrentRateService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
currentRateService = new CurrentRateService(null, null, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('get current positions', () => {
|
||||||
|
it.only('with BALN.SW buy and sell', async () => {
|
||||||
|
const portfolioCalculatorNew = new PortfolioCalculatorNew({
|
||||||
|
currentRateService,
|
||||||
|
currency: 'CHF',
|
||||||
|
orders: [
|
||||||
|
{
|
||||||
|
currency: 'CHF',
|
||||||
|
date: '2021-11-22',
|
||||||
|
dataSource: 'YAHOO',
|
||||||
|
fee: new Big(1.55),
|
||||||
|
name: 'Bâloise Holding AG',
|
||||||
|
quantity: new Big(2),
|
||||||
|
symbol: 'BALN.SW',
|
||||||
|
type: 'BUY',
|
||||||
|
unitPrice: new Big(142.9)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currency: 'CHF',
|
||||||
|
date: '2021-11-30',
|
||||||
|
dataSource: 'YAHOO',
|
||||||
|
fee: new Big(1.65),
|
||||||
|
name: 'Bâloise Holding AG',
|
||||||
|
quantity: new Big(2),
|
||||||
|
symbol: 'BALN.SW',
|
||||||
|
type: 'SELL',
|
||||||
|
unitPrice: new Big(136.6)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
portfolioCalculatorNew.computeTransactionPoints();
|
||||||
|
|
||||||
|
const spy = jest
|
||||||
|
.spyOn(Date, 'now')
|
||||||
|
.mockImplementation(() => parseDate('2021-12-18').getTime());
|
||||||
|
|
||||||
|
const currentPositions = await portfolioCalculatorNew.getCurrentPositions(
|
||||||
|
parseDate('2021-11-22')
|
||||||
|
);
|
||||||
|
|
||||||
|
spy.mockRestore();
|
||||||
|
|
||||||
|
expect(currentPositions).toEqual({
|
||||||
|
currentValue: new Big('0'),
|
||||||
|
grossPerformance: new Big('-12.6'),
|
||||||
|
grossPerformancePercentage: new Big('-0.0440867739678096571'),
|
||||||
|
hasErrors: false,
|
||||||
|
netPerformance: new Big('-15.8'),
|
||||||
|
netPerformancePercentage: new Big('-0.0552834149755073478'),
|
||||||
|
positions: [
|
||||||
|
{
|
||||||
|
averagePrice: new Big('0'),
|
||||||
|
currency: 'CHF',
|
||||||
|
dataSource: 'YAHOO',
|
||||||
|
firstBuyDate: '2021-11-22',
|
||||||
|
grossPerformance: new Big('-12.6'),
|
||||||
|
grossPerformancePercentage: new Big('-0.0440867739678096571'),
|
||||||
|
investment: new Big('0'),
|
||||||
|
netPerformance: new Big('-15.8'),
|
||||||
|
netPerformancePercentage: new Big('-0.0552834149755073478'),
|
||||||
|
marketPrice: 148.9,
|
||||||
|
quantity: new Big('0'),
|
||||||
|
symbol: 'BALN.SW',
|
||||||
|
transactionCount: 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
totalInvestment: new Big('0')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,84 @@
|
|||||||
|
import { CurrentRateService } from '@ghostfolio/api/app/portfolio/current-rate.service';
|
||||||
|
import { parseDate } from '@ghostfolio/common/helper';
|
||||||
|
import Big from 'big.js';
|
||||||
|
|
||||||
|
import { CurrentRateServiceMock } from './current-rate.service.mock';
|
||||||
|
import { PortfolioCalculatorNew } from './portfolio-calculator-new';
|
||||||
|
|
||||||
|
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
|
||||||
|
return {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
|
CurrentRateService: jest.fn().mockImplementation(() => {
|
||||||
|
return CurrentRateServiceMock;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PortfolioCalculatorNew', () => {
|
||||||
|
let currentRateService: CurrentRateService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
currentRateService = new CurrentRateService(null, null, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('get current positions', () => {
|
||||||
|
it.only('with BALN.SW buy', async () => {
|
||||||
|
const portfolioCalculatorNew = new PortfolioCalculatorNew({
|
||||||
|
currentRateService,
|
||||||
|
currency: 'CHF',
|
||||||
|
orders: [
|
||||||
|
{
|
||||||
|
currency: 'CHF',
|
||||||
|
date: '2021-11-30',
|
||||||
|
dataSource: 'YAHOO',
|
||||||
|
fee: new Big(1.55),
|
||||||
|
name: 'Bâloise Holding AG',
|
||||||
|
quantity: new Big(2),
|
||||||
|
symbol: 'BALN.SW',
|
||||||
|
type: 'BUY',
|
||||||
|
unitPrice: new Big(136.6)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
portfolioCalculatorNew.computeTransactionPoints();
|
||||||
|
|
||||||
|
const spy = jest
|
||||||
|
.spyOn(Date, 'now')
|
||||||
|
.mockImplementation(() => parseDate('2021-12-18').getTime());
|
||||||
|
|
||||||
|
const currentPositions = await portfolioCalculatorNew.getCurrentPositions(
|
||||||
|
parseDate('2021-11-30')
|
||||||
|
);
|
||||||
|
|
||||||
|
spy.mockRestore();
|
||||||
|
|
||||||
|
expect(currentPositions).toEqual({
|
||||||
|
currentValue: new Big('297.8'),
|
||||||
|
grossPerformance: new Big('24.6'),
|
||||||
|
grossPerformancePercentage: new Big('0.09004392386530014641'),
|
||||||
|
hasErrors: false,
|
||||||
|
netPerformance: new Big('23.05'),
|
||||||
|
netPerformancePercentage: new Big('0.08437042459736456808'),
|
||||||
|
positions: [
|
||||||
|
{
|
||||||
|
averagePrice: new Big('136.6'),
|
||||||
|
currency: 'CHF',
|
||||||
|
dataSource: 'YAHOO',
|
||||||
|
firstBuyDate: '2021-11-30',
|
||||||
|
grossPerformance: new Big('24.6'),
|
||||||
|
grossPerformancePercentage: new Big('0.09004392386530014641'),
|
||||||
|
investment: new Big('273.2'),
|
||||||
|
netPerformance: new Big('23.05'),
|
||||||
|
netPerformancePercentage: new Big('0.08437042459736456808'),
|
||||||
|
marketPrice: 148.9,
|
||||||
|
quantity: new Big('2'),
|
||||||
|
symbol: 'BALN.SW',
|
||||||
|
transactionCount: 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
totalInvestment: new Big('273.2')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,56 @@
|
|||||||
|
import { CurrentRateService } from '@ghostfolio/api/app/portfolio/current-rate.service';
|
||||||
|
import { parseDate } from '@ghostfolio/common/helper';
|
||||||
|
import Big from 'big.js';
|
||||||
|
|
||||||
|
import { CurrentRateServiceMock } from './current-rate.service.mock';
|
||||||
|
import { PortfolioCalculatorNew } from './portfolio-calculator-new';
|
||||||
|
|
||||||
|
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
|
||||||
|
return {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
|
CurrentRateService: jest.fn().mockImplementation(() => {
|
||||||
|
return CurrentRateServiceMock;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PortfolioCalculatorNew', () => {
|
||||||
|
let currentRateService: CurrentRateService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
currentRateService = new CurrentRateService(null, null, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('get current positions', () => {
|
||||||
|
it('with no orders', async () => {
|
||||||
|
const portfolioCalculatorNew = new PortfolioCalculatorNew({
|
||||||
|
currentRateService,
|
||||||
|
currency: 'CHF',
|
||||||
|
orders: []
|
||||||
|
});
|
||||||
|
|
||||||
|
portfolioCalculatorNew.computeTransactionPoints();
|
||||||
|
|
||||||
|
const spy = jest
|
||||||
|
.spyOn(Date, 'now')
|
||||||
|
.mockImplementation(() => parseDate('2021-12-18').getTime());
|
||||||
|
|
||||||
|
const currentPositions = await portfolioCalculatorNew.getCurrentPositions(
|
||||||
|
new Date()
|
||||||
|
);
|
||||||
|
|
||||||
|
spy.mockRestore();
|
||||||
|
|
||||||
|
expect(currentPositions).toEqual({
|
||||||
|
currentValue: new Big(0),
|
||||||
|
grossPerformance: new Big(0),
|
||||||
|
grossPerformancePercentage: new Big(0),
|
||||||
|
hasErrors: false,
|
||||||
|
netPerformance: new Big(0),
|
||||||
|
netPerformancePercentage: new Big(0),
|
||||||
|
positions: [],
|
||||||
|
totalInvestment: new Big(0)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -82,7 +82,7 @@ export class PortfolioCalculatorNew {
|
|||||||
: unitPrice
|
: unitPrice
|
||||||
.mul(order.quantity)
|
.mul(order.quantity)
|
||||||
.mul(factor)
|
.mul(factor)
|
||||||
.add(oldAccumulatedSymbol.investment),
|
.plus(oldAccumulatedSymbol.investment),
|
||||||
quantity: newQuantity,
|
quantity: newQuantity,
|
||||||
symbol: order.symbol,
|
symbol: order.symbol,
|
||||||
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
||||||
@ -281,243 +281,6 @@ export class PortfolioCalculatorNew {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSymbolMetrics({
|
|
||||||
marketSymbolMap,
|
|
||||||
start,
|
|
||||||
symbol
|
|
||||||
}: {
|
|
||||||
marketSymbolMap: {
|
|
||||||
[date: string]: { [symbol: string]: Big };
|
|
||||||
};
|
|
||||||
start: Date;
|
|
||||||
symbol: string;
|
|
||||||
}) {
|
|
||||||
let orders: PortfolioOrderItem[] = this.orders.filter((order) => {
|
|
||||||
return order.symbol === symbol;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (orders.length <= 0) {
|
|
||||||
return {
|
|
||||||
hasErrors: false,
|
|
||||||
initialValue: new Big(0),
|
|
||||||
netPerformance: new Big(0),
|
|
||||||
netPerformancePercentage: new Big(0),
|
|
||||||
grossPerformance: new Big(0),
|
|
||||||
grossPerformancePercentage: new Big(0)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const dateOfFirstTransaction = new Date(first(orders).date);
|
|
||||||
const endDate = new Date(Date.now());
|
|
||||||
|
|
||||||
const unitPriceAtStartDate =
|
|
||||||
marketSymbolMap[format(start, DATE_FORMAT)]?.[symbol];
|
|
||||||
|
|
||||||
const unitPriceAtEndDate =
|
|
||||||
marketSymbolMap[format(endDate, DATE_FORMAT)]?.[symbol];
|
|
||||||
|
|
||||||
if (
|
|
||||||
!unitPriceAtEndDate ||
|
|
||||||
(!unitPriceAtStartDate && isBefore(dateOfFirstTransaction, start))
|
|
||||||
) {
|
|
||||||
return {
|
|
||||||
hasErrors: true,
|
|
||||||
initialValue: new Big(0),
|
|
||||||
netPerformance: new Big(0),
|
|
||||||
netPerformancePercentage: new Big(0),
|
|
||||||
grossPerformance: new Big(0),
|
|
||||||
grossPerformancePercentage: new Big(0)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let feesAtStartDate = new Big(0);
|
|
||||||
let fees = new Big(0);
|
|
||||||
let grossPerformance = new Big(0);
|
|
||||||
let grossPerformanceAtStartDate = new Big(0);
|
|
||||||
let grossPerformanceFromSells = new Big(0);
|
|
||||||
let initialValue: Big;
|
|
||||||
let lastAveragePrice = new Big(0);
|
|
||||||
let lastTransactionInvestment = new Big(0);
|
|
||||||
let lastValueOfInvestmentBeforeTransaction = new Big(0);
|
|
||||||
let timeWeightedGrossPerformancePercentage = new Big(1);
|
|
||||||
let timeWeightedNetPerformancePercentage = new Big(1);
|
|
||||||
let totalInvestment = new Big(0);
|
|
||||||
let totalUnits = new Big(0);
|
|
||||||
|
|
||||||
// Add a synthetic order at the start and the end date
|
|
||||||
orders.push({
|
|
||||||
symbol,
|
|
||||||
currency: null,
|
|
||||||
date: format(start, DATE_FORMAT),
|
|
||||||
dataSource: null,
|
|
||||||
fee: new Big(0),
|
|
||||||
itemType: 'start',
|
|
||||||
name: '',
|
|
||||||
quantity: new Big(0),
|
|
||||||
type: TypeOfOrder.BUY,
|
|
||||||
unitPrice: unitPriceAtStartDate ?? new Big(0)
|
|
||||||
});
|
|
||||||
|
|
||||||
orders.push({
|
|
||||||
symbol,
|
|
||||||
currency: null,
|
|
||||||
date: format(endDate, DATE_FORMAT),
|
|
||||||
dataSource: null,
|
|
||||||
fee: new Big(0),
|
|
||||||
itemType: 'end',
|
|
||||||
name: '',
|
|
||||||
quantity: new Big(0),
|
|
||||||
type: TypeOfOrder.BUY,
|
|
||||||
unitPrice: unitPriceAtEndDate ?? new Big(0)
|
|
||||||
});
|
|
||||||
|
|
||||||
// Sort orders so that the start and end placeholder order are at the right
|
|
||||||
// position
|
|
||||||
orders = sortBy(orders, (order) => {
|
|
||||||
let sortIndex = new Date(order.date);
|
|
||||||
|
|
||||||
if (order.itemType === 'start') {
|
|
||||||
sortIndex = addMilliseconds(sortIndex, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (order.itemType === 'end') {
|
|
||||||
sortIndex = addMilliseconds(sortIndex, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sortIndex.getTime();
|
|
||||||
});
|
|
||||||
|
|
||||||
const indexOfStartOrder = orders.findIndex((order) => {
|
|
||||||
return order.itemType === 'start';
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i = 0; i < orders.length; i += 1) {
|
|
||||||
const order = orders[i];
|
|
||||||
|
|
||||||
const valueOfInvestmentBeforeTransaction = totalUnits.mul(
|
|
||||||
order.unitPrice
|
|
||||||
);
|
|
||||||
|
|
||||||
const transactionInvestment = order.quantity
|
|
||||||
.mul(order.unitPrice)
|
|
||||||
.mul(this.getFactor(order.type));
|
|
||||||
|
|
||||||
if (
|
|
||||||
!initialValue &&
|
|
||||||
order.itemType !== 'start' &&
|
|
||||||
order.itemType !== 'end'
|
|
||||||
) {
|
|
||||||
initialValue = transactionInvestment;
|
|
||||||
}
|
|
||||||
|
|
||||||
fees = fees.plus(order.fee);
|
|
||||||
|
|
||||||
totalUnits = totalUnits.plus(
|
|
||||||
order.quantity.mul(this.getFactor(order.type))
|
|
||||||
);
|
|
||||||
|
|
||||||
const valueOfInvestment = totalUnits.mul(order.unitPrice);
|
|
||||||
|
|
||||||
const grossPerformanceFromSell =
|
|
||||||
order.type === TypeOfOrder.SELL
|
|
||||||
? order.unitPrice.minus(lastAveragePrice).mul(order.quantity)
|
|
||||||
: new Big(0);
|
|
||||||
|
|
||||||
grossPerformanceFromSells = grossPerformanceFromSells.plus(
|
|
||||||
grossPerformanceFromSell
|
|
||||||
);
|
|
||||||
|
|
||||||
totalInvestment = totalInvestment
|
|
||||||
.plus(transactionInvestment)
|
|
||||||
.plus(grossPerformanceFromSell);
|
|
||||||
|
|
||||||
lastAveragePrice = totalUnits.eq(0)
|
|
||||||
? new Big(0)
|
|
||||||
: totalInvestment.div(totalUnits);
|
|
||||||
|
|
||||||
const newGrossPerformance = valueOfInvestment
|
|
||||||
.minus(totalInvestment)
|
|
||||||
.plus(grossPerformanceFromSells);
|
|
||||||
|
|
||||||
if (
|
|
||||||
i > indexOfStartOrder &&
|
|
||||||
!lastValueOfInvestmentBeforeTransaction
|
|
||||||
.plus(lastTransactionInvestment)
|
|
||||||
.eq(0)
|
|
||||||
) {
|
|
||||||
const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
|
||||||
.sub(
|
|
||||||
lastValueOfInvestmentBeforeTransaction.plus(
|
|
||||||
lastTransactionInvestment
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.div(
|
|
||||||
lastValueOfInvestmentBeforeTransaction.plus(
|
|
||||||
lastTransactionInvestment
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
timeWeightedGrossPerformancePercentage =
|
|
||||||
timeWeightedGrossPerformancePercentage.mul(
|
|
||||||
new Big(1).plus(grossHoldingPeriodReturn)
|
|
||||||
);
|
|
||||||
|
|
||||||
const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
|
||||||
.sub(fees.sub(order.fee))
|
|
||||||
.sub(
|
|
||||||
lastValueOfInvestmentBeforeTransaction.plus(
|
|
||||||
lastTransactionInvestment
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.div(
|
|
||||||
lastValueOfInvestmentBeforeTransaction.plus(
|
|
||||||
lastTransactionInvestment
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
timeWeightedNetPerformancePercentage =
|
|
||||||
timeWeightedNetPerformancePercentage.mul(
|
|
||||||
new Big(1).plus(netHoldingPeriodReturn)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
grossPerformance = newGrossPerformance;
|
|
||||||
|
|
||||||
lastTransactionInvestment = transactionInvestment;
|
|
||||||
|
|
||||||
lastValueOfInvestmentBeforeTransaction =
|
|
||||||
valueOfInvestmentBeforeTransaction;
|
|
||||||
|
|
||||||
if (order.itemType === 'start') {
|
|
||||||
feesAtStartDate = fees;
|
|
||||||
grossPerformanceAtStartDate = grossPerformance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
timeWeightedGrossPerformancePercentage =
|
|
||||||
timeWeightedGrossPerformancePercentage.sub(1);
|
|
||||||
|
|
||||||
timeWeightedNetPerformancePercentage =
|
|
||||||
timeWeightedNetPerformancePercentage.sub(1);
|
|
||||||
|
|
||||||
const totalGrossPerformance = grossPerformance.minus(
|
|
||||||
grossPerformanceAtStartDate
|
|
||||||
);
|
|
||||||
|
|
||||||
const totalNetPerformance = grossPerformance
|
|
||||||
.minus(grossPerformanceAtStartDate)
|
|
||||||
.minus(fees.minus(feesAtStartDate));
|
|
||||||
|
|
||||||
return {
|
|
||||||
initialValue,
|
|
||||||
hasErrors: !initialValue || !unitPriceAtEndDate,
|
|
||||||
netPerformance: totalNetPerformance,
|
|
||||||
netPerformancePercentage: timeWeightedNetPerformancePercentage,
|
|
||||||
grossPerformance: totalGrossPerformance,
|
|
||||||
grossPerformancePercentage: timeWeightedGrossPerformancePercentage
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public getInvestments(): { date: string; investment: Big }[] {
|
public getInvestments(): { date: string; investment: Big }[] {
|
||||||
if (this.transactionPoints.length === 0) {
|
if (this.transactionPoints.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
@ -528,7 +291,7 @@ export class PortfolioCalculatorNew {
|
|||||||
date: transactionPoint.date,
|
date: transactionPoint.date,
|
||||||
investment: transactionPoint.items.reduce(
|
investment: transactionPoint.items.reduce(
|
||||||
(investment, transactionPointSymbol) =>
|
(investment, transactionPointSymbol) =>
|
||||||
investment.add(transactionPointSymbol.investment),
|
investment.plus(transactionPointSymbol.investment),
|
||||||
new Big(0)
|
new Big(0)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -645,13 +408,13 @@ export class PortfolioCalculatorNew {
|
|||||||
|
|
||||||
for (const currentPosition of positions) {
|
for (const currentPosition of positions) {
|
||||||
if (currentPosition.marketPrice) {
|
if (currentPosition.marketPrice) {
|
||||||
currentValue = currentValue.add(
|
currentValue = currentValue.plus(
|
||||||
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
totalInvestment = totalInvestment.add(currentPosition.investment);
|
totalInvestment = totalInvestment.plus(currentPosition.investment);
|
||||||
if (currentPosition.grossPerformance) {
|
if (currentPosition.grossPerformance) {
|
||||||
grossPerformance = grossPerformance.plus(
|
grossPerformance = grossPerformance.plus(
|
||||||
currentPosition.grossPerformance
|
currentPosition.grossPerformance
|
||||||
@ -720,8 +483,8 @@ export class PortfolioCalculatorNew {
|
|||||||
dataSource: item.dataSource,
|
dataSource: item.dataSource,
|
||||||
symbol: item.symbol
|
symbol: item.symbol
|
||||||
});
|
});
|
||||||
investment = investment.add(item.investment);
|
investment = investment.plus(item.investment);
|
||||||
fees = fees.add(item.fee);
|
fees = fees.plus(item.fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
let marketSymbols: GetValueObject[] = [];
|
let marketSymbols: GetValueObject[] = [];
|
||||||
@ -777,7 +540,7 @@ export class PortfolioCalculatorNew {
|
|||||||
invalid = true;
|
invalid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value = value.add(
|
value = value.plus(
|
||||||
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -845,6 +608,283 @@ export class PortfolioCalculatorNew {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getSymbolMetrics({
|
||||||
|
marketSymbolMap,
|
||||||
|
start,
|
||||||
|
symbol
|
||||||
|
}: {
|
||||||
|
marketSymbolMap: {
|
||||||
|
[date: string]: { [symbol: string]: Big };
|
||||||
|
};
|
||||||
|
start: Date;
|
||||||
|
symbol: string;
|
||||||
|
}) {
|
||||||
|
let orders: PortfolioOrderItem[] = this.orders.filter((order) => {
|
||||||
|
return order.symbol === symbol;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (orders.length <= 0) {
|
||||||
|
return {
|
||||||
|
hasErrors: false,
|
||||||
|
initialValue: new Big(0),
|
||||||
|
netPerformance: new Big(0),
|
||||||
|
netPerformancePercentage: new Big(0),
|
||||||
|
grossPerformance: new Big(0),
|
||||||
|
grossPerformancePercentage: new Big(0)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const dateOfFirstTransaction = new Date(first(orders).date);
|
||||||
|
const endDate = new Date(Date.now());
|
||||||
|
|
||||||
|
const unitPriceAtStartDate =
|
||||||
|
marketSymbolMap[format(start, DATE_FORMAT)]?.[symbol];
|
||||||
|
|
||||||
|
const unitPriceAtEndDate =
|
||||||
|
marketSymbolMap[format(endDate, DATE_FORMAT)]?.[symbol];
|
||||||
|
|
||||||
|
if (
|
||||||
|
!unitPriceAtEndDate ||
|
||||||
|
(!unitPriceAtStartDate && isBefore(dateOfFirstTransaction, start))
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
hasErrors: true,
|
||||||
|
initialValue: new Big(0),
|
||||||
|
netPerformance: new Big(0),
|
||||||
|
netPerformancePercentage: new Big(0),
|
||||||
|
grossPerformance: new Big(0),
|
||||||
|
grossPerformancePercentage: new Big(0)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let feesAtStartDate = new Big(0);
|
||||||
|
let fees = new Big(0);
|
||||||
|
let grossPerformance = new Big(0);
|
||||||
|
let grossPerformanceAtStartDate = new Big(0);
|
||||||
|
let grossPerformanceFromSells = new Big(0);
|
||||||
|
let initialValue: Big;
|
||||||
|
let lastAveragePrice = new Big(0);
|
||||||
|
let lastTransactionInvestment = new Big(0);
|
||||||
|
let lastValueOfInvestmentBeforeTransaction = new Big(0);
|
||||||
|
let timeWeightedGrossPerformancePercentage = new Big(1);
|
||||||
|
let timeWeightedNetPerformancePercentage = new Big(1);
|
||||||
|
let totalInvestment = new Big(0);
|
||||||
|
let totalUnits = new Big(0);
|
||||||
|
|
||||||
|
const holdingPeriodPerformances: {
|
||||||
|
grossReturn: Big;
|
||||||
|
netReturn: Big;
|
||||||
|
valueOfInvestment: Big;
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
|
// Add a synthetic order at the start and the end date
|
||||||
|
orders.push({
|
||||||
|
symbol,
|
||||||
|
currency: null,
|
||||||
|
date: format(start, DATE_FORMAT),
|
||||||
|
dataSource: null,
|
||||||
|
fee: new Big(0),
|
||||||
|
itemType: 'start',
|
||||||
|
name: '',
|
||||||
|
quantity: new Big(0),
|
||||||
|
type: TypeOfOrder.BUY,
|
||||||
|
unitPrice: unitPriceAtStartDate ?? new Big(0)
|
||||||
|
});
|
||||||
|
|
||||||
|
orders.push({
|
||||||
|
symbol,
|
||||||
|
currency: null,
|
||||||
|
date: format(endDate, DATE_FORMAT),
|
||||||
|
dataSource: null,
|
||||||
|
fee: new Big(0),
|
||||||
|
itemType: 'end',
|
||||||
|
name: '',
|
||||||
|
quantity: new Big(0),
|
||||||
|
type: TypeOfOrder.BUY,
|
||||||
|
unitPrice: unitPriceAtEndDate ?? new Big(0)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Sort orders so that the start and end placeholder order are at the right
|
||||||
|
// position
|
||||||
|
orders = sortBy(orders, (order) => {
|
||||||
|
let sortIndex = new Date(order.date);
|
||||||
|
|
||||||
|
if (order.itemType === 'start') {
|
||||||
|
sortIndex = addMilliseconds(sortIndex, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (order.itemType === 'end') {
|
||||||
|
sortIndex = addMilliseconds(sortIndex, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sortIndex.getTime();
|
||||||
|
});
|
||||||
|
|
||||||
|
const indexOfStartOrder = orders.findIndex((order) => {
|
||||||
|
return order.itemType === 'start';
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i = 0; i < orders.length; i += 1) {
|
||||||
|
const order = orders[i];
|
||||||
|
|
||||||
|
const valueOfInvestmentBeforeTransaction = totalUnits.mul(
|
||||||
|
order.unitPrice
|
||||||
|
);
|
||||||
|
|
||||||
|
const transactionInvestment = order.quantity
|
||||||
|
.mul(order.unitPrice)
|
||||||
|
.mul(this.getFactor(order.type));
|
||||||
|
|
||||||
|
if (
|
||||||
|
!initialValue &&
|
||||||
|
order.itemType !== 'start' &&
|
||||||
|
order.itemType !== 'end'
|
||||||
|
) {
|
||||||
|
initialValue = transactionInvestment;
|
||||||
|
}
|
||||||
|
|
||||||
|
fees = fees.plus(order.fee);
|
||||||
|
|
||||||
|
totalUnits = totalUnits.plus(
|
||||||
|
order.quantity.mul(this.getFactor(order.type))
|
||||||
|
);
|
||||||
|
|
||||||
|
const valueOfInvestment = totalUnits.mul(order.unitPrice);
|
||||||
|
|
||||||
|
const grossPerformanceFromSell =
|
||||||
|
order.type === TypeOfOrder.SELL
|
||||||
|
? order.unitPrice.minus(lastAveragePrice).mul(order.quantity)
|
||||||
|
: new Big(0);
|
||||||
|
|
||||||
|
grossPerformanceFromSells = grossPerformanceFromSells.plus(
|
||||||
|
grossPerformanceFromSell
|
||||||
|
);
|
||||||
|
|
||||||
|
totalInvestment = totalInvestment
|
||||||
|
.plus(transactionInvestment)
|
||||||
|
.plus(grossPerformanceFromSell);
|
||||||
|
|
||||||
|
lastAveragePrice = totalUnits.eq(0)
|
||||||
|
? new Big(0)
|
||||||
|
: totalInvestment.div(totalUnits);
|
||||||
|
|
||||||
|
const newGrossPerformance = valueOfInvestment
|
||||||
|
.minus(totalInvestment)
|
||||||
|
.plus(grossPerformanceFromSells);
|
||||||
|
|
||||||
|
if (
|
||||||
|
i > indexOfStartOrder &&
|
||||||
|
!lastValueOfInvestmentBeforeTransaction
|
||||||
|
.plus(lastTransactionInvestment)
|
||||||
|
.eq(0)
|
||||||
|
) {
|
||||||
|
const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
||||||
|
.minus(
|
||||||
|
lastValueOfInvestmentBeforeTransaction.plus(
|
||||||
|
lastTransactionInvestment
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.div(
|
||||||
|
lastValueOfInvestmentBeforeTransaction.plus(
|
||||||
|
lastTransactionInvestment
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
timeWeightedGrossPerformancePercentage =
|
||||||
|
timeWeightedGrossPerformancePercentage.mul(
|
||||||
|
new Big(1).plus(grossHoldingPeriodReturn)
|
||||||
|
);
|
||||||
|
|
||||||
|
const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
||||||
|
.minus(fees.minus(feesAtStartDate))
|
||||||
|
.minus(
|
||||||
|
lastValueOfInvestmentBeforeTransaction.plus(
|
||||||
|
lastTransactionInvestment
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.div(
|
||||||
|
lastValueOfInvestmentBeforeTransaction.plus(
|
||||||
|
lastTransactionInvestment
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
timeWeightedNetPerformancePercentage =
|
||||||
|
timeWeightedNetPerformancePercentage.mul(
|
||||||
|
new Big(1).plus(netHoldingPeriodReturn)
|
||||||
|
);
|
||||||
|
|
||||||
|
holdingPeriodPerformances.push({
|
||||||
|
grossReturn: grossHoldingPeriodReturn,
|
||||||
|
netReturn: netHoldingPeriodReturn,
|
||||||
|
valueOfInvestment: lastValueOfInvestmentBeforeTransaction.plus(
|
||||||
|
lastTransactionInvestment
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
grossPerformance = newGrossPerformance;
|
||||||
|
|
||||||
|
lastTransactionInvestment = transactionInvestment;
|
||||||
|
|
||||||
|
lastValueOfInvestmentBeforeTransaction =
|
||||||
|
valueOfInvestmentBeforeTransaction;
|
||||||
|
|
||||||
|
if (order.itemType === 'start') {
|
||||||
|
feesAtStartDate = fees;
|
||||||
|
grossPerformanceAtStartDate = grossPerformance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timeWeightedGrossPerformancePercentage =
|
||||||
|
timeWeightedGrossPerformancePercentage.minus(1);
|
||||||
|
|
||||||
|
timeWeightedNetPerformancePercentage =
|
||||||
|
timeWeightedNetPerformancePercentage.minus(1);
|
||||||
|
|
||||||
|
const totalGrossPerformance = grossPerformance.minus(
|
||||||
|
grossPerformanceAtStartDate
|
||||||
|
);
|
||||||
|
|
||||||
|
const totalNetPerformance = grossPerformance
|
||||||
|
.minus(grossPerformanceAtStartDate)
|
||||||
|
.minus(fees.minus(feesAtStartDate));
|
||||||
|
|
||||||
|
let valueOfInvestmentSum = new Big(0);
|
||||||
|
|
||||||
|
for (const holdingPeriodPerformance of holdingPeriodPerformances) {
|
||||||
|
valueOfInvestmentSum = valueOfInvestmentSum.plus(
|
||||||
|
holdingPeriodPerformance.valueOfInvestment
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let totalWeightedGrossPerformance = new Big(0);
|
||||||
|
let totalWeightedNetPerformance = new Big(0);
|
||||||
|
|
||||||
|
// Weight the holding period returns according to their value of investment
|
||||||
|
for (const holdingPeriodPerformance of holdingPeriodPerformances) {
|
||||||
|
totalWeightedGrossPerformance = totalWeightedGrossPerformance.plus(
|
||||||
|
holdingPeriodPerformance.grossReturn
|
||||||
|
.mul(holdingPeriodPerformance.valueOfInvestment)
|
||||||
|
.div(valueOfInvestmentSum)
|
||||||
|
);
|
||||||
|
|
||||||
|
totalWeightedNetPerformance = totalWeightedNetPerformance.plus(
|
||||||
|
holdingPeriodPerformance.netReturn
|
||||||
|
.mul(holdingPeriodPerformance.valueOfInvestment)
|
||||||
|
.div(valueOfInvestmentSum)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
initialValue,
|
||||||
|
hasErrors: !initialValue || !unitPriceAtEndDate,
|
||||||
|
netPerformance: totalNetPerformance,
|
||||||
|
netPerformancePercentage: totalWeightedNetPerformance,
|
||||||
|
grossPerformance: totalGrossPerformance,
|
||||||
|
grossPerformancePercentage: totalWeightedGrossPerformance
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private isNextItemActive(
|
private isNextItemActive(
|
||||||
timelineSpecification: TimelineSpecification[],
|
timelineSpecification: TimelineSpecification[],
|
||||||
currentDate: Date,
|
currentDate: Date,
|
||||||
|
@ -69,7 +69,7 @@ export class PortfolioCalculator {
|
|||||||
: unitPrice
|
: unitPrice
|
||||||
.mul(order.quantity)
|
.mul(order.quantity)
|
||||||
.mul(factor)
|
.mul(factor)
|
||||||
.add(oldAccumulatedSymbol.investment),
|
.plus(oldAccumulatedSymbol.investment),
|
||||||
quantity: newQuantity,
|
quantity: newQuantity,
|
||||||
symbol: order.symbol,
|
symbol: order.symbol,
|
||||||
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
||||||
@ -354,7 +354,7 @@ export class PortfolioCalculator {
|
|||||||
date: transactionPoint.date,
|
date: transactionPoint.date,
|
||||||
investment: transactionPoint.items.reduce(
|
investment: transactionPoint.items.reduce(
|
||||||
(investment, transactionPointSymbol) =>
|
(investment, transactionPointSymbol) =>
|
||||||
investment.add(transactionPointSymbol.investment),
|
investment.plus(transactionPointSymbol.investment),
|
||||||
new Big(0)
|
new Big(0)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -475,13 +475,13 @@ export class PortfolioCalculator {
|
|||||||
|
|
||||||
for (const currentPosition of positions) {
|
for (const currentPosition of positions) {
|
||||||
if (currentPosition.marketPrice) {
|
if (currentPosition.marketPrice) {
|
||||||
currentValue = currentValue.add(
|
currentValue = currentValue.plus(
|
||||||
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
totalInvestment = totalInvestment.add(currentPosition.investment);
|
totalInvestment = totalInvestment.plus(currentPosition.investment);
|
||||||
if (currentPosition.grossPerformance) {
|
if (currentPosition.grossPerformance) {
|
||||||
grossPerformance = grossPerformance.plus(
|
grossPerformance = grossPerformance.plus(
|
||||||
currentPosition.grossPerformance
|
currentPosition.grossPerformance
|
||||||
@ -562,8 +562,8 @@ export class PortfolioCalculator {
|
|||||||
dataSource: item.dataSource,
|
dataSource: item.dataSource,
|
||||||
symbol: item.symbol
|
symbol: item.symbol
|
||||||
});
|
});
|
||||||
investment = investment.add(item.investment);
|
investment = investment.plus(item.investment);
|
||||||
fees = fees.add(item.fee);
|
fees = fees.plus(item.fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
let marketSymbols: GetValueObject[] = [];
|
let marketSymbols: GetValueObject[] = [];
|
||||||
@ -619,7 +619,7 @@ export class PortfolioCalculator {
|
|||||||
invalid = true;
|
invalid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value = value.add(
|
value = value.plus(
|
||||||
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -332,6 +332,7 @@ export class PortfolioController {
|
|||||||
'currentValue',
|
'currentValue',
|
||||||
'dividend',
|
'dividend',
|
||||||
'fees',
|
'fees',
|
||||||
|
'items',
|
||||||
'netWorth',
|
'netWorth',
|
||||||
'totalBuy',
|
'totalBuy',
|
||||||
'totalSell'
|
'totalSell'
|
||||||
@ -343,6 +344,7 @@ export class PortfolioController {
|
|||||||
|
|
||||||
@Get('position/:dataSource/:symbol')
|
@Get('position/:dataSource/:symbol')
|
||||||
@UseInterceptors(TransformDataSourceInRequestInterceptor)
|
@UseInterceptors(TransformDataSourceInRequestInterceptor)
|
||||||
|
@UseInterceptors(TransformDataSourceInResponseInterceptor)
|
||||||
@UseGuards(AuthGuard('jwt'))
|
@UseGuards(AuthGuard('jwt'))
|
||||||
public async getPosition(
|
public async getPosition(
|
||||||
@Headers('impersonation-id') impersonationId: string,
|
@Headers('impersonation-id') impersonationId: string,
|
||||||
|
@ -417,7 +417,6 @@ export class PortfolioServiceNew {
|
|||||||
if (orders.length <= 0) {
|
if (orders.length <= 0) {
|
||||||
return {
|
return {
|
||||||
averagePrice: undefined,
|
averagePrice: undefined,
|
||||||
currency: undefined,
|
|
||||||
firstBuyDate: undefined,
|
firstBuyDate: undefined,
|
||||||
grossPerformance: undefined,
|
grossPerformance: undefined,
|
||||||
grossPerformancePercent: undefined,
|
grossPerformancePercent: undefined,
|
||||||
@ -426,21 +425,20 @@ export class PortfolioServiceNew {
|
|||||||
marketPrice: undefined,
|
marketPrice: undefined,
|
||||||
maxPrice: undefined,
|
maxPrice: undefined,
|
||||||
minPrice: undefined,
|
minPrice: undefined,
|
||||||
name: undefined,
|
|
||||||
netPerformance: undefined,
|
netPerformance: undefined,
|
||||||
netPerformancePercent: undefined,
|
netPerformancePercent: undefined,
|
||||||
orders: [],
|
orders: [],
|
||||||
quantity: undefined,
|
quantity: undefined,
|
||||||
symbol: aSymbol,
|
SymbolProfile: undefined,
|
||||||
transactionCount: undefined,
|
transactionCount: undefined,
|
||||||
value: undefined
|
value: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetClass = orders[0].SymbolProfile?.assetClass;
|
|
||||||
const assetSubClass = orders[0].SymbolProfile?.assetSubClass;
|
|
||||||
const positionCurrency = orders[0].currency;
|
const positionCurrency = orders[0].currency;
|
||||||
const name = orders[0].SymbolProfile?.name ?? '';
|
const [SymbolProfile] = await this.symbolProfileService.getSymbolProfiles([
|
||||||
|
aSymbol
|
||||||
|
]);
|
||||||
|
|
||||||
const portfolioOrders: PortfolioOrder[] = orders
|
const portfolioOrders: PortfolioOrder[] = orders
|
||||||
.filter((order) => {
|
.filter((order) => {
|
||||||
@ -557,18 +555,15 @@ export class PortfolioServiceNew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assetClass,
|
|
||||||
assetSubClass,
|
|
||||||
currency,
|
|
||||||
firstBuyDate,
|
firstBuyDate,
|
||||||
grossPerformance,
|
grossPerformance,
|
||||||
investment,
|
investment,
|
||||||
marketPrice,
|
marketPrice,
|
||||||
maxPrice,
|
maxPrice,
|
||||||
minPrice,
|
minPrice,
|
||||||
name,
|
|
||||||
netPerformance,
|
netPerformance,
|
||||||
orders,
|
orders,
|
||||||
|
SymbolProfile,
|
||||||
transactionCount,
|
transactionCount,
|
||||||
averagePrice: averagePrice.toNumber(),
|
averagePrice: averagePrice.toNumber(),
|
||||||
grossPerformancePercent:
|
grossPerformancePercent:
|
||||||
@ -576,7 +571,6 @@ export class PortfolioServiceNew {
|
|||||||
historicalData: historicalDataArray,
|
historicalData: historicalDataArray,
|
||||||
netPerformancePercent: position.netPerformancePercentage?.toNumber(),
|
netPerformancePercent: position.netPerformancePercentage?.toNumber(),
|
||||||
quantity: quantity.toNumber(),
|
quantity: quantity.toNumber(),
|
||||||
symbol: aSymbol,
|
|
||||||
value: this.exchangeRateDataService.toCurrency(
|
value: this.exchangeRateDataService.toCurrency(
|
||||||
quantity.mul(marketPrice).toNumber(),
|
quantity.mul(marketPrice).toNumber(),
|
||||||
currency,
|
currency,
|
||||||
@ -621,15 +615,12 @@ export class PortfolioServiceNew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assetClass,
|
|
||||||
assetSubClass,
|
|
||||||
marketPrice,
|
marketPrice,
|
||||||
maxPrice,
|
maxPrice,
|
||||||
minPrice,
|
minPrice,
|
||||||
name,
|
|
||||||
orders,
|
orders,
|
||||||
|
SymbolProfile,
|
||||||
averagePrice: 0,
|
averagePrice: 0,
|
||||||
currency: currentData[aSymbol]?.currency,
|
|
||||||
firstBuyDate: undefined,
|
firstBuyDate: undefined,
|
||||||
grossPerformance: undefined,
|
grossPerformance: undefined,
|
||||||
grossPerformancePercent: undefined,
|
grossPerformancePercent: undefined,
|
||||||
@ -638,7 +629,6 @@ export class PortfolioServiceNew {
|
|||||||
netPerformance: undefined,
|
netPerformance: undefined,
|
||||||
netPerformancePercent: undefined,
|
netPerformancePercent: undefined,
|
||||||
quantity: 0,
|
quantity: 0,
|
||||||
symbol: aSymbol,
|
|
||||||
transactionCount: undefined,
|
transactionCount: undefined,
|
||||||
value: 0
|
value: 0
|
||||||
};
|
};
|
||||||
@ -891,14 +881,16 @@ export class PortfolioServiceNew {
|
|||||||
const dividend = this.getDividend(orders).toNumber();
|
const dividend = this.getDividend(orders).toNumber();
|
||||||
const fees = this.getFees(orders).toNumber();
|
const fees = this.getFees(orders).toNumber();
|
||||||
const firstOrderDate = orders[0]?.date;
|
const firstOrderDate = orders[0]?.date;
|
||||||
|
const items = this.getItems(orders).toNumber();
|
||||||
|
|
||||||
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
||||||
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
||||||
|
|
||||||
const committedFunds = new Big(totalBuy).sub(totalSell);
|
const committedFunds = new Big(totalBuy).minus(totalSell);
|
||||||
|
|
||||||
const netWorth = new Big(balance)
|
const netWorth = new Big(balance)
|
||||||
.plus(performanceInformation.performance.currentValue)
|
.plus(performanceInformation.performance.currentValue)
|
||||||
|
.plus(items)
|
||||||
.toNumber();
|
.toNumber();
|
||||||
|
|
||||||
const daysInMarket = differenceInDays(new Date(), firstOrderDate);
|
const daysInMarket = differenceInDays(new Date(), firstOrderDate);
|
||||||
@ -922,6 +914,7 @@ export class PortfolioServiceNew {
|
|||||||
dividend,
|
dividend,
|
||||||
fees,
|
fees,
|
||||||
firstOrderDate,
|
firstOrderDate,
|
||||||
|
items,
|
||||||
netWorth,
|
netWorth,
|
||||||
totalBuy,
|
totalBuy,
|
||||||
totalSell,
|
totalSell,
|
||||||
@ -1043,6 +1036,28 @@ export class PortfolioServiceNew {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getItems(orders: OrderWithAccount[], date = new Date(0)) {
|
||||||
|
return orders
|
||||||
|
.filter((order) => {
|
||||||
|
// Filter out all orders before given date and type item
|
||||||
|
return (
|
||||||
|
isBefore(date, new Date(order.date)) &&
|
||||||
|
order.type === TypeOfOrder.ITEM
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.map((order) => {
|
||||||
|
return this.exchangeRateDataService.toCurrency(
|
||||||
|
new Big(order.quantity).mul(order.unitPrice).toNumber(),
|
||||||
|
order.currency,
|
||||||
|
this.request.user.Settings.currency
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.reduce(
|
||||||
|
(previous, current) => new Big(previous).plus(current),
|
||||||
|
new Big(0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private getStartDate(aDateRange: DateRange, portfolioStart: Date) {
|
private getStartDate(aDateRange: DateRange, portfolioStart: Date) {
|
||||||
switch (aDateRange) {
|
switch (aDateRange) {
|
||||||
case '1d':
|
case '1d':
|
||||||
|
@ -405,7 +405,6 @@ export class PortfolioService {
|
|||||||
if (orders.length <= 0) {
|
if (orders.length <= 0) {
|
||||||
return {
|
return {
|
||||||
averagePrice: undefined,
|
averagePrice: undefined,
|
||||||
currency: undefined,
|
|
||||||
firstBuyDate: undefined,
|
firstBuyDate: undefined,
|
||||||
grossPerformance: undefined,
|
grossPerformance: undefined,
|
||||||
grossPerformancePercent: undefined,
|
grossPerformancePercent: undefined,
|
||||||
@ -414,21 +413,20 @@ export class PortfolioService {
|
|||||||
marketPrice: undefined,
|
marketPrice: undefined,
|
||||||
maxPrice: undefined,
|
maxPrice: undefined,
|
||||||
minPrice: undefined,
|
minPrice: undefined,
|
||||||
name: undefined,
|
|
||||||
netPerformance: undefined,
|
netPerformance: undefined,
|
||||||
netPerformancePercent: undefined,
|
netPerformancePercent: undefined,
|
||||||
orders: [],
|
orders: [],
|
||||||
quantity: undefined,
|
quantity: undefined,
|
||||||
symbol: aSymbol,
|
SymbolProfile: undefined,
|
||||||
transactionCount: undefined,
|
transactionCount: undefined,
|
||||||
value: undefined
|
value: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetClass = orders[0].SymbolProfile?.assetClass;
|
|
||||||
const assetSubClass = orders[0].SymbolProfile?.assetSubClass;
|
|
||||||
const positionCurrency = orders[0].currency;
|
const positionCurrency = orders[0].currency;
|
||||||
const name = orders[0].SymbolProfile?.name ?? '';
|
const [SymbolProfile] = await this.symbolProfileService.getSymbolProfiles([
|
||||||
|
aSymbol
|
||||||
|
]);
|
||||||
|
|
||||||
const portfolioOrders: PortfolioOrder[] = orders
|
const portfolioOrders: PortfolioOrder[] = orders
|
||||||
.filter((order) => {
|
.filter((order) => {
|
||||||
@ -543,25 +541,21 @@ export class PortfolioService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assetClass,
|
|
||||||
assetSubClass,
|
|
||||||
currency,
|
|
||||||
firstBuyDate,
|
firstBuyDate,
|
||||||
grossPerformance,
|
grossPerformance,
|
||||||
investment,
|
investment,
|
||||||
marketPrice,
|
marketPrice,
|
||||||
maxPrice,
|
maxPrice,
|
||||||
minPrice,
|
minPrice,
|
||||||
name,
|
|
||||||
netPerformance,
|
netPerformance,
|
||||||
orders,
|
orders,
|
||||||
|
SymbolProfile,
|
||||||
transactionCount,
|
transactionCount,
|
||||||
averagePrice: averagePrice.toNumber(),
|
averagePrice: averagePrice.toNumber(),
|
||||||
grossPerformancePercent: position.grossPerformancePercentage.toNumber(),
|
grossPerformancePercent: position.grossPerformancePercentage.toNumber(),
|
||||||
historicalData: historicalDataArray,
|
historicalData: historicalDataArray,
|
||||||
netPerformancePercent: position.netPerformancePercentage.toNumber(),
|
netPerformancePercent: position.netPerformancePercentage.toNumber(),
|
||||||
quantity: quantity.toNumber(),
|
quantity: quantity.toNumber(),
|
||||||
symbol: aSymbol,
|
|
||||||
value: this.exchangeRateDataService.toCurrency(
|
value: this.exchangeRateDataService.toCurrency(
|
||||||
quantity.mul(marketPrice).toNumber(),
|
quantity.mul(marketPrice).toNumber(),
|
||||||
currency,
|
currency,
|
||||||
@ -606,15 +600,12 @@ export class PortfolioService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assetClass,
|
|
||||||
assetSubClass,
|
|
||||||
marketPrice,
|
marketPrice,
|
||||||
maxPrice,
|
maxPrice,
|
||||||
minPrice,
|
minPrice,
|
||||||
name,
|
|
||||||
orders,
|
orders,
|
||||||
|
SymbolProfile,
|
||||||
averagePrice: 0,
|
averagePrice: 0,
|
||||||
currency: currentData[aSymbol]?.currency,
|
|
||||||
firstBuyDate: undefined,
|
firstBuyDate: undefined,
|
||||||
grossPerformance: undefined,
|
grossPerformance: undefined,
|
||||||
grossPerformancePercent: undefined,
|
grossPerformancePercent: undefined,
|
||||||
@ -623,7 +614,6 @@ export class PortfolioService {
|
|||||||
netPerformance: undefined,
|
netPerformance: undefined,
|
||||||
netPerformancePercent: undefined,
|
netPerformancePercent: undefined,
|
||||||
quantity: 0,
|
quantity: 0,
|
||||||
symbol: aSymbol,
|
|
||||||
transactionCount: undefined,
|
transactionCount: undefined,
|
||||||
value: 0
|
value: 0
|
||||||
};
|
};
|
||||||
@ -869,14 +859,16 @@ export class PortfolioService {
|
|||||||
const dividend = this.getDividend(orders).toNumber();
|
const dividend = this.getDividend(orders).toNumber();
|
||||||
const fees = this.getFees(orders).toNumber();
|
const fees = this.getFees(orders).toNumber();
|
||||||
const firstOrderDate = orders[0]?.date;
|
const firstOrderDate = orders[0]?.date;
|
||||||
|
const items = this.getItems(orders).toNumber();
|
||||||
|
|
||||||
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
||||||
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
||||||
|
|
||||||
const committedFunds = new Big(totalBuy).sub(totalSell);
|
const committedFunds = new Big(totalBuy).minus(totalSell);
|
||||||
|
|
||||||
const netWorth = new Big(balance)
|
const netWorth = new Big(balance)
|
||||||
.plus(performanceInformation.performance.currentValue)
|
.plus(performanceInformation.performance.currentValue)
|
||||||
|
.plus(items)
|
||||||
.toNumber();
|
.toNumber();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -884,6 +876,7 @@ export class PortfolioService {
|
|||||||
dividend,
|
dividend,
|
||||||
fees,
|
fees,
|
||||||
firstOrderDate,
|
firstOrderDate,
|
||||||
|
items,
|
||||||
netWorth,
|
netWorth,
|
||||||
totalBuy,
|
totalBuy,
|
||||||
totalSell,
|
totalSell,
|
||||||
@ -1007,6 +1000,28 @@ export class PortfolioService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getItems(orders: OrderWithAccount[], date = new Date(0)) {
|
||||||
|
return orders
|
||||||
|
.filter((order) => {
|
||||||
|
// Filter out all orders before given date and type item
|
||||||
|
return (
|
||||||
|
isBefore(date, new Date(order.date)) &&
|
||||||
|
order.type === TypeOfOrder.ITEM
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.map((order) => {
|
||||||
|
return this.exchangeRateDataService.toCurrency(
|
||||||
|
new Big(order.quantity).mul(order.unitPrice).toNumber(),
|
||||||
|
order.currency,
|
||||||
|
this.request.user.Settings.currency
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.reduce(
|
||||||
|
(previous, current) => new Big(previous).plus(current),
|
||||||
|
new Big(0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private getStartDate(aDateRange: DateRange, portfolioStart: Date) {
|
private getStartDate(aDateRange: DateRange, portfolioStart: Date) {
|
||||||
switch (aDateRange) {
|
switch (aDateRange) {
|
||||||
case '1d':
|
case '1d':
|
||||||
|
@ -8,13 +8,14 @@ import { SymbolController } from './symbol.controller';
|
|||||||
import { SymbolService } from './symbol.service';
|
import { SymbolService } from './symbol.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
controllers: [SymbolController],
|
||||||
|
exports: [SymbolService],
|
||||||
imports: [
|
imports: [
|
||||||
ConfigurationModule,
|
ConfigurationModule,
|
||||||
DataProviderModule,
|
DataProviderModule,
|
||||||
MarketDataModule,
|
MarketDataModule,
|
||||||
PrismaModule
|
PrismaModule
|
||||||
],
|
],
|
||||||
controllers: [SymbolController],
|
|
||||||
providers: [SymbolService]
|
providers: [SymbolService]
|
||||||
})
|
})
|
||||||
export class SymbolModule {}
|
export class SymbolModule {}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
import { Role } from '@prisma/client';
|
||||||
|
|
||||||
export interface UserItem {
|
export interface UserItem {
|
||||||
accessToken?: string;
|
accessToken?: string;
|
||||||
authToken: string;
|
authToken: string;
|
||||||
|
role: Role;
|
||||||
}
|
}
|
||||||
|
@ -85,12 +85,13 @@ export class UserController {
|
|||||||
|
|
||||||
const hasAdmin = await this.userService.hasAdmin();
|
const hasAdmin = await this.userService.hasAdmin();
|
||||||
|
|
||||||
const { accessToken, id } = await this.userService.createUser({
|
const { accessToken, id, role } = await this.userService.createUser({
|
||||||
role: hasAdmin ? 'USER' : 'ADMIN'
|
role: hasAdmin ? 'USER' : 'ADMIN'
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accessToken,
|
accessToken,
|
||||||
|
role,
|
||||||
authToken: this.jwtService.sign({
|
authToken: this.jwtService.sign({
|
||||||
id
|
id
|
||||||
})
|
})
|
||||||
|
@ -180,7 +180,11 @@ export class UserService {
|
|||||||
return hash.digest('hex');
|
return hash.digest('hex');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createUser(data?: Prisma.UserCreateInput): Promise<User> {
|
public async createUser(data: Prisma.UserCreateInput): Promise<User> {
|
||||||
|
if (!data?.provider) {
|
||||||
|
data.provider = 'ANONYMOUS';
|
||||||
|
}
|
||||||
|
|
||||||
let user = await this.prismaService.user.create({
|
let user = await this.prismaService.user.create({
|
||||||
data: {
|
data: {
|
||||||
...data,
|
...data,
|
||||||
@ -199,7 +203,7 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.provider === Provider.ANONYMOUS) {
|
if (data.provider === 'ANONYMOUS') {
|
||||||
const accessToken = this.createAccessToken(
|
const accessToken = this.createAccessToken(
|
||||||
user.id,
|
user.id,
|
||||||
this.getRandomString(10)
|
this.getRandomString(10)
|
||||||
|
@ -58,12 +58,25 @@ export class TransformDataSourceInResponseInterceptor<T>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.orders) {
|
||||||
|
data.orders.map((order) => {
|
||||||
|
order.dataSource = encodeDataSource(order.dataSource);
|
||||||
|
return order;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (data.positions) {
|
if (data.positions) {
|
||||||
data.positions.map((position) => {
|
data.positions.map((position) => {
|
||||||
position.dataSource = encodeDataSource(position.dataSource);
|
position.dataSource = encodeDataSource(position.dataSource);
|
||||||
return position;
|
return position;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.SymbolProfile) {
|
||||||
|
data.SymbolProfile.dataSource = encodeDataSource(
|
||||||
|
data.SymbolProfile.dataSource
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -39,6 +39,10 @@ export class ConfigurationService {
|
|||||||
ROOT_URL: str({ default: 'http://localhost:4200' }),
|
ROOT_URL: str({ default: 'http://localhost:4200' }),
|
||||||
STRIPE_PUBLIC_KEY: str({ default: '' }),
|
STRIPE_PUBLIC_KEY: str({ default: '' }),
|
||||||
STRIPE_SECRET_KEY: str({ default: '' }),
|
STRIPE_SECRET_KEY: str({ default: '' }),
|
||||||
|
TWITTER_ACCESS_TOKEN: str({ default: 'dummyAccessToken' }),
|
||||||
|
TWITTER_ACCESS_TOKEN_SECRET: str({ default: 'dummyAccessTokenSecret' }),
|
||||||
|
TWITTER_API_KEY: str({ default: 'dummyApiKey' }),
|
||||||
|
TWITTER_API_SECRET: str({ default: 'dummyApiSecret' }),
|
||||||
WEB_AUTH_RP_ID: host({ default: 'localhost' })
|
WEB_AUTH_RP_ID: host({ default: 'localhost' })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,14 @@ import { Cron, CronExpression } from '@nestjs/schedule';
|
|||||||
|
|
||||||
import { DataGatheringService } from './data-gathering.service';
|
import { DataGatheringService } from './data-gathering.service';
|
||||||
import { ExchangeRateDataService } from './exchange-rate-data.service';
|
import { ExchangeRateDataService } from './exchange-rate-data.service';
|
||||||
|
import { TwitterBotService } from './twitter-bot/twitter-bot.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CronService {
|
export class CronService {
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly dataGatheringService: DataGatheringService,
|
private readonly dataGatheringService: DataGatheringService,
|
||||||
private readonly exchangeRateDataService: ExchangeRateDataService
|
private readonly exchangeRateDataService: ExchangeRateDataService,
|
||||||
|
private readonly twitterBotService: TwitterBotService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Cron(CronExpression.EVERY_MINUTE)
|
@Cron(CronExpression.EVERY_MINUTE)
|
||||||
@ -21,6 +23,11 @@ export class CronService {
|
|||||||
await this.exchangeRateDataService.loadCurrencies();
|
await this.exchangeRateDataService.loadCurrencies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cron(CronExpression.EVERY_DAY_AT_6PM)
|
||||||
|
public async runEveryDayAtSixPM() {
|
||||||
|
this.twitterBotService.tweetFearAndGreedIndex();
|
||||||
|
}
|
||||||
|
|
||||||
@Cron(CronExpression.EVERY_WEEKEND)
|
@Cron(CronExpression.EVERY_WEEKEND)
|
||||||
public async runEveryWeekend() {
|
public async runEveryWeekend() {
|
||||||
await this.dataGatheringService.gatherProfileData();
|
await this.dataGatheringService.gatherProfileData();
|
||||||
|
@ -445,6 +445,11 @@ export class DataGatheringService {
|
|||||||
},
|
},
|
||||||
scraperConfiguration: true,
|
scraperConfiguration: true,
|
||||||
symbol: true
|
symbol: true
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
dataSource: {
|
||||||
|
not: 'MANUAL'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
).map((symbolProfile) => {
|
).map((symbolProfile) => {
|
||||||
@ -479,6 +484,11 @@ export class DataGatheringService {
|
|||||||
dataSource: true,
|
dataSource: true,
|
||||||
scraperConfiguration: true,
|
scraperConfiguration: true,
|
||||||
symbol: true
|
symbol: true
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
dataSource: {
|
||||||
|
not: 'MANUAL'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -537,6 +547,7 @@ export class DataGatheringService {
|
|||||||
return distinctOrders.filter((distinctOrder) => {
|
return distinctOrders.filter((distinctOrder) => {
|
||||||
return (
|
return (
|
||||||
distinctOrder.dataSource !== DataSource.GHOSTFOLIO &&
|
distinctOrder.dataSource !== DataSource.GHOSTFOLIO &&
|
||||||
|
distinctOrder.dataSource !== DataSource.MANUAL &&
|
||||||
distinctOrder.dataSource !== DataSource.RAKUTEN
|
distinctOrder.dataSource !== DataSource.RAKUTEN
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,7 @@ import { ConfigurationModule } from '@ghostfolio/api/services/configuration.modu
|
|||||||
import { CryptocurrencyModule } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.module';
|
import { CryptocurrencyModule } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.module';
|
||||||
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
import { GoogleSheetsService } from '@ghostfolio/api/services/data-provider/google-sheets/google-sheets.service';
|
import { GoogleSheetsService } from '@ghostfolio/api/services/data-provider/google-sheets/google-sheets.service';
|
||||||
|
import { ManualService } from '@ghostfolio/api/services/data-provider/manual/manual.service';
|
||||||
import { RakutenRapidApiService } from '@ghostfolio/api/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
import { RakutenRapidApiService } from '@ghostfolio/api/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
import { YahooFinanceService } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
import { YahooFinanceService } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
||||||
@ -23,6 +24,7 @@ import { DataProviderService } from './data-provider.service';
|
|||||||
DataProviderService,
|
DataProviderService,
|
||||||
GhostfolioScraperApiService,
|
GhostfolioScraperApiService,
|
||||||
GoogleSheetsService,
|
GoogleSheetsService,
|
||||||
|
ManualService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
YahooFinanceService,
|
YahooFinanceService,
|
||||||
{
|
{
|
||||||
@ -30,6 +32,7 @@ import { DataProviderService } from './data-provider.service';
|
|||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
GhostfolioScraperApiService,
|
GhostfolioScraperApiService,
|
||||||
GoogleSheetsService,
|
GoogleSheetsService,
|
||||||
|
ManualService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
YahooFinanceService
|
YahooFinanceService
|
||||||
],
|
],
|
||||||
@ -38,12 +41,14 @@ import { DataProviderService } from './data-provider.service';
|
|||||||
alphaVantageService,
|
alphaVantageService,
|
||||||
ghostfolioScraperApiService,
|
ghostfolioScraperApiService,
|
||||||
googleSheetsService,
|
googleSheetsService,
|
||||||
|
manualService,
|
||||||
rakutenRapidApiService,
|
rakutenRapidApiService,
|
||||||
yahooFinanceService
|
yahooFinanceService
|
||||||
) => [
|
) => [
|
||||||
alphaVantageService,
|
alphaVantageService,
|
||||||
ghostfolioScraperApiService,
|
ghostfolioScraperApiService,
|
||||||
googleSheetsService,
|
googleSheetsService,
|
||||||
|
manualService,
|
||||||
rakutenRapidApiService,
|
rakutenRapidApiService,
|
||||||
yahooFinanceService
|
yahooFinanceService
|
||||||
]
|
]
|
||||||
|
@ -194,6 +194,7 @@ export class DataProviderService {
|
|||||||
return dataProviderInterface;
|
return dataProviderInterface;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error('No data provider has been found.');
|
throw new Error('No data provider has been found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
43
apps/api/src/services/data-provider/manual/manual.service.ts
Normal file
43
apps/api/src/services/data-provider/manual/manual.service.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface';
|
||||||
|
import { DataProviderInterface } from '@ghostfolio/api/services/data-provider/interfaces/data-provider.interface';
|
||||||
|
import {
|
||||||
|
IDataProviderHistoricalResponse,
|
||||||
|
IDataProviderResponse
|
||||||
|
} from '@ghostfolio/api/services/interfaces/interfaces';
|
||||||
|
import { Granularity } from '@ghostfolio/common/types';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DataSource } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ManualService implements DataProviderInterface {
|
||||||
|
public constructor() {}
|
||||||
|
|
||||||
|
public canHandle(symbol: string) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(
|
||||||
|
aSymbols: string[]
|
||||||
|
): Promise<{ [symbol: string]: IDataProviderResponse }> {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getHistorical(
|
||||||
|
aSymbols: string[],
|
||||||
|
aGranularity: Granularity = 'day',
|
||||||
|
from: Date,
|
||||||
|
to: Date
|
||||||
|
): Promise<{
|
||||||
|
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
|
||||||
|
}> {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
public getName(): DataSource {
|
||||||
|
return DataSource.MANUAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
||||||
|
return { items: [] };
|
||||||
|
}
|
||||||
|
}
|
@ -30,5 +30,9 @@ export interface Environment extends CleanedEnvAccessors {
|
|||||||
ROOT_URL: string;
|
ROOT_URL: string;
|
||||||
STRIPE_PUBLIC_KEY: string;
|
STRIPE_PUBLIC_KEY: string;
|
||||||
STRIPE_SECRET_KEY: string;
|
STRIPE_SECRET_KEY: string;
|
||||||
|
TWITTER_ACCESS_TOKEN: string;
|
||||||
|
TWITTER_ACCESS_TOKEN_SECRET: string;
|
||||||
|
TWITTER_API_KEY: string;
|
||||||
|
TWITTER_API_SECRET: string;
|
||||||
WEB_AUTH_RP_ID: string;
|
WEB_AUTH_RP_ID: string;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,12 @@ export class SymbolProfileService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async deleteById(id: string) {
|
||||||
|
return this.prismaService.symbolProfile.delete({
|
||||||
|
where: { id }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public async getSymbolProfiles(
|
public async getSymbolProfiles(
|
||||||
symbols: string[]
|
symbols: string[]
|
||||||
): Promise<EnhancedSymbolProfile[]> {
|
): Promise<EnhancedSymbolProfile[]> {
|
||||||
|
11
apps/api/src/services/twitter-bot/twitter-bot.module.ts
Normal file
11
apps/api/src/services/twitter-bot/twitter-bot.module.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { SymbolModule } from '@ghostfolio/api/app/symbol/symbol.module';
|
||||||
|
import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module';
|
||||||
|
import { TwitterBotService } from '@ghostfolio/api/services/twitter-bot/twitter-bot.service';
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
exports: [TwitterBotService],
|
||||||
|
imports: [ConfigurationModule, SymbolModule],
|
||||||
|
providers: [TwitterBotService]
|
||||||
|
})
|
||||||
|
export class TwitterBotModule {}
|
60
apps/api/src/services/twitter-bot/twitter-bot.service.ts
Normal file
60
apps/api/src/services/twitter-bot/twitter-bot.service.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { SymbolService } from '@ghostfolio/api/app/symbol/symbol.service';
|
||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import {
|
||||||
|
ghostfolioFearAndGreedIndexDataSource,
|
||||||
|
ghostfolioFearAndGreedIndexSymbol
|
||||||
|
} from '@ghostfolio/common/config';
|
||||||
|
import { resolveFearAndGreedIndex } from '@ghostfolio/common/helper';
|
||||||
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
|
import { TwitterApi, TwitterApiReadWrite } from 'twitter-api-v2';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TwitterBotService {
|
||||||
|
private twitterClient: TwitterApiReadWrite;
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private readonly symbolService: SymbolService
|
||||||
|
) {
|
||||||
|
this.twitterClient = new TwitterApi({
|
||||||
|
accessSecret: this.configurationService.get(
|
||||||
|
'TWITTER_ACCESS_TOKEN_SECRET'
|
||||||
|
),
|
||||||
|
accessToken: this.configurationService.get('TWITTER_ACCESS_TOKEN'),
|
||||||
|
appKey: this.configurationService.get('TWITTER_API_KEY'),
|
||||||
|
appSecret: this.configurationService.get('TWITTER_API_SECRET')
|
||||||
|
}).readWrite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async tweetFearAndGreedIndex() {
|
||||||
|
if (!this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const symbolItem = await this.symbolService.get({
|
||||||
|
dataGatheringItem: {
|
||||||
|
dataSource: ghostfolioFearAndGreedIndexDataSource,
|
||||||
|
symbol: ghostfolioFearAndGreedIndexSymbol
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (symbolItem?.marketPrice) {
|
||||||
|
const { emoji, text } = resolveFearAndGreedIndex(
|
||||||
|
symbolItem.marketPrice
|
||||||
|
);
|
||||||
|
|
||||||
|
const status = `Current Market Mood: ${emoji} ${text} (${symbolItem.marketPrice}/100)\n\n#FearAndGreed #Markets #ServiceTweet`;
|
||||||
|
const { data: createdTweet } = await this.twitterClient.v2.tweet(
|
||||||
|
status
|
||||||
|
);
|
||||||
|
|
||||||
|
Logger.log(
|
||||||
|
`Fear & Greed Index has been tweeted: https://twitter.com/ghostfolio_/status/${createdTweet.id}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -66,6 +66,13 @@ const routes: Routes = [
|
|||||||
'./pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.module'
|
'./pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.module'
|
||||||
).then((m) => m.FirstMonthsInOpenSourcePageModule)
|
).then((m) => m.FirstMonthsInOpenSourcePageModule)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'features',
|
||||||
|
loadChildren: () =>
|
||||||
|
import('./pages/features/features-page.module').then(
|
||||||
|
(m) => m.FeaturesPageModule
|
||||||
|
)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'home',
|
path: 'home',
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
|
@ -48,9 +48,9 @@ export class AccountsTableComponent implements OnChanges, OnDestroy, OnInit {
|
|||||||
'account',
|
'account',
|
||||||
'platform',
|
'platform',
|
||||||
'transactions',
|
'transactions',
|
||||||
'currency',
|
|
||||||
'balance',
|
'balance',
|
||||||
'value'
|
'value',
|
||||||
|
'currency'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (this.showActions) {
|
if (this.showActions) {
|
||||||
|
@ -24,12 +24,9 @@ export class FearAndGreedIndexComponent implements OnChanges, OnInit {
|
|||||||
public ngOnInit() {}
|
public ngOnInit() {}
|
||||||
|
|
||||||
public ngOnChanges() {
|
public ngOnChanges() {
|
||||||
this.fearAndGreedIndexEmoji = resolveFearAndGreedIndex(
|
const { emoji, text } = resolveFearAndGreedIndex(this.fearAndGreedIndex);
|
||||||
this.fearAndGreedIndex
|
|
||||||
).emoji;
|
|
||||||
|
|
||||||
this.fearAndGreedIndexText = resolveFearAndGreedIndex(
|
this.fearAndGreedIndexEmoji = emoji;
|
||||||
this.fearAndGreedIndex
|
this.fearAndGreedIndexText = text;
|
||||||
).text;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,17 @@
|
|||||||
></gf-logo>
|
></gf-logo>
|
||||||
</a>
|
</a>
|
||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
|
<a
|
||||||
|
class="d-none d-sm-block mx-1"
|
||||||
|
i18n
|
||||||
|
mat-flat-button
|
||||||
|
[ngClass]="{
|
||||||
|
'font-weight-bold': currentRoute === 'features',
|
||||||
|
'text-decoration-underline': currentRoute === 'features'
|
||||||
|
}"
|
||||||
|
[routerLink]="['/features']"
|
||||||
|
>Features</a
|
||||||
|
>
|
||||||
<a
|
<a
|
||||||
class="d-none d-sm-block mx-1"
|
class="d-none d-sm-block mx-1"
|
||||||
i18n
|
i18n
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
i18n
|
i18n
|
||||||
mat-button
|
mat-button
|
||||||
[routerLink]="['/portfolio', 'activities']"
|
[routerLink]="['/portfolio', 'activities']"
|
||||||
>Manage Activities...</a
|
>Manage Activities</a
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
<div class="row px-3 py-1">
|
<div class="row px-3 py-1">
|
||||||
<div class="d-flex flex-grow-1" i18n>Time in Market</div>
|
<div class="d-flex flex-grow-1" i18n>Time in Market</div>
|
||||||
<div class="d-flex justify-content-end">
|
<div class="d-flex justify-content-end">
|
||||||
{{ timeInMarket }}
|
|
||||||
<gf-value class="justify-content-end" [value]="timeInMarket"></gf-value>
|
<gf-value class="justify-content-end" [value]="timeInMarket"></gf-value>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -142,6 +141,17 @@
|
|||||||
></gf-value>
|
></gf-value>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row px-3 py-1">
|
||||||
|
<div class="d-flex flex-grow-1" i18n>Items</div>
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
<gf-value
|
||||||
|
class="justify-content-end"
|
||||||
|
[currency]="baseCurrency"
|
||||||
|
[locale]="locale"
|
||||||
|
[value]="isLoading ? undefined : summary?.items"
|
||||||
|
></gf-value>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col"><hr /></div>
|
<div class="col"><hr /></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,7 +11,7 @@ import { DataService } from '@ghostfolio/client/services/data.service';
|
|||||||
import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper';
|
import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper';
|
||||||
import { OrderWithAccount } from '@ghostfolio/common/types';
|
import { OrderWithAccount } from '@ghostfolio/common/types';
|
||||||
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface';
|
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface';
|
||||||
import { AssetSubClass } from '@prisma/client';
|
import { SymbolProfile } from '@prisma/client';
|
||||||
import { format, isSameMonth, isToday, parseISO } from 'date-fns';
|
import { format, isSameMonth, isToday, parseISO } from 'date-fns';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
@ -26,10 +26,11 @@ import { PositionDetailDialogParams } from './interfaces/interfaces';
|
|||||||
styleUrls: ['./position-detail-dialog.component.scss']
|
styleUrls: ['./position-detail-dialog.component.scss']
|
||||||
})
|
})
|
||||||
export class PositionDetailDialog implements OnDestroy, OnInit {
|
export class PositionDetailDialog implements OnDestroy, OnInit {
|
||||||
public assetSubClass: AssetSubClass;
|
|
||||||
public averagePrice: number;
|
public averagePrice: number;
|
||||||
public benchmarkDataItems: LineChartItem[];
|
public benchmarkDataItems: LineChartItem[];
|
||||||
public currency: string;
|
public countries: {
|
||||||
|
[code: string]: { name: string; value: number };
|
||||||
|
};
|
||||||
public firstBuyDate: string;
|
public firstBuyDate: string;
|
||||||
public grossPerformance: number;
|
public grossPerformance: number;
|
||||||
public grossPerformancePercent: number;
|
public grossPerformancePercent: number;
|
||||||
@ -38,13 +39,15 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
|
|||||||
public marketPrice: number;
|
public marketPrice: number;
|
||||||
public maxPrice: number;
|
public maxPrice: number;
|
||||||
public minPrice: number;
|
public minPrice: number;
|
||||||
public name: string;
|
|
||||||
public netPerformance: number;
|
public netPerformance: number;
|
||||||
public netPerformancePercent: number;
|
public netPerformancePercent: number;
|
||||||
public orders: OrderWithAccount[];
|
public orders: OrderWithAccount[];
|
||||||
public quantity: number;
|
public quantity: number;
|
||||||
public quantityPrecision = 2;
|
public quantityPrecision = 2;
|
||||||
public symbol: string;
|
public sectors: {
|
||||||
|
[name: string]: { name: string; value: number };
|
||||||
|
};
|
||||||
|
public SymbolProfile: SymbolProfile;
|
||||||
public transactionCount: number;
|
public transactionCount: number;
|
||||||
public value: number;
|
public value: number;
|
||||||
|
|
||||||
@ -66,9 +69,7 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
|
|||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
({
|
({
|
||||||
assetSubClass,
|
|
||||||
averagePrice,
|
averagePrice,
|
||||||
currency,
|
|
||||||
firstBuyDate,
|
firstBuyDate,
|
||||||
grossPerformance,
|
grossPerformance,
|
||||||
grossPerformancePercent,
|
grossPerformancePercent,
|
||||||
@ -77,19 +78,17 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
|
|||||||
marketPrice,
|
marketPrice,
|
||||||
maxPrice,
|
maxPrice,
|
||||||
minPrice,
|
minPrice,
|
||||||
name,
|
|
||||||
netPerformance,
|
netPerformance,
|
||||||
netPerformancePercent,
|
netPerformancePercent,
|
||||||
orders,
|
orders,
|
||||||
quantity,
|
quantity,
|
||||||
symbol,
|
SymbolProfile,
|
||||||
transactionCount,
|
transactionCount,
|
||||||
value
|
value
|
||||||
}) => {
|
}) => {
|
||||||
this.assetSubClass = assetSubClass;
|
|
||||||
this.averagePrice = averagePrice;
|
this.averagePrice = averagePrice;
|
||||||
this.benchmarkDataItems = [];
|
this.benchmarkDataItems = [];
|
||||||
this.currency = currency;
|
this.countries = {};
|
||||||
this.firstBuyDate = firstBuyDate;
|
this.firstBuyDate = firstBuyDate;
|
||||||
this.grossPerformance = grossPerformance;
|
this.grossPerformance = grossPerformance;
|
||||||
this.grossPerformancePercent = grossPerformancePercent;
|
this.grossPerformancePercent = grossPerformancePercent;
|
||||||
@ -110,15 +109,33 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
|
|||||||
this.marketPrice = marketPrice;
|
this.marketPrice = marketPrice;
|
||||||
this.maxPrice = maxPrice;
|
this.maxPrice = maxPrice;
|
||||||
this.minPrice = minPrice;
|
this.minPrice = minPrice;
|
||||||
this.name = name;
|
|
||||||
this.netPerformance = netPerformance;
|
this.netPerformance = netPerformance;
|
||||||
this.netPerformancePercent = netPerformancePercent;
|
this.netPerformancePercent = netPerformancePercent;
|
||||||
this.orders = orders;
|
this.orders = orders;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.symbol = symbol;
|
this.sectors = {};
|
||||||
|
this.SymbolProfile = SymbolProfile;
|
||||||
this.transactionCount = transactionCount;
|
this.transactionCount = transactionCount;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|
||||||
|
if (SymbolProfile?.countries?.length > 0) {
|
||||||
|
for (const country of SymbolProfile.countries) {
|
||||||
|
this.countries[country.code] = {
|
||||||
|
name: country.name,
|
||||||
|
value: country.weight
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SymbolProfile?.sectors?.length > 0) {
|
||||||
|
for (const sector of SymbolProfile.sectors) {
|
||||||
|
this.sectors[sector.name] = {
|
||||||
|
name: sector.name,
|
||||||
|
value: sector.weight
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isToday(parseISO(this.firstBuyDate))) {
|
if (isToday(parseISO(this.firstBuyDate))) {
|
||||||
// Add average price
|
// Add average price
|
||||||
this.historicalDataItems.push({
|
this.historicalDataItems.push({
|
||||||
@ -166,7 +183,7 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
|
|||||||
|
|
||||||
if (Number.isInteger(this.quantity)) {
|
if (Number.isInteger(this.quantity)) {
|
||||||
this.quantityPrecision = 0;
|
this.quantityPrecision = 0;
|
||||||
} else if (assetSubClass === 'CRYPTOCURRENCY') {
|
} else if (this.SymbolProfile?.assetSubClass === 'CRYPTOCURRENCY') {
|
||||||
if (this.quantity < 1) {
|
if (this.quantity < 1) {
|
||||||
this.quantityPrecision = 7;
|
this.quantityPrecision = 7;
|
||||||
} else if (this.quantity < 1000) {
|
} else if (this.quantity < 1000) {
|
||||||
@ -196,7 +213,7 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
|
|||||||
.subscribe((data) => {
|
.subscribe((data) => {
|
||||||
downloadAsFile(
|
downloadAsFile(
|
||||||
data,
|
data,
|
||||||
`ghostfolio-export-${this.symbol}-${format(
|
`ghostfolio-export-${this.SymbolProfile?.symbol}-${format(
|
||||||
parseISO(data.meta.date),
|
parseISO(data.meta.date),
|
||||||
'yyyyMMddHHmm'
|
'yyyyMMddHHmm'
|
||||||
)}.json`,
|
)}.json`,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
mat-dialog-title
|
mat-dialog-title
|
||||||
position="center"
|
position="center"
|
||||||
[deviceType]="data.deviceType"
|
[deviceType]="data.deviceType"
|
||||||
[title]="name ?? symbol"
|
[title]="SymbolProfile?.name ?? SymbolProfile?.symbol"
|
||||||
(closeButtonClicked)="onClose()"
|
(closeButtonClicked)="onClose()"
|
||||||
></gf-dialog-header>
|
></gf-dialog-header>
|
||||||
|
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<gf-value
|
<gf-value
|
||||||
label="Ø Buy Price"
|
label="Ø Buy Price"
|
||||||
size="medium"
|
size="medium"
|
||||||
[currency]="currency"
|
[currency]="SymbolProfile?.currency"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
[value]="averagePrice"
|
[value]="averagePrice"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<gf-value
|
<gf-value
|
||||||
label="Market Price"
|
label="Market Price"
|
||||||
size="medium"
|
size="medium"
|
||||||
[currency]="currency"
|
[currency]="SymbolProfile?.currency"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
[value]="marketPrice"
|
[value]="marketPrice"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
@ -73,7 +73,7 @@
|
|||||||
<gf-value
|
<gf-value
|
||||||
label="Minimum Price"
|
label="Minimum Price"
|
||||||
size="medium"
|
size="medium"
|
||||||
[currency]="currency"
|
[currency]="SymbolProfile?.currency"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
[ngClass]="{ 'text-danger': minPrice?.toFixed(2) === marketPrice?.toFixed(2) && maxPrice?.toFixed(2) !== minPrice?.toFixed(2) }"
|
[ngClass]="{ 'text-danger': minPrice?.toFixed(2) === marketPrice?.toFixed(2) && maxPrice?.toFixed(2) !== minPrice?.toFixed(2) }"
|
||||||
[value]="minPrice"
|
[value]="minPrice"
|
||||||
@ -83,7 +83,7 @@
|
|||||||
<gf-value
|
<gf-value
|
||||||
label="Maximum Price"
|
label="Maximum Price"
|
||||||
size="medium"
|
size="medium"
|
||||||
[currency]="currency"
|
[currency]="SymbolProfile?.currency"
|
||||||
[locale]="data.locale"
|
[locale]="data.locale"
|
||||||
[ngClass]="{ 'text-success': maxPrice?.toFixed(2) === marketPrice?.toFixed(2) && maxPrice?.toFixed(2) !== minPrice?.toFixed(2) }"
|
[ngClass]="{ 'text-success': maxPrice?.toFixed(2) === marketPrice?.toFixed(2) && maxPrice?.toFixed(2) !== minPrice?.toFixed(2) }"
|
||||||
[value]="maxPrice"
|
[value]="maxPrice"
|
||||||
@ -122,6 +122,73 @@
|
|||||||
[value]="transactionCount"
|
[value]="transactionCount"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-6 mb-3">
|
||||||
|
<gf-value
|
||||||
|
label="Asset Class"
|
||||||
|
size="medium"
|
||||||
|
[hidden]="!SymbolProfile?.assetClass"
|
||||||
|
[value]="SymbolProfile?.assetClass"
|
||||||
|
></gf-value>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 mb-3">
|
||||||
|
<gf-value
|
||||||
|
label="Asset Sub Class"
|
||||||
|
size="medium"
|
||||||
|
[hidden]="!SymbolProfile?.assetSubClass"
|
||||||
|
[value]="SymbolProfile?.assetSubClass"
|
||||||
|
></gf-value>
|
||||||
|
</div>
|
||||||
|
<ng-container
|
||||||
|
*ngIf="SymbolProfile?.countries?.length > 0 || SymbolProfile?.sectors?.length > 0"
|
||||||
|
>
|
||||||
|
<ng-container
|
||||||
|
*ngIf="SymbolProfile?.countries?.length === 1 && SymbolProfile?.sectors?.length === 1; else charts"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
*ngIf="SymbolProfile?.countries?.length === 1"
|
||||||
|
class="col-6 mb-3"
|
||||||
|
>
|
||||||
|
<gf-value
|
||||||
|
label="Country"
|
||||||
|
size="medium"
|
||||||
|
[locale]="data.locale"
|
||||||
|
[value]="SymbolProfile.countries[0].name"
|
||||||
|
></gf-value>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="SymbolProfile?.sectors?.length === 1" class="col-6 mb-3">
|
||||||
|
<gf-value
|
||||||
|
label="Sector"
|
||||||
|
size="medium"
|
||||||
|
[locale]="data.locale"
|
||||||
|
[value]="SymbolProfile.sectors[0].name"
|
||||||
|
></gf-value>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
|
<ng-template #charts>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<div class="h4" i18n>Countries</div>
|
||||||
|
<gf-portfolio-proportion-chart
|
||||||
|
[baseCurrency]="user?.settings?.baseCurrency"
|
||||||
|
[isInPercent]="true"
|
||||||
|
[keys]="['name']"
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
[maxItems]="10"
|
||||||
|
[positions]="countries"
|
||||||
|
></gf-portfolio-proportion-chart>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<div class="h4" i18n>Sectors</div>
|
||||||
|
<gf-portfolio-proportion-chart
|
||||||
|
[baseCurrency]="user?.settings?.baseCurrency"
|
||||||
|
[isInPercent]="true"
|
||||||
|
[keys]="['name']"
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
[maxItems]="10"
|
||||||
|
[positions]="sectors"
|
||||||
|
></gf-portfolio-proportion-chart>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -6,6 +6,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 { GfActivitiesTableModule } from '@ghostfolio/ui/activities-table/activities-table.module';
|
import { GfActivitiesTableModule } from '@ghostfolio/ui/activities-table/activities-table.module';
|
||||||
import { GfLineChartModule } from '@ghostfolio/ui/line-chart/line-chart.module';
|
import { GfLineChartModule } from '@ghostfolio/ui/line-chart/line-chart.module';
|
||||||
|
import { GfPortfolioProportionChartModule } from '@ghostfolio/ui/portfolio-proportion-chart/portfolio-proportion-chart.module';
|
||||||
import { GfValueModule } from '@ghostfolio/ui/value';
|
import { GfValueModule } from '@ghostfolio/ui/value';
|
||||||
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ import { PositionDetailDialog } from './position-detail-dialog.component';
|
|||||||
GfDialogFooterModule,
|
GfDialogFooterModule,
|
||||||
GfDialogHeaderModule,
|
GfDialogHeaderModule,
|
||||||
GfLineChartModule,
|
GfLineChartModule,
|
||||||
|
GfPortfolioProportionChartModule,
|
||||||
GfValueModule,
|
GfValueModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
|
@ -139,7 +139,7 @@
|
|||||||
class="my-3 text-center"
|
class="my-3 text-center"
|
||||||
>
|
>
|
||||||
<button i18n mat-stroked-button (click)="onShowAllPositions()">
|
<button i18n mat-stroked-button (click)="onShowAllPositions()">
|
||||||
Show all...
|
Show all
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ export class AuthGuard implements CanActivate {
|
|||||||
'/blog',
|
'/blog',
|
||||||
'/de/blog',
|
'/de/blog',
|
||||||
'/en/blog',
|
'/en/blog',
|
||||||
|
'/features',
|
||||||
'/p',
|
'/p',
|
||||||
'/pricing',
|
'/pricing',
|
||||||
'/register',
|
'/register',
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If you encounter a bug or would like to suggest an improvement or a
|
If you encounter a bug or would like to suggest an improvement or a
|
||||||
new feature, please join the Ghostfolio
|
new <a [routerLink]="['/features']">feature</a>, please join the
|
||||||
|
Ghostfolio
|
||||||
<a
|
<a
|
||||||
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"
|
||||||
title="Join the Ghostfolio Slack community"
|
title="Join the Ghostfolio Slack community"
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { AuthGuard } from '@ghostfolio/client/core/auth.guard';
|
||||||
|
|
||||||
|
import { FeaturesPageComponent } from './features-page.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{ path: '', component: FeaturesPageComponent, canActivate: [AuthGuard] }
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class FeaturesPageRoutingModule {}
|
@ -0,0 +1,44 @@
|
|||||||
|
import { ChangeDetectorRef, Component, OnDestroy } from '@angular/core';
|
||||||
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { User } from '@ghostfolio/common/interfaces';
|
||||||
|
import { Subject, takeUntil } from 'rxjs';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
host: { class: 'page' },
|
||||||
|
selector: 'gf-features-page',
|
||||||
|
styleUrls: ['./features-page.scss'],
|
||||||
|
templateUrl: './features-page.html'
|
||||||
|
})
|
||||||
|
export class FeaturesPageComponent implements OnDestroy {
|
||||||
|
public user: User;
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private userService: UserService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {
|
||||||
|
this.userService.stateChanged
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((state) => {
|
||||||
|
if (state?.user) {
|
||||||
|
this.user = state.user;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
}
|
220
apps/client/src/app/pages/features/features-page.html
Normal file
220
apps/client/src/app/pages/features/features-page.html
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h3 class="d-flex justify-content-center mb-3 text-center" i18n>
|
||||||
|
Features
|
||||||
|
</h3>
|
||||||
|
<mat-card class="mb-4">
|
||||||
|
<mat-card-content>
|
||||||
|
<p>
|
||||||
|
Check out the numerous features of <strong>Ghostfolio</strong> to
|
||||||
|
manage your wealth.
|
||||||
|
</p>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 i18n>Stocks</h4>
|
||||||
|
<p class="m-0">Keep track of your stock purchases and sales.</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 i18n>ETFs</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Are you into ETFs (Exchange Traded Funds)? Track your ETF
|
||||||
|
investments.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 i18n>Cryptocurrencies</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Keep track of your Bitcoin and Altcoin holdings.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 i18n>Dividend</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Are you building a dividend portfolio? Track your dividend in
|
||||||
|
Ghostfolio.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex" i18n>Wealth Items</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Track all your treasuries, be it your luxury watch or rare
|
||||||
|
trading cards.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex" i18n>Import and Export</h4>
|
||||||
|
<p class="m-0">Import and export your investment activities.</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 i18n>Multi-Accounts</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Keep an eye on all your accounts across multiple platforms
|
||||||
|
(multi-banking).
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex">
|
||||||
|
<span i18n>Portfolio Calculations</span>
|
||||||
|
<ion-icon
|
||||||
|
class="ml-1 text-muted"
|
||||||
|
name="diamond-outline"
|
||||||
|
></ion-icon>
|
||||||
|
</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Check the rate of return of your portfolio for
|
||||||
|
<code>Today</code>, <code>YTD</code>, <code>1Y</code>,
|
||||||
|
<code>5Y</code>, and <code>Max</code>.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex">
|
||||||
|
<span i18n>Portfolio Allocations</span>
|
||||||
|
<ion-icon
|
||||||
|
class="ml-1 text-muted"
|
||||||
|
name="diamond-outline"
|
||||||
|
></ion-icon>
|
||||||
|
</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Check the allocations of your portfolio by account, asset class,
|
||||||
|
currency, region, and sector.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex" i18n>Dark Mode</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Ghostfolio automatically switches to a dark color theme based on
|
||||||
|
your operating system's preferences.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex" i18n>Zen Mode</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Keep calm and activate Zen Mode if the markets are going crazy.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex">
|
||||||
|
<span i18n>Market Mood</span>
|
||||||
|
<ion-icon
|
||||||
|
class="ml-1 text-muted"
|
||||||
|
name="diamond-outline"
|
||||||
|
></ion-icon>
|
||||||
|
</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Check the current market mood (<a [routerLink]="['/resources']"
|
||||||
|
>Fear & Greed Index</a
|
||||||
|
>) within the app.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 class="align-items-center d-flex">
|
||||||
|
<span i18n>Static Analysis</span>
|
||||||
|
<ion-icon
|
||||||
|
class="ml-1 text-muted"
|
||||||
|
name="diamond-outline"
|
||||||
|
></ion-icon>
|
||||||
|
</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Identify potential risks in your portfolio with Ghostfolio
|
||||||
|
X-ray, the static portfolio analysis.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 i18n>Community</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
Join the Ghostfolio
|
||||||
|
<a
|
||||||
|
href="https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg"
|
||||||
|
title="Join the Ghostfolio Slack community"
|
||||||
|
>Slack channel</a
|
||||||
|
>
|
||||||
|
full of enthusiastic investors and discuss the latest market
|
||||||
|
trends.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 mb-3">
|
||||||
|
<mat-card class="d-flex flex-column h-100">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h4 i18n>Open Source Software</h4>
|
||||||
|
<p class="m-0">
|
||||||
|
The source code is fully available as
|
||||||
|
<a
|
||||||
|
href="https://github.com/ghostfolio/ghostfolio"
|
||||||
|
title="Find Ghostfolio on GitHub"
|
||||||
|
>open source software</a
|
||||||
|
>
|
||||||
|
(OSS) and licensed under the <i>AGPLv3 License</i>.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="!user" class="row">
|
||||||
|
<div class="col mt-3 text-center">
|
||||||
|
<a color="primary" i18n mat-flat-button [routerLink]="['/register']">
|
||||||
|
Get Started
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
19
apps/client/src/app/pages/features/features-page.module.ts
Normal file
19
apps/client/src/app/pages/features/features-page.module.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
|
||||||
|
import { FeaturesPageRoutingModule } from './features-page-routing.module';
|
||||||
|
import { FeaturesPageComponent } from './features-page.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [FeaturesPageComponent],
|
||||||
|
imports: [
|
||||||
|
FeaturesPageRoutingModule,
|
||||||
|
CommonModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatCardModule
|
||||||
|
],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class FeaturesPageModule {}
|
17
apps/client/src/app/pages/features/features-page.scss
Normal file
17
apps/client/src/app/pages/features/features-page.scss
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
:host {
|
||||||
|
color: rgb(var(--dark-primary-text));
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: rgba(var(--palette-primary-500), 1);
|
||||||
|
font-weight: 500;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: rgba(var(--palette-primary-300), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:host-context(.is-dark-theme) {
|
||||||
|
color: rgb(var(--light-primary-text));
|
||||||
|
}
|
@ -6,11 +6,15 @@ import {
|
|||||||
OnDestroy,
|
OnDestroy,
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { FormControl, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
|
import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto';
|
||||||
|
import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto';
|
||||||
import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface';
|
import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface';
|
||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { Type } from '@prisma/client';
|
||||||
|
import { isUUID } from 'class-validator';
|
||||||
import { isString } from 'lodash';
|
import { isString } from 'lodash';
|
||||||
import { EMPTY, Observable, Subject } from 'rxjs';
|
import { EMPTY, Observable, Subject } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
@ -34,19 +38,15 @@ import { CreateOrUpdateTransactionDialogParams } from './interfaces/interfaces';
|
|||||||
export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
||||||
@ViewChild('autocomplete') autocomplete;
|
@ViewChild('autocomplete') autocomplete;
|
||||||
|
|
||||||
|
public activityForm: FormGroup;
|
||||||
|
|
||||||
public currencies: string[] = [];
|
public currencies: string[] = [];
|
||||||
public currentMarketPrice = null;
|
public currentMarketPrice = null;
|
||||||
public filteredLookupItems: LookupItem[];
|
public filteredLookupItems: LookupItem[];
|
||||||
public filteredLookupItemsObservable: Observable<LookupItem[]>;
|
public filteredLookupItemsObservable: Observable<LookupItem[]>;
|
||||||
public isLoading = false;
|
public isLoading = false;
|
||||||
public platforms: { id: string; name: string }[];
|
public platforms: { id: string; name: string }[];
|
||||||
public searchSymbolCtrl = new FormControl(
|
public Validators = Validators;
|
||||||
{
|
|
||||||
dataSource: this.data.transaction.dataSource,
|
|
||||||
symbol: this.data.transaction.symbol
|
|
||||||
},
|
|
||||||
Validators.required
|
|
||||||
);
|
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
@ -54,6 +54,7 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private dataService: DataService,
|
private dataService: DataService,
|
||||||
public dialogRef: MatDialogRef<CreateOrUpdateTransactionDialog>,
|
public dialogRef: MatDialogRef<CreateOrUpdateTransactionDialog>,
|
||||||
|
private formBuilder: FormBuilder,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: CreateOrUpdateTransactionDialogParams
|
@Inject(MAT_DIALOG_DATA) public data: CreateOrUpdateTransactionDialogParams
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -63,36 +64,105 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
this.currencies = currencies;
|
this.currencies = currencies;
|
||||||
this.platforms = platforms;
|
this.platforms = platforms;
|
||||||
|
|
||||||
this.filteredLookupItemsObservable =
|
this.activityForm = this.formBuilder.group({
|
||||||
this.searchSymbolCtrl.valueChanges.pipe(
|
accountId: [this.data.activity?.accountId, Validators.required],
|
||||||
startWith(''),
|
currency: [
|
||||||
debounceTime(400),
|
this.data.activity?.SymbolProfile?.currency,
|
||||||
distinctUntilChanged(),
|
Validators.required
|
||||||
switchMap((query: string) => {
|
],
|
||||||
if (isString(query)) {
|
dataSource: [
|
||||||
const filteredLookupItemsObservable =
|
this.data.activity?.SymbolProfile?.dataSource,
|
||||||
this.dataService.fetchSymbols(query);
|
Validators.required
|
||||||
|
],
|
||||||
|
date: [this.data.activity?.date, Validators.required],
|
||||||
|
fee: [this.data.activity?.fee, Validators.required],
|
||||||
|
name: [this.data.activity?.SymbolProfile?.name, Validators.required],
|
||||||
|
quantity: [this.data.activity?.quantity, Validators.required],
|
||||||
|
searchSymbol: [
|
||||||
|
{
|
||||||
|
dataSource: this.data.activity?.SymbolProfile?.dataSource,
|
||||||
|
symbol: this.data.activity?.SymbolProfile?.symbol
|
||||||
|
},
|
||||||
|
Validators.required
|
||||||
|
],
|
||||||
|
type: [undefined, Validators.required], // Set after value changes subscription
|
||||||
|
unitPrice: [this.data.activity?.unitPrice, Validators.required]
|
||||||
|
});
|
||||||
|
|
||||||
filteredLookupItemsObservable.subscribe((filteredLookupItems) => {
|
this.filteredLookupItemsObservable = this.activityForm.controls[
|
||||||
this.filteredLookupItems = filteredLookupItems;
|
'searchSymbol'
|
||||||
});
|
].valueChanges.pipe(
|
||||||
|
startWith(''),
|
||||||
|
debounceTime(400),
|
||||||
|
distinctUntilChanged(),
|
||||||
|
switchMap((query: string) => {
|
||||||
|
if (isString(query)) {
|
||||||
|
const filteredLookupItemsObservable =
|
||||||
|
this.dataService.fetchSymbols(query);
|
||||||
|
|
||||||
return filteredLookupItemsObservable;
|
filteredLookupItemsObservable.subscribe((filteredLookupItems) => {
|
||||||
}
|
this.filteredLookupItems = filteredLookupItems;
|
||||||
|
});
|
||||||
|
|
||||||
return [];
|
return filteredLookupItemsObservable;
|
||||||
})
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if (this.data.transaction.id) {
|
return [];
|
||||||
this.searchSymbolCtrl.disable();
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
this.activityForm.controls['type'].valueChanges.subscribe((type: Type) => {
|
||||||
|
if (type === 'ITEM') {
|
||||||
|
this.activityForm.controls['accountId'].removeValidators(
|
||||||
|
Validators.required
|
||||||
|
);
|
||||||
|
this.activityForm.controls['accountId'].updateValueAndValidity();
|
||||||
|
this.activityForm.controls['currency'].setValue(
|
||||||
|
this.data.user.settings.baseCurrency
|
||||||
|
);
|
||||||
|
this.activityForm.controls['dataSource'].removeValidators(
|
||||||
|
Validators.required
|
||||||
|
);
|
||||||
|
this.activityForm.controls['dataSource'].updateValueAndValidity();
|
||||||
|
this.activityForm.controls['name'].setValidators(Validators.required);
|
||||||
|
this.activityForm.controls['name'].updateValueAndValidity();
|
||||||
|
this.activityForm.controls['quantity'].setValue(1);
|
||||||
|
this.activityForm.controls['searchSymbol'].removeValidators(
|
||||||
|
Validators.required
|
||||||
|
);
|
||||||
|
this.activityForm.controls['searchSymbol'].updateValueAndValidity();
|
||||||
|
} else {
|
||||||
|
this.activityForm.controls['accountId'].setValidators(
|
||||||
|
Validators.required
|
||||||
|
);
|
||||||
|
this.activityForm.controls['accountId'].updateValueAndValidity();
|
||||||
|
this.activityForm.controls['dataSource'].setValidators(
|
||||||
|
Validators.required
|
||||||
|
);
|
||||||
|
this.activityForm.controls['dataSource'].updateValueAndValidity();
|
||||||
|
this.activityForm.controls['name'].removeValidators(
|
||||||
|
Validators.required
|
||||||
|
);
|
||||||
|
this.activityForm.controls['name'].updateValueAndValidity();
|
||||||
|
this.activityForm.controls['searchSymbol'].setValidators(
|
||||||
|
Validators.required
|
||||||
|
);
|
||||||
|
this.activityForm.controls['searchSymbol'].updateValueAndValidity();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activityForm.controls['type'].setValue(this.data.activity?.type);
|
||||||
|
|
||||||
|
if (this.data.activity?.id) {
|
||||||
|
this.activityForm.controls['searchSymbol'].disable();
|
||||||
|
this.activityForm.controls['type'].disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.data.transaction.symbol) {
|
if (this.data.activity?.symbol) {
|
||||||
this.dataService
|
this.dataService
|
||||||
.fetchSymbolItem({
|
.fetchSymbolItem({
|
||||||
dataSource: this.data.transaction.dataSource,
|
dataSource: this.data.activity?.dataSource,
|
||||||
symbol: this.data.transaction.symbol
|
symbol: this.data.activity?.symbol
|
||||||
})
|
})
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe(({ marketPrice }) => {
|
.subscribe(({ marketPrice }) => {
|
||||||
@ -104,7 +174,9 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public applyCurrentMarketPrice() {
|
public applyCurrentMarketPrice() {
|
||||||
this.data.transaction.unitPrice = this.currentMarketPrice;
|
this.activityForm.patchValue({
|
||||||
|
unitPrice: this.currentMarketPrice
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public displayFn(aLookupItem: LookupItem) {
|
public displayFn(aLookupItem: LookupItem) {
|
||||||
@ -113,17 +185,20 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
|
|
||||||
public onBlurSymbol() {
|
public onBlurSymbol() {
|
||||||
const currentLookupItem = this.filteredLookupItems.find((lookupItem) => {
|
const currentLookupItem = this.filteredLookupItems.find((lookupItem) => {
|
||||||
return lookupItem.symbol === this.data.transaction.symbol;
|
return (
|
||||||
|
lookupItem.symbol ===
|
||||||
|
this.activityForm.controls['searchSymbol'].value.symbol
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (currentLookupItem) {
|
if (currentLookupItem) {
|
||||||
this.updateSymbol(currentLookupItem.symbol);
|
this.updateSymbol(currentLookupItem.symbol);
|
||||||
} else {
|
} else {
|
||||||
this.searchSymbolCtrl.setErrors({ incorrect: true });
|
this.activityForm.controls['searchSymbol'].setErrors({ incorrect: true });
|
||||||
|
|
||||||
this.data.transaction.currency = null;
|
this.data.activity.currency = null;
|
||||||
this.data.transaction.dataSource = null;
|
this.data.activity.dataSource = null;
|
||||||
this.data.transaction.symbol = null;
|
this.data.activity.symbol = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
@ -133,8 +208,34 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onSubmit() {
|
||||||
|
const activity: CreateOrderDto | UpdateOrderDto = {
|
||||||
|
accountId: this.activityForm.controls['accountId'].value,
|
||||||
|
currency: this.activityForm.controls['currency'].value,
|
||||||
|
date: this.activityForm.controls['date'].value,
|
||||||
|
dataSource: this.activityForm.controls['dataSource'].value,
|
||||||
|
fee: this.activityForm.controls['fee'].value,
|
||||||
|
quantity: this.activityForm.controls['quantity'].value,
|
||||||
|
symbol:
|
||||||
|
this.activityForm.controls['searchSymbol'].value.symbol === undefined ||
|
||||||
|
isUUID(this.activityForm.controls['searchSymbol'].value.symbol)
|
||||||
|
? this.activityForm.controls['name'].value
|
||||||
|
: this.activityForm.controls['searchSymbol'].value.symbol,
|
||||||
|
type: this.activityForm.controls['type'].value,
|
||||||
|
unitPrice: this.activityForm.controls['unitPrice'].value
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.data.activity.id) {
|
||||||
|
(activity as UpdateOrderDto).id = this.data.activity.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dialogRef.close({ activity });
|
||||||
|
}
|
||||||
|
|
||||||
public onUpdateSymbol(event: MatAutocompleteSelectedEvent) {
|
public onUpdateSymbol(event: MatAutocompleteSelectedEvent) {
|
||||||
this.data.transaction.dataSource = event.option.value.dataSource;
|
this.activityForm.controls['dataSource'].setValue(
|
||||||
|
event.option.value.dataSource
|
||||||
|
);
|
||||||
this.updateSymbol(event.option.value.symbol);
|
this.updateSymbol(event.option.value.symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,20 +247,21 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
private updateSymbol(symbol: string) {
|
private updateSymbol(symbol: string) {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
this.searchSymbolCtrl.setErrors(null);
|
this.activityForm.controls['searchSymbol'].setErrors(null);
|
||||||
|
this.activityForm.controls['searchSymbol'].setValue({ symbol });
|
||||||
|
|
||||||
this.data.transaction.symbol = symbol;
|
this.changeDetectorRef.markForCheck();
|
||||||
|
|
||||||
this.dataService
|
this.dataService
|
||||||
.fetchSymbolItem({
|
.fetchSymbolItem({
|
||||||
dataSource: this.data.transaction.dataSource,
|
dataSource: this.activityForm.controls['dataSource'].value,
|
||||||
symbol: this.data.transaction.symbol
|
symbol: this.activityForm.controls['searchSymbol'].value.symbol
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
this.data.transaction.currency = null;
|
this.data.activity.currency = null;
|
||||||
this.data.transaction.dataSource = null;
|
this.data.activity.dataSource = null;
|
||||||
this.data.transaction.unitPrice = null;
|
this.data.activity.unitPrice = null;
|
||||||
|
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
|
||||||
@ -170,8 +272,9 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
takeUntil(this.unsubscribeSubject)
|
takeUntil(this.unsubscribeSubject)
|
||||||
)
|
)
|
||||||
.subscribe(({ currency, dataSource, marketPrice }) => {
|
.subscribe(({ currency, dataSource, marketPrice }) => {
|
||||||
this.data.transaction.currency = currency;
|
this.activityForm.controls['currency'].setValue(currency);
|
||||||
this.data.transaction.dataSource = dataSource;
|
this.activityForm.controls['dataSource'].setValue(dataSource);
|
||||||
|
|
||||||
this.currentMarketPrice = marketPrice;
|
this.currentMarketPrice = marketPrice;
|
||||||
|
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -1,31 +1,45 @@
|
|||||||
<form #addTransactionForm="ngForm" class="d-flex flex-column h-100">
|
<form
|
||||||
<h1 *ngIf="data.transaction.id" mat-dialog-title i18n>Update activity</h1>
|
class="d-flex flex-column h-100"
|
||||||
<h1 *ngIf="!data.transaction.id" mat-dialog-title i18n>Add activity</h1>
|
[formGroup]="activityForm"
|
||||||
|
(ngSubmit)="onSubmit()"
|
||||||
|
>
|
||||||
|
<h1 *ngIf="data.activity.id" mat-dialog-title i18n>Update activity</h1>
|
||||||
|
<h1 *ngIf="!data.activity.id" mat-dialog-title i18n>Add activity</h1>
|
||||||
<div class="flex-grow-1" mat-dialog-content>
|
<div class="flex-grow-1" mat-dialog-content>
|
||||||
<div>
|
<div>
|
||||||
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
|
<mat-label i18n>Type</mat-label>
|
||||||
|
<mat-select formControlName="type">
|
||||||
|
<mat-option value="BUY" i18n>BUY</mat-option>
|
||||||
|
<mat-option value="DIVIDEND" i18n>DIVIDEND</mat-option>
|
||||||
|
<mat-option value="ITEM" i18n>ITEM</mat-option>
|
||||||
|
<mat-option value="SELL" i18n>SELL</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
[ngClass]="{ 'd-none': !activityForm.controls['accountId'].hasValidator(Validators.required) }"
|
||||||
|
>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Account</mat-label>
|
<mat-label i18n>Account</mat-label>
|
||||||
<mat-select
|
<mat-select formControlName="accountId">
|
||||||
name="accountId"
|
|
||||||
required
|
|
||||||
[(value)]="data.transaction.accountId"
|
|
||||||
>
|
|
||||||
<mat-option *ngFor="let account of data.accounts" [value]="account.id"
|
<mat-option *ngFor="let account of data.accounts" [value]="account.id"
|
||||||
>{{ account.name }}</mat-option
|
>{{ account.name }}</mat-option
|
||||||
>
|
>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div
|
||||||
|
[ngClass]="{ 'd-none': !activityForm.controls['searchSymbol'].hasValidator(Validators.required) }"
|
||||||
|
>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Symbol or ISIN</mat-label>
|
<mat-label i18n>Symbol or ISIN</mat-label>
|
||||||
<input
|
<input
|
||||||
autocapitalize="off"
|
autocapitalize="off"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
autocorrect="off"
|
autocorrect="off"
|
||||||
|
formControlName="searchSymbol"
|
||||||
matInput
|
matInput
|
||||||
required
|
|
||||||
[formControl]="searchSymbolCtrl"
|
|
||||||
[matAutocomplete]="autocomplete"
|
[matAutocomplete]="autocomplete"
|
||||||
(blur)="onBlurSymbol()"
|
(blur)="onBlurSymbol()"
|
||||||
/>
|
/>
|
||||||
@ -48,26 +62,18 @@
|
|||||||
<mat-spinner *ngIf="isLoading" matSuffix [diameter]="20"></mat-spinner>
|
<mat-spinner *ngIf="isLoading" matSuffix [diameter]="20"></mat-spinner>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div
|
||||||
|
[ngClass]="{ 'd-none': !activityForm.controls['name'].hasValidator(Validators.required) }"
|
||||||
|
>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Type</mat-label>
|
<mat-label i18n>Name</mat-label>
|
||||||
<mat-select name="type" required [(value)]="data.transaction.type">
|
<input formControlName="name" matInput />
|
||||||
<mat-option value="BUY" i18n>BUY</mat-option>
|
|
||||||
<mat-option value="DIVIDEND" i18n>DIVIDEND</mat-option>
|
|
||||||
<mat-option value="SELL" i18n>SELL</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-none">
|
<div class="d-none">
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Currency</mat-label>
|
<mat-label i18n>Currency</mat-label>
|
||||||
<mat-select
|
<mat-select class="no-arrow" formControlName="currency">
|
||||||
class="no-arrow"
|
|
||||||
disabled
|
|
||||||
name="currency"
|
|
||||||
required
|
|
||||||
[(value)]="data.transaction.currency"
|
|
||||||
>
|
|
||||||
<mat-option *ngFor="let currency of currencies" [value]="currency"
|
<mat-option *ngFor="let currency of currencies" [value]="currency"
|
||||||
>{{ currency }}</mat-option
|
>{{ currency }}</mat-option
|
||||||
>
|
>
|
||||||
@ -77,26 +83,13 @@
|
|||||||
<div class="d-none">
|
<div class="d-none">
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Data Source</mat-label>
|
<mat-label i18n>Data Source</mat-label>
|
||||||
<input
|
<input formControlName="dataSource" matInput />
|
||||||
disabled
|
|
||||||
matInput
|
|
||||||
name="dataSource"
|
|
||||||
required
|
|
||||||
[(ngModel)]="data.transaction.dataSource"
|
|
||||||
/>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Date</mat-label>
|
<mat-label i18n>Date</mat-label>
|
||||||
<input
|
<input formControlName="date" matInput [matDatepicker]="date" />
|
||||||
disabled
|
|
||||||
matInput
|
|
||||||
name="date"
|
|
||||||
required
|
|
||||||
[matDatepicker]="date"
|
|
||||||
[(ngModel)]="data.transaction.date"
|
|
||||||
/>
|
|
||||||
<mat-datepicker-toggle matSuffix [for]="date">
|
<mat-datepicker-toggle matSuffix [for]="date">
|
||||||
<ion-icon
|
<ion-icon
|
||||||
class="text-muted"
|
class="text-muted"
|
||||||
@ -110,31 +103,22 @@
|
|||||||
<div>
|
<div>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Quantity</mat-label>
|
<mat-label i18n>Quantity</mat-label>
|
||||||
<input
|
<input formControlName="quantity" matInput type="number" />
|
||||||
matInput
|
|
||||||
name="quantity"
|
|
||||||
required
|
|
||||||
type="number"
|
|
||||||
[(ngModel)]="data.transaction.quantity"
|
|
||||||
/>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Unit Price</mat-label>
|
<mat-label i18n>Unit Price</mat-label>
|
||||||
<input
|
<input formControlName="unitPrice" matInput type="number" />
|
||||||
matInput
|
<span class="ml-2" matSuffix
|
||||||
name="unitPrice"
|
>{{ activityForm.controls['currency'].value }}</span
|
||||||
required
|
>
|
||||||
type="number"
|
|
||||||
[(ngModel)]="data.transaction.unitPrice"
|
|
||||||
/>
|
|
||||||
<span class="ml-2" matSuffix>{{ data.transaction.currency }}</span>
|
|
||||||
<button
|
<button
|
||||||
*ngIf="currentMarketPrice && (data.transaction.type === 'BUY' || data.transaction.type === 'SELL')"
|
*ngIf="currentMarketPrice && (data.activity.type === 'BUY' || data.activity.type === 'SELL')"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
matSuffix
|
matSuffix
|
||||||
title="Apply current market price"
|
title="Apply current market price"
|
||||||
|
type="button"
|
||||||
(click)="applyCurrentMarketPrice()"
|
(click)="applyCurrentMarketPrice()"
|
||||||
>
|
>
|
||||||
<ion-icon class="text-muted" name="refresh-outline"></ion-icon>
|
<ion-icon class="text-muted" name="refresh-outline"></ion-icon>
|
||||||
@ -144,32 +128,28 @@
|
|||||||
<div>
|
<div>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Fee</mat-label>
|
<mat-label i18n>Fee</mat-label>
|
||||||
<input
|
<input formControlName="fee" matInput type="number" />
|
||||||
matInput
|
<span class="ml-2" matSuffix
|
||||||
name="fee"
|
>{{ activityForm.controls['currency'].value }}</span
|
||||||
required
|
>
|
||||||
type="number"
|
|
||||||
[(ngModel)]="data.transaction.fee"
|
|
||||||
/>
|
|
||||||
<span class="ml-2" matSuffix>{{ data.transaction.currency }}</span>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex" mat-dialog-actions>
|
<div class="d-flex" mat-dialog-actions>
|
||||||
<gf-value
|
<gf-value
|
||||||
class="flex-grow-1"
|
class="flex-grow-1"
|
||||||
[currency]="data.transaction.currency"
|
[currency]="activityForm.controls['currency'].value"
|
||||||
[locale]="data.user?.settings?.locale"
|
[locale]="data.user?.settings?.locale"
|
||||||
[value]="data.transaction.fee + (data.transaction.quantity * data.transaction.unitPrice)"
|
[value]="activityForm.controls['fee'].value + (activityForm.controls['quantity'].value * activityForm.controls['unitPrice'].value) ?? 0"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
<div>
|
<div>
|
||||||
<button i18n mat-button (click)="onCancel()">Cancel</button>
|
<button i18n mat-button type="button" (click)="onCancel()">Cancel</button>
|
||||||
<button
|
<button
|
||||||
color="primary"
|
color="primary"
|
||||||
i18n
|
i18n
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
[disabled]="!(addTransactionForm.form.valid && data.transaction.currency && data.transaction.symbol)"
|
type="submit"
|
||||||
[mat-dialog-close]="data"
|
[disabled]="!activityForm.valid"
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface';
|
||||||
import { User } from '@ghostfolio/common/interfaces';
|
import { User } from '@ghostfolio/common/interfaces';
|
||||||
import { Account, Order } from '@prisma/client';
|
import { Account } from '@prisma/client';
|
||||||
|
|
||||||
export interface CreateOrUpdateTransactionDialogParams {
|
export interface CreateOrUpdateTransactionDialogParams {
|
||||||
accountId: string;
|
accountId: string;
|
||||||
accounts: Account[];
|
accounts: Account[];
|
||||||
transaction: Order;
|
activity: Activity;
|
||||||
user: User;
|
user: User;
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,8 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCloneTransaction(aTransaction: OrderModel) {
|
public onCloneTransaction(aActivity: Activity) {
|
||||||
this.openCreateTransactionDialog(aTransaction);
|
this.openCreateTransactionDialog(aActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public onDeleteTransaction(aId: string) {
|
public onDeleteTransaction(aId: string) {
|
||||||
@ -242,35 +242,13 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public openUpdateTransactionDialog({
|
public openUpdateTransactionDialog(activity: Activity): void {
|
||||||
accountId,
|
|
||||||
currency,
|
|
||||||
dataSource,
|
|
||||||
date,
|
|
||||||
fee,
|
|
||||||
id,
|
|
||||||
quantity,
|
|
||||||
symbol,
|
|
||||||
type,
|
|
||||||
unitPrice
|
|
||||||
}: OrderModel): void {
|
|
||||||
const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, {
|
const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, {
|
||||||
data: {
|
data: {
|
||||||
|
activity,
|
||||||
accounts: this.user?.accounts?.filter((account) => {
|
accounts: this.user?.accounts?.filter((account) => {
|
||||||
return account.accountType === 'SECURITIES';
|
return account.accountType === 'SECURITIES';
|
||||||
}),
|
}),
|
||||||
transaction: {
|
|
||||||
accountId,
|
|
||||||
currency,
|
|
||||||
dataSource,
|
|
||||||
date,
|
|
||||||
fee,
|
|
||||||
id,
|
|
||||||
quantity,
|
|
||||||
symbol,
|
|
||||||
type,
|
|
||||||
unitPrice
|
|
||||||
},
|
|
||||||
user: this.user
|
user: this.user
|
||||||
},
|
},
|
||||||
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
|
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
|
||||||
@ -281,7 +259,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe((data: any) => {
|
.subscribe((data: any) => {
|
||||||
const transaction: UpdateOrderDto = data?.transaction;
|
const transaction: UpdateOrderDto = data?.activity;
|
||||||
|
|
||||||
if (transaction) {
|
if (transaction) {
|
||||||
this.dataService
|
this.dataService
|
||||||
@ -324,7 +302,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private openCreateTransactionDialog(aTransaction?: OrderModel): void {
|
private openCreateTransactionDialog(aActivity?: Activity): void {
|
||||||
this.userService
|
this.userService
|
||||||
.get()
|
.get()
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
@ -336,15 +314,14 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|||||||
accounts: this.user?.accounts?.filter((account) => {
|
accounts: this.user?.accounts?.filter((account) => {
|
||||||
return account.accountType === 'SECURITIES';
|
return account.accountType === 'SECURITIES';
|
||||||
}),
|
}),
|
||||||
transaction: {
|
activity: {
|
||||||
accountId: aTransaction?.accountId ?? this.defaultAccountId,
|
...aActivity,
|
||||||
currency: aTransaction?.currency ?? null,
|
accountId: aActivity?.accountId ?? this.defaultAccountId,
|
||||||
dataSource: aTransaction?.dataSource ?? null,
|
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
|
id: null,
|
||||||
fee: 0,
|
fee: 0,
|
||||||
quantity: null,
|
quantity: null,
|
||||||
symbol: aTransaction?.symbol ?? null,
|
type: aActivity?.type ?? 'BUY',
|
||||||
type: aTransaction?.type ?? 'BUY',
|
|
||||||
unitPrice: null
|
unitPrice: null
|
||||||
},
|
},
|
||||||
user: this.user
|
user: this.user
|
||||||
@ -357,7 +334,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe((data: any) => {
|
.subscribe((data: any) => {
|
||||||
const transaction: CreateOrderDto = data?.transaction;
|
const transaction: CreateOrderDto = data?.activity;
|
||||||
|
|
||||||
if (transaction) {
|
if (transaction) {
|
||||||
this.dataService.postOrder(transaction).subscribe({
|
this.dataService.postOrder(transaction).subscribe({
|
||||||
|
@ -6,6 +6,7 @@ import { TokenStorageService } from '@ghostfolio/client/services/token-storage.s
|
|||||||
import { InfoItem } from '@ghostfolio/common/interfaces';
|
import { InfoItem } from '@ghostfolio/common/interfaces';
|
||||||
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||||
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface';
|
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface';
|
||||||
|
import { Role } from '@prisma/client';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
@ -62,19 +63,21 @@ export class RegisterPageComponent implements OnDestroy, OnInit {
|
|||||||
this.dataService
|
this.dataService
|
||||||
.postUser()
|
.postUser()
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe(({ accessToken, authToken }) => {
|
.subscribe(({ accessToken, authToken, role }) => {
|
||||||
this.openShowAccessTokenDialog(accessToken, authToken);
|
this.openShowAccessTokenDialog(accessToken, authToken, role);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public openShowAccessTokenDialog(
|
public openShowAccessTokenDialog(
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
authToken: string
|
authToken: string,
|
||||||
|
role: Role
|
||||||
): void {
|
): void {
|
||||||
const dialogRef = this.dialog.open(ShowAccessTokenDialog, {
|
const dialogRef = this.dialog.open(ShowAccessTokenDialog, {
|
||||||
data: {
|
data: {
|
||||||
accessToken,
|
accessToken,
|
||||||
authToken
|
authToken,
|
||||||
|
role
|
||||||
},
|
},
|
||||||
disableClose: true,
|
disableClose: true,
|
||||||
width: '30rem'
|
width: '30rem'
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<h1 mat-dialog-title i18n>Create Account</h1>
|
<h1 mat-dialog-title>
|
||||||
|
<span i18n>Create Account</span
|
||||||
|
><span *ngIf="data.role === 'ADMIN'" class="badge badge-light ml-2"
|
||||||
|
>{{ data.role }}</span
|
||||||
|
>
|
||||||
|
</h1>
|
||||||
<div mat-dialog-content>
|
<div mat-dialog-content>
|
||||||
<div>
|
<div>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
|
@ -6,7 +6,7 @@ import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
|||||||
import { AdminMarketDataDetails } from '@ghostfolio/common/interfaces';
|
import { AdminMarketDataDetails } from '@ghostfolio/common/interfaces';
|
||||||
import { DataSource, MarketData } from '@prisma/client';
|
import { DataSource, MarketData } from '@prisma/client';
|
||||||
import { format, parseISO } from 'date-fns';
|
import { format, parseISO } from 'date-fns';
|
||||||
import { map, Observable } from 'rxjs';
|
import { Observable, map } from 'rxjs';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -245,6 +245,8 @@ export class ImportTransactionsService {
|
|||||||
return Type.BUY;
|
return Type.BUY;
|
||||||
case 'dividend':
|
case 'dividend':
|
||||||
return Type.DIVIDEND;
|
return Type.DIVIDEND;
|
||||||
|
case 'item':
|
||||||
|
return Type.ITEM;
|
||||||
case 'sell':
|
case 'sell':
|
||||||
return Type.SELL;
|
return Type.SELL;
|
||||||
default:
|
default:
|
||||||
|
@ -6,42 +6,46 @@
|
|||||||
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io</loc>
|
<loc>https://ghostfol.io</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/about</loc>
|
<loc>https://ghostfol.io/about</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/about/changelog</loc>
|
<loc>https://ghostfol.io/about/changelog</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/blog</loc>
|
<loc>https://ghostfol.io/blog</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/de/blog/2021/07/hallo-ghostfolio</loc>
|
<loc>https://ghostfol.io/de/blog/2021/07/hallo-ghostfolio</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/en/blog/2021/07/hello-ghostfolio</loc>
|
<loc>https://ghostfol.io/en/blog/2021/07/hello-ghostfolio</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/en/blog/2022/01/ghostfolio-first-months-in-open-source</loc>
|
<loc>https://ghostfol.io/en/blog/2022/01/ghostfolio-first-months-in-open-source</loc>
|
||||||
<lastmod>2022-01-05T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://ghostfol.io/features</loc>
|
||||||
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/pricing</loc>
|
<loc>https://ghostfol.io/pricing</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/register</loc>
|
<loc>https://ghostfol.io/register</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://ghostfol.io/resources</loc>
|
<loc>https://ghostfol.io/resources</loc>
|
||||||
<lastmod>2022-01-01T00:00:00+00:00</lastmod>
|
<lastmod>2022-02-13T00:00:00+00:00</lastmod>
|
||||||
</url>
|
</url>
|
||||||
</urlset>
|
</urlset>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { DataSource } from '@prisma/client';
|
||||||
|
|
||||||
import { ToggleOption } from './types';
|
import { ToggleOption } from './types';
|
||||||
|
|
||||||
export const baseCurrency = 'USD';
|
export const baseCurrency = 'USD';
|
||||||
@ -14,6 +16,7 @@ export const DEMO_USER_ID = '9b112b4d-3b7d-4bad-9bdd-3b0f7b4dac2f';
|
|||||||
|
|
||||||
export const ghostfolioScraperApiSymbolPrefix = '_GF_';
|
export const ghostfolioScraperApiSymbolPrefix = '_GF_';
|
||||||
export const ghostfolioCashSymbol = `${ghostfolioScraperApiSymbolPrefix}CASH`;
|
export const ghostfolioCashSymbol = `${ghostfolioScraperApiSymbolPrefix}CASH`;
|
||||||
|
export const ghostfolioFearAndGreedIndexDataSource = DataSource.RAKUTEN;
|
||||||
export const ghostfolioFearAndGreedIndexSymbol = `${ghostfolioScraperApiSymbolPrefix}FEAR_AND_GREED_INDEX`;
|
export const ghostfolioFearAndGreedIndexSymbol = `${ghostfolioScraperApiSymbolPrefix}FEAR_AND_GREED_INDEX`;
|
||||||
|
|
||||||
export const locale = 'de-CH';
|
export const locale = 'de-CH';
|
||||||
|
@ -7,6 +7,7 @@ export interface PortfolioSummary extends PortfolioPerformance {
|
|||||||
committedFunds: number;
|
committedFunds: number;
|
||||||
fees: number;
|
fees: number;
|
||||||
firstOrderDate: Date;
|
firstOrderDate: Date;
|
||||||
|
items: number;
|
||||||
netWorth: number;
|
netWorth: number;
|
||||||
ordersCount: number;
|
ordersCount: number;
|
||||||
totalBuy: number;
|
totalBuy: number;
|
||||||
|
@ -87,15 +87,21 @@
|
|||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
buy: element.type === 'BUY',
|
buy: element.type === 'BUY',
|
||||||
dividend: element.type === 'DIVIDEND',
|
dividend: element.type === 'DIVIDEND',
|
||||||
|
item: element.type === 'ITEM',
|
||||||
sell: element.type === 'SELL'
|
sell: element.type === 'SELL'
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<ion-icon
|
<ion-icon
|
||||||
[name]="
|
*ngIf="element.type === 'BUY' || element.type === 'DIVIDEND'"
|
||||||
element.type === 'BUY' || element.type === 'DIVIDEND'
|
name="arrow-forward-circle-outline"
|
||||||
? 'arrow-forward-circle-outline'
|
></ion-icon>
|
||||||
: 'arrow-back-circle-outline'
|
<ion-icon
|
||||||
"
|
*ngIf="element.type === 'ITEM'"
|
||||||
|
name="cube-outline"
|
||||||
|
></ion-icon>
|
||||||
|
<ion-icon
|
||||||
|
*ngIf="element.type === 'SELL'"
|
||||||
|
name="arrow-back-circle-outline"
|
||||||
></ion-icon>
|
></ion-icon>
|
||||||
<span class="d-none d-lg-block mx-1">{{ element.type }}</span>
|
<span class="d-none d-lg-block mx-1">{{ element.type }}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -109,7 +115,12 @@
|
|||||||
</th>
|
</th>
|
||||||
<td *matCellDef="let element" class="px-1" mat-cell>
|
<td *matCellDef="let element" class="px-1" mat-cell>
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
{{ element.symbol | gfSymbol }}
|
<span *ngIf="isUUID(element.SymbolProfile.symbol); else symbol">
|
||||||
|
{{ element.SymbolProfile.name }}
|
||||||
|
</span>
|
||||||
|
<ng-template #symbol>
|
||||||
|
{{ element.SymbolProfile.symbol | gfSymbol }}
|
||||||
|
</ng-template>
|
||||||
<span *ngIf="element.isDraft" class="badge badge-secondary ml-1" i18n
|
<span *ngIf="element.isDraft" class="badge badge-secondary ml-1" i18n
|
||||||
>Draft</span
|
>Draft</span
|
||||||
>
|
>
|
||||||
@ -349,13 +360,15 @@
|
|||||||
(click)="
|
(click)="
|
||||||
hasPermissionToOpenDetails &&
|
hasPermissionToOpenDetails &&
|
||||||
!row.isDraft &&
|
!row.isDraft &&
|
||||||
|
row.type !== 'ITEM' &&
|
||||||
onOpenPositionDialog({
|
onOpenPositionDialog({
|
||||||
dataSource: row.dataSource,
|
dataSource: row.dataSource,
|
||||||
symbol: row.symbol
|
symbol: row.SymbolProfile.symbol
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'cursor-pointer': hasPermissionToOpenDetails && !row.isDraft
|
'cursor-pointer':
|
||||||
|
hasPermissionToOpenDetails && !row.isDraft && row.type !== 'ITEM'
|
||||||
}"
|
}"
|
||||||
></tr>
|
></tr>
|
||||||
<tr
|
<tr
|
||||||
|
@ -54,6 +54,10 @@
|
|||||||
color: var(--blue);
|
color: var(--blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.item {
|
||||||
|
color: var(--purple);
|
||||||
|
}
|
||||||
|
|
||||||
&.sell {
|
&.sell {
|
||||||
color: var(--orange);
|
color: var(--orange);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
|
|||||||
import { OrderWithAccount } from '@ghostfolio/common/types';
|
import { OrderWithAccount } from '@ghostfolio/common/types';
|
||||||
import { DataSource } from '@prisma/client';
|
import { DataSource } from '@prisma/client';
|
||||||
import Big from 'big.js';
|
import Big from 'big.js';
|
||||||
|
import { isUUID } from 'class-validator';
|
||||||
import { endOfToday, format, isAfter } from 'date-fns';
|
import { endOfToday, format, isAfter } from 'date-fns';
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
|
import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
|
||||||
@ -69,6 +70,7 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
|
|||||||
public filters: Observable<string[]> = this.filters$.asObservable();
|
public filters: Observable<string[]> = this.filters$.asObservable();
|
||||||
public isAfter = isAfter;
|
public isAfter = isAfter;
|
||||||
public isLoading = true;
|
public isLoading = true;
|
||||||
|
public isUUID = isUUID;
|
||||||
public placeholder = '';
|
public placeholder = '';
|
||||||
public routeQueryParams: Subscription;
|
public routeQueryParams: Subscription;
|
||||||
public searchControl = new FormControl();
|
public searchControl = new FormControl();
|
||||||
@ -134,10 +136,10 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
|
|||||||
'type',
|
'type',
|
||||||
'symbol',
|
'symbol',
|
||||||
'quantity',
|
'quantity',
|
||||||
'currency',
|
|
||||||
'unitPrice',
|
'unitPrice',
|
||||||
'fee',
|
'fee',
|
||||||
'value',
|
'value',
|
||||||
|
'currency',
|
||||||
'account',
|
'account',
|
||||||
'actions'
|
'actions'
|
||||||
];
|
];
|
||||||
@ -271,11 +273,15 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
|
|||||||
activity: OrderWithAccount,
|
activity: OrderWithAccount,
|
||||||
fieldValues: Set<string> = new Set<string>()
|
fieldValues: Set<string> = new Set<string>()
|
||||||
): string[] {
|
): string[] {
|
||||||
fieldValues.add(activity.currency);
|
|
||||||
fieldValues.add(activity.symbol);
|
|
||||||
fieldValues.add(activity.type);
|
|
||||||
fieldValues.add(activity.Account?.name);
|
fieldValues.add(activity.Account?.name);
|
||||||
fieldValues.add(activity.Account?.Platform?.name);
|
fieldValues.add(activity.Account?.Platform?.name);
|
||||||
|
fieldValues.add(activity.SymbolProfile.currency);
|
||||||
|
|
||||||
|
if (!isUUID(activity.SymbolProfile.symbol)) {
|
||||||
|
fieldValues.add(activity.SymbolProfile.symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldValues.add(activity.type);
|
||||||
fieldValues.add(format(activity.date, 'yyyy'));
|
fieldValues.add(format(activity.date, 'yyyy'));
|
||||||
|
|
||||||
return [...fieldValues].filter((item) => {
|
return [...fieldValues].filter((item) => {
|
||||||
@ -302,7 +308,7 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
|
|||||||
|
|
||||||
for (const activity of this.dataSource.filteredData) {
|
for (const activity of this.dataSource.filteredData) {
|
||||||
if (isNumber(activity.valueInBaseCurrency)) {
|
if (isNumber(activity.valueInBaseCurrency)) {
|
||||||
if (activity.type === 'BUY') {
|
if (activity.type === 'BUY' || activity.type === 'ITEM') {
|
||||||
totalValue = totalValue.plus(activity.valueInBaseCurrency);
|
totalValue = totalValue.plus(activity.valueInBaseCurrency);
|
||||||
} else if (activity.type === 'SELL') {
|
} else if (activity.type === 'SELL') {
|
||||||
totalValue = totalValue.minus(activity.valueInBaseCurrency);
|
totalValue = totalValue.minus(activity.valueInBaseCurrency);
|
||||||
|
@ -150,11 +150,11 @@ export class PortfolioProportionChartComponent
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!unknownItem) {
|
if (!unknownItem) {
|
||||||
const index = chartDataSorted.push([
|
chartDataSorted.push([
|
||||||
UNKNOWN_KEY,
|
UNKNOWN_KEY,
|
||||||
{ name: UNKNOWN_KEY, subCategory: {}, value: 0 }
|
{ name: UNKNOWN_KEY, subCategory: {}, value: 0 }
|
||||||
]);
|
]);
|
||||||
unknownItem = chartDataSorted[index];
|
unknownItem = chartDataSorted[chartDataSorted.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
rest.forEach((restItem) => {
|
rest.forEach((restItem) => {
|
||||||
|
@ -34,12 +34,12 @@
|
|||||||
{{ currency }}
|
{{ currency }}
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="isDate">
|
<ng-container *ngIf="isString">
|
||||||
<div
|
<div
|
||||||
class="mb-0"
|
class="mb-0 text-truncate"
|
||||||
[ngClass]="{ h2: size === 'large', h4: size === 'medium' }"
|
[ngClass]="{ h2: size === 'large', h4: size === 'medium' }"
|
||||||
>
|
>
|
||||||
{{ formattedDate }}
|
{{ formattedValue | titlecase }}
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
OnChanges
|
OnChanges
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
|
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
|
||||||
import { format, isDate } from 'date-fns';
|
import { format, isDate, parseISO } from 'date-fns';
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -28,10 +28,9 @@ export class ValueComponent implements OnChanges {
|
|||||||
@Input() value: number | string = '';
|
@Input() value: number | string = '';
|
||||||
|
|
||||||
public absoluteValue = 0;
|
public absoluteValue = 0;
|
||||||
public formattedDate = '';
|
|
||||||
public formattedValue = '';
|
public formattedValue = '';
|
||||||
public isDate = false;
|
|
||||||
public isNumber = false;
|
public isNumber = false;
|
||||||
|
public isString = false;
|
||||||
public useAbsoluteValue = false;
|
public useAbsoluteValue = false;
|
||||||
|
|
||||||
public constructor() {}
|
public constructor() {}
|
||||||
@ -39,8 +38,8 @@ export class ValueComponent implements OnChanges {
|
|||||||
public ngOnChanges() {
|
public ngOnChanges() {
|
||||||
if (this.value || this.value === 0) {
|
if (this.value || this.value === 0) {
|
||||||
if (isNumber(this.value)) {
|
if (isNumber(this.value)) {
|
||||||
this.isDate = false;
|
|
||||||
this.isNumber = true;
|
this.isNumber = true;
|
||||||
|
this.isString = false;
|
||||||
this.absoluteValue = Math.abs(<number>this.value);
|
this.absoluteValue = Math.abs(<number>this.value);
|
||||||
|
|
||||||
if (this.colorizeSign) {
|
if (this.colorizeSign) {
|
||||||
@ -98,17 +97,19 @@ export class ValueComponent implements OnChanges {
|
|||||||
this.formattedValue = this.formattedValue.replace(/^-/, '');
|
this.formattedValue = this.formattedValue.replace(/^-/, '');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
this.isNumber = false;
|
||||||
if (isDate(new Date(this.value))) {
|
this.isString = true;
|
||||||
this.isDate = true;
|
|
||||||
this.isNumber = false;
|
|
||||||
|
|
||||||
this.formattedDate = format(
|
try {
|
||||||
|
if (isDate(parseISO(this.value))) {
|
||||||
|
this.formattedValue = format(
|
||||||
new Date(<string>this.value),
|
new Date(<string>this.value),
|
||||||
DEFAULT_DATE_FORMAT
|
DEFAULT_DATE_FORMAT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {
|
||||||
|
this.formattedValue = this.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
64
package.json
64
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ghostfolio",
|
"name": "ghostfolio",
|
||||||
"version": "1.112.0",
|
"version": "1.116.0",
|
||||||
"homepage": "https://ghostfol.io",
|
"homepage": "https://ghostfol.io",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -42,6 +42,7 @@
|
|||||||
"start:server": "nx serve api --watch",
|
"start:server": "nx serve api --watch",
|
||||||
"start:storybook": "nx run ui:storybook",
|
"start:storybook": "nx run ui:storybook",
|
||||||
"test": "nx test",
|
"test": "nx test",
|
||||||
|
"test:single": "nx test --test-file portfolio-calculator-new.spec.ts",
|
||||||
"ts-node": "ts-node",
|
"ts-node": "ts-node",
|
||||||
"update": "nx migrate latest",
|
"update": "nx migrate latest",
|
||||||
"watch:server": "nx build api --watch",
|
"watch:server": "nx build api --watch",
|
||||||
@ -49,16 +50,16 @@
|
|||||||
"workspace-generator": "nx workspace-generator"
|
"workspace-generator": "nx workspace-generator"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "13.1.1",
|
"@angular/animations": "13.2.2",
|
||||||
"@angular/cdk": "13.1.1",
|
"@angular/cdk": "13.2.2",
|
||||||
"@angular/common": "13.1.1",
|
"@angular/common": "13.2.2",
|
||||||
"@angular/compiler": "13.1.1",
|
"@angular/compiler": "13.2.2",
|
||||||
"@angular/core": "13.1.1",
|
"@angular/core": "13.2.2",
|
||||||
"@angular/forms": "13.1.1",
|
"@angular/forms": "13.2.2",
|
||||||
"@angular/material": "13.1.1",
|
"@angular/material": "13.2.2",
|
||||||
"@angular/platform-browser": "13.1.1",
|
"@angular/platform-browser": "13.2.2",
|
||||||
"@angular/platform-browser-dynamic": "13.1.1",
|
"@angular/platform-browser-dynamic": "13.2.2",
|
||||||
"@angular/router": "13.1.1",
|
"@angular/router": "13.2.2",
|
||||||
"@codewithdan/observable-store": "2.2.11",
|
"@codewithdan/observable-store": "2.2.11",
|
||||||
"@dinero.js/currencies": "2.0.0-alpha.8",
|
"@dinero.js/currencies": "2.0.0-alpha.8",
|
||||||
"@nestjs/common": "8.2.3",
|
"@nestjs/common": "8.2.3",
|
||||||
@ -69,7 +70,7 @@
|
|||||||
"@nestjs/platform-express": "8.2.3",
|
"@nestjs/platform-express": "8.2.3",
|
||||||
"@nestjs/schedule": "1.0.2",
|
"@nestjs/schedule": "1.0.2",
|
||||||
"@nestjs/serve-static": "2.2.2",
|
"@nestjs/serve-static": "2.2.2",
|
||||||
"@nrwl/angular": "13.4.1",
|
"@nrwl/angular": "13.8.1",
|
||||||
"@prisma/client": "3.9.1",
|
"@prisma/client": "3.9.1",
|
||||||
"@simplewebauthn/browser": "4.1.0",
|
"@simplewebauthn/browser": "4.1.0",
|
||||||
"@simplewebauthn/server": "4.1.0",
|
"@simplewebauthn/server": "4.1.0",
|
||||||
@ -114,34 +115,35 @@
|
|||||||
"stripe": "8.199.0",
|
"stripe": "8.199.0",
|
||||||
"svgmap": "2.6.0",
|
"svgmap": "2.6.0",
|
||||||
"tslib": "2.0.0",
|
"tslib": "2.0.0",
|
||||||
|
"twitter-api-v2": "1.10.3",
|
||||||
"uuid": "8.3.2",
|
"uuid": "8.3.2",
|
||||||
"yahoo-finance": "0.3.6",
|
"yahoo-finance": "0.3.6",
|
||||||
"zone.js": "0.11.4"
|
"zone.js": "0.11.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "13.1.2",
|
"@angular-devkit/build-angular": "13.2.3",
|
||||||
"@angular-eslint/eslint-plugin": "13.0.1",
|
"@angular-eslint/eslint-plugin": "13.0.1",
|
||||||
"@angular-eslint/eslint-plugin-template": "13.0.1",
|
"@angular-eslint/eslint-plugin-template": "13.0.1",
|
||||||
"@angular-eslint/template-parser": "13.0.1",
|
"@angular-eslint/template-parser": "13.0.1",
|
||||||
"@angular/cli": "13.1.2",
|
"@angular/cli": "13.2.3",
|
||||||
"@angular/compiler-cli": "13.1.1",
|
"@angular/compiler-cli": "13.2.2",
|
||||||
"@angular/language-service": "13.1.1",
|
"@angular/language-service": "13.2.2",
|
||||||
"@angular/localize": "13.1.1",
|
"@angular/localize": "13.2.2",
|
||||||
"@nestjs/schematics": "8.0.5",
|
"@nestjs/schematics": "8.0.5",
|
||||||
"@nestjs/testing": "8.2.3",
|
"@nestjs/testing": "8.2.3",
|
||||||
"@nrwl/cli": "13.4.1",
|
"@nrwl/cli": "13.8.1",
|
||||||
"@nrwl/cypress": "13.4.1",
|
"@nrwl/cypress": "13.8.1",
|
||||||
"@nrwl/eslint-plugin-nx": "13.4.1",
|
"@nrwl/eslint-plugin-nx": "13.8.1",
|
||||||
"@nrwl/jest": "13.4.1",
|
"@nrwl/jest": "13.8.1",
|
||||||
"@nrwl/nest": "13.4.1",
|
"@nrwl/nest": "13.8.1",
|
||||||
"@nrwl/node": "13.4.1",
|
"@nrwl/node": "13.8.1",
|
||||||
"@nrwl/storybook": "13.4.1",
|
"@nrwl/storybook": "13.8.1",
|
||||||
"@nrwl/tao": "13.4.1",
|
"@nrwl/tao": "13.8.1",
|
||||||
"@nrwl/workspace": "13.4.1",
|
"@nrwl/workspace": "13.8.1",
|
||||||
"@storybook/addon-essentials": "6.4.9",
|
"@storybook/addon-essentials": "6.4.18",
|
||||||
"@storybook/angular": "6.4.9",
|
"@storybook/angular": "6.4.18",
|
||||||
"@storybook/builder-webpack5": "6.4.9",
|
"@storybook/builder-webpack5": "6.4.18",
|
||||||
"@storybook/manager-webpack5": "6.4.9",
|
"@storybook/manager-webpack5": "6.4.18",
|
||||||
"@types/big.js": "6.1.2",
|
"@types/big.js": "6.1.2",
|
||||||
"@types/cache-manager": "3.4.2",
|
"@types/cache-manager": "3.4.2",
|
||||||
"@types/color": "3.0.2",
|
"@types/color": "3.0.2",
|
||||||
@ -169,7 +171,7 @@
|
|||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"ts-jest": "27.0.5",
|
"ts-jest": "27.0.5",
|
||||||
"ts-node": "9.1.1",
|
"ts-node": "9.1.1",
|
||||||
"typescript": "4.5.4"
|
"typescript": "4.5.5"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
-- AlterEnum
|
||||||
|
ALTER TYPE "DataSource" ADD VALUE 'MANUAL';
|
@ -0,0 +1,2 @@
|
|||||||
|
-- AlterEnum
|
||||||
|
ALTER TYPE "Type" ADD VALUE 'ITEM';
|
@ -185,6 +185,7 @@ enum DataSource {
|
|||||||
ALPHA_VANTAGE
|
ALPHA_VANTAGE
|
||||||
GHOSTFOLIO
|
GHOSTFOLIO
|
||||||
GOOGLE_SHEETS
|
GOOGLE_SHEETS
|
||||||
|
MANUAL
|
||||||
RAKUTEN
|
RAKUTEN
|
||||||
YAHOO
|
YAHOO
|
||||||
}
|
}
|
||||||
@ -208,5 +209,6 @@ enum Role {
|
|||||||
enum Type {
|
enum Type {
|
||||||
BUY
|
BUY
|
||||||
DIVIDEND
|
DIVIDEND
|
||||||
|
ITEM
|
||||||
SELL
|
SELL
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
Date,Code,Currency,Price,Quantity,Action,Fee
|
Date,Code,Currency,Price,Quantity,Action,Fee
|
||||||
17/11/2021,MSFT,USD,0.62,5,dividend,0.00
|
17/11/2021,MSFT,USD,0.62,5,dividend,0.00
|
||||||
16/09/2021,MSFT,USD,298.580,5,buy,19.00
|
16/09/2021,MSFT,USD,298.580,5,buy,19.00
|
||||||
|
01/01/2022,Penthouse Apartment,USD,500000.0,1,item,0.00
|
||||||
|
|
Reference in New Issue
Block a user