示例#1
0
 static void Main(string[] args)
 {
     while (true)
     {
         var json = Console.ReadLine();
         if (json == null)
         {
             break;
         }
         CalculationQuery data = Newtonsoft.Json.JsonConvert.DeserializeObject <CalculationQuery>(json);
         //cErrorHandler m_objErrors = new cErrorHandler();
         cPrepareSmallData m_objSmallEngine;
         m_objSmallEngine = new cPrepareSmallData();
         var colRisks   = new List <double>();
         var colReturns = new List <double>();
         double[,] matWeights = new double[0, 0];
         string err = m_objSmallEngine.runOptimizationProcess(out colRisks, out colReturns, out matWeights, data.MatCovariance, data.ArrReturns);
         CalculationResponse resp = new CalculationResponse
         {
             colReturns  = colReturns,
             colRisks    = colRisks,
             matWeights  = matWeights,
             errorString = err
         };
         Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(resp));
         //cErrorHandler m_objErrors = new cErrorHandler();
     }
 }
示例#2
0
        public String runOptimizationProcess(out List <double> colRisks, out List <double> colReturns, out double[,] matWeights, double[,] dCovarMatrix, double[] dRatesVector,
                                             double[] arrUpperBound, double[] arrLowerBound, List <List <double> > colEqualitySecs, double[] arrEqualityVals, int iEqualityNum, List <List <double> > colInequalitySecs,
                                             double[] arrInequalityVals, int iEps, int iLoopsMax)
        { // Performs the entire optimization process and returns portfolio risk / returns + weights matrix
            // Initialize collections
            colRisks   = new List <double>();
            colReturns = new List <double>();


            String sSciError = "";

            matWeights = new double[0, 0];

            CalculationQuery query = new CalculationQuery
            {
                ArrReturns    = dRatesVector,
                MatCovariance = dCovarMatrix
            };

            lock (lockObject)
            {
                cQLDService.compiler.StandardInput.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(query));
                var res = cQLDService.compiler.StandardOutput.ReadLine();
                CalculationResponse resp = Newtonsoft.Json.JsonConvert.DeserializeObject <CalculationResponse>(res);

                colRisks   = resp.colRisks;
                colReturns = resp.colReturns;
                matWeights = resp.matWeights;
                sSciError  = resp.errorString;
            }
            return(sSciError);
        }//runOptimizationProcess
示例#3
0
        public decimal Calculate(CalculationQuery query)
        {
            var result = calculator.CalculateSalaryFor(query.PersonId, query.Date.DateTime);

            return(result);
        }