Exemple #1
0
        public static MTable GetMutliSetData(MongoDataReader w, string[] code, DateTime endt, Cycle cyc, PriceAdj prcAdj, bool IncludeBaseData, string args)
        {
            RunNoticeClass ret  = new RunNoticeClass();
            MTable         mtab = new MTable();

            if (IncludeBaseData)
            {
                BaseDataProcess bp   = new BaseDataProcess_ForMG(w, cyc, prcAdj);
                RunResultClass  bret = bp.getSetDataResult(code, endt, new object[0] {
                });
                if (!bret.Notice.Success)
                {
                    mtab.Union(bret.Result);
                    //return new BaseDataTable();
                }
            }
            Dictionary <string, HashSet <string> > guids = getMutliValueGuid(args.Split(','));

            foreach (string key in guids.Keys)
            {
                MutliValueGuidProcess_ForMG cgp = new MutliValueGuidProcess_ForMG(w, key, guids[key].ToArray <string>());
                cgp.cycle  = cyc;
                cgp.prcAdj = prcAdj;
                RunResultClass cret = cgp.getSetDataResult(code, endt, new object[0] {
                });
                mtab.Union(cret.Result);
            }
            return(mtab);
        }
Exemple #2
0
        public static MTable getBkList(MongoDataReader w, string sec, DateTime dt, bool FilterTheNoPrice)
        {
            SecIndexClass   sic = new SecIndexClass(sec);
            secIndexBuilder sib = new secIndexBuilder(w, sic);
            MTable          mt  = sib.getBkList(dt);

            if (mt == null || mt.Count == 0)
            {
                return(mt);
            }
            BaseDataProcess_ForMG bdp = new BaseDataProcess_ForMG(w);

            string[]       seccodes = mt["wind_code"].ToList <string>().ToArray();
            RunResultClass rc       = bdp.getSetDataResult(seccodes, "close", dt);
            MTable         ret      = new MTable();
            List <DataRow> NewDrs   = new List <DataRow>();

            for (int i = 0; i < rc.Result.Count; i++)
            {
                DataRow retdr = mt.GetTable().Rows[i];
                DataRow dr    = rc.Result.GetTable().Rows[i];
                if (dr.IsNull("CLOSE") && FilterTheNoPrice)
                {
                    continue;
                }
                NewDrs.Add(retdr);
            }
            ret.FillList(NewDrs.ToArray());
            return(ret);
        }
Exemple #3
0
        public static DateTime[] getTradeDates(MongoDataReader w, string SecCode, DateTime begt, DateTime endt, Cycle cyc)
        {
            BaseDataTable tb  = CommWDToolClass.GetBaseSerialData(w, SecCode, begt, endt, cyc, PriceAdj.UnDo, BaseDataPoint.trade_status, BaseDataPoint.sec_type, BaseDataPoint.close);
            BaseDataTable ttb = tb.AvaliableData;

            return(ttb["DateTime"].ToList <DateTime>().ToArray());
        }
Exemple #4
0
        public static DateTime Offset(MongoDataReader w, BaseDataItemClass SecItem, DateTime dt, int N, Cycle cyc)
        {
            DateTime begt = SecItem.Ipo_date;

            if (SecItem.SecType == SecType.Index)
            {
                //指数不停牌,自然日按交易日*7/5,放大到10/2=2倍指定开始日
                switch (cyc)
                {
                case Cycle.Day:
                {
                    begt = dt.AddDays(-2 * N);
                    break;
                }

                case Cycle.Week:
                {
                    begt = dt.AddDays(-7 * N);
                    break;
                }

                case Cycle.Month:
                {
                    begt = dt.AddMonths(N);
                    break;
                }

                case Cycle.Year:
                {
                    begt = dt.AddYears(N);
                    break;
                }
                }
            }
            if (begt.CompareTo(SecItem.Ipo_date) < 0)//任何情况(index的ipo日期为1899-12-31)如果开始日期小于ipo日期,开始日期设置为Ipo日期。
            {
                begt = SecItem.Ipo_date;
            }


            BaseDataTable tb = CommMGToolClass.GetBaseSerialData(
                w,
                SecItem.WindCode,
                begt,
                dt,
                Cycle.Day,
                PriceAdj.UnDo,
                BaseDataPoint.trade_status, BaseDataPoint.sec_type);
            BaseDataTable ttb = tb.AvaliableData;

            if (ttb.Count == 0)
            {
                return(dt);              //如果数据为空,返回回览日
            }
            if (ttb.Count > N)
            {
                return(((BaseDataItemClass)ttb[ttb.Count - N]).DateTime);
            }
            return(((BaseDataItemClass)ttb[0]).DateTime);
        }
Exemple #5
0
        public static int getTradeDays(MongoDataReader w, DateTime begt, DateTime endt)
        {
            TDaysGuidClas          tgc = new TDaysGuidClas();
            TDayGuildBuilder_ForMG tgb = new TDayGuildBuilder_ForMG(w, tgc);
            MTable ret = tgb.getRecordsCount(begt, endt);

            return((int)ret.GetTable().Rows[0][0]);
        }
Exemple #6
0
 /// <summary>
 /// 市场最后交易日
 /// </summary>
 /// <param name="w"></param>
 /// <param name="dt"></param>
 /// <returns></returns>
 public static DateTime LastTradeDay(MongoDataReader w, DateTime dt, Cycle cy)
 {
     DateTime[] ret = getTradeDates(w, dt.AddDays(-20), dt, cy);
     if (ret.Length > 0)
     {
         return(ret[ret.Length - 1]);
     }
     return(DateTime.MinValue);
 }
Exemple #7
0
        public static DateTime[] getTradeDates(MongoDataReader w, DateTime begt, DateTime endt, Cycle cyc)
        {
            TDaysGuidClas tgc = new TDaysGuidClas();

            tgc.cycle = cyc;
            TDayGuildBuilder_ForMG tgb = new TDayGuildBuilder_ForMG(w, tgc);
            MTable ret = tgb.getRecords(begt, endt);

            return(ret.ToList <DateTime>().ToArray());
        }
Exemple #8
0
        public static DateTime LastTradeDay(MongoDataReader w, string SecCode, DateTime dt)
        {
            BaseDataTable tb  = CommMGToolClass.GetBaseSerialData(w, SecCode, dt.AddDays(-1000), dt, Cycle.Day, PriceAdj.UnDo, BaseDataPoint.trade_status, BaseDataPoint.sec_type, BaseDataPoint.close);
            BaseDataTable ttb = tb.AvaliableData;

            if (ttb.Count == 0)
            {
                return(DateTime.MinValue);
            }
            return(((BaseDataItemClass)ttb[ttb.Count - 1]).DateTime);
        }
Exemple #9
0
        /// <summary>
        /// 根据指数获得未停牌股票
        /// </summary>
        /// <param name="indexName">板块/指数组合</param>
        /// <param name="EndT"></param>
        /// <param name="CheckDays"></param>
        /// <param name="NextDay"></param>
        /// <param name="ExcludeSt"></param>
        /// <param name="MAFilter"></param>
        /// <param name="ExcludeSecList"></param>
        public static BaseDataTable GetMarketsStocks(MongoDataReader w, string indexName, DateTime EndT, Int64 CheckDays, bool NextDay, bool ExcludeSt, bool MAFilter, List <string> ExcludeSecList)
        {
            BaseDataTable ret = new BaseDataTable();

            string[] bkArr    = indexName.Split(';');
            string[] seclist  = new string[0]; //默认股票列表为空
            string[] secnames = new string[0]; //默认股票列表为空
            if (bkArr.Length > 1)              //板块或指数组合
            {
                return(ret);
            }
            else
            {
                if (!IsSecIndex(w, indexName, EndT, out seclist, out secnames)) //不是集合
                {
                    if (indexName.IndexOf(".") > 0)                             //如果是0000xx.xx类型
                    {
                        seclist = new string[1] {
                            indexName
                        };
                    }
                    else
                    {
                        return(ret);
                    }
                }
            }
            //ret.Result.AddColumnByArray<string>("Code", seclist);
            //ret.Result.AddColumnByArray<string>("Name", secnames);
            BaseDataTable dt = GetBaseData(w, seclist, EndT, Cycle.Day, PriceAdj.Beyond, new object[0] {
            });

            dt = dt.AvaliableData;
            BaseDataTable rdt = new BaseDataTable();

            rdt = new BaseDataTable(dt.GetTable().Clone());
            var Tarr = from dr in dt.ToFillableList <BaseDataItemClass>()
                       where dr.OnMarketDayCount >= CheckDays
                       select dr;

            rdt.FillByItems <BaseDataItemClass>(Tarr.ToArray <BaseDataItemClass>());
            ret = rdt;
            if (ExcludeSt)
            {
                var NoSTArr = from dr in rdt.ToFillableList <BaseDataItemClass>()
                              where dr.IsST == false
                              select dr;

                ret = new BaseDataTable(rdt.GetTable());
                ret.FillByItems <BaseDataItemClass>(NoSTArr.ToArray <BaseDataItemClass>());
            }
            return(ret);
        }
Exemple #10
0
        public static BaseDataTable GetBaseData(MongoDataReader w, string[] codes, DateTime endt, Cycle cyc, PriceAdj prcAdj, params object[] args)
        {
            RunNoticeClass ret = new RunNoticeClass();
            //MACDGuidProcess mp = new MACDGuidProcess(gb.w);
            //RunResultClass ret = mp.getDateSerialResult("000100.SZ",Convert.ToDateTime("2017/7/7"), DateTime.Today);
            BaseDataProcess bp   = new BaseDataProcess_ForMG(w, cyc, prcAdj);
            RunResultClass  bret = bp.getSetDataResult(codes, endt, args);

            if (!bret.Notice.Success)
            {
                return(new BaseDataTable());
            }
            return(new BaseDataTable(bret.Result));
        }
Exemple #11
0
        public static DateTime Offset(MongoDataReader w, DateTime endt, int N, Cycle cyc)
        {
            TDaysGuidClas tgc = new TDaysGuidClas();

            tgc.cycle = cyc;
            TDayGuildBuilder_ForMG tgb = new TDayGuildBuilder_ForMG(w, tgc);
            MTable   ret      = tgb.getRecords(endt, N);
            DateTime lastdate = Convert.ToDateTime(ret.GetTable().Rows[0][0]);

            if (cyc == Cycle.Day)
            {
                return(lastdate);
            }
            DateTime[] dates = getTradeDates(w, lastdate, endt);
            for (int i = 0; i < dates.Length - 1; i++)
            {
                if (dates[i].AddDays(1).CompareTo(dates[i + 1]) < 0)
                {
                    return(dates[i]);
                }
            }
            return(lastdate);
        }
Exemple #12
0
        public static bool IsSecIndex(MongoDataReader w, string strName, DateTime EndT, out string[] seclist, out string[] secnames)
        {
            seclist  = new string[0];
            secnames = new string[0];
            if (strName == null || strName.Trim().Length == 0)
            {
                return(false);
            }

            SecIndexClass   sic = new SecIndexClass(strName);
            secIndexBuilder sib = new secIndexBuilder(w, sic);
            MTable          mtb = sib.getBkList(EndT);

            if (mtb.Count == 0)
            {
                return(false);
            }

            //throw (new Exception(mtb.ToRowData(0)));
            seclist  = mtb.ToList <string>("wind_code").ToArray();
            secnames = mtb.ToList <string>("sec_name").ToArray();
            return(true);
        }
Exemple #13
0
 public GuidBuilder_ForMG(MongoDataReader _w, GuidBaseClass guidClass) : base(new CommDataInterface_ForMG(_w), guidClass)
 {
     w = _w;
     strParamsStyle = "tradeDate={0};priceAdj={2};cycle={3};{1}";
 }
Exemple #14
0
 //WindData wd = w.wsd("600011.SH", "MACD", "2017-02-05", "2018-03-06", "MACD_L=26;MACD_S=12;MACD_N=9;MACD_IO=1;Fill=Previous");
 public DateSerialGuidBuilder_ForMG(MongoDataReader _w, GuidBaseClass guidClass) : base(_w, guidClass)
 {
     strParamsStyle = "priceAdj={1};Period={2};Fill=Previous;{0}";
 }
 public CommDataBuilder_ForMG(MongoDataReader _w) : base(new CommDataInterface_ForMG(_w))
 {
     w = _w;
 }
Exemple #16
0
 public static MTable getBkList(MongoDataReader w, string sec, DateTime dt)
 {
     return(getBkList(w, sec, dt, true));
 }
 public CommDataBuilder_ForMG(MongoDataReader _w, GuidBaseClass guidClass) : base(new CommDataInterface_ForMG(_w), guidClass)
 {
     w = _w;
 }
Exemple #18
0
 public static BaseDataTable GetBaseData(MongoDataReader w, string codes, DateTime endt, Cycle cyc, PriceAdj prcAdj, params object[] args)
 {
     return(GetBaseData(w, codes.Split(','), endt, cyc, prcAdj, args));
 }
Exemple #19
0
 public static BaseDataTable GetBaseSerialData(MongoDataReader w, string code, DateTime begt, DateTime endt)
 {
     return(GetBaseSerialData(w, code, begt, endt, Cycle.Day, PriceAdj.Beyond));
 }
 public CommGuidProcess_ForMG(CommDataInterface_ForMG cdi) : base(cdi)
 {
     w = cdi.w;
 }
 public CommDataInterface_ForMG(MongoDataReader _w) : base()
 {
     w = _w;
 }
Exemple #22
0
 public static BaseDataTable GetBaseSerialData(MongoDataReader w, string code, DateTime begt, DateTime endt, Cycle cyc, PriceAdj prcAdj)
 {
     return(GetBaseSerialData(w, code, begt, endt, cyc, prcAdj, new object[0] {
     }));
 }
 public CommGuidProcess_ForMG(CommDataInterface_ForMG cdi, CommDataBuilder_ForMG _gbc, Cycle cyc, PriceAdj rate) : base(cdi, _gbc, cyc, rate)
 {
     w = cdi.w;
 }
 public BaseDataProcess_ForMG(MongoDataReader _w, CommDataBuilder_ForMG _gbc, Cycle cyc, PriceAdj rate) : base(new CommDataInterface_ForMG(_w), cyc, rate)
 {
     w = _w;
 }
 public MutliValueGuidProcess_ForMG(MongoDataReader _w, string guidName, params string[] args) : base(new CommDataInterface_ForMG(_w))
 {
     w          = _w;
     GuildName  = guidName;
     ValueNames = args;
 }
Exemple #26
0
 public static DateTime LastTradeDay(MongoDataReader w, DateTime dt)
 {
     return(LastTradeDay(w, dt, Cycle.Day));
 }
Exemple #27
0
 public static DateTime[] getTradeDates(MongoDataReader w, DateTime begt, DateTime endt)
 {
     return(getTradeDates(w, begt, endt, Cycle.Day));
 }
 public TDayGuildBuilder_ForMG(MongoDataReader _w, GuidBaseClass guidClass)
     : base(_w, guidClass)
 {
     strParamsStyle = "Period={0};";//Days=Weekdays
 }
 public BaseDataProcess_ForMG(MongoDataReader _w) : base(new CommDataInterface_ForMG(_w))
 {
     w = _w;
 }