diff --git a/CHANGELOG.md b/CHANGELOG.md index f0a678ea0..fee45137d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.95.0 - 28.04.2021 + +### Added + +- Added a data source attribute to the transactions model + ## 0.94.0 - 27.04.2021 ### Added diff --git a/apps/api/src/app/experimental/experimental.service.ts b/apps/api/src/app/experimental/experimental.service.ts index 311f2aca8..30d0a9ff9 100644 --- a/apps/api/src/app/experimental/experimental.service.ts +++ b/apps/api/src/app/experimental/experimental.service.ts @@ -39,6 +39,7 @@ export class ExperimentalService { accountId: undefined, accountUserId: undefined, createdAt: new Date(), + dataSource: undefined, date: parseISO(order.date), fee: 0, id: undefined, diff --git a/apps/api/src/app/order/create-order.dto.ts b/apps/api/src/app/order/create-order.dto.ts index 177361555..f330eb027 100644 --- a/apps/api/src/app/order/create-order.dto.ts +++ b/apps/api/src/app/order/create-order.dto.ts @@ -1,4 +1,4 @@ -import { Currency, Type } from '@prisma/client'; +import { Currency, DataSource, Type } from '@prisma/client'; import { IsISO8601, IsNumber, IsString, ValidateIf } from 'class-validator'; export class CreateOrderDto { @@ -8,6 +8,9 @@ export class CreateOrderDto { @IsString() currency: Currency; + @IsString() + dataSource: DataSource; + @IsISO8601() date: string; diff --git a/apps/api/src/app/order/update-order.dto.ts b/apps/api/src/app/order/update-order.dto.ts index 8d278e589..26f1fa08d 100644 --- a/apps/api/src/app/order/update-order.dto.ts +++ b/apps/api/src/app/order/update-order.dto.ts @@ -1,4 +1,4 @@ -import { Currency, Type } from '@prisma/client'; +import { Currency, DataSource, Type } from '@prisma/client'; import { IsISO8601, IsNumber, IsString, ValidateIf } from 'class-validator'; export class UpdateOrderDto { @@ -8,6 +8,9 @@ export class UpdateOrderDto { @IsString() currency: Currency; + @IsString() + dataSource: DataSource; + @IsISO8601() date: string; diff --git a/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts b/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts index 0ff0ec0c3..c3848729b 100644 --- a/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts +++ b/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts @@ -1,6 +1,8 @@ +import { Currency } from '@prisma/client'; + export interface PortfolioPositionDetail { averagePrice: number; - currency: string; + currency: Currency; firstBuyDate: string; grossPerformance: number; grossPerformancePercent: number; diff --git a/apps/api/src/app/symbol/interfaces/symbol-item.interface.ts b/apps/api/src/app/symbol/interfaces/symbol-item.interface.ts index ecf95559d..fb18a2211 100644 --- a/apps/api/src/app/symbol/interfaces/symbol-item.interface.ts +++ b/apps/api/src/app/symbol/interfaces/symbol-item.interface.ts @@ -1,6 +1,7 @@ -import { Currency } from '@prisma/client'; +import { Currency, DataSource } from '@prisma/client'; export interface SymbolItem { currency: Currency; + dataSource: DataSource; marketPrice: number; } diff --git a/apps/api/src/app/symbol/symbol.service.ts b/apps/api/src/app/symbol/symbol.service.ts index 611c91f38..9da9488b9 100644 --- a/apps/api/src/app/symbol/symbol.service.ts +++ b/apps/api/src/app/symbol/symbol.service.ts @@ -18,9 +18,10 @@ export class SymbolService { public async get(aSymbol: string): Promise { const response = await this.dataProviderService.get([aSymbol]); - const { currency, marketPrice } = response[aSymbol]; + const { currency, dataSource, marketPrice } = response[aSymbol]; return { + dataSource, marketPrice, currency: (currency) }; diff --git a/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts b/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts index f848ffe7a..be3c961b2 100644 --- a/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts +++ b/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts @@ -1,3 +1,4 @@ +import { DataSource } from '.prisma/client'; import { getYesterday } from '@ghostfolio/helper'; import { Injectable } from '@nestjs/common'; import * as bent from 'bent'; @@ -45,6 +46,7 @@ export class GhostfolioScraperApiService implements DataProviderInterface { [symbol]: { marketPrice, currency: scraperConfig?.currency, + dataSource: DataSource.GHOSTFOLIO, marketState: MarketState.delayed, name: scraperConfig?.name } diff --git a/apps/api/src/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service.ts b/apps/api/src/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service.ts index bec82d881..f45e85fc7 100644 --- a/apps/api/src/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service.ts +++ b/apps/api/src/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service.ts @@ -1,3 +1,4 @@ +import { DataSource } from '.prisma/client'; import { getToday, getYesterday } from '@ghostfolio/helper'; import { Injectable } from '@nestjs/common'; import * as bent from 'bent'; @@ -39,6 +40,7 @@ export class RakutenRapidApiService implements DataProviderInterface { return { 'GF.FEAR_AND_GREED_INDEX': { currency: undefined, + dataSource: DataSource.RAKUTEN, marketPrice: fgi.now.value, marketState: MarketState.open, name: RakutenRapidApiService.FEAR_AND_GREED_INDEX_NAME diff --git a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts index ef15f99d4..90f9da459 100644 --- a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts @@ -1,3 +1,4 @@ +import { DataSource } from '.prisma/client'; import { isCrypto, isCurrency, parseCurrency } from '@ghostfolio/helper'; import { Injectable } from '@nestjs/common'; import { format } from 'date-fns'; @@ -49,6 +50,7 @@ export class YahooFinanceService implements DataProviderInterface { response[symbol] = { currency: parseCurrency(value.price?.currency), + dataSource: DataSource.YAHOO, exchange: this.parseExchange(value.price?.exchangeName), marketState: value.price?.marketState === 'REGULAR' || isCrypto(symbol) diff --git a/apps/api/src/services/interfaces/interfaces.ts b/apps/api/src/services/interfaces/interfaces.ts index 8da86143b..62e69fa4f 100644 --- a/apps/api/src/services/interfaces/interfaces.ts +++ b/apps/api/src/services/interfaces/interfaces.ts @@ -1,4 +1,4 @@ -import { Currency, Platform } from '@prisma/client'; +import { Currency, DataSource, Platform } from '@prisma/client'; import { OrderType } from '../../models/order-type'; @@ -51,6 +51,7 @@ export interface IDataProviderHistoricalResponse { export interface IDataProviderResponse { currency: Currency; + dataSource: DataSource; exchange?: string; industry?: Industry; marketChange?: number; diff --git a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts index 5785f740c..e1b30a8ef 100644 --- a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts +++ b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts @@ -78,8 +78,9 @@ export class CreateOrUpdateTransactionDialog { this.dataService .fetchSymbolItem(this.data.transaction.symbol) .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ currency, marketPrice }) => { + .subscribe(({ currency, dataSource, marketPrice }) => { this.data.transaction.currency = currency; + this.data.transaction.dataSource = dataSource; this.data.transaction.unitPrice = marketPrice; this.isLoading = false; @@ -90,6 +91,7 @@ export class CreateOrUpdateTransactionDialog { public onUpdateSymbolByTyping(value: string) { this.data.transaction.currency = null; + this.data.transaction.dataSource = null; this.data.transaction.unitPrice = null; this.data.transaction.symbol = value; diff --git a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html index 8ee43c7ec..829be07c7 100644 --- a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html +++ b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html @@ -58,6 +58,18 @@ +
+ + Data Source + + +
Date @@ -113,6 +125,7 @@ Account { + accountId: this.user?.accounts.find((account) => { return account.isDefault; })?.id, currency: null, diff --git a/package.json b/package.json index b007d9d93..15c528c30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ghostfolio", - "version": "0.94.0", + "version": "0.95.0", "homepage": "https://ghostfol.io", "license": "AGPL-3.0", "scripts": { diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 03cf1eaaa..43d688c3b 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -59,22 +59,23 @@ model MarketData { } model Order { - Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId]) + Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId]) accountId String? accountUserId String? - createdAt DateTime @default(now()) + createdAt DateTime @default(now()) currency Currency + dataSource DataSource @default(YAHOO) date DateTime fee Float - id String @default(uuid()) - Platform Platform? @relation(fields: [platformId], references: [id]) + id String @default(uuid()) + Platform Platform? @relation(fields: [platformId], references: [id]) platformId String? quantity Float symbol String type Type unitPrice Float - updatedAt DateTime @updatedAt - User User @relation(fields: [userId], references: [id]) + updatedAt DateTime @updatedAt + User User @relation(fields: [userId], references: [id]) userId String @@id([id, userId]) @@ -128,6 +129,12 @@ enum Currency { USD } +enum DataSource { + GHOSTFOLIO + RAKUTEN + YAHOO +} + enum Provider { ANONYMOUS GOOGLE