mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
219 changed files with 16373 additions and 13576 deletions
@ -1,6 +1,6 @@ |
|||
# Run linting and stop the commit process if any errors are found |
|||
# --quiet suppresses warnings (temporary until all warnings are fixed) |
|||
npm run lint --quiet || exit 1 |
|||
npm run affected:lint --base=main --head=HEAD --parallel=2 --quiet || exit 1 |
|||
|
|||
# Check formatting on modified and uncommitted files, stop the commit if issues are found |
|||
npm run format:check --uncommitted || exit 1 |
|||
|
@ -0,0 +1,84 @@ |
|||
import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface'; |
|||
import { Rule } from '@ghostfolio/api/models/rule'; |
|||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; |
|||
import { UserSettings } from '@ghostfolio/common/interfaces'; |
|||
|
|||
export class EconomicMarketClusterRiskDevelopedMarkets extends Rule<Settings> { |
|||
private currentValueInBaseCurrency: number; |
|||
private developedMarketsValueInBaseCurrency: number; |
|||
|
|||
public constructor( |
|||
protected exchangeRateDataService: ExchangeRateDataService, |
|||
currentValueInBaseCurrency: number, |
|||
developedMarketsValueInBaseCurrency: number |
|||
) { |
|||
super(exchangeRateDataService, { |
|||
key: EconomicMarketClusterRiskDevelopedMarkets.name, |
|||
name: 'Developed Markets' |
|||
}); |
|||
|
|||
this.currentValueInBaseCurrency = currentValueInBaseCurrency; |
|||
this.developedMarketsValueInBaseCurrency = |
|||
developedMarketsValueInBaseCurrency; |
|||
} |
|||
|
|||
public evaluate(ruleSettings: Settings) { |
|||
const developedMarketsValueRatio = this.currentValueInBaseCurrency |
|||
? this.developedMarketsValueInBaseCurrency / |
|||
this.currentValueInBaseCurrency |
|||
: 0; |
|||
|
|||
if (developedMarketsValueRatio > ruleSettings.thresholdMax) { |
|||
return { |
|||
evaluation: `The developed markets contribution of your current investment (${(developedMarketsValueRatio * 100).toPrecision(3)}%) exceeds ${( |
|||
ruleSettings.thresholdMax * 100 |
|||
).toPrecision(3)}%`,
|
|||
value: false |
|||
}; |
|||
} else if (developedMarketsValueRatio < ruleSettings.thresholdMin) { |
|||
return { |
|||
evaluation: `The developed markets contribution of your current investment (${(developedMarketsValueRatio * 100).toPrecision(3)}%) is below ${( |
|||
ruleSettings.thresholdMin * 100 |
|||
).toPrecision(3)}%`,
|
|||
value: false |
|||
}; |
|||
} |
|||
|
|||
return { |
|||
evaluation: `The developed markets contribution of your current investment (${(developedMarketsValueRatio * 100).toPrecision(3)}%) is within the range of ${( |
|||
ruleSettings.thresholdMin * 100 |
|||
).toPrecision( |
|||
3 |
|||
)}% and ${(ruleSettings.thresholdMax * 100).toPrecision(3)}%`,
|
|||
value: true |
|||
}; |
|||
} |
|||
|
|||
public getConfiguration() { |
|||
return { |
|||
threshold: { |
|||
max: 1, |
|||
min: 0, |
|||
step: 0.01, |
|||
unit: '%' |
|||
}, |
|||
thresholdMax: true, |
|||
thresholdMin: true |
|||
}; |
|||
} |
|||
|
|||
public getSettings({ baseCurrency, xRayRules }: UserSettings): Settings { |
|||
return { |
|||
baseCurrency, |
|||
isActive: xRayRules?.[this.getKey()]?.isActive ?? true, |
|||
thresholdMax: xRayRules?.[this.getKey()]?.thresholdMax ?? 0.72, |
|||
thresholdMin: xRayRules?.[this.getKey()]?.thresholdMin ?? 0.68 |
|||
}; |
|||
} |
|||
} |
|||
|
|||
interface Settings extends RuleSettings { |
|||
baseCurrency: string; |
|||
thresholdMin: number; |
|||
thresholdMax: number; |
|||
} |
@ -0,0 +1,84 @@ |
|||
import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface'; |
|||
import { Rule } from '@ghostfolio/api/models/rule'; |
|||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; |
|||
import { UserSettings } from '@ghostfolio/common/interfaces'; |
|||
|
|||
export class EconomicMarketClusterRiskEmergingMarkets extends Rule<Settings> { |
|||
private currentValueInBaseCurrency: number; |
|||
private emergingMarketsValueInBaseCurrency: number; |
|||
|
|||
public constructor( |
|||
protected exchangeRateDataService: ExchangeRateDataService, |
|||
currentValueInBaseCurrency: number, |
|||
emergingMarketsValueInBaseCurrency: number |
|||
) { |
|||
super(exchangeRateDataService, { |
|||
key: EconomicMarketClusterRiskEmergingMarkets.name, |
|||
name: 'Emerging Markets' |
|||
}); |
|||
|
|||
this.currentValueInBaseCurrency = currentValueInBaseCurrency; |
|||
this.emergingMarketsValueInBaseCurrency = |
|||
emergingMarketsValueInBaseCurrency; |
|||
} |
|||
|
|||
public evaluate(ruleSettings: Settings) { |
|||
const emergingMarketsValueRatio = this.currentValueInBaseCurrency |
|||
? this.emergingMarketsValueInBaseCurrency / |
|||
this.currentValueInBaseCurrency |
|||
: 0; |
|||
|
|||
if (emergingMarketsValueRatio > ruleSettings.thresholdMax) { |
|||
return { |
|||
evaluation: `The emerging markets contribution of your current investment (${(emergingMarketsValueRatio * 100).toPrecision(3)}%) exceeds ${( |
|||
ruleSettings.thresholdMax * 100 |
|||
).toPrecision(3)}%`,
|
|||
value: false |
|||
}; |
|||
} else if (emergingMarketsValueRatio < ruleSettings.thresholdMin) { |
|||
return { |
|||
evaluation: `The emerging markets contribution of your current investment (${(emergingMarketsValueRatio * 100).toPrecision(3)}%) is below ${( |
|||
ruleSettings.thresholdMin * 100 |
|||
).toPrecision(3)}%`,
|
|||
value: false |
|||
}; |
|||
} |
|||
|
|||
return { |
|||
evaluation: `The emerging markets contribution of your current investment (${(emergingMarketsValueRatio * 100).toPrecision(3)}%) is within the range of ${( |
|||
ruleSettings.thresholdMin * 100 |
|||
).toPrecision( |
|||
3 |
|||
)}% and ${(ruleSettings.thresholdMax * 100).toPrecision(3)}%`,
|
|||
value: true |
|||
}; |
|||
} |
|||
|
|||
public getConfiguration() { |
|||
return { |
|||
threshold: { |
|||
max: 1, |
|||
min: 0, |
|||
step: 0.01, |
|||
unit: '%' |
|||
}, |
|||
thresholdMax: true, |
|||
thresholdMin: true |
|||
}; |
|||
} |
|||
|
|||
public getSettings({ baseCurrency, xRayRules }: UserSettings): Settings { |
|||
return { |
|||
baseCurrency, |
|||
isActive: xRayRules?.[this.getKey()]?.isActive ?? true, |
|||
thresholdMax: xRayRules?.[this.getKey()]?.thresholdMax ?? 0.32, |
|||
thresholdMin: xRayRules?.[this.getKey()]?.thresholdMin ?? 0.28 |
|||
}; |
|||
} |
|||
} |
|||
|
|||
interface Settings extends RuleSettings { |
|||
baseCurrency: string; |
|||
thresholdMin: number; |
|||
thresholdMax: number; |
|||
} |
@ -0,0 +1,39 @@ |
|||
import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; |
|||
|
|||
import { CommonModule } from '@angular/common'; |
|||
import { Component, Inject } from '@angular/core'; |
|||
import { MatButtonModule } from '@angular/material/button'; |
|||
import { |
|||
MAT_DIALOG_DATA, |
|||
MatDialogModule, |
|||
MatDialogRef |
|||
} from '@angular/material/dialog'; |
|||
|
|||
import { GfDialogFooterModule } from '../../dialog-footer/dialog-footer.module'; |
|||
import { GfDialogHeaderModule } from '../../dialog-header/dialog-header.module'; |
|||
import { GhostfolioPremiumApiDialogParams } from './interfaces/interfaces'; |
|||
|
|||
@Component({ |
|||
imports: [ |
|||
CommonModule, |
|||
GfDialogFooterModule, |
|||
GfDialogHeaderModule, |
|||
GfPremiumIndicatorComponent, |
|||
MatButtonModule, |
|||
MatDialogModule |
|||
], |
|||
selector: 'gf-ghostfolio-premium-api-dialog', |
|||
standalone: true, |
|||
styleUrls: ['./ghostfolio-premium-api-dialog.scss'], |
|||
templateUrl: './ghostfolio-premium-api-dialog.html' |
|||
}) |
|||
export class GfGhostfolioPremiumApiDialogComponent { |
|||
public constructor( |
|||
@Inject(MAT_DIALOG_DATA) public data: GhostfolioPremiumApiDialogParams, |
|||
public dialogRef: MatDialogRef<GfGhostfolioPremiumApiDialogComponent> |
|||
) {} |
|||
|
|||
public onCancel() { |
|||
this.dialogRef.close(); |
|||
} |
|||
} |
@ -0,0 +1,42 @@ |
|||
<gf-dialog-header |
|||
mat-dialog-title |
|||
position="center" |
|||
title="Ghostfolio Premium Data Provider" |
|||
[deviceType]="data.deviceType" |
|||
(closeButtonClicked)="onCancel()" |
|||
/> |
|||
|
|||
<div class="text-center" mat-dialog-content> |
|||
<p class="gf-text-wrap-balance mb-1"> |
|||
The official |
|||
<a |
|||
class="align-items-center d-inline-flex" |
|||
target="_blank" |
|||
[href]="data.pricingUrl" |
|||
>Ghostfolio Premium |
|||
<gf-premium-indicator class="d-inline-block ml-1" [enableLink]="false" /> |
|||
</a> |
|||
data provider <strong>for self-hosters</strong>, offering |
|||
<strong>100’000+ tickers</strong> from over <strong>50 exchanges</strong>, |
|||
is coming soon! |
|||
</p> |
|||
<p i18n> |
|||
Want to stay updated? Click below to get notified as soon as it’s available. |
|||
</p> |
|||
<div> |
|||
<a |
|||
color="primary" |
|||
href="mailto:hi@ghostfol.io?Subject=Ghostfolio Premium Data Provider&body=Hello%0D%0DPlease notify me as soon as the Ghostfolio Premium Data Provider is available.%0D%0DKind regards" |
|||
i18n |
|||
mat-flat-button |
|||
> |
|||
Notify me |
|||
</a> |
|||
</div> |
|||
</div> |
|||
|
|||
<gf-dialog-footer |
|||
mat-dialog-actions |
|||
[deviceType]="data.deviceType" |
|||
(closeButtonClicked)="onCancel()" |
|||
/> |
@ -0,0 +1,2 @@ |
|||
:host { |
|||
} |
@ -0,0 +1,4 @@ |
|||
export interface GhostfolioPremiumApiDialogParams { |
|||
deviceType: string; |
|||
pricingUrl: string; |
|||
} |
@ -1,5 +1,9 @@ |
|||
import { PortfolioReportRule } from '@ghostfolio/common/interfaces'; |
|||
import { |
|||
PortfolioReportRule, |
|||
XRayRulesSettings |
|||
} from '@ghostfolio/common/interfaces'; |
|||
|
|||
export interface IRuleSettingsDialogParams { |
|||
rule: PortfolioReportRule; |
|||
settings: XRayRulesSettings['AccountClusterRiskCurrentInvestment']; |
|||
} |
|||
|
@ -1,37 +1,85 @@ |
|||
<div mat-dialog-title>{{ data.rule.name }}</div> |
|||
|
|||
<div class="py-3" mat-dialog-content> |
|||
<mat-form-field |
|||
appearance="outline" |
|||
<div |
|||
class="w-100" |
|||
[ngClass]="{ 'd-none': settings.thresholdMin === undefined }" |
|||
[ngClass]="{ 'd-none': !data.rule.configuration.thresholdMin }" |
|||
> |
|||
<mat-label i18n>Threshold Min</mat-label> |
|||
<input |
|||
matInput |
|||
<h6 class="mb-0"> |
|||
<ng-container i18n>Threshold Min</ng-container>: |
|||
@if (data.rule.configuration.threshold.unit === '%') { |
|||
{{ data.settings.thresholdMin | percent: '1.2-2' }} |
|||
} @else { |
|||
{{ data.settings.thresholdMin }} |
|||
} |
|||
</h6> |
|||
@if (data.rule.configuration.threshold.unit === '%') { |
|||
<label>{{ |
|||
data.rule.configuration.threshold.min | percent: '1.2-2' |
|||
}}</label> |
|||
} @else { |
|||
<label>{{ data.rule.configuration.threshold.min }}</label> |
|||
} |
|||
<mat-slider |
|||
name="thresholdMin" |
|||
type="number" |
|||
[(ngModel)]="settings.thresholdMin" |
|||
/> |
|||
</mat-form-field> |
|||
<mat-form-field |
|||
appearance="outline" |
|||
[max]="data.rule.configuration.threshold.max" |
|||
[min]="data.rule.configuration.threshold.min" |
|||
[step]="data.rule.configuration.threshold.step" |
|||
> |
|||
<input matSliderThumb [(ngModel)]="data.settings.thresholdMin" /> |
|||
</mat-slider> |
|||
@if (data.rule.configuration.threshold.unit === '%') { |
|||
<label>{{ |
|||
data.rule.configuration.threshold.max | percent: '1.2-2' |
|||
}}</label> |
|||
} @else { |
|||
<label>{{ data.rule.configuration.threshold.max }}</label> |
|||
} |
|||
</div> |
|||
<div |
|||
class="w-100" |
|||
[ngClass]="{ 'd-none': settings.thresholdMax === undefined }" |
|||
[ngClass]="{ 'd-none': !data.rule.configuration.thresholdMax }" |
|||
> |
|||
<mat-label i18n>Threshold Max</mat-label> |
|||
<input |
|||
matInput |
|||
<h6 class="mb-0"> |
|||
<ng-container i18n>Threshold Max</ng-container>: |
|||
@if (data.rule.configuration.threshold.unit === '%') { |
|||
{{ data.settings.thresholdMax | percent: '1.2-2' }} |
|||
} @else { |
|||
{{ data.settings.thresholdMax }} |
|||
} |
|||
</h6> |
|||
@if (data.rule.configuration.threshold.unit === '%') { |
|||
<label>{{ |
|||
data.rule.configuration.threshold.min | percent: '1.2-2' |
|||
}}</label> |
|||
} @else { |
|||
<label>{{ data.rule.configuration.threshold.min }}</label> |
|||
} |
|||
<mat-slider |
|||
name="thresholdMax" |
|||
type="number" |
|||
[(ngModel)]="settings.thresholdMax" |
|||
/> |
|||
</mat-form-field> |
|||
[max]="data.rule.configuration.threshold.max" |
|||
[min]="data.rule.configuration.threshold.min" |
|||
[step]="data.rule.configuration.threshold.step" |
|||
> |
|||
<input matSliderThumb [(ngModel)]="data.settings.thresholdMax" /> |
|||
</mat-slider> |
|||
@if (data.rule.configuration.threshold.unit === '%') { |
|||
<label>{{ |
|||
data.rule.configuration.threshold.max | percent: '1.2-2' |
|||
}}</label> |
|||
} @else { |
|||
<label>{{ data.rule.configuration.threshold.max }}</label> |
|||
} |
|||
</div> |
|||
</div> |
|||
|
|||
<div align="end" mat-dialog-actions> |
|||
<button i18n mat-button (click)="dialogRef.close()">Close</button> |
|||
<button color="primary" mat-flat-button (click)="dialogRef.close(settings)"> |
|||
<button |
|||
color="primary" |
|||
mat-flat-button |
|||
(click)="dialogRef.close(data.settings)" |
|||
> |
|||
<ng-container i18n>Save</ng-container> |
|||
</button> |
|||
</div> |
|||
|
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue