Example #1
0
        public override bool getNumericValue(string stockID, out double val)
        {
            StockFinanceData fd = StockDataCenter.getInstance().getFinanceData(stockID);
            StockMarketData  md = StockDataCenter.getInstance().getMarketData(stockID);

            val = 0.0;
            if (fd == null || md == null)
            {
                return(false);
            }

            double epsTTM      = fd.eps4Quarter;
            double epsLastYear = fd.epsLastYear;

            if (epsTTM < 0.0)
            {
                return(false);
            }

            if (epsLastYear < 0.0 && epsTTM > double.Epsilon)
            {
                return(true);
            }

            val = (epsTTM - epsLastYear) / md.latestPrice;

            return(false);
        }
Example #2
0
        public override bool filterMethod(string stockID)
        {
            if (m_pattern == null)
            {
                return(false);
            }

            List <StockKLineBaidu> arr = StockDataCenter.getInstance().getKLineBaidu(stockID);

            if (arr == null)
            {
                return(false);
            }

            if (m_definiteDays)
            {
                return(m_pattern.isMatch(arr));
            }
            else
            {
                for (int i = m_minDays; i < m_maxDays; i++)
                {
                    int startIndex = arr.Count - i;
                    List <StockKLineBaidu> subArr = arr.GetRange(startIndex, arr.Count - startIndex);
                    if (m_pattern.isMatch(subArr))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #3
0
        public override bool filterMethod(string stockID)
        {
            List <StockKLineBaidu> arr = StockDataCenter.getInstance().getKLineBaidu(stockID);

            if (arr == null || arr.Count == 0)
            {
                return(false);
            }
            int days  = Math.Min(m_lastDays, arr.Count - 1);
            int count = 0;

            for (int i = 0; i < days; i++)
            {
                int    index = arr.Count - 1 - i;
                double chg   = (arr[index].latestPrice - arr[index - 1].latestPrice) / arr[index - 1].latestPrice;
                if (chg >= m_increaseAmount)
                {
                    count++;
                }
            }

            if (count < m_daysCount)
            {
                return(false);
            }

            return(true);
        }
        public override bool filterMethod(string stockID)
        {
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            if (md != null &&
                PriceAnalyzer.isPriceScaleSatisfied(stockID, md.latestPrice, m_ratio))
            {
                return(true);
            }

            return(false);
        }
        public override bool filterMethod(string stockID)
        {
            List <StockKLineBaidu> arr = StockDataCenter.getInstance().getKLineBaidu(stockID);
            double avgAmp = KLineDataProcessor.calcKLineAverageAmplitude(arr, m_lastDays);

            if (avgAmp < m_avgVal)
            {
                return(false);
            }

            return(true);
        }
Example #6
0
        public int getEarliestYearInKLineInfo(string stockID)
        {
            List <StockKLine> arr = StockDataCenter.getInstance().getMonthKLine(stockID);

            if (arr == null || arr.Count == 0)
            {
                return(0);
            }

            int year = DateUtil.getShortDateYear(arr[0].date);

            return(year);
        }
Example #7
0
        public override bool getNumericValue(string stockID, out double val)
        {
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            val = 0.0;
            if (md != null)
            {
                val = md.PE;
                return(true);
            }

            return(false);
        }
Example #8
0
 public void refresh(List <string> stocks, string beginDate, string endDate)
 {
     m_priceCompList.Clear();
     foreach (string stockID in stocks)
     {
         T item = new T();
         item.init(stockID, m_beginDate, m_endDate);
         StockDataCenter.getInstance().subscribeMarketData(stockID);
         m_priceCompList.Add(item);
     }
     m_beginDate = beginDate;
     m_endDate   = endDate;
 }
Example #9
0
        public static double calcCurCostRefValue(string stockID, string year, string season)
        {
            double          costRefVal = 0.0;
            StockReportData rd         = StockDBVisitor.getInstance().getStockReportData(stockID, year, season);

            StockMarketData md      = StockDataCenter.getInstance().getMarketData(stockID);
            int             quarter = int.Parse(season);

            if (rd != null && md != null)
            {
                costRefVal = (rd.eps / md.latestPrice) / quarter * 4;
            }

            return(costRefVal);
        }
Example #10
0
        public static bool calcDynamicPE(string stockID, out double val)
        {
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            string          year    = GlobalConfig.getInstance().curYear;
            string          quarter = GlobalConfig.getInstance().curQuarter;
            StockReportData rd      = StockDBVisitor.getInstance().getStockReportData(stockID, year, quarter);

            val = 0.0;
            if (md != null && rd != null)
            {
                double profitVal = getEstimateProfitValue(rd.net_profits, quarter);
                val = md.totalCapitalisation * 10000.0 / profitVal;
                return(true);
            }

            return(false);
        }
Example #11
0
        public static bool isPriceScaleSatisfied(string stockID, double curPrice, double ratio)
        {
            List <StockKLine> monthKData = StockDataCenter.getInstance().getMonthKLineBaidu(stockID);

            if (monthKData == null)
            {
                return(false);
            }

            double sr = getPriceScale(monthKData, curPrice, "20120101");

            if (sr < ratio && sr > 0.0 && curPrice > 0.0)
            {
                return(true);
            }

            return(false);
        }
Example #12
0
        public virtual void update()
        {
            StockRealTimeData rd = StockDataCenter.getInstance().getMarketRealTimeData(m_code);

            if (rd != null)
            {
                m_curPrice = rd.latestPrice;
            }

            if (m_lowestPrice > 0.0)
            {
                m_chgFromLowest = (m_curPrice - m_lowestPrice) / m_lowestPrice;
            }
            else
            {
                m_chgFromLowest = 0.0;
            }
        }
Example #13
0
        public static bool getLowestPriceBetweenDate(string stockID, string beginDate, string endDate, out double lowestPrice)
        {
            if (StockDataCache.getInstance().getLowestPriceBetweenDate(stockID, beginDate, endDate, out lowestPrice))
            {
                return(true);
            }

            List <StockKLineBaidu> arr = StockDataCenter.getInstance().getKLineBaidu(stockID);

            lowestPrice = 0.0;
            if (arr == null || arr.Count == 0)
            {
                return(false);
            }

            lowestPrice = getLowestPrice(arr, beginDate, endDate);
            StockDataCache.getInstance().setLowestPriceBetweenDate(stockID, beginDate, endDate, lowestPrice);
            return(true);
        }
Example #14
0
        public static double calcBonusRefValue(string stockID, string year, string season)
        {
            double bonus = 0;

            if (getDistribBonus(stockID, year, season, out bonus))
            {
                List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID);
                if (mk == null)
                {
                    return(0.0);
                }
                string     targetMonth = convertMonthBySeason(season);
                StockKLine kl          = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth);

                return(bonus / kl.latestPrice);
            }

            return(0.0);
        }
        public static double calcCostRefValueForQuarter(string stockID, string year, string season)
        {
            double          costRefVal = 0.0;
            StockReportData rd         = StockDBVisitor.getInstance().getStockReportData(stockID, year, season);
            int             qt         = int.Parse(season);

            if (rd == null)
            {
                return(0.0);
            }

            double eps = rd.eps;

            if (qt > 1)
            {
                int             prevQuarter = qt - 1;
                StockReportData prevRd      = StockDBVisitor.getInstance().getStockReportData(stockID, year, prevQuarter.ToString());
                if (prevRd != null)
                {
                    eps -= prevRd.eps;
                }
            }

            //string str = StockDataCollector.queryMonthlyKLineData(stockID);
            List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID); //StockDataConvertor.parseKLineArray(str);

            if (mk == null)
            {
                return(0.0);
            }

            string     targetMonth = convertMonthBySeason(season);
            StockKLine kl          = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth);
            int        quarter     = int.Parse(season);

            if (kl != null)
            {
                costRefVal = eps / kl.latestPrice;
            }

            return(costRefVal);
        }
Example #16
0
        public static bool getPriceScaleFromDate(string stockID, string beginDate, out double ratio)
        {
            ratio = 0.0;
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            if (md == null)
            {
                return(false);
            }

            double curPrice            = md.latestPrice;
            List <StockKLineBaidu> arr = StockDataCenter.getInstance().getKLineBaidu(stockID);

            if (arr == null || arr.Count == 0)
            {
                return(false);
            }

            ratio = getPriceScale(arr, curPrice, beginDate);
            return(true);
        }
Example #17
0
        public static double calcCostRefValue(string stockID, string year, string season)
        {
            double          costRefVal = 0.0;
            StockReportData rd         = StockDBVisitor.getInstance().getStockReportData(stockID, year, season);

            List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID);

            if (mk == null)
            {
                return(0.0);
            }
            string     targetMonth = convertMonthBySeason(season);
            StockKLine kl          = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth);
            int        quarter     = int.Parse(season);

            if (rd != null && kl != null)
            {
                costRefVal = (rd.eps / kl.latestPrice) / quarter * 4;
            }

            return(costRefVal);
        }
Example #18
0
        public static double calcPBCostValue(string stockID, string year, string quarter)
        {
            double          costRefVal = 0.0;
            double          pe         = 0.0;
            StockReportData rd         = StockDBVisitor.getInstance().getStockReportData(stockID, year, quarter);

            if (rd == null)
            {
                return(double.MaxValue);
            }

            List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID);

            if (mk == null)
            {
                return(double.MaxValue);
            }

            string     targetMonth = convertMonthBySeason(quarter);
            StockKLine kl          = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth);

            if (kl == null)
            {
                return(double.MaxValue);
            }
            pe = kl.latestPrice / rd.eps;

            StockProfitData pd = StockDBVisitor.getInstance().getStockProfitData(stockID, year, quarter);

            if (pd == null)
            {
                return(double.MaxValue);
            }

            costRefVal = pe * pd.roe;

            return(costRefVal);
        }