コード例 #1
0
        public String Output()
        {
            List <DateTime> dates  = datesAndValuation.Keys.ToList();
            List <double>   values = datesAndValuation.Values.ToList();

            String output = "<stock benchID=\"" + benchId + '\"' + '\n' +
                            "benchmark=\"" + benchmark + '\"' + '\n' +
                            "id=\"" + id + '\"' + '\n' +
                            "industry=\"" + industry + '\"' + '\n' +
                            "name=\"" + name + '\"' + '\n' +
                            "sector=\"" + sector + '\"' + '>' + '\n' +
                            "<zone zname=\"" + zone + "\">" + '\n' +
                            "<country cname=\"" + country + "\" />" + '\n' + "</zone>" + '\n' +
                            "<sector sname=\"" + sector + "\" >" + '\n' +
                            "<industry iname=\"" + industry + "\" />" + '\n' +
                            "</sector>" + '\n' + "<prices>";

            for (int i = 0; i < datesAndValuation.Count(); i++)
            {
                double mm4 = -1, mm12 = -1, mm24 = -1;
                avg4M.TryGetValue(dates.ElementAt(i), out mm4);
                avg1Y.TryGetValue(dates.ElementAt(i), out mm12);
                avg2Y.TryGetValue(dates.ElementAt(i), out mm24);
                string d = dates.ElementAt(i).ToString().Substring(0, 10);
                output += "<obs relativePerf= \"" + Math.Round(relativePerf.ElementAt(i), 2) + "\" mm24 =" + (((int)mm24 != 0) ? "\"" + Math.Round(mm24, 2) : "\"") + "\" mm12 = \"" + (((int)mm12 != 0) ? Math.Round(mm12, 2) + "\"" : "\"");
                output += " mm4 = \"" + (((int)mm4 != 0) ? Math.Round(mm4, 2) + "\"" : "\"") + " priceBench=\"" + Math.Round(index.ValueAt(i), 2) + "\" price = \"" + Math.Round(values.ElementAt(i), 2) + "\"";
                output += "  date=\"" + d + "\" />";
                output += '\n';
            }
            output += "</prices>" + '\n' + "<indicators> " + '\n';
            output += "<indicator" + ((alpha3M != VALUE_IF_ERROR) ? " alpha=\"" + Math.Round(alpha3M, 2) + "\"" : "") + ((beta3M != VALUE_IF_ERROR) ? " beta=\"" + Math.Round(beta3M, 2) + "\"" : "") + " perf=\"" + Math.Round(perf3M, 2) + "\" period =\"3M\" />";
            output += "<indicator" + ((alpha6M != VALUE_IF_ERROR) ? " alpha=\"" + Math.Round(alpha6M, 2) + "\"" : "") + ((beta6M != VALUE_IF_ERROR) ? " beta=\"" + Math.Round(beta6M, 2) + "\"" : "") + " perf=\"" + Math.Round(perf6M, 2) + "\" period =\"6M\" />";
            output += "<indicator" + ((alpha1Y != VALUE_IF_ERROR) ? " alpha=\"" + Math.Round(alpha1Y, 2) + "\"" : "") + ((beta1Y != VALUE_IF_ERROR) ? " beta=\"" + Math.Round(beta1Y, 2) + "\"" : "") + " perf=\"" + Math.Round(perf1Y, 2) + "\" period =\"1Y\" />";
            output += "<indicator" + ((alpha3Y != VALUE_IF_ERROR) ? " alpha=\"" + Math.Round(alpha3Y, 2) + "\"" : "") + ((beta3Y != VALUE_IF_ERROR) ? " beta=\"" + Math.Round(beta3Y, 2) + "\"" : "") + " perf=\"" + Math.Round(perf3Y, 2) + "\" period =\"3Y\" />";
            output += "<indicator" + ((alpha5Y != VALUE_IF_ERROR) ? " alpha=\"" + Math.Round(alpha5Y, 2) + "\"" : "") + ((beta5Y != VALUE_IF_ERROR) ? " beta=\"" + Math.Round(beta5Y, 2) + "\"" : "") + " perf=\"" + Math.Round(perf5Y, 2) + "\" period =\"5Y\" />";
            output += "<indicator" + ((alpha != VALUE_IF_ERROR) ? " alpha=\"" + Math.Round(alpha, 2) + "\"" : "") + ((beta != VALUE_IF_ERROR) ? " beta=\"" + Math.Round(beta, 2) + "\"" : "") + " perf=\"" + Math.Round(perfAT, 2) + "\" period =\"All-Time\" />";
            output += "<volat>" + '\n' +
                      "<vol Vol_weekly = \"" + Math.Round(volatility, 2) + "\" />" +
                      "<vol Vol_annual = \"" + Math.Round(annualVolatility, 2) + "\" />" + '\n' + "</volat>" + '\n' + "</indicators>" + '\n' +
                      "<trackingError te= \"" + Math.Round(trackingError, 2) + "\" />" + '\n' +
                      "<informationRatio ir= \"" + Math.Round(informationRatio, 2) + "\" />" + '\n' + "</stock>" + '\n';

            return(output);
        }