[](https://www.factset.com)
# Open:Risk client library for Python
[](https://pypi.org/project/fds.sdk.OpenRisk/)
[](https://www.apache.org/licenses/LICENSE-2.0)
Service to calculate parametric linear risk statistics and generate risk model asset identifier mappings.
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.23.0
- Package version: 1.1.1
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
## Requirements
* Python >= 3.7
## Installation
### Poetry
```shell
poetry add fds.sdk.utils fds.sdk.OpenRisk
```
### pip
```shell
pip install fds.sdk.utils fds.sdk.OpenRisk
```
## Usage
1. [Generate authentication credentials](../../../../README.md#authentication).
2. Setup Python environment.
1. Install and activate python 3.7+. If you're using [pyenv](https://github.com/pyenv/pyenv):
```sh
pyenv install 3.9.7
pyenv shell 3.9.7
```
2. (optional) [Install poetry](https://python-poetry.org/docs/#installation).
3. [Install dependencies](#installation).
4. Run the following:
```python
from fds.sdk.utils.authentication import ConfidentialClient
import fds.sdk.OpenRisk
from fds.sdk.OpenRisk.api import about_api
from fds.sdk.OpenRisk.models import *
from dateutil.parser import parse as dateutil_parser
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
# Examples for each supported authentication method are below,
# choose one that satisfies your use case.
# (Preferred) OAuth 2.0: FactSetOAuth2
# See https://github.com/FactSet/enterprise-sdk#oauth-20
# for information on how to create the app-config.json file
# See https://github.com/FactSet/enterprise-sdk-utils-python#authentication
# for more information on using the ConfidentialClient class
configuration = fds.sdk.OpenRisk.Configuration(
fds_oauth_client=ConfidentialClient('/path/to/app-config.json')
)
# Basic authentication: FactSetApiKey
# See https://github.com/FactSet/enterprise-sdk#api-key
# for information how to create an API key
# configuration = fds.sdk.OpenRisk.Configuration(
# username='USERNAME-SERIAL',
# password='API-KEY'
# )
# Enter a context with an instance of the API client
with fds.sdk.OpenRisk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = about_api.AboutApi(api_client)
version = "v1" # str | Semantic version number. See [this link here](https://regexr.com/47b7t) to test validate patterns.
try:
# Get OpenAPI Specification documentation
api_response = api_instance.documentation(version)
pprint(api_response)
except fds.sdk.OpenRisk.ApiException as e:
print("Exception when calling AboutApi->documentation: %s\n" % e)
# Get response, http status code and response headers
# try:
# # Get OpenAPI Specification documentation
# api_response, http_status_code, response_headers = api_instance.documentation_with_http_info(version)
# pprint(api_response)
# pprint(http_status_code)
# pprint(response_headers)
# except fds.sdk.OpenRisk.ApiException as e:
# print("Exception when calling AboutApi->documentation: %s\n" % e)
# Get response asynchronous
# try:
# # Get OpenAPI Specification documentation
# async_result = api_instance.documentation_async(version)
# api_response = async_result.get()
# pprint(api_response)
# except fds.sdk.OpenRisk.ApiException as e:
# print("Exception when calling AboutApi->documentation: %s\n" % e)
# Get response, http status code and response headers asynchronous
# try:
# # Get OpenAPI Specification documentation
# async_result = api_instance.documentation_with_http_info_async(version)
# api_response, http_status_code, response_headers = async_result.get()
# pprint(api_response)
# pprint(http_status_code)
# pprint(response_headers)
# except fds.sdk.OpenRisk.ApiException as e:
# print("Exception when calling AboutApi->documentation: %s\n" % e)
```
### Using Pandas
To convert an API response to a Pandas DataFrame, it is necessary to transform it first to a dictionary.
```python
import pandas as pd
response_dict = api_response.to_dict()['data']
simple_json_response = pd.DataFrame(response_dict)
nested_json_response = pd.json_normalize(response_dict)
```
### Debugging
The SDK uses the standard library [`logging`](https://docs.python.org/3/library/logging.html#module-logging) module.
Setting `debug` to `True` on an instance of the `Configuration` class sets the log-level of related packages to `DEBUG`
and enables additional logging in Pythons [HTTP Client](https://docs.python.org/3/library/http.client.html).
**Note**: This prints out sensitive information (e.g. the full request and response). Use with care.
```python
import logging
import fds.sdk.OpenRisk
logging.basicConfig(level=logging.DEBUG)
configuration = fds.sdk.OpenRisk.Configuration(...)
configuration.debug = True
```
## Documentation for API Endpoints
All URIs are relative to *https://api.factset.com/analytics/openrisk*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AboutApi* | [**documentation**](docs/AboutApi.md#documentation) | **GET** /linear/{version} | Get OpenAPI Specification documentation
*AboutApi* | [**health_status**](docs/AboutApi.md#health_status) | **GET** /linear/{version}/health | Get health of service
*AboutApi* | [**list_risk_models**](docs/AboutApi.md#list_risk_models) | **GET** /linear/{version}/riskmodels | Get available risk models
*AboutApi* | [**risk_model_metadata**](docs/AboutApi.md#risk_model_metadata) | **GET** /linear/{version}/riskmodels/{modelCode} | Get risk model details
*AboutApi* | [**stats**](docs/AboutApi.md#stats) | **GET** /linear/{version}/stats | Get available risk statistics details
*AboutApi* | [**stats_names_only**](docs/AboutApi.md#stats_names_only) | **GET** /linear/{version}/stats-names-only | Get available risk statistics names
*OperationsApi* | [**calculate_from_holdings**](docs/OperationsApi.md#calculate_from_holdings) | **POST** /linear/{version}/calculate/from-holdings | Calculate risk statistics
*OperationsApi* | [**generate_id_mapping**](docs/OperationsApi.md#generate_id_mapping) | **POST** /linear/{version}/generate/id-mapping | Generate risk model ID mapping
## Documentation For Models
- [AdditionalCalculationInputs](docs/AdditionalCalculationInputs.md)
- [AdditionalCalculationInputsMarketExcess](docs/AdditionalCalculationInputsMarketExcess.md)
- [AssetTypes](docs/AssetTypes.md)
- [CalculateFromHoldingsRequestBody](docs/CalculateFromHoldingsRequestBody.md)
- [CalculateFromHoldingsRequestData](docs/CalculateFromHoldingsRequestData.md)
- [CalendarCode](docs/CalendarCode.md)
- [CompositeAssetDefinitions](docs/CompositeAssetDefinitions.md)
- [CovarianceDateFormatConvention](docs/CovarianceDateFormatConvention.md)
- [CurrencyISOCode](docs/CurrencyISOCode.md)
- [Date](docs/Date.md)
- [ErrorItem](docs/ErrorItem.md)
- [ErrorResponse](docs/ErrorResponse.md)
- [ExposureDateFormatConvention](docs/ExposureDateFormatConvention.md)
- [FactorGroup](docs/FactorGroup.md)
- [FactorGroupNodes](docs/FactorGroupNodes.md)
- [FactorsVisible](docs/FactorsVisible.md)
- [GenerateIDMappingRequestBody](docs/GenerateIDMappingRequestBody.md)
- [GenerateIDMappingRequestData](docs/GenerateIDMappingRequestData.md)
- [GroupsLabels](docs/GroupsLabels.md)
- [Holding](docs/Holding.md)
- [HoldingAllOf](docs/HoldingAllOf.md)
- [Holdings](docs/Holdings.md)
- [IDsAndMarketValues](docs/IDsAndMarketValues.md)
- [InlineResponse200](docs/InlineResponse200.md)
- [InlineResponse2001](docs/InlineResponse2001.md)
- [InlineResponse2001Data](docs/InlineResponse2001Data.md)
- [InlineResponse2002](docs/InlineResponse2002.md)
- [InlineResponse2002Data](docs/InlineResponse2002Data.md)
- [InlineResponse2002DataFactors](docs/InlineResponse2002DataFactors.md)
- [InlineResponse2002DataRiskModelAppendFormat](docs/InlineResponse2002DataRiskModelAppendFormat.md)
- [InlineResponse2003](docs/InlineResponse2003.md)
- [InlineResponse2004](docs/InlineResponse2004.md)
- [InlineResponse2005](docs/InlineResponse2005.md)
- [InlineResponse200Components](docs/InlineResponse200Components.md)
- [InlineResponse200Info](docs/InlineResponse200Info.md)
- [InlineResponse200Servers](docs/InlineResponse200Servers.md)
- [InlineResponse403](docs/InlineResponse403.md)
- [InlineResponse404](docs/InlineResponse404.md)
- [InputToResultSecurityIndexMapping](docs/InputToResultSecurityIndexMapping.md)
- [Labels](docs/Labels.md)
- [LabelsFactor](docs/LabelsFactor.md)
- [LabelsSecurity](docs/LabelsSecurity.md)
- [LaggingDates](docs/LaggingDates.md)
- [MappedSecurityInfo](docs/MappedSecurityInfo.md)
- [RemoveCurrencyRisk](docs/RemoveCurrencyRisk.md)
- [RemoveCurrencyRiskIDs](docs/RemoveCurrencyRiskIDs.md)
- [RequiresFactorReturns](docs/RequiresFactorReturns.md)
- [ResolvedDates](docs/ResolvedDates.md)
- [ResultToInputSecurityIndexMapping](docs/ResultToInputSecurityIndexMapping.md)
- [RiskExclusionInfo](docs/RiskExclusionInfo.md)
- [RiskExclusionInfoExclusionInfo](docs/RiskExclusionInfoExclusionInfo.md)
- [RiskMappingEntry](docs/RiskMappingEntry.md)
- [RiskModelAppendData](docs/RiskModelAppendData.md)
- [RiskModelAppendDataValue](docs/RiskModelAppendDataValue.md)
- [RiskModelCode](docs/RiskModelCode.md)
- [RiskModelFactor](docs/RiskModelFactor.md)
- [SecurityGroup](docs/SecurityGroup.md)
- [SecurityIndexMapping](docs/SecurityIndexMapping.md)
- [SecurityOnlyLabels](docs/SecurityOnlyLabels.md)
- [SecurityOnlyLabelsSecurity](docs/SecurityOnlyLabelsSecurity.md)
- [SecurityOnlySuccessResponseMeta](docs/SecurityOnlySuccessResponseMeta.md)
- [Stat](docs/Stat.md)
- [StatCalculationLevel](docs/StatCalculationLevel.md)
- [StatCalculationSettings](docs/StatCalculationSettings.md)
- [StatResultValue](docs/StatResultValue.md)
- [StatResultValueDenseMatrix](docs/StatResultValueDenseMatrix.md)
- [StatResultValueSparseMatrix](docs/StatResultValueSparseMatrix.md)
- [StatResultValueVector](docs/StatResultValueVector.md)
- [Stats](docs/Stats.md)
- [StatsResults](docs/StatsResults.md)
- [StringDate](docs/StringDate.md)
- [SuccessResponseMeta](docs/SuccessResponseMeta.md)
- [SupportedStats](docs/SupportedStats.md)
- [SupportedStatsData](docs/SupportedStatsData.md)
- [SupportedStatsLevels](docs/SupportedStatsLevels.md)
- [SupportedStatsNamesOnly](docs/SupportedStatsNamesOnly.md)
- [SupportedStatsSecurityGroupMethod](docs/SupportedStatsSecurityGroupMethod.md)
- [UnderlyingIDs](docs/UnderlyingIDs.md)
- [WarningItem](docs/WarningItem.md)
- [Warnings](docs/Warnings.md)
## Documentation For Authorization
## FactSetApiKey
- **Type**: HTTP basic authentication
## FactSetOAuth2
- **Type**: OAuth
- **Flow**: application
- **Authorization URL**:
- **Scopes**: N/A
## Notes for Large OpenAPI documents
If the OpenAPI document is large, imports in fds.sdk.OpenRisk.apis and fds.sdk.OpenRisk.models may fail with a
RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:
Solution 1:
Use specific imports for apis and models like:
- `from fds.sdk.OpenRisk.api.default_api import DefaultApi`
- `from fds.sdk.OpenRisk.model.pet import Pet`
Solution 2:
Before importing the package, adjust the maximum recursion limit as shown below:
```
import sys
sys.setrecursionlimit(1500)
import fds.sdk.OpenRisk
from fds.sdk.OpenRisk.apis import *
from fds.sdk.OpenRisk.models import *
```
## Contributing
Please refer to the [contributing guide](../../../../CONTRIBUTING.md).
## Copyright
Copyright 2022 FactSet Research Systems Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.