Browse Source

Add additional time horizon options for portfolio performance.

This mirrors the time horizons used in popular finance tracking websites online.
pull/2405/head
Prashanth Mohan 2 years ago
parent
commit
3b901446f1
  1. 2
      README.md
  2. 19
      apps/api/src/app/portfolio/portfolio.service.ts
  3. 2
      apps/api/src/app/user/update-user-setting.dto.ts
  4. 3
      apps/client/src/app/components/toggle/toggle.component.ts
  5. 3
      apps/client/src/app/pages/features/features-page.html
  6. 2
      libs/common/src/lib/types/date-range.type.ts

2
README.md

@ -49,7 +49,7 @@ Ghostfolio is for you if you are...
- ✅ Create, update and delete transactions
- ✅ Multi account management
- ✅ Portfolio performance for `Today`, `YTD`, `1Y`, `5Y`, `Max`
- ✅ Portfolio performance for `Today`, `1D`, `5D`, `1M`, `6M`, `YTD`, `1Y`, `5Y`, `Max`
- ✅ Various charts
- ✅ Static analysis to identify potential risks in your portfolio
- ✅ Import and export transactions

19
apps/api/src/app/portfolio/portfolio.service.ts

@ -71,6 +71,7 @@ import {
set,
setDayOfYear,
subDays,
subMonths,
subYears
} from 'date-fns';
import { isEmpty, sortBy, uniq, uniqBy } from 'lodash';
@ -1493,6 +1494,24 @@ export class PortfolioService {
subDays(new Date().setHours(0, 0, 0, 0), 1)
]);
break;
case '5d':
portfolioStart = max([
portfolioStart,
subDays(new Date().setHours(0, 0, 0, 0), 5)
]);
break;
case '1m':
portfolioStart = max([
portfolioStart,
subMonths(new Date().setHours(0, 0, 0, 0), 1)
]);
break;
case '6m':
portfolioStart = max([
portfolioStart,
subMonths(new Date().setHours(0, 0, 0, 0), 6)
]);
break;
case 'ytd':
portfolioStart = max([
portfolioStart,

2
apps/api/src/app/user/update-user-setting.dto.ts

@ -29,7 +29,7 @@ export class UpdateUserSettingDto {
@IsOptional()
colorScheme?: ColorScheme;
@IsIn(<DateRange[]>['1d', '1y', '5y', 'max', 'ytd'])
@IsIn(<DateRange[]>['1d', '5d', '1m', '6m', '1y', '5y', 'max', 'ytd'])
@IsOptional()
dateRange?: DateRange;

3
apps/client/src/app/components/toggle/toggle.component.ts

@ -19,6 +19,9 @@ import { ToggleOption } from '@ghostfolio/common/types';
export class ToggleComponent implements OnChanges, OnInit {
public static DEFAULT_DATE_RANGE_OPTIONS: ToggleOption[] = [
{ label: $localize`Today`, value: '1d' },
{ label: $localize`5D`, value: '5d' },
{ label: $localize`1M`, value: '1m' },
{ label: $localize`6M`, value: '6m' },
{ label: $localize`YTD`, value: 'ytd' },
{ label: $localize`1Y`, value: '1y' },
{ label: $localize`5Y`, value: '5y' },

3
apps/client/src/app/pages/features/features-page.html

@ -146,7 +146,8 @@
</h4>
<p class="m-0">
Check the rate of return of your portfolio for
<code>Today</code>, <code>YTD</code>, <code>1Y</code>,
<code>Today</code>, <code>5D</code>, <code>1M</code>,
<code>6M</code>, <code>YTD</code>, <code>1Y</code>,
<code>5Y</code>, and <code>Max</code>.
</p>
</div>

2
libs/common/src/lib/types/date-range.type.ts

@ -1 +1 @@
export type DateRange = '1d' | '1y' | '5y' | 'max' | 'ytd';
export type DateRange = '1d' | '5d' | '1m' | '6m' | '1y' | '5y' | 'max' | 'ytd';

Loading…
Cancel
Save