| 
						
						
							
								
							
						
						
					 | 
					@ -14,6 +14,27 @@ import type { ColumnDescriptor } from 'tablemark'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					@Injectable() | 
					 | 
					 | 
					@Injectable() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					export class AiService { | 
					 | 
					 | 
					export class AiService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  private static readonly HOLDINGS_TABLE_COLUMN_DEFINITIONS: ({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    key: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      | 'ALLOCATION_PERCENTAGE' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      | 'ASSET_CLASS' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      | 'ASSET_SUB_CLASS' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      | 'CURRENCY' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      | 'NAME' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      | 'SYMBOL'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  } & ColumnDescriptor)[] = [ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    { key: 'NAME', name: 'Name' }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    { key: 'SYMBOL', name: 'Symbol' }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    { key: 'CURRENCY', name: 'Currency' }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    { key: 'ASSET_CLASS', name: 'Asset Class' }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    { key: 'ASSET_SUB_CLASS', name: 'Asset Sub Class' }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      align: 'right', | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      key: 'ALLOCATION_PERCENTAGE', | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      name: 'Allocation in Percentage' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  ]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public constructor( | 
					 | 
					 | 
					  public constructor( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private readonly portfolioService: PortfolioService, | 
					 | 
					 | 
					    private readonly portfolioService: PortfolioService, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private readonly propertyService: PropertyService | 
					 | 
					 | 
					    private readonly propertyService: PropertyService | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -59,14 +80,10 @@ export class AiService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      userId | 
					 | 
					 | 
					      userId | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    }); | 
					 | 
					 | 
					    }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const holdingsTableColumns: ColumnDescriptor[] = [ | 
					 | 
					 | 
					    const holdingsTableColumns: ColumnDescriptor[] = | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      { name: 'Name' }, | 
					 | 
					 | 
					      AiService.HOLDINGS_TABLE_COLUMN_DEFINITIONS.map(({ align, name }) => { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      { name: 'Symbol' }, | 
					 | 
					 | 
					        return { name, align: align ?? 'left' }; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      { name: 'Currency' }, | 
					 | 
					 | 
					      }); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					      { name: 'Asset Class' }, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      { name: 'Asset Sub Class' }, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      { align: 'right', name: 'Allocation in Percentage' } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    ]; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const holdingsTableRows = Object.values(holdings) | 
					 | 
					 | 
					    const holdingsTableRows = Object.values(holdings) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      .sort((a, b) => { | 
					 | 
					 | 
					      .sort((a, b) => { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -78,17 +95,45 @@ export class AiService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          assetClass, | 
					 | 
					 | 
					          assetClass, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          assetSubClass, | 
					 | 
					 | 
					          assetSubClass, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          currency, | 
					 | 
					 | 
					          currency, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					          name, | 
					 | 
					 | 
					          name: label, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					          symbol | 
					 | 
					 | 
					          symbol | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        }) => { | 
					 | 
					 | 
					        }) => { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					          return { | 
					 | 
					 | 
					          return AiService.HOLDINGS_TABLE_COLUMN_DEFINITIONS.reduce( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            Name: name, | 
					 | 
					 | 
					            (row, { key, name }) => { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            Symbol: symbol, | 
					 | 
					 | 
					              switch (key) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            Currency: currency, | 
					 | 
					 | 
					                case 'ALLOCATION_PERCENTAGE': | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'Asset Class': assetClass ?? '', | 
					 | 
					 | 
					                  row[name] = `${(allocationInPercentage * 100).toFixed(3)}%`; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'Asset Sub Class': assetSubClass ?? '', | 
					 | 
					 | 
					                  break; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'Allocation in Percentage': `${(allocationInPercentage * 100).toFixed(3)}%` | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					          }; | 
					 | 
					 | 
					                case 'ASSET_CLASS': | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  row[name] = assetClass ?? ''; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                case 'ASSET_SUB_CLASS': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  row[name] = assetSubClass ?? ''; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                case 'CURRENCY': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  row[name] = currency; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                case 'NAME': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  row[name] = label; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                case 'SYMBOL': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  row[name] = symbol; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                default: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  row[name] = ''; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              return row; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            {} as Record<string, string> | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      ); | 
					 | 
					 | 
					      ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |