Browse Source

Bugfix/empty historical market data in asset profile dialog for asset profiles without activities (#7623)

* Fix empty historical market data for asset profiles without activities

* Update changelog
pull/7628/head
Thomas Kaul 4 days ago
committed by GitHub
parent
commit
4926d59d4d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 26
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.ts

1
CHANGELOG.md

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed the cash balance update related to activities in a custom currency - Fixed the cash balance update related to activities in a custom currency
- Fixed the empty historical market data of the asset profile dialog of the admin control panel for asset profiles without activities
- Fixed the missing mapping for Czech Republic in the country weightings of the _Financial Modeling Prep_ service - Fixed the missing mapping for Czech Republic in the country weightings of the _Financial Modeling Prep_ service
- Fixed the missing mapping for Macau in the data enhancer for asset profile data via _Yahoo Finance_ - Fixed the missing mapping for Macau in the data enhancer for asset profile data via _Yahoo Finance_
- Fixed the outdated exchange rates of currency pairs which are calculated indirectly via the base currency - Fixed the outdated exchange rates of currency pairs which are calculated indirectly via the base currency

26
libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.ts

@ -41,7 +41,6 @@ import {
parse, parse,
parseISO parseISO
} from 'date-fns'; } from 'date-fns';
import { first, last } from 'lodash';
import ms from 'ms'; import ms from 'ms';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { parse as csvToJson } from 'papaparse'; import { parse as csvToJson } from 'papaparse';
@ -123,8 +122,13 @@ export class GfHistoricalMarketDataEditorComponent
} }
public ngOnChanges() { public ngOnChanges() {
if (this.dateOfFirstActivity) { const startDate = this.dateOfFirstActivity ?? this.marketData()[0]?.date;
let date = this.dateOfFirstActivity;
if (!startDate) {
return;
}
let date = startDate;
const missingMarketData: { date: Date; marketPrice?: number }[] = []; const missingMarketData: { date: Date; marketPrice?: number }[] = [];
@ -146,7 +150,7 @@ export class GfHistoricalMarketDataEditorComponent
const marketDataItems = [...missingMarketData, ...this.marketData()]; const marketDataItems = [...missingMarketData, ...this.marketData()];
const lastDate = last(marketDataItems)?.date; const lastDate = marketDataItems.at(-1)?.date;
if (!lastDate || !isToday(lastDate)) { if (!lastDate || !isToday(lastDate)) {
marketDataItems.push({ date: new Date() }); marketDataItems.push({ date: new Date() });
} }
@ -172,17 +176,16 @@ export class GfHistoricalMarketDataEditorComponent
// Fill up missing months // Fill up missing months
const dates = Object.keys(this.marketDataByMonth).sort(); const dates = Object.keys(this.marketDataByMonth).sort();
const startDateString = first(dates); const startDateString = dates[0];
const startDate = min([ const endDateString = dates.at(-1);
this.dateOfFirstActivity,
...(startDateString ? [parseISO(startDateString)] : [])
]);
const endDateString = last(dates);
if (endDateString) { if (endDateString) {
const endDate = parseISO(endDateString); const endDate = parseISO(endDateString);
let currentDate = startDate; let currentDate = min([
startDate,
...(startDateString ? [parseISO(startDateString)] : [])
]);
while (isBefore(currentDate, endDate)) { while (isBefore(currentDate, endDate)) {
const key = format(currentDate, 'yyyy-MM'); const key = format(currentDate, 'yyyy-MM');
@ -194,7 +197,6 @@ export class GfHistoricalMarketDataEditorComponent
} }
} }
} }
}
public formatDay(day: number): string { public formatDay(day: number): string {
return day < 10 ? `0${day}` : `${day}`; return day < 10 ? `0${day}` : `${day}`;

Loading…
Cancel
Save