Feature/extend market data in admin panel (#716)

* Extend market data view

* Update changelog
pull/717/head
Thomas Kaul 3 years ago committed by GitHub
parent a5771f601d
commit fed771525e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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 };
}

@ -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)
)

@ -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<MarketData, 'date' | 'marketPrice'> & { day: number };
};
} = {};
private unsubscribeSubject = new Subject<void>();
@ -57,9 +68,30 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
value: marketDataItem.marketPrice
};
});
let date = parseISO(this.dateOfFirstActivity);
const missingMarketData: Partial<MarketData>[] = [];
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
};
}
}

@ -64,6 +64,7 @@
<td class="p-1" colspan="6">
<gf-admin-market-data-detail
[dataSource]="item.dataSource"
[dateOfFirstActivity]="item.date"
[marketData]="marketDataDetails"
[symbol]="item.symbol"
(marketDataChanged)="onMarketDataChanged($event)"

Loading…
Cancel
Save