Refactoring
This commit is contained in:
parent
e7ef1d426e
commit
8571709014
@ -103,14 +103,14 @@ export class PortfolioCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setTransactionPoints(transactionPoints: TransactionPoint[]) {
|
|
||||||
this.transactionPoints = transactionPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getTransactionPoints(): TransactionPoint[] {
|
public getTransactionPoints(): TransactionPoint[] {
|
||||||
return this.transactionPoints;
|
return this.transactionPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setTransactionPoints(transactionPoints: TransactionPoint[]) {
|
||||||
|
this.transactionPoints = transactionPoints;
|
||||||
|
}
|
||||||
|
|
||||||
public async getCurrentPositions(start: Date): Promise<{
|
public async getCurrentPositions(start: Date): Promise<{
|
||||||
hasErrors: boolean;
|
hasErrors: boolean;
|
||||||
positions: TimelinePosition[];
|
positions: TimelinePosition[];
|
||||||
@ -331,35 +331,6 @@ export class PortfolioCalculator {
|
|||||||
return flatten(timelinePeriods);
|
return flatten(timelinePeriods);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getMarketValues(
|
|
||||||
transactionPoint: TransactionPoint,
|
|
||||||
dateRangeStart: Date,
|
|
||||||
dateRangeEnd: Date
|
|
||||||
) {
|
|
||||||
const symbols: string[] = [];
|
|
||||||
const currencies: { [symbol: string]: Currency } = {};
|
|
||||||
|
|
||||||
for (const item of transactionPoint.items) {
|
|
||||||
symbols.push(item.symbol);
|
|
||||||
currencies[item.symbol] = item.currency;
|
|
||||||
}
|
|
||||||
const values = await this.currentRateService.getValues({
|
|
||||||
dateQuery: {
|
|
||||||
gte: dateRangeStart,
|
|
||||||
lt: endOfDay(dateRangeEnd)
|
|
||||||
},
|
|
||||||
symbols,
|
|
||||||
currencies,
|
|
||||||
userCurrency: this.currency
|
|
||||||
});
|
|
||||||
|
|
||||||
const marketValues: { [symbol: string]: GetValueObject } = {};
|
|
||||||
for (const value of values) {
|
|
||||||
marketValues[value.symbol] = value;
|
|
||||||
}
|
|
||||||
return marketValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getTimePeriodForDate(
|
private async getTimePeriodForDate(
|
||||||
j: number,
|
j: number,
|
||||||
startDate: Date,
|
startDate: Date,
|
||||||
@ -450,6 +421,7 @@ export class PortfolioCalculator {
|
|||||||
|
|
||||||
private getFactor(type: OrderType) {
|
private getFactor(type: OrderType) {
|
||||||
let factor: number;
|
let factor: number;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OrderType.Buy:
|
case OrderType.Buy:
|
||||||
factor = 1;
|
factor = 1;
|
||||||
@ -461,6 +433,7 @@ export class PortfolioCalculator {
|
|||||||
factor = 0;
|
factor = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return factor;
|
return factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user