Feature/add asset and asset sub class to search endpoint (#1795)
* Add asset and asset sub class to search endpoint * Update changelog
This commit is contained in:
parent
a0bec9e97f
commit
bd1963ec26
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- Added the asset and asset sub class to the search functionality
|
||||
- Added the subscription expiration date to the users table of the admin control panel
|
||||
|
||||
### Changed
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { DataSource } from '@prisma/client';
|
||||
import { AssetClass, AssetSubClass, DataSource } from '@prisma/client';
|
||||
|
||||
export interface LookupItem {
|
||||
assetClass: AssetClass;
|
||||
assetSubClass: AssetSubClass;
|
||||
currency: string;
|
||||
dataSource: DataSource;
|
||||
name: string;
|
||||
|
@ -176,6 +176,8 @@ export class CoinGeckoService implements DataProviderInterface {
|
||||
return {
|
||||
name,
|
||||
symbol,
|
||||
assetClass: AssetClass.CASH,
|
||||
assetSubClass: AssetSubClass.CRYPTOCURRENCY,
|
||||
currency: this.baseCurrency,
|
||||
dataSource: this.getName()
|
||||
};
|
||||
|
@ -171,9 +171,25 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
||||
.filter(({ symbol }) => {
|
||||
return !symbol.toLowerCase().endsWith('forex');
|
||||
})
|
||||
.map(({ currency, dataSource, name, symbol }) => {
|
||||
return { currency, dataSource, name, symbol };
|
||||
})
|
||||
.map(
|
||||
({
|
||||
assetClass,
|
||||
assetSubClass,
|
||||
currency,
|
||||
dataSource,
|
||||
name,
|
||||
symbol
|
||||
}) => {
|
||||
return {
|
||||
assetClass,
|
||||
assetSubClass,
|
||||
currency,
|
||||
dataSource,
|
||||
name,
|
||||
symbol
|
||||
};
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,8 @@ export class GoogleSheetsService implements DataProviderInterface {
|
||||
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
||||
const items = await this.prismaService.symbolProfile.findMany({
|
||||
select: {
|
||||
assetClass: true,
|
||||
assetSubClass: true,
|
||||
currency: true,
|
||||
dataSource: true,
|
||||
name: true,
|
||||
|
@ -165,6 +165,8 @@ export class ManualService implements DataProviderInterface {
|
||||
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
||||
let items = await this.prismaService.symbolProfile.findMany({
|
||||
select: {
|
||||
assetClass: true,
|
||||
assetSubClass: true,
|
||||
currency: true,
|
||||
dataSource: true,
|
||||
name: true,
|
||||
|
@ -101,9 +101,10 @@ export class YahooFinanceService implements DataProviderInterface {
|
||||
modules: ['price', 'summaryProfile', 'topHoldings']
|
||||
});
|
||||
|
||||
const { assetClass, assetSubClass } = this.parseAssetClass(
|
||||
assetProfile.price
|
||||
);
|
||||
const { assetClass, assetSubClass } = this.parseAssetClass({
|
||||
quoteType: assetProfile.price.quoteType,
|
||||
shortName: assetProfile.price.shortName
|
||||
});
|
||||
|
||||
response.assetClass = assetClass;
|
||||
response.assetSubClass = assetSubClass;
|
||||
@ -408,7 +409,14 @@ export class YahooFinanceService implements DataProviderInterface {
|
||||
marketDataItem.symbol
|
||||
);
|
||||
|
||||
const { assetClass, assetSubClass } = this.parseAssetClass({
|
||||
quoteType: quote.quoteType,
|
||||
shortName: quote.shortname
|
||||
});
|
||||
|
||||
items.push({
|
||||
assetClass,
|
||||
assetSubClass,
|
||||
symbol,
|
||||
currency: marketDataItem.currency,
|
||||
dataSource: this.getName(),
|
||||
@ -484,14 +492,20 @@ export class YahooFinanceService implements DataProviderInterface {
|
||||
return value;
|
||||
}
|
||||
|
||||
private parseAssetClass(aPrice: Price): {
|
||||
private parseAssetClass({
|
||||
quoteType,
|
||||
shortName
|
||||
}: {
|
||||
quoteType: string;
|
||||
shortName: string;
|
||||
}): {
|
||||
assetClass: AssetClass;
|
||||
assetSubClass: AssetSubClass;
|
||||
} {
|
||||
let assetClass: AssetClass;
|
||||
let assetSubClass: AssetSubClass;
|
||||
|
||||
switch (aPrice?.quoteType?.toLowerCase()) {
|
||||
switch (quoteType?.toLowerCase()) {
|
||||
case 'cryptocurrency':
|
||||
assetClass = AssetClass.CASH;
|
||||
assetSubClass = AssetSubClass.CRYPTOCURRENCY;
|
||||
@ -509,10 +523,10 @@ export class YahooFinanceService implements DataProviderInterface {
|
||||
assetSubClass = AssetSubClass.COMMODITY;
|
||||
|
||||
if (
|
||||
aPrice?.shortName?.toLowerCase()?.startsWith('gold') ||
|
||||
aPrice?.shortName?.toLowerCase()?.startsWith('palladium') ||
|
||||
aPrice?.shortName?.toLowerCase()?.startsWith('platinum') ||
|
||||
aPrice?.shortName?.toLowerCase()?.startsWith('silver')
|
||||
shortName?.toLowerCase()?.startsWith('gold') ||
|
||||
shortName?.toLowerCase()?.startsWith('palladium') ||
|
||||
shortName?.toLowerCase()?.startsWith('platinum') ||
|
||||
shortName?.toLowerCase()?.startsWith('silver')
|
||||
) {
|
||||
assetSubClass = AssetSubClass.PRECIOUS_METAL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user