Browse Source

Refactor fear and greed index symbol

GF.FEAR_AND_GREED_INDEX -> _GF_FEAR_AND_GREED_INDEX
pull/359/head
Thomas 4 years ago
parent
commit
3414823b88
  1. 8
      apps/api/src/services/data-gathering.service.ts
  2. 9
      apps/api/src/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service.ts
  3. 3
      apps/client/src/app/pages/home/home-page.component.ts
  4. 1
      libs/common/src/lib/config.ts

8
apps/api/src/services/data-gathering.service.ts

@ -1,4 +1,8 @@
import { benchmarks, currencyPairs } from '@ghostfolio/common/config'; import {
benchmarks,
currencyPairs,
ghostfolioFearAndGreedIndexSymbol
} from '@ghostfolio/common/config';
import { import {
DATE_FORMAT, DATE_FORMAT,
getUtc, getUtc,
@ -295,7 +299,7 @@ export class DataGatheringService {
benchmarksToGather.push({ benchmarksToGather.push({
dataSource: DataSource.RAKUTEN, dataSource: DataSource.RAKUTEN,
date: startDate, date: startDate,
symbol: 'GF.FEAR_AND_GREED_INDEX' symbol: ghostfolioFearAndGreedIndexSymbol
}); });
} }

9
apps/api/src/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service.ts

@ -1,6 +1,7 @@
import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface';
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
import { PrismaService } from '@ghostfolio/api/services/prisma.service'; import { PrismaService } from '@ghostfolio/api/services/prisma.service';
import { ghostfolioFearAndGreedIndexSymbol } from '@ghostfolio/common/config';
import { import {
DATE_FORMAT, DATE_FORMAT,
getToday, getToday,
@ -47,11 +48,11 @@ export class RakutenRapidApiService implements DataProviderInterface {
try { try {
const symbol = aSymbols[0]; const symbol = aSymbols[0];
if (symbol === 'GF.FEAR_AND_GREED_INDEX') { if (symbol === ghostfolioFearAndGreedIndexSymbol) {
const fgi = await this.getFearAndGreedIndex(); const fgi = await this.getFearAndGreedIndex();
return { return {
'GF.FEAR_AND_GREED_INDEX': { [ghostfolioFearAndGreedIndexSymbol]: {
currency: undefined, currency: undefined,
dataSource: DataSource.RAKUTEN, dataSource: DataSource.RAKUTEN,
marketPrice: fgi.now.value, marketPrice: fgi.now.value,
@ -82,7 +83,7 @@ export class RakutenRapidApiService implements DataProviderInterface {
try { try {
const symbol = aSymbols[0]; const symbol = aSymbols[0];
if (symbol === 'GF.FEAR_AND_GREED_INDEX') { if (symbol === ghostfolioFearAndGreedIndexSymbol) {
const fgi = await this.getFearAndGreedIndex(); const fgi = await this.getFearAndGreedIndex();
try { try {
@ -118,7 +119,7 @@ export class RakutenRapidApiService implements DataProviderInterface {
} catch {} } catch {}
return { return {
'GF.FEAR_AND_GREED_INDEX': { [ghostfolioFearAndGreedIndexSymbol]: {
[format(getYesterday(), DATE_FORMAT)]: { [format(getYesterday(), DATE_FORMAT)]: {
marketPrice: fgi.previousClose.value marketPrice: fgi.previousClose.value
} }

3
apps/client/src/app/pages/home/home-page.component.ts

@ -20,6 +20,7 @@ import {
SettingsStorageService SettingsStorageService
} from '@ghostfolio/client/services/settings-storage.service'; } from '@ghostfolio/client/services/settings-storage.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { ghostfolioFearAndGreedIndexSymbol } from '@ghostfolio/common/config';
import { import {
PortfolioPerformance, PortfolioPerformance,
PortfolioSummary, PortfolioSummary,
@ -111,7 +112,7 @@ export class HomePageComponent implements OnDestroy, OnInit {
if (this.hasPermissionToAccessFearAndGreedIndex) { if (this.hasPermissionToAccessFearAndGreedIndex) {
this.dataService this.dataService
.fetchSymbolItem('GF.FEAR_AND_GREED_INDEX') .fetchSymbolItem(ghostfolioFearAndGreedIndexSymbol)
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ marketPrice }) => { .subscribe(({ marketPrice }) => {
this.fearAndGreedIndex = marketPrice; this.fearAndGreedIndex = marketPrice;

1
libs/common/src/lib/config.ts

@ -28,6 +28,7 @@ export const currencyPairs: Partial<
export const ghostfolioScraperApiSymbolPrefix = '_GF_'; export const ghostfolioScraperApiSymbolPrefix = '_GF_';
export const ghostfolioCashSymbol = `${ghostfolioScraperApiSymbolPrefix}CASH`; export const ghostfolioCashSymbol = `${ghostfolioScraperApiSymbolPrefix}CASH`;
export const ghostfolioFearAndGreedIndexSymbol = `${ghostfolioScraperApiSymbolPrefix}FEAR_AND_GREED_INDEX`;
export const locale = 'de-CH'; export const locale = 'de-CH';

Loading…
Cancel
Save