diff --git a/CHANGELOG.md b/CHANGELOG.md index f99a25f35..db10283d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Displayed features in features overview page based on permissions +- Extended the data points of historical data in the admin control panel ## 1.117.0 - 19.02.2022 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 2b4fe8f92..556cf71a1 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 @@ -25,7 +25,7 @@ import { @Injectable() export class YahooFinanceService implements DataProviderInterface { - private yahooFinanceHostname = 'https://query1.finance.yahoo.com'; + private readonly yahooFinanceHostname = 'https://query1.finance.yahoo.com'; public constructor( private readonly cryptocurrencyService: CryptocurrencyService @@ -274,7 +274,9 @@ export class YahooFinanceService implements DataProviderInterface { name: value.name }); } - } catch {} + } catch (error) { + Logger.error(error); + } return { items }; } diff --git a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html index 00b42388b..7264be84d 100644 --- a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html +++ b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html @@ -18,8 +18,7 @@ available: marketDataByMonth[itemByMonth.key][ i + 1 < 10 ? '0' + (i + 1) : i + 1 - ]?.day === - i + 1, + ]?.marketPrice, today: isToday( itemByMonth.key + '-' + (i + 1 < 10 ? '0' + (i + 1) : i + 1) ) diff --git a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts index 210f48805..9f935cb91 100644 --- a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts +++ b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts @@ -12,7 +12,15 @@ import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config'; import { DATE_FORMAT } from '@ghostfolio/common/helper'; import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface'; import { DataSource, MarketData } from '@prisma/client'; -import { format, isBefore, isSameDay, isValid, parse } from 'date-fns'; +import { + addDays, + format, + isBefore, + isSameDay, + isValid, + parse, + parseISO +} from 'date-fns'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Subject, takeUntil } from 'rxjs'; @@ -26,6 +34,7 @@ import { MarketDataDetailDialog } from './market-data-detail-dialog/market-data- }) export class AdminMarketDataDetailComponent implements OnChanges, OnInit { @Input() dataSource: DataSource; + @Input() dateOfFirstActivity: string; @Input() marketData: MarketData[]; @Input() symbol: string; @@ -36,7 +45,9 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit { public deviceType: string; public historicalDataItems: LineChartItem[]; public marketDataByMonth: { - [yearMonth: string]: { [day: string]: MarketData & { day: number } }; + [yearMonth: string]: { + [day: string]: Pick & { day: number }; + }; } = {}; private unsubscribeSubject = new Subject(); @@ -57,9 +68,30 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit { value: marketDataItem.marketPrice }; }); + + let date = parseISO(this.dateOfFirstActivity); + + const missingMarketData: Partial[] = []; + + if (this.historicalDataItems?.[0]?.date) { + while ( + isBefore( + date, + parse(this.historicalDataItems[0].date, DATE_FORMAT, new Date()) + ) + ) { + missingMarketData.push({ + date, + marketPrice: undefined + }); + + date = addDays(date, 1); + } + } + this.marketDataByMonth = {}; - for (const marketDataItem of this.marketData) { + for (const marketDataItem of [...missingMarketData, ...this.marketData]) { const currentDay = parseInt(format(marketDataItem.date, 'd'), 10); const key = format(marketDataItem.date, 'yyyy-MM'); @@ -70,8 +102,9 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit { this.marketDataByMonth[key][ currentDay < 10 ? `0${currentDay}` : currentDay ] = { - ...marketDataItem, - day: currentDay + date: marketDataItem.date, + day: currentDay, + marketPrice: marketDataItem.marketPrice }; } } diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.html b/apps/client/src/app/components/admin-market-data/admin-market-data.html index 3ff7435b4..7638d6110 100644 --- a/apps/client/src/app/components/admin-market-data/admin-market-data.html +++ b/apps/client/src/app/components/admin-market-data/admin-market-data.html @@ -64,6 +64,7 @@