예제 #1
0
        private MWNumericArray GetIndexTimeSeries(IndexType type, int yieldspan)
        {
            IndexSelector ids    = new IndexSelector();
            IndexGroup    idgSWI = null;;

            switch (type)
            {
            case IndexType.SWIndustry:
                idgSWI = ids.GetSWIndustryIndex();
                break;

            case IndexType.ZXIndustry:
                idgSWI = ids.GetZXIndustryIndex();
                break;

            case IndexType.JCIndustry:
                idgSWI = ids.GetJCIndustryIndex();
                break;

            case IndexType.ZZSize:
                idgSWI = ids.GetZZSizeIndex();
                break;

            case IndexType.JCSize:
                idgSWI = ids.GetJCSizeIndex();
                break;

            case IndexType.SWProfit:
                idgSWI = ids.GetSWProfitIndex();
                break;

            case IndexType.JCStyle:
                idgSWI = ids.GetJCStyleIndex();
                break;

            default:
                throw new Exception("未知的指数类型");
            }

            idgSWI.SetDatePeriod(this.StartDate, this.EndDate);
            idgSWI.LoadData(DataInfoType.SecurityInfo);
            idgSWI.LoadData(DataInfoType.TradingPrice);

            int rows = idgSWI.SecurityHoldings[0].TradingPrice.AdjustedTimeSeries.Count;
            int cols = idgSWI.SecurityHoldings.Count;

            double[,] aryi = new double[rows, cols];
            for (int irow = 0; irow < rows; irow++)
            {
                for (int icol = 0; icol < cols; icol++)
                {
                    //从降序排列转换为升序排列
                    Nullable <double> d = null;
                    switch (yieldspan)
                    {
                    case 1:
                        d = idgSWI.SecurityHoldings[icol].TradingPrice.AdjustedTimeSeries[irow].UpAndDown.KLineDay1;
                        break;

                    case 2:
                        d = idgSWI.SecurityHoldings[icol].TradingPrice.AdjustedTimeSeries[irow].UpAndDown.KLineDay2;
                        break;

                    case 3:
                        d = idgSWI.SecurityHoldings[icol].TradingPrice.AdjustedTimeSeries[irow].UpAndDown.KLineDay3;
                        break;

                    case 4:
                        d = idgSWI.SecurityHoldings[icol].TradingPrice.AdjustedTimeSeries[irow].UpAndDown.KLineDay4;
                        break;

                    case 5:
                        d = idgSWI.SecurityHoldings[icol].TradingPrice.AdjustedTimeSeries[irow].UpAndDown.KLineDay5;
                        break;

                    default:
                        d = idgSWI.SecurityHoldings[icol].TradingPrice.AdjustedTimeSeries[irow].UpAndDown.KLineDay1;
                        break;
                    }

                    if (d == null)
                    {
                        aryi[rows - irow - 1, icol] = 0;
                    }
                    else
                    {
                        aryi[rows - irow - 1, icol] = d.Value;
                    }
                }
            }

            MWNumericArray x = aryi;

            return(x);
        }