Esempio n. 1
0
        private static PACalculationParametersRoot GetPaCalculationParameters()
        {
            var componentsApi = new ComponentsApi(GetApiConfiguration());

            var componentsResponse = componentsApi.GetPAComponents(PADocument);

            var paComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == ComponentName && component.Value.Category == ComponentCategory)).Key;

            Console.WriteLine($"PA Component Id : {paComponentId}");

            var paAccountIdentifier = new PAIdentifier(Portfolio);
            var paAccounts          = new List <PAIdentifier> {
                paAccountIdentifier
            };
            var paBenchmarkIdentifier = new PAIdentifier(Benchmark);
            var paBenchmarks          = new List <PAIdentifier> {
                paBenchmarkIdentifier
            };

            var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);

            var calculationParameters = new PACalculationParametersRoot
            {
                Data = new Dictionary <string, PACalculationParameters> {
                    { "1", paCalculation },
                    { "2", paCalculation }
                }
            };

            return(calculationParameters);
        }
Esempio n. 2
0
        private ApiResponse <object> RunCalculation()
        {
            var parameters = new Calculation();

            var paComponents = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument);

            var paComponentId       = paComponents.Data.Keys.First();
            var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50);
            var paAccounts          = new List <PAIdentifier> {
                paAccountIdentifier
            };
            var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50PF);
            var paBenchmarks          = new List <PAIdentifier> {
                paBenchmarkIdentifier
            };

            var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);

            parameters.Pa = new Dictionary <string, PACalculationParameters> {
                { "1", paCalculation }
            };

            var response = _calculationsApi.RunCalculationWithHttpInfo(parameters);

            return(response);
        }
Esempio n. 3
0
        private ApiResponse <object> RunCalculation()
        {
            var parameters = new Calculation();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var paComponents        = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument);
            var paComponentId       = paComponents.Data.Keys.First();
            var paComponentId2      = paComponents.Data.Keys.Last();
            var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50);
            var paAccounts          = new List <PAIdentifier> {
                paAccountIdentifier
            };
            var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50PF);
            var paBenchmarks          = new List <PAIdentifier> {
                paBenchmarkIdentifier
            };

            var paCalculation  = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);
            var paCalculation2 = new PACalculationParameters(paComponentId2, paAccounts, paBenchmarks);

            parameters.Pa = new Dictionary <string, PACalculationParameters> {
                { "1", paCalculation }, { "2", paCalculation2 }
            };

            var response = _calculationsApi.RunCalculationWithHttpInfo(parameters);

            return(response);
        }
Esempio n. 4
0
        private ApiResponse <object> RunCalculation()
        {
            var paComponents = componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument);

            var paComponentId       = paComponents.Data.Data.Keys.First();
            var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50);
            var paAccounts          = new List <PAIdentifier> {
                paAccountIdentifier
            };
            var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkR1000);
            var paBenchmarks          = new List <PAIdentifier> {
                paBenchmarkIdentifier
            };

            var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);

            var parameters = new PACalculationParametersRoot
            {
                Data = new Dictionary <string, PACalculationParameters> {
                    { "1", paCalculation }, { "2", paCalculation }
                }
            };

            var response = calculationsApi.PostAndCalculateWithHttpInfo(null, "max-stale=0", parameters);

            return(response);
        }
Esempio n. 5
0
        private ApiResponse <object> RunCalculation()
        {
            var parameters = new Calculation();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var paComponents        = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument);
            var paComponentId       = paComponents.Data.Keys.First();
            var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50);
            var paAccounts          = new List <PAIdentifier> {
                paAccountIdentifier
            };
            var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkR1000);
            var paBenchmarks          = new List <PAIdentifier> {
                paBenchmarkIdentifier
            };

            var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);

            parameters.Pa = new Dictionary <string, PACalculationParameters> {
                { "1", paCalculation }
            };

            var sparComponents        = _componentsApi.GetSPARComponentsWithHttpInfo(CommonParameters.SPARDefaultDocument);
            var sparComponentId       = sparComponents.Data.Keys.First();
            var sparAccountIdentifier = new SPARIdentifier(CommonParameters.SPARBenchmarkR1000, CommonParameters.SPARBenchmarkRussellReturnType, CommonParameters.SPARBenchmarkRussellPrefix);
            var sparAccounts          = new List <SPARIdentifier> {
                sparAccountIdentifier
            };
            var sparBenchmarkIdentifier = new SPARIdentifier(CommonParameters.SPARBenchmarkRussellPR2000, CommonParameters.SPARBenchmarkRussellReturnType, CommonParameters.SPARBenchmarkRussellPrefix);

            var sparCalculation = new SPARCalculationParameters(sparComponentId, sparAccounts, sparBenchmarkIdentifier);

            parameters.Spar = new Dictionary <string, SPARCalculationParameters> {
                { "2", sparCalculation }
            };

            var vaultComponents  = _componentsApi.GetVaultComponentsWithHttpInfo(CommonParameters.VaultDefaultDocument);
            var vaultComponentId = vaultComponents.Data.Keys.First();

            var vaultAccount = new VaultIdentifier(CommonParameters.VaultDefaultAccount);
            var vaultDates   = new VaultDateParameters(CommonParameters.VaultStartDate, CommonParameters.VaultEndDate, CommonParameters.VaultFrequency);

            var vaultConfiguration   = _configurationsApi.GetVaultConfigurationsWithHttpInfo(CommonParameters.VaultDefaultAccount);
            var vaultConfigurationId = vaultConfiguration.Data.Keys.First();

            var vaultCalculation = new VaultCalculationParameters(vaultComponentId, vaultAccount, vaultDates, vaultConfigurationId);

            parameters.Vault = new Dictionary <string, VaultCalculationParameters> {
                { "3", vaultCalculation }
            };

            var response = _calculationsApi.RunCalculationWithHttpInfo(parameters);

            return(response);
        }
        public static void Main(string[] args)
        {
            try
            {
                var componentsApi = new ComponentsApi(GetEngineApiConfiguration());

                var componentsResponse = componentsApi.GetPAComponentsWithHttpInfo(PADefaultDocument);

                var paComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == PAComponentName && component.Value.Category == PAComponentCategory)).Key;
                Console.WriteLine($"PA Component Id : {paComponentId}");

                var paAccountIdentifier = new PAIdentifier(PABenchmarkSP50);
                var paAccounts          = new List <PAIdentifier> {
                    paAccountIdentifier
                };
                var paBenchmarkIdentifier = new PAIdentifier(PABenchmarkR1000);
                var paBenchmarks          = new List <PAIdentifier> {
                    paBenchmarkIdentifier
                };

                var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);

                var calculationApi = new PACalculationsApi(GetEngineApiConfiguration());

                var runCalculationResponse = calculationApi.RunPACalculationWithHttpInfo(paCalculation);

                var calculationId = string.Empty;

                while (runCalculationResponse.StatusCode == HttpStatusCode.Accepted)
                {
                    if (string.IsNullOrWhiteSpace(calculationId))
                    {
                        runCalculationResponse.Headers.TryGetValue("Location", out var location);
                        calculationId = location?[0].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
                    }

                    if (runCalculationResponse.Headers.ContainsKey("Cache-Control") &&
                        runCalculationResponse.Headers["Cache-Control"][0] is var maxAge &&
                        !string.IsNullOrWhiteSpace(maxAge))
                    {
                        var age = int.Parse(maxAge.Replace("max-age=", ""));
                        Console.WriteLine($"Sleeping for {age} seconds");
                        Thread.Sleep(age * 1000);
                    }
                    else
                    {
                        Console.WriteLine("Sleeping for 2 seconds");
                        // Sleep for at least 2 seconds.
                        Thread.Sleep(2000);
                    }

                    runCalculationResponse = calculationApi.GetPACalculationByIdWithHttpInfo(calculationId);
                }
Esempio n. 7
0
        private static PACalculationParameters GetPaCalculationParameters()
        {
            // Build PA Engine calculation parameters
            var componentsApi = new ComponentsApi(GetEngineApiConfiguration());

            var componentsResponse = componentsApi.GetPAComponentsWithHttpInfo(PADefaultDocument);

            var paComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == PAComponentName && component.Value.Category == PAComponentCategory)).Key;

            Console.WriteLine($"PA Component Id : {paComponentId}");

            var paAccountIdentifier = new PAIdentifier(PABenchmarkSP50);
            var paAccounts          = new List <PAIdentifier> {
                paAccountIdentifier
            };
            var paBenchmarkIdentifier = new PAIdentifier(PABenchmarkR1000);
            var paBenchmarks          = new List <PAIdentifier> {
                paBenchmarkIdentifier
            };

            var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);

            return(paCalculation);
        }
        /// <summary>
        /// Run PA Calculation This endpoint runs the PA calculation specified in the POST body parameters.  It must be used first before polling or cancelling endpoints.  A successful response will contain the URL to poll for the result of the calculation.    Remarks:    * Any settings in POST body will act as a one-time override over the settings saved in the PA template.
        /// </summary>
        /// <exception cref="FactSet.AnalyticsAPI.Engines.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="pACalculationParameters"> (optional)</param>
        /// <returns>Task of ApiResponse (Object)</returns>
        public async System.Threading.Tasks.Task <FactSet.AnalyticsAPI.Engines.Client.ApiResponse <Object> > RunPACalculationAsyncWithHttpInfo(PACalculationParameters pACalculationParameters = default(PACalculationParameters))
        {
            FactSet.AnalyticsAPI.Engines.Client.RequestOptions localVarRequestOptions = new FactSet.AnalyticsAPI.Engines.Client.RequestOptions();

            String[] _contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "application/json"
            };

            foreach (var _contentType in _contentTypes)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var _accept in _accepts)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
            }

            localVarRequestOptions.Data = pACalculationParameters;

            // authentication (Basic) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + FactSet.AnalyticsAPI.Engines.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
            }

            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.PostAsync <Object>("/analytics/engines/pa/v2/calculations", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("RunPACalculation", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
        /// <summary>
        /// Run PA Calculation This endpoint runs the PA calculation specified in the POST body parameters.  It must be used first before polling or cancelling endpoints.  A successful response will contain the URL to poll for the result of the calculation.    Remarks:    * Any settings in POST body will act as a one-time override over the settings saved in the PA template.
        /// </summary>
        /// <exception cref="FactSet.AnalyticsAPI.Engines.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="pACalculationParameters"> (optional)</param>
        /// <returns>Task of Object</returns>
        public async System.Threading.Tasks.Task <Object> RunPACalculationAsync(PACalculationParameters pACalculationParameters = default(PACalculationParameters))
        {
            FactSet.AnalyticsAPI.Engines.Client.ApiResponse <Object> localVarResponse = await RunPACalculationAsyncWithHttpInfo(pACalculationParameters);

            return(localVarResponse.Data);
        }
 /// <summary>
 /// Run PA Calculation This endpoint runs the PA calculation specified in the POST body parameters.  It must be used first before polling or cancelling endpoints.  A successful response will contain the URL to poll for the result of the calculation.    Remarks:    * Any settings in POST body will act as a one-time override over the settings saved in the PA template.
 /// </summary>
 /// <exception cref="FactSet.AnalyticsAPI.Engines.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="pACalculationParameters"> (optional)</param>
 /// <returns>Object</returns>
 public Object RunPACalculation(PACalculationParameters pACalculationParameters = default(PACalculationParameters))
 {
     FactSet.AnalyticsAPI.Engines.Client.ApiResponse <Object> localVarResponse = RunPACalculationWithHttpInfo(pACalculationParameters);
     return(localVarResponse.Data);
 }