Nephila RiskStore

<back to all web services

GetAnalysisRequest

General
Requires Authentication
Requires any of the roles:Riskstore.Write, Riskstore.Admin
The following routes are available for this service:
GET/api/riskstore/analysis/resultsGet the analysis by id, this will return results if the analysis is completed
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


class ResultOutputLevel(str, Enum):
    NOT_SET = 'NotSet'
    PORTFOLIO_METRICS = 'PortfolioMetrics'
    CURVE = 'Curve'
    YLT = 'YLT'
    TAIL_INTENSITY = 'TailIntensity'
    DEAL_YLT = 'DealYlt'
    DEAL_ELT = 'DealElt'
    DEAL_ELT_WITH_INDUSTRY_LOSS = 'DealEltWithIndustryLoss'
    PORTFOLIO_ELT = 'PortfolioElt'
    PORTFOLIO_ELT_WITH_INDUSTRY_LOSS = 'PortfolioEltWithIndustryLoss'
    EVENT_SET_GENERATION = 'EventSetGeneration'
    PORTFOLIO_RAPS = 'PortfolioRaps'
    DEAL_RAPS = 'DealRaps'
    PORTFOLIO_SEPY_INDUSTRY_LOSS = 'PortfolioSepyIndustryLoss'
    DEAL_SEPY_INDUSTRY_LOSS = 'DealSepyIndustryLoss'


class ProcessingStatus(IntEnum):
    NEW = 0
    PROCESSING = 1
    FAILED = 10
    SUCCESSFUL = 20


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisPortfolioEventSetConfiguration(IObjectWithId, IHasAnalysisId):
    id: int = 0
    analysis_id: int = 0
    analysis_configuration_id: int = 0
    portfolio_name: Optional[str] = None
    model_id: Optional[str] = None
    row_identifier: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisConfiguration(IObjectWithId, IHasAnalysisId):
    id: int = 0
    analysis_id: int = 0
    window_start_date: Optional[datetime.datetime] = None
    window_end_date: Optional[datetime.datetime] = None
    standard_enabled: bool = False
    run_off_enabled: bool = False
    aggregate_enabled: bool = False
    occurrence_enabled: bool = False
    nett_enabled: bool = False
    gross_enabled: bool = False
    tail_intensity_percentage_start: Optional[Decimal] = None
    tail_intensity_percentage_end: Optional[Decimal] = None
    meta_risk_id: int = 0
    output_level: Optional[ResultOutputLevel] = None
    processing_status: Optional[ProcessingStatus] = None
    event_loss_floor_start_range: Optional[Decimal] = None
    event_loss_floor_end_range: Optional[Decimal] = None
    analysis_portfolio_event_set_configurations: Optional[List[AnalysisPortfolioEventSetConfiguration]] = None
    row_identifier: Optional[str] = None


class TransactionType(str, Enum):
    NOT_SET = 'NotSet'
    S = 'S'
    B = 'B'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisPortfolioAllocation(IObjectWithId):
    id: int = 0
    analysis_deal_id: int = 0
    # @Validate(Validator="NotEmpty", Message="PortfolioName is mandatory")
    portfolio_name: Optional[str] = None

    allocation_percentage: float = 0.0
    row_identifier: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisDeal(IObjectWithId, IHasAnalysisId):
    id: int = 0
    analysis_id: int = 0
    source_deal_id: Optional[str] = None
    deal_ref: Optional[str] = None
    source_deal_system: Optional[str] = None
    event_set_id: int = 0
    rol: float = 0.0
    limit: float = 0.0
    inception_date: datetime.datetime = datetime.datetime(1, 1, 1)
    expiry_date: datetime.datetime = datetime.datetime(1, 1, 1)
    transaction_type: Optional[TransactionType] = None
    allocations: Optional[List[AnalysisPortfolioAllocation]] = None
    perspective_id_override: Optional[int] = None
    event_set_id_override: Optional[int] = None
    model_as_of_date_override: Optional[datetime.datetime] = None
    source_model_system_override: Optional[str] = None
    source_model_id_override: Optional[str] = None
    source_event_set_id_override: Optional[str] = None
    event_source_system_override: Optional[str] = None
    row_identifier: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisEventIdFilter(IObjectWithId, IHasAnalysisId):
    id: int = 0
    analysis_id: int = 0
    event_source_id: int = 0
    event_id: int = 0
    row_identifier: Optional[str] = None


class MessageType(str, Enum):
    NOT_SET = 'NotSet'
    PERSISTENCE = 'Persistence'
    ARCHIVAL = 'Archival'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class MessageTracking:
    id: Optional[str] = None
    analysis_id: Optional[int] = None
    processing_status: Optional[ProcessingStatus] = None
    message_type: Optional[MessageType] = None
    created_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)
    updated_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Analysis(IObjectWithId):
    id: int = 0
    name: Optional[str] = None
    model_as_of_date: Optional[datetime.datetime] = None
    perspective_id: int = 0
    configurations: Optional[List[AnalysisConfiguration]] = None
    deals: Optional[List[AnalysisDeal]] = None
    event_id_filters: Optional[List[AnalysisEventIdFilter]] = None
    created_by: Optional[str] = None
    created_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)
    completed_date_utc: Optional[datetime.datetime] = None
    legacy_analysis_id: Optional[int] = None
    result_persistence_tracking: Optional[List[MessageTracking]] = None
    processing_status: Optional[ProcessingStatus] = None
    save_results: bool = False
    event_source_system: Optional[str] = None
    updated_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)
    is_expired: bool = False
    row_identifier: Optional[str] = None
    error_message: Optional[str] = None
    # @ApiMember(DataType="boolean", Description="Take the minimum simulation count when we have different simulations between event sets")
    ignore_simulation_count_mismatch: bool = False
    """
    Take the minimum simulation count when we have different simulations between event sets
    """


    # @Ignore()
    final_status: Optional[ProcessingStatus] = None


class AnalysisType(str, Enum):
    NOT_SET = 'NotSet'
    STANDARD = 'Standard'
    RUN_OFF = 'RunOff'


class SimulationLossPerspective(str, Enum):
    NOT_SET = 'NotSet'
    AGG = 'Agg'
    OCC = 'Occ'


class ReinsurancePremiumLossType(str, Enum):
    NOT_SET = 'NotSet'
    NET = 'Net'
    GROSS = 'Gross'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisPortfolioMetric(IHasAnalysisResultId):
    analysis_type: Optional[AnalysisType] = None
    simulation_loss_perspective: Optional[SimulationLossPerspective] = None
    reinsurance_premium_loss_type: Optional[ReinsurancePremiumLossType] = None
    metric_description: Optional[str] = None
    portfolio_name: Optional[str] = None
    metric: float = 0.0
    meta_risk_id: int = 0
    simulation: Optional[int] = None
    analysis_result_id: int = 0


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisPortfolioEventSetResult(IObjectWithId, IHasAnalysisId):
    id: int = 0
    analysis_id: int = 0
    analysis_portfolio_event_set_configuration_id: int = 0
    analysis_result_id: int = 0
    portfolio_name: Optional[str] = None
    row_identifier: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisResult(IObjectWithId):
    id: int = 0
    analysis_id: int = 0
    analysis_configuration_id: int = 0
    container: Optional[str] = None
    blob_name: Optional[str] = None
    result_table_name: Optional[str] = None
    analysis_type: Optional[AnalysisType] = None
    simulation_loss_perspective: Optional[SimulationLossPerspective] = None
    reinsurance_premium_loss_type: Optional[ReinsurancePremiumLossType] = None
    output_level: Optional[ResultOutputLevel] = None
    meta_risk_id: int = 0
    analysis_portfolio_event_set_results: Optional[List[AnalysisPortfolioEventSetResult]] = None
    row_identifier: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RollupResponse:
    analysis: Optional[Analysis] = None
    portfolio_metrics: Optional[List[AnalysisPortfolioMetric]] = None
    results: Optional[List[AnalysisResult]] = None
    response_status: Optional[ResponseStatus] = None
    unresolved_deal_ids: Optional[List[str]] = None
    unlinked_deal_ids: Optional[List[ValueTuple[str, str]]] = None
    message: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class GetAnalysisRequest(IGet):
    # @ApiMember(DataType="integer", Description="The analysis id", Format="int64")
    id: Optional[int] = None
    """
    The analysis id
    """


    # @ApiMember(DataType="integer", Description="The legacy analysis id", Format="int64")
    legacy_id: Optional[int] = None
    """
    The legacy analysis id
    """


    # @ApiMember(DataType="boolean", Description="True to not load all deal allocations, analysis runs etc...")
    only_core_data: Optional[bool] = None
    """
    True to not load all deal allocations, analysis runs etc...
    """

Python GetAnalysisRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /api/riskstore/analysis/results HTTP/1.1 
Host: riskstoreng-dev.nephila.com 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	analysis: 
	{
		id: 0,
		name: String,
		modelAsOfDate: 0001-01-01,
		perspectiveId: 0,
		configurations: 
		[
			{
				id: 0,
				analysisId: 0,
				windowStartDate: 0001-01-01,
				windowEndDate: 0001-01-01,
				standardEnabled: False,
				runOffEnabled: False,
				aggregateEnabled: False,
				occurrenceEnabled: False,
				nettEnabled: False,
				grossEnabled: False,
				tailIntensityPercentageStart: 0,
				tailIntensityPercentageEnd: 0,
				metaRiskId: 0,
				outputLevel: NotSet,
				processingStatus: New,
				eventLossFloorStartRange: 0,
				eventLossFloorEndRange: 0,
				analysisPortfolioEventSetConfigurations: 
				[
					{
						id: 0,
						analysisId: 0,
						analysisConfigurationId: 0,
						portfolioName: String,
						modelId: String,
						rowIdentifier: 00000000000000000000000000000000
					}
				],
				rowIdentifier: 00000000000000000000000000000000
			}
		],
		deals: 
		[
			{
				id: 0,
				analysisId: 0,
				sourceDealId: String,
				dealRef: String,
				sourceDealSystem: String,
				eventSetId: 0,
				rol: 0,
				limit: 0,
				inceptionDate: 0001-01-01,
				expiryDate: 0001-01-01,
				transactionType: NotSet,
				allocations: 
				[
					{
						id: 0,
						analysisDealId: 0,
						portfolioName: String,
						allocationPercentage: 0,
						rowIdentifier: 00000000000000000000000000000000
					}
				],
				perspectiveIdOverride: 0,
				eventSetIdOverride: 0,
				modelAsOfDateOverride: 0001-01-01,
				sourceModelSystemOverride: String,
				sourceModelIdOverride: String,
				sourceEventSetIdOverride: String,
				eventSourceSystemOverride: String,
				rowIdentifier: 00000000000000000000000000000000
			}
		],
		eventIdFilters: 
		[
			{
				id: 0,
				analysisId: 0,
				eventSourceId: 0,
				eventId: 0,
				rowIdentifier: 00000000000000000000000000000000
			}
		],
		createdBy: String,
		createdDateUtc: 0001-01-01,
		completedDateUtc: 0001-01-01,
		legacyAnalysisId: 0,
		resultPersistenceTracking: 
		[
			{
				id: 00000000000000000000000000000000,
				analysisId: 0,
				processingStatus: New,
				messageType: NotSet,
				createdDateUtc: 0001-01-01,
				updatedDateUtc: 0001-01-01
			}
		],
		processingStatus: New,
		saveResults: False,
		eventSourceSystem: String,
		updatedDateUtc: 0001-01-01,
		isExpired: False,
		rowIdentifier: 00000000000000000000000000000000,
		errorMessage: String,
		ignoreSimulationCountMismatch: False,
		finalStatus: New
	},
	portfolioMetrics: 
	[
		{
			analysisType: NotSet,
			simulationLossPerspective: NotSet,
			reinsurancePremiumLossType: NotSet,
			metricDescription: String,
			portfolioName: String,
			metric: 0,
			metaRiskId: 0,
			simulation: 0,
			analysisResultId: 0
		}
	],
	results: 
	[
		{
			id: 0,
			analysisId: 0,
			analysisConfigurationId: 0,
			container: String,
			blobName: String,
			resultTableName: String,
			analysisType: NotSet,
			simulationLossPerspective: NotSet,
			reinsurancePremiumLossType: NotSet,
			outputLevel: NotSet,
			metaRiskId: 0,
			analysisPortfolioEventSetResults: 
			[
				{
					id: 0,
					analysisId: 0,
					analysisPortfolioEventSetConfigurationId: 0,
					analysisResultId: 0,
					portfolioName: String,
					rowIdentifier: 00000000000000000000000000000000
				}
			],
			rowIdentifier: 00000000000000000000000000000000
		}
	],
	responseStatus: 
	{
		errorCode: String,
		message: String,
		stackTrace: String,
		errors: 
		[
			{
				errorCode: String,
				fieldName: String,
				message: String,
				meta: 
				{
					String: String
				}
			}
		],
		meta: 
		{
			String: String
		}
	},
	unresolvedDealIds: 
	[
		String
	],
	unlinkedDealIds: 
	[
		"(, )"
	],
	message: String
}