예제 #1
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);
        }
예제 #2
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);
        }
예제 #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);
        }