From 73370f092bbad71ab1a7305573ae459c24cfbf43 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 2 Jul 2025 20:36:52 +0200 Subject: [PATCH] Extend markets --- .../app/endpoints/market-data/market-data.controller.ts | 7 ++++--- .../client/src/app/components/markets/markets.component.ts | 5 +++-- apps/client/src/app/services/data.service.ts | 5 +++-- libs/common/src/lib/config.ts | 2 ++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/api/src/app/endpoints/market-data/market-data.controller.ts b/apps/api/src/app/endpoints/market-data/market-data.controller.ts index c9646c8e6..d1cbb73cd 100644 --- a/apps/api/src/app/endpoints/market-data/market-data.controller.ts +++ b/apps/api/src/app/endpoints/market-data/market-data.controller.ts @@ -6,7 +6,8 @@ import { MarketDataService } from '@ghostfolio/api/services/market-data/market-d import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service'; import { ghostfolioFearAndGreedIndexDataSource, - ghostfolioFearAndGreedIndexSymbol + ghostfolioFearAndGreedIndexSymbolCryptocurrencies, + ghostfolioFearAndGreedIndexSymbolStocks } from '@ghostfolio/common/config'; import { getCurrencyFromSymbol, isCurrency } from '@ghostfolio/common/helper'; import { @@ -59,14 +60,14 @@ export class MarketDataController { includeHistoricalData, dataGatheringItem: { dataSource: 'MANUAL', - symbol: 'GF_FEAR_AND_GREED_INDEX_CRYPTO' + symbol: ghostfolioFearAndGreedIndexSymbolCryptocurrencies } }), this.symbolService.get({ includeHistoricalData, dataGatheringItem: { dataSource: ghostfolioFearAndGreedIndexDataSource, - symbol: ghostfolioFearAndGreedIndexSymbol + symbol: ghostfolioFearAndGreedIndexSymbolStocks } }) ]); diff --git a/apps/client/src/app/components/markets/markets.component.ts b/apps/client/src/app/components/markets/markets.component.ts index cd3a44acd..2dc1eb3d3 100644 --- a/apps/client/src/app/components/markets/markets.component.ts +++ b/apps/client/src/app/components/markets/markets.component.ts @@ -102,10 +102,11 @@ export class MarketsComponent implements OnDestroy, OnInit { public initialize() { this.fearAndGreedIndex = - this.fearAndGreedIndexData[this.fearAndGreedIndexMode].marketPrice; + this.fearAndGreedIndexData[this.fearAndGreedIndexMode]?.marketPrice; this.historicalDataItems = [ - ...this.fearAndGreedIndexData[this.fearAndGreedIndexMode].historicalData, + ...(this.fearAndGreedIndexData[this.fearAndGreedIndexMode] + ?.historicalData ?? []), { date: resetHours(new Date()).toISOString(), value: this.fearAndGreedIndex diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts index fa339badd..820ad5e3c 100644 --- a/apps/client/src/app/services/data.service.ts +++ b/apps/client/src/app/services/data.service.ts @@ -498,11 +498,12 @@ export class DataService { return this.http.get('/api/v1/market-data/markets', { params }).pipe( map((data) => { for (const item of data.fearAndGreedIndex.CRYPTOCURRENCIES - .historicalData) { + ?.historicalData ?? []) { item.date = parseISO(item.date); } - for (const item of data.fearAndGreedIndex.STOCKS.historicalData) { + for (const item of data.fearAndGreedIndex.STOCKS?.historicalData ?? + []) { item.date = parseISO(item.date); } diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.ts index 336235e58..d4b2c2a6f 100644 --- a/libs/common/src/lib/config.ts +++ b/libs/common/src/lib/config.ts @@ -6,6 +6,8 @@ export const ghostfolioPrefix = 'GF'; export const ghostfolioScraperApiSymbolPrefix = `_${ghostfolioPrefix}_`; export const ghostfolioFearAndGreedIndexDataSource = DataSource.RAPID_API; export const ghostfolioFearAndGreedIndexSymbol = `${ghostfolioScraperApiSymbolPrefix}FEAR_AND_GREED_INDEX`; +export const ghostfolioFearAndGreedIndexSymbolCryptocurrencies = `${ghostfolioPrefix}_FEAR_AND_GREED_INDEX_CRYPTOCURRENCIES`; +export const ghostfolioFearAndGreedIndexSymbolStocks = `${ghostfolioPrefix}_FEAR_AND_GREED_INDEX_STOCKS`; export const locale = 'en-US';