move interfaces to separate files
This commit is contained in:
parent
602a770a09
commit
ea66081073
@ -2,10 +2,12 @@ import { DataProviderService } from '@ghostfolio/api/services/data-provider.serv
|
||||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||
import { resetHours } from '@ghostfolio/common/helper';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Currency } from '@prisma/client';
|
||||
import { isToday } from 'date-fns';
|
||||
|
||||
import { DateQuery, MarketDataService } from './market-data.service';
|
||||
import { MarketDataService } from './market-data.service';
|
||||
import { GetValueObject } from '@ghostfolio/api/app/core/get-value.object';
|
||||
import { GetValuesParams } from '@ghostfolio/api/app/core/get-values.params';
|
||||
import { GetValueParams } from '@ghostfolio/api/app/core/get-value.params';
|
||||
|
||||
@Injectable()
|
||||
export class CurrentRateService {
|
||||
@ -79,22 +81,3 @@ export class CurrentRateService {
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetValueParams {
|
||||
date: Date;
|
||||
symbol: string;
|
||||
currency: Currency;
|
||||
userCurrency: Currency;
|
||||
}
|
||||
|
||||
export interface GetValuesParams {
|
||||
dateQuery: DateQuery;
|
||||
symbols: string[];
|
||||
currencies: { [symbol: string]: Currency };
|
||||
userCurrency: Currency;
|
||||
}
|
||||
|
||||
export interface GetValueObject {
|
||||
date: Date;
|
||||
symbol: string;
|
||||
marketPrice: number;
|
||||
}
|
||||
|
5
apps/api/src/app/core/get-value.object.ts
Normal file
5
apps/api/src/app/core/get-value.object.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface GetValueObject {
|
||||
date: Date;
|
||||
symbol: string;
|
||||
marketPrice: number;
|
||||
}
|
8
apps/api/src/app/core/get-value.params.ts
Normal file
8
apps/api/src/app/core/get-value.params.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Currency } from '@prisma/client';
|
||||
|
||||
export interface GetValueParams {
|
||||
date: Date;
|
||||
symbol: string;
|
||||
currency: Currency;
|
||||
userCurrency: Currency;
|
||||
}
|
9
apps/api/src/app/core/get-values.params.ts
Normal file
9
apps/api/src/app/core/get-values.params.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { DateQuery } from '@ghostfolio/api/app/core/market-data.service';
|
||||
import { Currency } from '@prisma/client';
|
||||
|
||||
export interface GetValuesParams {
|
||||
dateQuery: DateQuery;
|
||||
symbols: string[];
|
||||
currencies: { [symbol: string]: Currency };
|
||||
userCurrency: Currency;
|
||||
}
|
@ -1,15 +1,7 @@
|
||||
import {
|
||||
CurrentRateService,
|
||||
GetValueParams,
|
||||
GetValuesParams
|
||||
CurrentRateService
|
||||
} from '@ghostfolio/api/app/core/current-rate.service';
|
||||
import {
|
||||
PortfolioCalculator,
|
||||
PortfolioOrder,
|
||||
TimelinePeriod,
|
||||
TimelineSpecification,
|
||||
TransactionPoint
|
||||
} from '@ghostfolio/api/app/core/portfolio-calculator';
|
||||
import { PortfolioCalculator } from '@ghostfolio/api/app/core/portfolio-calculator';
|
||||
import { OrderType } from '@ghostfolio/api/models/order-type';
|
||||
import { resetHours } from '@ghostfolio/common/helper';
|
||||
import { Currency } from '@prisma/client';
|
||||
@ -21,6 +13,12 @@ import {
|
||||
isBefore,
|
||||
parse
|
||||
} from 'date-fns';
|
||||
import { PortfolioOrder } from '@ghostfolio/api/app/core/portfolio-order';
|
||||
import { TimelinePeriod } from '@ghostfolio/api/app/core/timeline-period';
|
||||
import { TimelineSpecification } from '@ghostfolio/api/app/core/timeline-specification';
|
||||
import { TransactionPoint } from '@ghostfolio/api/app/core/transaction-point';
|
||||
import { GetValuesParams } from '@ghostfolio/api/app/core/get-values.params';
|
||||
import { GetValueParams } from '@ghostfolio/api/app/core/get-value.params';
|
||||
|
||||
function toYearMonthDay(date: Date) {
|
||||
const year = date.getFullYear();
|
||||
|
@ -1,7 +1,4 @@
|
||||
import {
|
||||
CurrentRateService,
|
||||
GetValueObject
|
||||
} from '@ghostfolio/api/app/core/current-rate.service';
|
||||
import { CurrentRateService } from '@ghostfolio/api/app/core/current-rate.service';
|
||||
import { OrderType } from '@ghostfolio/api/models/order-type';
|
||||
import { DATE_FORMAT, parseDate, resetHours } from '@ghostfolio/common/helper';
|
||||
import { TimelinePosition } from '@ghostfolio/common/interfaces';
|
||||
@ -20,6 +17,15 @@ import {
|
||||
subDays
|
||||
} from 'date-fns';
|
||||
import { flatten } from 'lodash';
|
||||
import { PortfolioOrder } from '@ghostfolio/api/app/core/portfolio-order';
|
||||
import { TimelinePeriod } from '@ghostfolio/api/app/core/timeline-period';
|
||||
import {
|
||||
Accuracy,
|
||||
TimelineSpecification
|
||||
} from '@ghostfolio/api/app/core/timeline-specification';
|
||||
import { TransactionPointSymbol } from '@ghostfolio/api/app/core/transaction-point-symbol';
|
||||
import { TransactionPoint } from '@ghostfolio/api/app/core/transaction-point';
|
||||
import { GetValueObject } from '@ghostfolio/api/app/core/get-value.object';
|
||||
|
||||
export class PortfolioCalculator {
|
||||
private transactionPoints: TransactionPoint[];
|
||||
@ -483,42 +489,3 @@ export class PortfolioCalculator {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TransactionPoint {
|
||||
date: string;
|
||||
items: TransactionPointSymbol[];
|
||||
}
|
||||
|
||||
interface TransactionPointSymbol {
|
||||
currency: Currency;
|
||||
firstBuyDate: string;
|
||||
investment: Big;
|
||||
name: string;
|
||||
quantity: Big;
|
||||
symbol: string;
|
||||
transactionCount: number;
|
||||
}
|
||||
|
||||
type Accuracy = 'year' | 'month' | 'day';
|
||||
|
||||
export interface TimelineSpecification {
|
||||
start: string;
|
||||
accuracy: Accuracy;
|
||||
}
|
||||
|
||||
export interface TimelinePeriod {
|
||||
date: string;
|
||||
grossPerformance: Big;
|
||||
investment: Big;
|
||||
value: Big;
|
||||
}
|
||||
|
||||
export interface PortfolioOrder {
|
||||
currency: Currency;
|
||||
date: string;
|
||||
name: string;
|
||||
quantity: Big;
|
||||
symbol: string;
|
||||
type: OrderType;
|
||||
unitPrice: Big;
|
||||
}
|
||||
|
13
apps/api/src/app/core/portfolio-order.ts
Normal file
13
apps/api/src/app/core/portfolio-order.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Currency } from '@prisma/client';
|
||||
import Big from 'big.js';
|
||||
import { OrderType } from '@ghostfolio/api/models/order-type';
|
||||
|
||||
export interface PortfolioOrder {
|
||||
currency: Currency;
|
||||
date: string;
|
||||
name: string;
|
||||
quantity: Big;
|
||||
symbol: string;
|
||||
type: OrderType;
|
||||
unitPrice: Big;
|
||||
}
|
8
apps/api/src/app/core/timeline-period.ts
Normal file
8
apps/api/src/app/core/timeline-period.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import Big from 'big.js';
|
||||
|
||||
export interface TimelinePeriod {
|
||||
date: string;
|
||||
grossPerformance: Big;
|
||||
investment: Big;
|
||||
value: Big;
|
||||
}
|
6
apps/api/src/app/core/timeline-specification.ts
Normal file
6
apps/api/src/app/core/timeline-specification.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export type Accuracy = 'year' | 'month' | 'day';
|
||||
|
||||
export interface TimelineSpecification {
|
||||
start: string;
|
||||
accuracy: Accuracy;
|
||||
}
|
12
apps/api/src/app/core/transaction-point-symbol.ts
Normal file
12
apps/api/src/app/core/transaction-point-symbol.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Currency } from '@prisma/client';
|
||||
import Big from 'big.js';
|
||||
|
||||
export interface TransactionPointSymbol {
|
||||
currency: Currency;
|
||||
firstBuyDate: string;
|
||||
investment: Big;
|
||||
name: string;
|
||||
quantity: Big;
|
||||
symbol: string;
|
||||
transactionCount: number;
|
||||
}
|
6
apps/api/src/app/core/transaction-point.ts
Normal file
6
apps/api/src/app/core/transaction-point.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { TransactionPointSymbol } from '@ghostfolio/api/app/core/transaction-point-symbol';
|
||||
|
||||
export interface TransactionPoint {
|
||||
date: string;
|
||||
items: TransactionPointSymbol[];
|
||||
}
|
@ -1,10 +1,6 @@
|
||||
import { AccountService } from '@ghostfolio/api/app/account/account.service';
|
||||
import { CurrentRateService } from '@ghostfolio/api/app/core/current-rate.service';
|
||||
import {
|
||||
PortfolioCalculator,
|
||||
PortfolioOrder,
|
||||
TimelineSpecification
|
||||
} from '@ghostfolio/api/app/core/portfolio-calculator';
|
||||
import { PortfolioCalculator } from '@ghostfolio/api/app/core/portfolio-calculator';
|
||||
import { OrderService } from '@ghostfolio/api/app/order/order.service';
|
||||
import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service';
|
||||
import { UserService } from '@ghostfolio/api/app/user/user.service';
|
||||
@ -53,6 +49,8 @@ import {
|
||||
PortfolioPositionDetail
|
||||
} from './interfaces/portfolio-position-detail.interface';
|
||||
import { parseDate } from '@ghostfolio/common/helper';
|
||||
import { PortfolioOrder } from '@ghostfolio/api/app/core/portfolio-order';
|
||||
import { TimelineSpecification } from '@ghostfolio/api/app/core/timeline-specification';
|
||||
|
||||
@Injectable()
|
||||
export class PortfolioService {
|
||||
|
Loading…
x
Reference in New Issue
Block a user