protected override double calcRefData(string code) { string year = GlobalConfig.getInstance().curYear; string quarter = GlobalConfig.getInstance().curQuarter; double histData = CostPerfFilter.calcCostRefValue(code, m_refYear, m_refQuarter); double curData = CostPerfFilter.calcCurCostRefValue(code, year, quarter); return(curData / histData); }
static double calcCostPerfInHistory(string stockID) { double curVal = CostPerfFilter.calcCurCostRefValue(stockID, "2018", "1"); int maxYear = 0, maxQuarter = 0, maxYearAnl = 0; double refValByReport = CostPerfFilter.getMaxCostRefValueBefore(stockID, "2018", "1", out maxYear, out maxQuarter); double refValByAnnual = AnnualCostPerfFilter.getMaxAnnualCostRefValueBefore(stockID, "2018", out maxYearAnl); double refVal = Math.Max(refValByReport, refValByAnnual); double ratio = curVal / refVal; return(ratio); }
protected override double calcRefData(string code) { string year = GlobalConfig.getInstance().curYear; string quarter = GlobalConfig.getInstance().curQuarter; int maxYear = 0, maxQuarter = 0; double histData = CostPerfFilter.getMaxCostRefValueBefore(code, year, quarter, out maxYear, out maxQuarter); double curData = CostPerfFilter.calcCurCostRefValue(code, year, quarter); return(curData / histData); }
public override void init(string stockID, string beginDate, string endDate) { base.init(stockID, beginDate, endDate); string year = GlobalConfig.getInstance().curYear; string curYear = year; string quarter = GlobalConfig.getInstance().curQuarter; string curQuarter = quarter; if (m_basedOnAnnual) { if (int.Parse(quarter) < 4) { year = (int.Parse(year) - 1).ToString(); quarter = "4"; } } AvgValInIndustryFilter peAvgFlt = new AvgValInIndustryFilter(new PEFilter(0.0), 0.0); peAvgFlt.calcAvgValInIndustry(m_code, out m_peIndustry); AvgValInIndustryFilter roeAvgFlt = new AvgValInIndustryFilter(new ROEFilter(year, quarter, 0.0), 0.0); roeAvgFlt.calcAvgValInIndustry(m_code, out m_roeIndustry); AvgValInIndustryFilter nprAvgFlt = new AvgValInIndustryFilter(new NetProfitRatioFilter(year, quarter, 0.0), 0.0); nprAvgFlt.calcAvgValInIndustry(m_code, out m_nprIndustry); m_roe = ROEFilter.getStockROE(m_code, year, quarter); m_netProfitRatio = NetProfitRatioFilter.getStockNetProfitRatio(m_code, year, quarter); m_histCost = StockDataCache.getInstance().getMaxAnnualCostRefValueBefore(m_code, curYear); m_curCost = CostPerfFilter.calcCurCostRefValue(m_code, curYear, curQuarter); m_costRatio = m_curCost / m_histCost; DynamicPEFilter.calcDynamicPE(m_code, out m_dynamicPE); }
static void Main(string[] args) { GlobalConfig.getInstance().init(); StockPool.getInstance().init(); OptionalStocks.getInstance().init(); // #1 //LowLevelCheapPESelector s = new LowLevelCheapPESelector(); //List<string> stocks = s.screen(); // #2 //List<string> src = new List<string>(); //src.Add("sh600097"); //PEFilter peFilter = new PEFilter(40); //IndustryFilter indFilter = new IndustryFilter(); //EPSPerfFilter epsFilter = new EPSPerfFilter(0.2); //List<string> r0 = peFilter.filter(src); //List<string> r1 = indFilter.filter(r0); //List<string> stocks = epsFilter.filter(r1); //foreach (string stockCode in stocks) //{ // Logger.debugOutput(stockCode); //} // #3 //string curYear = "2018"; //string curSeason = "1"; ////string targetYear = "2013"; ////string targetSeason = "1"; //string stc1 = "sh600995"; //string stc2 = "sz000883"; //double curVal1 = CostPerfFilter.calcCostRefValue(stc1, curYear, curSeason); //double curVal2 = CostPerfFilter.calcCostRefValue(stc2, curYear, curSeason); ////double targVal1 = CostPerfFilter.calcCostRefValue(stc1, targetYear, targetSeason); ////double targVal2 = CostPerfFilter.calcCostRefValue(stc2, targetYear, targetSeason); ////double param = curVal1 / targVal1 - curVal2 / targVal2; //double histVal1 = CostPerfFilter.getMaxCostRefValueBefore(stc1, curYear, curSeason); //double histVal2 = CostPerfFilter.getMaxCostRefValueBefore(stc2, curYear, curSeason); //double param = curVal1 / histVal1 - curVal2 / histVal2; // #4 //HighCostPerfNotHighPosSelector s = new HighCostPerfNotHighPosSelector(); //List<string> stocks = s.screen(); // #5 //List<string> src = IntermediateImporter.readCheapStocks(); //List<StockSortableMetadata> target = new List<StockSortableMetadata>(); //foreach(string stockID in src) //{ // if (IndustryFilter.isStockInIndustry(stockID, "银行")) // { // continue; // } // StockSortableMetadata sd = new SSMDCostPerf(stockID); // target.Add(sd); //} //target.Sort(); //List<string> stocks = new List<string>(); //for(int i = target.Count - 1; i >= 0; i--) //{ // stocks.Add(target[i].stockID); //} //foreach (string stockCode in stocks) //{ // Logger.debugOutput(stockCode); //} // #6 string stockID = "sz000034"; double curVal = CostPerfFilter.calcCurCostRefValue(stockID, "2018", "1"); int maxYearDyn = 0, maxQuarterDyn = 0, maxYearAnl = 0; double refValByReport = CostPerfFilter.getMaxCostRefValueBefore(stockID, "2018", "1", out maxYearDyn, out maxQuarterDyn); double refValByAnnual = AnnualCostPerfFilter.getMaxAnnualCostRefValueBefore(stockID, "2018", out maxYearAnl); double refVal = Math.Max(refValByReport, refValByAnnual); double ratio = curVal / refVal; // #7 //List<string> selfSelectedList = OptionalStocks.getInstance().optionalStockList; //List<StockSortableMetadata> selfSelectSortByQuarter = new List<StockSortableMetadata>(); //List<StockSortableMetadata> selfSelectSortByYoy = new List<StockSortableMetadata>(); //List<StockSortableMetadata> selfSelectSortByNormal = new List<StockSortableMetadata>(); //List<StockSortableMetadata> selfSelectSortByAnnual = new List<StockSortableMetadata>(); //foreach (string stockCode in selfSelectedList) //{ // StockSortableMetadata sdn = new SSMDCostPerf(stockCode); // StockSortableMetadata sdq = new SSMDQuarterCostPerf(stockCode); // StockSortableMetadata sdy = new SSMDCostPerf(stockCode); // StockSortableMetadata sda = new SSMDAnnualCostPerf(stockCode); // selfSelectSortByQuarter.Add(sdq); // selfSelectSortByNormal.Add(sdn); // selfSelectSortByYoy.Add(sdy); // selfSelectSortByAnnual.Add(sda); //} //selfSelectSortByQuarter.Sort(); //selfSelectSortByQuarter.Reverse(); //selfSelectSortByNormal.Sort(); //selfSelectSortByNormal.Reverse(); //selfSelectSortByYoy.Sort(); //selfSelectSortByYoy.Reverse(); //selfSelectSortByAnnual.Sort(); //selfSelectSortByAnnual.Reverse(); //Logger.log("Normal sort: "); //outputSortData(selfSelectSortByNormal); //Logger.log("Quarter sort: "); //outputSortData(selfSelectSortByQuarter); //Logger.log("Yoy sort: "); //outputSortData(selfSelectSortByYoy); //Logger.log("Annual sort: "); //outputSortData(selfSelectSortByAnnual); // #8 //List<string> src = IntermediateImporter.readMidRepGrowthStocks(); //AnnualCostPerfFilter acpFilter = new AnnualCostPerfFilter("2018", "1", 0.0); //PriceScaleFilter pcFilter = new PriceScaleFilter(0.5); //List<string> stocks = pcFilter.filter(acpFilter.filter(src)); //List<StockSortableMetadata> arr = new List<StockSortableMetadata>(); //foreach(string code in stocks) //{ // StockSortableMetadata sda = new SSMDAnnualCostPerf(code); // arr.Add(sda); //} //arr.Sort(); //outputSortData(arr); // #9 //OversoldSelector s = new OversoldSelector(); //List<string> stocks = s.screen(); //List<StockSortableMetadata> stocksSortByAnnual = new List<StockSortableMetadata>(); //foreach (string stockCode in stocks) //{ // StockSortableMetadata sda = new SSMDAnnualCostPerf(stockCode); // stocksSortByAnnual.Add(sda); //} //stocksSortByAnnual.Sort(); //outputSortData(stocksSortByAnnual); // # temp //string stockID = "sh600703"; //string str = StockDataCollector.queryKLineDataBaidu(stockID); //List<StockKLineBaidu> arr = StockDataConvertor.parseKLineArrayBaiduAdvanced(str); //int endIndex = StockDataUtil.getIndexByDate(arr, "20180426"); //List<StockKLineBaidu> subArr = arr.GetRange(0, endIndex + 1); //Oversold2Day osp = new Oversold2Day(); //bool ret = osp.isMatch(subArr); while (true) { Thread.Sleep(1000); } }