public FilterLogicBaseClass(Cycle cyc, PriceAdj rate)
 {
     Cycle = cyc;
     Rate  = rate;
 }
Beispiel #2
0
 public FirstPointFilter(Cycle cyc, PriceAdj rate) : base(cyc, rate)
 {
 }
Beispiel #3
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));
 }
Beispiel #4
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);
        }
Beispiel #5
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] {
     }));
 }
Beispiel #6
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));
        }
Beispiel #7
0
        public MongoDataDictionary <StockMongoData> Stock_FQ(MongoDataDictionary <StockMongoData> orgData, MongoDataDictionary <XDXRData> XData = null, PriceAdj fqType = PriceAdj.Fore)
        {
            MongoDataDictionary <StockMongoData> ret = new MongoDataDictionary <StockMongoData>();

            foreach (string key in orgData.Keys)
            {
                MongoReturnDataList <StockMongoData> val  = orgData[key];
                MongoReturnDataList <XDXRData>       xval = null;
                if (XData != null)
                {
                    if (XData.ContainsKey(key))
                    {
                        xval = XData[key];
                    }
                }
                if (!ret.ContainsKey(key))
                {
                    ret.Add(key, Stock_FQ(key, val, xval, fqType));
                }
            }
            return(ret);
        }
 public BaseDataProcess_ForWD(WindAPI _w, CommDataBuilder_ForWD _gbc, Cycle cyc, PriceAdj rate) : base(new CommDataInterface_ForWD(_w), cyc, rate)
 {
     w = _w;
 }
Beispiel #9
0
 public CommGuidProcess(CommDataIntface cdi, CommDataBuilder _gbc, Cycle cyc, PriceAdj rate) : base(cdi)
 {
     gbc    = _gbc;
     cycle  = cyc;
     prcAdj = rate;
 }
Beispiel #10
0
        public MongoReturnDataList <StockMongoData> Stock_FQ(string code, MongoReturnDataList <StockMongoData> org_bfq_data = null, MongoReturnDataList <XDXRData> org_xdxr_data = null, PriceAdj fqType = PriceAdj.Fore)
        {
            /*
             * 1、一般的股票交易软件中,都有计算复权的功能。股票行情有除权与复权,在计算股票涨跌幅时采用复权价格,这是经常要用到的。系统计算分为以下步骤:
             * ①每次除权行为日,在登记日计算除权价;
             * 除权价=(除权前一日收盘价+配股价X配股比率-每股派息)/(1+配股比率+送股比率)
             * ②用登记日的收盘价除以除权价得到单次除权因子;
             * 除权因子=收盘价/除权价
             * ③将公司上市以来的除权因子连乘积,得到对应每一交易日的除权因子;
             * ④向后复权价=股票收盘价(实际交易价)*每一交易日的除权因子;
             * ⑤复权涨幅(不特别说明,涨幅均指复权涨幅)=复权价/前一日复权价-1。
             * 2、所谓复权就是对股价和成交量进行权息修复,按照股票的实际涨跌绘制股价走势图,并把成交量调整为相同的股本口径。
             */
            if (org_bfq_data == null)
            {
                org_bfq_data = new SecurityReader(base.DbTypeName, base.TableName, new string[] { code }).GetAllCodeDateSerialDataList <StockMongoData>()?[code];
            }
            if (org_xdxr_data == null)
            {
                org_xdxr_data = new XDXRReader().getXDXRList(DbTypeName, code);
            }
            MongoReturnDataList <XDXRData>       xdxr_data = org_xdxr_data.Copy(false);
            MongoReturnDataList <StockMongoData> bfq_data  = org_bfq_data.Copy(false);
            MongoReturnDataList <StockMongoData> ret       = bfq_data;

            if (bfq_data.Count == 0)
            {
                return(ret);
            }
            if (xdxr_data.Count == 0)
            {
                return(ret);
            }
            MongoReturnDataList <XDXRData>       info    = xdxr_data.Query <int>("category", 1);
            MongoReturnDataList <StockMongoData> retList = null;
            List <StockMongoData> list = null;

            #region category = 1
            if (info.Count > 0)
            {
                list = Pandas.Concat <StockMongoData, XDXRData, string>(
                    ret,
                    info,
                    a => a.date,
                    a => a.date,
                    (s, a, b) => {
                    XDXRData ExObj = s.ExtentData as XDXRData;
                    if (ExObj == null)
                    {
                        ExObj = new XDXRData();
                    }
                    if (b)
                    {
                        ExObj.date     = s.date;
                        ExObj.category = a.category;
                    }
                    s.ExtentData = ExObj;
                });
                var testlist = list;
                //retList = new MongoReturnDataList<StockMongoData>(list);

                list = Pandas.FillNa <StockMongoData, string, XDXRData>(list,
                                                                        a => a.ExtentData as XDXRData,
                                                                        a => (a.ExtentData as XDXRData).date,
                                                                        (a, b, c) =>
                {
                    XDXRData data = a.ExtentData as XDXRData;
                    if (data == null)
                    {
                        data = new XDXRData();
                    }
                    //data.date = a.date;
                    data.category = b.category ?? 0;
                    a.ExtentData  = data;
                }
                                                                        , FillType.FFill);
                //retList = new MongoReturnDataList<StockMongoData>(list);
                //(a, b) =>
                //{
                //    return (a.ExtentData as XDXRData).category;
                //}, (a, b) => { a.ExtentData = b; }, FillType.FFill);
                list = Pandas.Concat <StockMongoData, XDXRData, string>(new MongoReturnDataList <StockMongoData>(list), info,
                                                                        a => a.date,
                                                                        a => a.date,
                                                                        (s, a, b) => {
                    XDXRData ExObj = s.ExtentData as XDXRData;
                    if (ExObj == null)
                    {
                        ExObj = new XDXRData();
                    }
                    //ExObj.date = s.date;
                    if (b)
                    {
                        ExObj.date        = a.date;
                        ExObj.fenhong     = a.fenhong;
                        ExObj.peigu       = a.peigu;
                        ExObj.peigujia    = a.peigujia;
                        ExObj.songzhuangu = a.songzhuangu;
                    }
                    s.ExtentData = ExObj;
                });
                //ret.FillNa({ return a => a.ExtentData; }, "category", FillType.FFill);
                //retList = new MongoReturnDataList<StockMongoData>(list);
            }
            #endregion
            #region 其他分红
            else
            {
                list = Pandas.Concat <StockMongoData, XDXRData, string>(ret, info,
                                                                        a => a.date,
                                                                        a => a.date,
                                                                        (s, a, b) => {
                    XDXRData ExObj = s.ExtentData as XDXRData;
                    if (ExObj == null)
                    {
                        ExObj = new XDXRData();
                    }
                    //ExObj.date = s.date;
                    if (b)
                    {
                        ExObj.date        = s.date;
                        ExObj.category    = a.category;
                        ExObj.fenhong     = a.fenhong;
                        ExObj.peigu       = a.peigu;
                        ExObj.peigujia    = a.peigujia;
                        ExObj.songzhuangu = a.songzhuangu;
                    }
                    s.ExtentData = ExObj;
                });
            }
            #endregion
            list = Pandas.FillNa <StockMongoData, string, XDXRData>(list,
                                                                    a => a.ExtentData as XDXRData,
                                                                    a => (a.ExtentData as XDXRData).date,
                                                                    (a, b, c) =>
            {
                XDXRData ExObj = a.ExtentData as XDXRData;
                if (ExObj == null)
                {
                    ExObj = new XDXRData();
                }
                ExObj.date        = a.date;
                ExObj.fenhong     = 0;
                ExObj.peigu       = 0;
                ExObj.peigujia    = 0;
                ExObj.songzhuangu = 0;
            }, FillType.None);
            ret = new MongoReturnDataList <StockMongoData>(list);
            int            xscnt      = GlobalClass.TypeDataPoints[base.DbTypeName].RuntimeInfo.SecurityInfoList[code].decimal_point;
            long           Lbase      = (long)Math.Pow(10, xscnt);
            List <long?>   CloseList  = ret.ToList(a => (long?)(a.close * Lbase));
            List <long?>   closes     = Pandas.ShiftX <long?>(CloseList, 1);
            List <double?> xdxrcloses = new List <double?>();
            for (int i = 0; i < ret.Count; i++)
            {
                XDXRData xdata = ret[i].ExtentData as XDXRData;

                double midval = ((closes[i] ?? 0) * 10 - xdata.fenhong.Value * Lbase + xdata.peigu.Value * xdata.peigujia.Value * Lbase) / (10 + xdata.peigu.Value + xdata.songzhuangu.Value);
                //long xdprice = Math.Round(midval);
                xdxrcloses.Add(midval);
            }
            //precloses = Pandas.ShiftX<double>(precloses, -1);
            List <double?> ProAdjList = new List <double?>();

            List <double?> ppclose = Pandas.ShiftX <double?>(xdxrcloses, -1);//
            for (int i = 0; i < ppclose.Count; i++)
            {
                if (ppclose[i] == null)
                {
                    ProAdjList.Add(1);
                    continue;
                }
                //double? midval = (double?)(1*((double)ppclose[i].Value)/ ((double)CloseList[i]) / 1);
                double?midval = (double?)(1 * ((double)ppclose[i].Value) / ((double)CloseList[i]) / 1);
                ProAdjList.Add((double?)midval);
            }
            List <double?> adj = new List <double?>();
            if (fqType == PriceAdj.Fore)
            {
                adj = ProAdjList;
                adj = Pandas.Recovert <double?>(adj);
                adj = Pandas.Cumprod(adj);
                adj = Pandas.Recovert <double?>(adj);
                double?curr = adj[adj.Count - 1];
                if (curr.Value != 1)
                {
                    //adj.ForEach(a => a = a / curr);
                    for (int i = 0; i < adj.Count; i++)
                    {
                        adj[i] /= curr;
                    }
                }
                //adj = Pandas.Recovert<double?>(adj);
            }
            else
            {
                adj = Pandas.Cumprod(ProAdjList);
                Pandas.ShiftX <double?>(adj, -1);
            }
            for (int i = 0; i < ret.Count; i++)
            {
                ret[i].close *= adj[i].Value;
                ret[i].open  *= adj[i].Value;
                ret[i].high  *= adj[i].Value;
                ret[i].low   *= adj[i].Value;
                ret[i].vol   /= adj[i].Value;
            }
            return(ret);
        }
Beispiel #11
0
 public CommGuidProcess(CommDataIntface cdi, Cycle cyc, PriceAdj rate) : base(cdi)
 {
     cycle  = cyc;
     prcAdj = rate;
 }
 public CommGuidProcess_ForMG(CommDataInterface_ForMG cdi, CommDataBuilder_ForMG _gbc, Cycle cyc, PriceAdj rate) : base(cdi, _gbc, cyc, rate)
 {
     w = cdi.w;
 }
 public CommGuidProcess_ForWD(CommDataInterface_ForWD cdi, Cycle cyc, PriceAdj rate) : base(cdi, cyc, rate)
 {
     w = cdi.w;
 }
Beispiel #14
0
 public BaseDataProcess(CommDataIntface cdi, Cycle cyc, PriceAdj rate)
     : base(cdi)
 {
     this.cycle  = cyc;
     this.prcAdj = rate;
 }
 public BaseDataProcess_ForMG(MongoDataReader _w, CommDataBuilder_ForMG _gbc, Cycle cyc, PriceAdj rate) : base(new CommDataInterface_ForMG(_w), cyc, rate)
 {
     w = _w;
 }