Skip to content

Commit fd62401

Browse files
a-ghagGitHub Enterprise
authored andcommitted
feat(new-sdk-version): Adding 4.0.0 sdk (#20)
1 parent 28feb92 commit fd62401

14 files changed

+5718
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ Summary:
77
* Adding support for new features
88

99
Breaking changes:
10-
* No changes
10+
* Additional parameter in calculation object constructor
1111

1212
Functionality Additions:
1313
* Publisher API calculation and document lookup
1414
* New componentdetail parameter for PA and Vault calculation
15+
* Interactive endpoints for PA, SPAR and Vault APIs
1516

1617
Bug Fixes:
1718
* No changes

Utilities/codegen/openapi-schema.json

Lines changed: 3652 additions & 24 deletions
Large diffs are not rendered by default.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import json
2+
import sys
3+
import time
4+
5+
from fds.analyticsapi.engines import ComponentSummary
6+
from fds.analyticsapi.engines.api.components_api import ComponentsApi
7+
from fds.analyticsapi.engines.api.pa_calculations_api import PACalculationsApi
8+
from fds.analyticsapi.engines.api_client import ApiClient
9+
from fds.analyticsapi.engines.configuration import Configuration
10+
from fds.analyticsapi.engines.models.pa_calculation_parameters import PACalculationParameters
11+
from fds.analyticsapi.engines.models.pa_date_parameters import PADateParameters
12+
from fds.analyticsapi.engines.models.pa_identifier import PAIdentifier
13+
from fds.protobuf.stach.Package_pb2 import Package
14+
15+
from google.protobuf import json_format
16+
from google.protobuf.json_format import MessageToJson
17+
from google.protobuf.json_format import MessageToDict
18+
from urllib3 import Retry
19+
20+
# Copy 'Converting API output to Table Format' snippet to a file with name 'stach_extensions.py' to use below import statement
21+
from stach_extensions import StachExtensions
22+
23+
def print_result(response):
24+
# converting the data to Package object
25+
result = json_format.Parse(json.dumps(response), Package())
26+
# print(MessageToJson(result)) # To print the result object as a JSON
27+
# print(MessageToDict(result)) # To print the result object as a Dictionary
28+
tables = StachExtensions.convert_to_table_format(result) # To convert result to 2D tables.
29+
print(tables[0]) # Prints the result in 2D table format.
30+
# StachExtensions.generate_excel(result) # To get the result in table format exported to excel file.
31+
32+
def print_error(response):
33+
print("Calculation Failed!!!")
34+
print("Status Code: " + str(response[1]))
35+
print("Request Key: " + response[2].get("x-datadirect-request-key"))
36+
print(response[0])
37+
38+
host = "https://api.factset.com"
39+
username = "<username-serial>"
40+
password = "<apiKey>"
41+
42+
pa_document_name = "PA_DOCUMENTS:DEFAULT"
43+
pa_component_name = "Weights"
44+
pa_component_category = "Weights / Exposures"
45+
pa_benchmark_sp_50 = "BENCH:SP50"
46+
pa_benchmark_r_1000 = "BENCH:R.1000"
47+
startdate = "20180101"
48+
enddate = "20181231"
49+
frequency = "Monthly"
50+
51+
config = Configuration()
52+
config.host = host
53+
config.username = username
54+
config.password = password
55+
# add proxy and/or disable ssl verification according to your development environment
56+
# config.proxy = "<proxyUrl>"
57+
config.verify_ssl = False
58+
59+
# Setting configuration to retry api calls on http status codes of 429 and 503.
60+
config.retries = Retry(total=3, status=3, status_forcelist=frozenset([429, 503]), backoff_factor=2, raise_on_status=False)
61+
62+
api_client = ApiClient(config)
63+
64+
components_api = ComponentsApi(api_client)
65+
66+
components = components_api.get_pa_components(pa_document_name)
67+
component_desc = ComponentSummary(name=pa_component_name, category=pa_component_category)
68+
component_id = [id for id in list(components.keys()) if components[id] == component_desc][0]
69+
70+
pa_account_identifier = PAIdentifier(pa_benchmark_sp_50)
71+
pa_accounts = [pa_account_identifier]
72+
pa_benchmark_identifier = PAIdentifier(pa_benchmark_r_1000)
73+
pa_benchmarks = [pa_benchmark_identifier]
74+
pa_dates = PADateParameters(startdate, enddate, frequency)
75+
76+
pa_calculation_parameters = PACalculationParameters(component_id, pa_accounts, pa_benchmarks, pa_dates)
77+
78+
print(pa_calculation_parameters)
79+
80+
pa_calculations_api = PACalculationsApi(api_client)
81+
run_calculation_response = pa_calculations_api.run_pa_calculation_with_http_info(pa_calculation_parameters=pa_calculation_parameters)
82+
83+
if run_calculation_response[1] != 202 and run_calculation_response[1] != 201:
84+
print_error(run_calculation_response)
85+
sys.exit()
86+
87+
if run_calculation_response[1] == 201:
88+
print_result(run_calculation_response[0])
89+
sys.exit()
90+
91+
92+
calculation_id = run_calculation_response[2].get("location").split("/")[-1]
93+
print("Calculation Id: " + calculation_id)
94+
95+
status_response = pa_calculations_api.get_pa_calculation_by_id_with_http_info(calculation_id)
96+
while status_response[1] == 202:
97+
max_age = '5'
98+
age_value = status_response[2].get("cache-control")
99+
if age_value is not None:
100+
max_age = age_value.replace("max-age=", "")
101+
print('Sleeping: ' + max_age)
102+
time.sleep(int(max_age))
103+
status_response = pa_calculations_api.get_pa_calculation_by_id_with_http_info(calculation_id)
104+
105+
if status_response[1] != 200:
106+
print_error(status_response)
107+
sys.exit()
108+
109+
print_result(status_response[0])
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import json
2+
import sys
3+
import time
4+
5+
from fds.analyticsapi.engines import ComponentSummary
6+
from fds.analyticsapi.engines.api.components_api import ComponentsApi
7+
from fds.analyticsapi.engines.api_client import ApiClient
8+
from fds.analyticsapi.engines.configuration import Configuration
9+
from fds.analyticsapi.engines.api.spar_calculations_api import SPARCalculationsApi
10+
from fds.analyticsapi.engines.models.spar_date_parameters import SPARDateParameters
11+
from fds.analyticsapi.engines.models.spar_calculation_parameters import SPARCalculationParameters
12+
from fds.analyticsapi.engines.models.spar_identifier import SPARIdentifier
13+
from fds.protobuf.stach.Package_pb2 import Package
14+
15+
from google.protobuf import json_format
16+
from google.protobuf.json_format import MessageToJson
17+
from google.protobuf.json_format import MessageToDict
18+
from urllib3 import Retry
19+
20+
# Copy 'Converting API output to Table Format' snippet to a file with name 'stach_extensions.py' to use below import statement
21+
from stach_extensions import StachExtensions
22+
23+
def print_result(response):
24+
# converting the data to Package object
25+
result = json_format.Parse(json.dumps(response), Package())
26+
# print(MessageToJson(result)) # To print the result object as a JSON
27+
# print(MessageToDict(result)) # To print the result object as a Dictionary
28+
tables = StachExtensions.convert_to_table_format(result) # To convert result to 2D tables.
29+
print(tables[0]) # Prints the result in 2D table format.
30+
# StachExtensions.generate_excel(result) # To get the result in table format exported to excel file.
31+
32+
def print_error(response):
33+
print("Calculation Failed!!!")
34+
print("Status Code: " + str(response[1]))
35+
print("Request Key: " + response[2].get("x-datadirect-request-key"))
36+
print(response[0])
37+
38+
host = "https://api.factset.com"
39+
username = "<username-serial>"
40+
password = "<apiKey>"
41+
42+
spar_document_name = "pmw_root:/spar_documents/Factset Default Document"
43+
spar_component_name = "Returns Table"
44+
spar_component_category = "Raw Data / Returns"
45+
spar_benchmark_r_1000 = "R.1000"
46+
spar_benchmark_russell_pr_2000 = "RUSSELL_P:R.2000"
47+
spar_benchmark_russell_prefix = "RUSSELL"
48+
spar_benchmark_russell_return_type = "GTR"
49+
startdate = "20180101"
50+
enddate = "20181231"
51+
frequency = "Monthly"
52+
53+
config = Configuration()
54+
config.host = host
55+
config.username = username
56+
config.password = password
57+
# add proxy and/or disable ssl verification according to your development environment
58+
# config.proxy = "<proxyUrl>"
59+
config.verify_ssl = False
60+
61+
# Setting configuration to retry api calls on http status codes of 429 and 503.
62+
config.retries = Retry(total=3, status=3, status_forcelist=frozenset([429, 503]), backoff_factor=2, raise_on_status=False)
63+
64+
api_client = ApiClient(config)
65+
66+
components_api = ComponentsApi(api_client)
67+
68+
components = components_api.get_spar_components(spar_document_name)
69+
component_desc = ComponentSummary(name=spar_component_name, category=spar_component_category)
70+
component_id = [id for id in list(components.keys()) if components[id] == component_desc][0]
71+
72+
spar_account_identifier = SPARIdentifier(spar_benchmark_r_1000, spar_benchmark_russell_return_type, spar_benchmark_russell_prefix)
73+
spar_accounts = [spar_account_identifier]
74+
spar_benchmark_identifier = SPARIdentifier(spar_benchmark_russell_pr_2000, spar_benchmark_russell_return_type, spar_benchmark_russell_prefix)
75+
spar_dates = SPARDateParameters(startdate, enddate, frequency)
76+
77+
78+
spar_calculation_parameters = SPARCalculationParameters(component_id, spar_accounts, spar_benchmark_identifier, spar_dates)
79+
80+
print(spar_calculation_parameters)
81+
82+
spar_calculations_api = SPARCalculationsApi(api_client)
83+
run_calculation_response = spar_calculations_api.run_spar_calculation_with_http_info(spar_calculation_parameters=spar_calculation_parameters)
84+
85+
if run_calculation_response[1] != 202 and run_calculation_response[1] != 201:
86+
print_error(run_calculation_response)
87+
sys.exit()
88+
89+
if run_calculation_response[1] == 201:
90+
print_result(run_calculation_response[0])
91+
sys.exit()
92+
93+
94+
calculation_id = run_calculation_response[2].get("location").split("/")[-1]
95+
print("Calculation Id: " + calculation_id)
96+
97+
status_response = spar_calculations_api.get_spar_calculation_by_id_with_http_info(calculation_id)
98+
while status_response[1] == 202:
99+
max_age = '5'
100+
age_value = status_response[2].get("cache-control")
101+
if age_value is not None:
102+
max_age = age_value.replace("max-age=", "")
103+
print('Sleeping: ' + max_age)
104+
time.sleep(int(max_age))
105+
status_response = spar_calculations_api.get_spar_calculation_by_id_with_http_info(calculation_id)
106+
107+
if status_response[1] != 200:
108+
print_error(status_response)
109+
sys.exit()
110+
111+
print_result(status_response[0])
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import json
2+
import sys
3+
import time
4+
5+
from fds.analyticsapi.engines import ComponentSummary
6+
from fds.analyticsapi.engines.api.components_api import ComponentsApi
7+
from fds.analyticsapi.engines.api.configurations_api import ConfigurationsApi
8+
from fds.analyticsapi.engines.api_client import ApiClient
9+
from fds.analyticsapi.engines.configuration import Configuration
10+
from fds.analyticsapi.engines.api.vault_calculations_api import VaultCalculationsApi
11+
from fds.analyticsapi.engines.models.vault_date_parameters import VaultDateParameters
12+
from fds.analyticsapi.engines.models.vault_calculation_parameters import VaultCalculationParameters
13+
from fds.analyticsapi.engines.models.vault_identifier import VaultIdentifier
14+
from fds.protobuf.stach.Package_pb2 import Package
15+
16+
from google.protobuf import json_format
17+
from google.protobuf.json_format import MessageToJson
18+
from google.protobuf.json_format import MessageToDict
19+
from urllib3 import Retry
20+
21+
# Copy 'Converting API output to Table Format' snippet to a file with name 'stach_extensions.py' to use below import statement
22+
from stach_extensions import StachExtensions
23+
24+
def print_result(response):
25+
# converting the data to Package object
26+
result = json_format.Parse(json.dumps(response), Package())
27+
# print(MessageToJson(result)) # To print the result object as a JSON
28+
# print(MessageToDict(result)) # To print the result object as a Dictionary
29+
tables = StachExtensions.convert_to_table_format(result) # To convert result to 2D tables.
30+
print(tables[0]) # Prints the result in 2D table format.
31+
# StachExtensions.generate_excel(result) # To get the result in table format exported to excel file.
32+
33+
def print_error(response):
34+
print("Calculation Failed!!!")
35+
print("Status Code: " + str(response[1]))
36+
print("Request Key: " + response[2].get("x-datadirect-request-key"))
37+
print(response[0])
38+
39+
host = "https://api.factset.com"
40+
username = "<username-serial>"
41+
password = "<apiKey>"
42+
43+
vault_document_name = "Client:/API Demo"
44+
vault_component_name = "Macro Attribution with Currency"
45+
vault_component_category = "Attribution / Macro Attribution with Currency"
46+
vault_default_account = "Client:/analytics/data/US_MID_CAP_CORE.ACTM"
47+
vault_startdate = "FIRST_REPOSITORY"
48+
vault_enddate = "LAST_REPOSITORY"
49+
frequency = "Monthly"
50+
51+
config = Configuration()
52+
config.host = host
53+
config.username = username
54+
config.password = password
55+
# add proxy and/or disable ssl verification according to your development environment
56+
# config.proxy = "<proxyUrl>"
57+
config.verify_ssl = False
58+
59+
# Setting configuration to retry api calls on http status codes of 429 and 503.
60+
config.retries = Retry(total=3, status=3, status_forcelist=frozenset([429, 503]), backoff_factor=2, raise_on_status=False)
61+
62+
api_client = ApiClient(config)
63+
64+
components_api = ComponentsApi(api_client)
65+
66+
components = components_api.get_vault_components(vault_document_name)
67+
component_desc = ComponentSummary(name=vault_component_name, category=vault_component_category)
68+
component_id = [id for id in list(components.keys()) if components[id] == component_desc][0]
69+
70+
vault_account_identifier = VaultIdentifier(vault_default_account)
71+
vault_dates = VaultDateParameters(vault_startdate, vault_enddate, frequency)
72+
73+
configurations_api = ConfigurationsApi(api_client)
74+
configurations = configurations_api.get_vault_configurations(vault_default_account)
75+
configuration_id = list(configurations.keys())[0]
76+
77+
vault_calculation_parameters = VaultCalculationParameters(component_id, vault_account_identifier, vault_dates, configuration_id)
78+
79+
print(vault_calculation_parameters)
80+
81+
vault_calculations_api = VaultCalculationsApi(api_client)
82+
run_calculation_response = vault_calculations_api.run_vault_calculation_with_http_info(vault_calculation_parameters=vault_calculation_parameters)
83+
84+
if run_calculation_response[1] != 202 and run_calculation_response[1] != 201:
85+
print_error(run_calculation_response)
86+
sys.exit()
87+
88+
if run_calculation_response[1] == 201:
89+
print_result(run_calculation_response[0])
90+
sys.exit()
91+
92+
93+
calculation_id = run_calculation_response[2].get("location").split("/")[-1]
94+
print("Calculation Id: " + calculation_id)
95+
96+
status_response = vault_calculations_api.get_vault_calculation_by_id_with_http_info(calculation_id)
97+
while status_response[1] == 202:
98+
max_age = '5'
99+
age_value = status_response[2].get("cache-control")
100+
if age_value is not None:
101+
max_age = age_value.replace("max-age=", "")
102+
print('Sleeping: ' + max_age)
103+
time.sleep(int(max_age))
104+
status_response = vault_calculations_api.get_vault_calculation_by_id_with_http_info(calculation_id)
105+
106+
if status_response[1] != 200:
107+
print_error(status_response)
108+
sys.exit()
109+
110+
print_result(status_response[0])

fds.analyticsapi.engines/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,16 @@ Class | Method | HTTP request | Description
104104
*FrequenciesApi* | [**get_spar_frequencies**](docs/FrequenciesApi.md#get_spar_frequencies) | **GET** /analytics/lookups/v2/engines/spar/frequencies | Get SPAR frequencies
105105
*FrequenciesApi* | [**get_vault_frequencies**](docs/FrequenciesApi.md#get_vault_frequencies) | **GET** /analytics/lookups/v2/engines/vault/frequencies | Get Vault frequencies
106106
*GroupsApi* | [**get_pa_groups**](docs/GroupsApi.md#get_pa_groups) | **GET** /analytics/lookups/v2/engines/pa/groups | Get PA groups
107+
*PACalculationsApi* | [**cancel_pa_calculation_by_id**](docs/PACalculationsApi.md#cancel_pa_calculation_by_id) | **DELETE** /analytics/engines/pa/v2/calculations/{id} | Cancel PA calculation by id
108+
*PACalculationsApi* | [**get_pa_calculation_by_id**](docs/PACalculationsApi.md#get_pa_calculation_by_id) | **GET** /analytics/engines/pa/v2/calculations/{id} | Get PA calculation by id
109+
*PACalculationsApi* | [**run_pa_calculation**](docs/PACalculationsApi.md#run_pa_calculation) | **POST** /analytics/engines/pa/v2/calculations | Run PA Calculation
107110
*SPARBenchmarkApi* | [**get_spar_benchmark_by_id**](docs/SPARBenchmarkApi.md#get_spar_benchmark_by_id) | **GET** /analytics/lookups/v2/engines/spar/benchmarks | Get SPAR benchmark details
111+
*SPARCalculationsApi* | [**cancel_spar_calculation_by_id**](docs/SPARCalculationsApi.md#cancel_spar_calculation_by_id) | **DELETE** /analytics/engines/spar/v2/calculations/{id} | Cancel SPAR calculation
112+
*SPARCalculationsApi* | [**get_spar_calculation_by_id**](docs/SPARCalculationsApi.md#get_spar_calculation_by_id) | **GET** /analytics/engines/spar/v2/calculations/{id} | Get SPAR calculation by id
113+
*SPARCalculationsApi* | [**run_spar_calculation**](docs/SPARCalculationsApi.md#run_spar_calculation) | **POST** /analytics/engines/spar/v2/calculations | Run SPAR Calculation
114+
*VaultCalculationsApi* | [**cancel_vault_calculation_by_id**](docs/VaultCalculationsApi.md#cancel_vault_calculation_by_id) | **DELETE** /analytics/engines/vault/v2/calculations/{id} | Cancel Vault calculation by id
115+
*VaultCalculationsApi* | [**get_vault_calculation_by_id**](docs/VaultCalculationsApi.md#get_vault_calculation_by_id) | **GET** /analytics/engines/vault/v2/calculations/{id} | Get Vault calculation by id
116+
*VaultCalculationsApi* | [**run_vault_calculation**](docs/VaultCalculationsApi.md#run_vault_calculation) | **POST** /analytics/engines/vault/v2/calculations | Run Vault Calculation
108117
*UtilityApi* | [**get_by_url**](docs/UtilityApi.md#get_by_url) | **GET** {url} | Get by url
109118

110119
## Documentation For Models

0 commit comments

Comments
 (0)