Пример #1
0
        private ApiResponse <object> RunCalculation()
        {
            var sparComponents  = componentsApi.GetSPARComponentsWithHttpInfo(CommonParameters.SPARDefaultDocument);
            var sparComponentId = sparComponents.Data.Data.Keys.First();

            var sparAccountIdentifier = new SPARIdentifier(CommonParameters.SPARBenchmarkR1000);
            var sparAccount           = new List <SPARIdentifier> {
                sparAccountIdentifier
            };
            var sparBenchmark = new SPARIdentifier(CommonParameters.SPARBenchmarkRussellPR1000);
            var sparDates     = new SPARDateParameters("20180101", "20181231", "Monthly");

            var sparCalculationParameters = new SPARCalculationParameters(sparComponentId, sparAccount, sparBenchmark, sparDates);

            var parameters = new SPARCalculationParametersRoot
            {
                Data = new Dictionary <string, SPARCalculationParameters> {
                    { "1", sparCalculationParameters }, { "2", sparCalculationParameters }
                }
            };

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

            return(response);
        }
Пример #2
0
        private ApiResponse <object> RunCalculation()
        {
            var parameters = new Calculation();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

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

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

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


            var response = _calculationsApi.RunCalculationWithHttpInfo(parameters);

            return(response);
        }
Пример #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 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
            {
                // Build SPAR Engine calculation parameters
                var componentsApi = new ComponentsApi(GetEngineApiConfiguration());

                var componentsResponse = componentsApi.GetSPARComponentsWithHttpInfo(SPARDefaultDocument);

                var sparComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == SPARComponentName && component.Value.Category == SPARComponentCategory)).Key;
                Console.WriteLine($"SPAR Component Id : {sparComponentId}");
                var sparAccountIdentifier = new SPARIdentifier(SPARBenchmarkR1000, SPARBenchmarkRussellReturnType, SPARBenchmarkRussellPrefix);
                var sparAccounts          = new List <SPARIdentifier> {
                    sparAccountIdentifier
                };
                var sparBenchmarkIdentifier = new SPARIdentifier(SPARBenchmarkRussellPr2000, SPARBenchmarkRussellReturnType, SPARBenchmarkRussellPrefix);

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

                var calculationApi = new SPARCalculationsApi(GetEngineApiConfiguration());

                var runCalculationResponse = calculationApi.RunSPARCalculationWithHttpInfo(sparCalculation);

                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.GetSPARCalculationByIdWithHttpInfo(calculationId);
                }
Пример #5
0
        private ApiResponse <object> RunCalculation()
        {
            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.SPARBenchmarkR1000, CommonParameters.SPARBenchmarkRussellReturnTypeP, CommonParameters.SPARBenchmarkRussellPrefix);

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

            var response = _calculationsApi.RunSPARCalculationWithHttpInfo(sparCalculation);

            return(response);
        }
        private static SPARCalculationParameters GetSparCalculationParameters()
        {
            // Build SPAR Engine calculation parameters
            var componentsApi = new ComponentsApi(GetEngineApiConfiguration());

            var componentsResponse = componentsApi.GetSPARComponentsWithHttpInfo(SPARDefaultDocument);

            var sparComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == SPARComponentName && component.Value.Category == SPARComponentCategory)).Key;

            Console.WriteLine($"SPAR Component Id : {sparComponentId}");
            var sparAccountIdentifier = new SPARIdentifier(SPARBenchmarkR1000, SPARBenchmarkRussellReturnType, SPARBenchmarkRussellPrefix);
            var sparAccounts          = new List <SPARIdentifier> {
                sparAccountIdentifier
            };
            var sparBenchmarkIdentifier = new SPARIdentifier(SPARBenchmarkRussellPr2000, SPARBenchmarkRussellReturnType, SPARBenchmarkRussellPrefix);

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

            return(sparCalculation);
        }
Пример #7
0
        private static SPARCalculationParameters GetSparCalculationParameters1()
        {
            var componentsApi = new ComponentsApi(GetApiConfiguration());

            var componentsResponse = componentsApi.GetSPARComponents(SPARDefaultDocument);

            var sparComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == SPARComponentName && component.Value.Category == SPARComponentCategory)).Key;

            Console.WriteLine($"SPAR Component Id : {sparComponentId}");

            var sparAccountIdentifier = new SPARIdentifier(SPARBenchmark1, SPARBenchmarkReturnType, SPARBenchmarkPrefix);
            var sparAccounts          = new List <SPARIdentifier> {
                sparAccountIdentifier
            };
            var sparBenchmarkIdentifier = new SPARIdentifier(SPARBenchmark, SPARBenchmarkReturnType, SPARBenchmarkPrefix);

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

            return(sparCalculation);
        }
        /// <summary>
        /// Run SPAR Calculation This endpoint runs the SPAR 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 SPAR template.
        /// </summary>
        /// <exception cref="FactSet.AnalyticsAPI.Engines.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="sPARCalculationParameters"> (optional)</param>
        /// <returns>Task of ApiResponse (Object)</returns>
        public async System.Threading.Tasks.Task <FactSet.AnalyticsAPI.Engines.Client.ApiResponse <Object> > RunSPARCalculationAsyncWithHttpInfo(SPARCalculationParameters sPARCalculationParameters = default(SPARCalculationParameters))
        {
            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 = sPARCalculationParameters;

            // 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/spar/v2/calculations", localVarRequestOptions, this.Configuration);

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

            return(localVarResponse);
        }
        /// <summary>
        /// Run SPAR Calculation This endpoint runs the SPAR 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 SPAR template.
        /// </summary>
        /// <exception cref="FactSet.AnalyticsAPI.Engines.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="sPARCalculationParameters"> (optional)</param>
        /// <returns>Task of Object</returns>
        public async System.Threading.Tasks.Task <Object> RunSPARCalculationAsync(SPARCalculationParameters sPARCalculationParameters = default(SPARCalculationParameters))
        {
            FactSet.AnalyticsAPI.Engines.Client.ApiResponse <Object> localVarResponse = await RunSPARCalculationAsyncWithHttpInfo(sPARCalculationParameters);

            return(localVarResponse.Data);
        }
 /// <summary>
 /// Run SPAR Calculation This endpoint runs the SPAR 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 SPAR template.
 /// </summary>
 /// <exception cref="FactSet.AnalyticsAPI.Engines.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="sPARCalculationParameters"> (optional)</param>
 /// <returns>Object</returns>
 public Object RunSPARCalculation(SPARCalculationParameters sPARCalculationParameters = default(SPARCalculationParameters))
 {
     FactSet.AnalyticsAPI.Engines.Client.ApiResponse <Object> localVarResponse = RunSPARCalculationWithHttpInfo(sPARCalculationParameters);
     return(localVarResponse.Data);
 }