Example #1
0
        /// <summary>
        /// If args contains only filename, use default options.
        /// </summary>
        /// <param name="scores">Collection of BowlingScore</param>
        protected void SimpleScoreCounterBranch(ref ICollection <BowlingScore> scores)
        {
            IBowling bowling = new SimpleBowling();

            CountFinalScore(ref bowling, ref scores);

            IOutput output = new HTMLOutput();

            CreateOutput(ref output, GetDefaultFilename(ref output), ref scores);
        }
        /// <summary>
        /// Get HTMLOutput and path to template
        /// </summary>
        /// <param name="data">HTMLOutput and string</param>
        public void SetData(params object[] data)
        {
            if (data.Length > 0)
            {
                Output = (HTMLOutput)data[0];

                if (data.Length > 1)
                {
                    string command = (string)data[1];
                    templatePath = command.Split("=")[1];
                }
                else
                {
                    templatePath = Output.TemplatePath;
                }
            }
        }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                LabelStatus.Visible = false;

                string fundCode = Request["code"].ToString();
                _htmloutput = HTMLOutput.GetActiveInstance(fundCode);

                if (_htmloutput == null)
                {
                    LabelStatus.Text    = "必须从《持仓与归因分析》中调用本页面!";
                    LabelStatus.Visible = true;
                }
                else
                {
                    //基本信息
                    spFundInfo.InnerHtml = _htmloutput.GetFundInfo();

                    //交易明细
                    GridViewTradingDetail.DataSource = _htmloutput.GetTransactionTable();
                    GridViewTradingDetail.DataBind();

                    //申赎明细
                    GridViewSubscribeRedeem.DataSource = _htmloutput.GetSubscribeRedeemTable();
                    GridViewSubscribeRedeem.DataBind();
                }
            }
            catch (Exception ex)
            {
                LabelStatus.Text    = ex.Message;
                LabelStatus.Visible = true;
            }
        }
    }
Example #4
0
        /// <summary>
        /// Set custom or defualt Output
        /// </summary>
        /// <param name="output"></param>
        protected void TypeOutputBranch(out IOutput output)
        {
            string arg;

            if ((arg = ArgsContainsFlag(Constants.OUTPUT_TYPE_COMMAND_FULL_FLAG, Constants.OUTPUT_TYPE_COMMAND_SHORT_FLAG)) != null)
            {
                try
                {
                    command = factory.CreateCommand(Constants.OUTPUT_TYPE_COMMAND_FULL_FLAG);
                    command.SetData(arg);
                    command.Execute();

                    output = ((OutputTypeCommand)command).Output;
                }catch (Exception ex)
                {
                    ExecuteErrorCommand("Can not found type output.", "Use html type.");
                    output = new HTMLOutput();
                }
            }
            else
            {
                output = new HTMLOutput();
            }
        }
Example #5
0
    private void buildPerformanceReport(DateTime reportStart, DateTime reportEnd, string fundCode)
    {
        try
        {
            IFundDataAdapter   IFDA = FundDataAdaptorFactory.GetAdaptor(FundDataAdaptorFactory.AdapterType.YSS);
            IMarketDataAdapter IMDA = MarketDataAdaptorFactory.GetAdaptor(MarketDataAdaptorFactory.AdapterType.Wind);

            //基金类型数据
            DataTable dtFund   = DataService.GetInstance().GetPortfolioList();
            DataRow   oFundRow = null;
            if (dtFund != null)
            {
                for (int i = 0; i < dtFund.Rows.Count; i++)
                {
                    string fcode = dtFund.Rows[i]["Code"].ToString();
                    if (fcode == fundCode)
                    {
                        oFundRow = dtFund.Rows[i];
                        break;
                    }
                }
            }

            if (oFundRow == null)
            {
                LabelStatus.Text = "未知的代码!";
                return;
            }

            string fundName      = oFundRow["Name"].ToString();
            string isHedgeFund   = oFundRow["IsHedgeFund"].ToString();
            string assetType     = oFundRow["AssetType"].ToString();
            string operationType = oFundRow["opType"].ToString();

            Portfolio.PortfolioType       pType       = Portfolio.PortfolioType.MutualFund;
            Portfolio.PortfolioCategoryI  pCategoryI  = Portfolio.PortfolioCategoryI.EquityFund;
            Portfolio.PortfolioCategoryII pCategoryII = Portfolio.PortfolioCategoryII.OpenEnd;

            switch (assetType)
            {
            case "E":       //Equity
                pCategoryI = Portfolio.PortfolioCategoryI.EquityFund;
                break;

            case "B":       //Bond
                pCategoryI = Portfolio.PortfolioCategoryI.BondFund;
                break;

            case "M":       //Monetary
                pCategoryI = Portfolio.PortfolioCategoryI.MonetaryFund;
                break;

            default:
                break;
            }

            switch (operationType)
            {
            case "O":       //Open End
                pCategoryII = Portfolio.PortfolioCategoryII.OpenEnd;
                break;

            case "C":       //Close End
                pCategoryII = Portfolio.PortfolioCategoryII.CloseEnd;
                break;

            default:
                break;
            }

            if (isHedgeFund == "1")
            {
                pType = Portfolio.PortfolioType.HedgeFunds;
            }
            else
            {
                pType = Portfolio.PortfolioType.MutualFund;
            }


            //market data
            DataTable dtGZB          = DataService.GetInstance().GetGZB(reportStart, reportEnd, fundCode, null);
            DataTable dtTradingDays  = DataService.GetInstance().GetTradingDaysList(reportStart, reportEnd);
            DataTable dtPriceInfo    = DataService.GetInstance().GetStockPrices(reportStart, reportEnd);          //1Month:   2400 * 22 = 52800 Rows
            DataTable dtEquityInfo   = DataService.GetInstance().GetAShareStockList(null);                        //Total:    2400 Rows
            DataTable dtCapitalInfo  = DataService.GetInstance().GetFreeFloatCapital(reportEnd, null);            //Total:    2400 Rows
            DataTable dtIndustryInfo = DataService.GetInstance().GetSWIndustryList();                             //Total:      23 Rows

            //==============================
            //Benchmark
            //==============================
            DataTable          dtBenchmarkList = DataService.GetInstance().GetPortfolioBenchmarkList(fundCode);
            string             defaultBMCode   = "000300.SH";
            BenchmarkPortfolio bmf             = new BenchmarkPortfolio(reportStart, reportEnd, reportStart, reportEnd);
            if (dtBenchmarkList.Rows.Count > 0)
            {
                foreach (DataRow oRow in dtBenchmarkList.Rows)
                {
                    string benchmarkcode   = "";
                    string benchmarkname   = "";
                    double benchmarkweight = 0;
                    double constrate       = 0;

                    if (oRow["BENCHMARKCODE"] != DBNull.Value)
                    {
                        benchmarkcode = oRow["BENCHMARKCODE"].ToString();
                    }
                    if (oRow["BENCHMARKNAME"] != DBNull.Value)
                    {
                        benchmarkname = oRow["BENCHMARKNAME"].ToString();
                    }
                    if (oRow["BENCHMARKWEIGHT"] != DBNull.Value)
                    {
                        benchmarkweight = Convert.ToDouble(oRow["BENCHMARKWEIGHT"]);
                    }
                    if (oRow["CONSTRATE"] != DBNull.Value)
                    {
                        constrate = Convert.ToDouble(oRow["CONSTRATE"]);
                    }

                    if (benchmarkcode.Length > 0)
                    {
                        //e.g. 沪深300指数
                        DataTable dtBenchmarkIndex = DataService.GetInstance().GetIndexPrices(reportStart, reportEnd, benchmarkcode);
                        bmf.AddBenchmarkIndex(new BenchmarkDef(benchmarkcode, benchmarkname, benchmarkweight, 0, IMDA.GetPriceList(dtBenchmarkIndex)));
                        defaultBMCode = benchmarkcode;
                    }
                    else
                    {
                        //e.g. 银行存款
                        bmf.AddBenchmarkIndex(new BenchmarkDef(null, benchmarkname, benchmarkweight, constrate, null));
                    }
                }
            }

            DataTable dtBMWeight = DataService.GetInstance().GetIndexWeights(defaultBMCode, reportEnd);
            bmf.BuildBenchmarkComponents(IMDA.GetPositionList(dtBMWeight), IMDA.GetPriceList(dtPriceInfo));

            //==============================
            //Performance Evaluator
            //==============================
            PerformanceEvaluator pe = new PerformanceEvaluator(reportStart, reportEnd, fundCode, fundName, pType, pCategoryI, pCategoryII);
            pe.BuildPortfolios(IFDA.BuildGZBList(dtGZB), IMDA.GetPositionList(dtEquityInfo), IMDA.GetPriceList(dtPriceInfo), IMDA.GetPositionList(dtCapitalInfo));

            //更新债券到期日等
            string bondcodelist = "";
            pe.GetBondPositions(out bondcodelist);
            if (bondcodelist.Length > 0)
            {
                DataTable dtBondInfo = DataService.GetInstance().GetChinaBondList(bondcodelist);
                pe.UpdateBondPositions(IMDA.GetPositionList(dtBondInfo));
            }

            //评估
            pe.Evaluate(bmf, IMDA.GetIndustryList(dtIndustryInfo));

            //==============================
            //Output
            //==============================
            _htmloutput = new HTMLOutput(pe);

            //基本信息
            spFundInfo.InnerHtml = _htmloutput.GetFundInfo();

            //流动性风险: 股票/债券
            GridViewEquityPositionDetail.DataSource = _htmloutput.GetEquityPositionTable();
            GridViewEquityPositionDetail.DataBind();
            GridViewBondPositionDetail.DataSource = _htmloutput.GetPureBondPositionTable();
            GridViewBondPositionDetail.DataBind();
            GridViewCBondPositionDetail.DataSource = _htmloutput.GetConvertableBondPositionTable();
            GridViewCBondPositionDetail.DataBind();
            GridViewCashPositionDetail.DataSource = _htmloutput.GetCashPositionTable();
            GridViewCashPositionDetail.DataBind();
            GridViewOtherPositionDetail.DataSource = _htmloutput.GetOtherPositionTable();
            GridViewOtherPositionDetail.DataBind();

            //绩效归因
            GridViewIndustry.DataSource = _htmloutput.GetIndustryTable();
            GridViewIndustry.DataBind();
        }
        catch (Exception ex)
        {
            LabelStatus.Visible = true;
            LabelStatus.Text    = ex.Message;
        }
    }