Beispiel #1
0
 public BigDealData(StockData data, String filter,String type)
 {
     this.data = data;
     this.filter = filter;
     this.type = type;
     // base.Stock = data.Stock;
 }
        public static string Analyze(StockData stockData,string filter)
        {
            string analyzePath;
            List<DailyData> dds = stockData.DailyList;
            StringBuilder str = new StringBuilder();
            str.Append("date,bigBuyShare,bigSellShare,toalShare,bigBuyMoney,bigSellMoney,toalMoney,Open,Close,Average,Hightest,WhenHighest,Lowest,WhenLowest,BigBuyShareRate,BigSellShareRate,BigBuyMoneyRate,BigSellMoneyRate\n");
            foreach (DailyData ds in dds)
            {

                BigDeal fd = new BigDeal(ds, filter);
                fd.Analye();
                str.Append(StockUtil.FormatDate(fd.set.Date) + ",");
                str.Append(fd.TotalBuyShareByBigDeal + ",");
                str.Append(fd.TotalSellShareByBigDeal + ",");
                str.Append(fd.set.TotalShare + ",");
                str.Append(fd.TotalBuyMoneyByBigDeal + ",");
                str.Append(fd.TotalSellMoneyByBigDeal + ",");
                str.Append(fd.set.TotalMoney + ",");
                str.Append(fd.set.OpenPrice + ",");
                str.Append(fd.set.ClosePrice + ",");
                str.Append(fd.set.Average + ",");
                str.Append(fd.set.HighestPrice + ",");
                str.Append(StockUtil.FormatTime(fd.set.TimeWhenHighest) + ",");
                str.Append(fd.set.LowestPrice + ",");
                str.Append(StockUtil.FormatTime(fd.set.TimeWhenLowest) + ",");
                str.Append(fd.RateOfBuyShareByTotal + ",");
                str.Append(fd.RateOfSellShareByTotal + ",");
                str.Append(fd.RateOfBuyMoneyByTotal + ",");
                str.Append(fd.RateOfSellMoneyByTotal + ",");
                str.Append("\n");

            }

            analyzePath = Constant.ANALYZE_FOLDER + stockData.stock + "_" + stockData.startDate + "_" + stockData.endDate + "_" + filter + ".csv";

            if (File.Exists(analyzePath))
            {
                File.Delete(analyzePath);
            }
            using (StreamWriter outfile = new StreamWriter(Constant.ANALYZE_FOLDER + stockData.stock + "_" + stockData.startDate + "_" + stockData.endDate + "_" + filter + ".csv"))
            {
                outfile.Write(str);
                Console.WriteLine("Analyzed: " + Constant.ANALYZE_FOLDER + stockData.stock + "_" + stockData.startDate + "_" + stockData.endDate + "_" + filter + ".csv");
            }

            return analyzePath;
        }
Beispiel #3
0
        public static void Analyze(String stock, string startDate, string endDate, string filter)
        {
            //IApplicationContext ctx = ContextRegistry.GetContext();
            StockLog.Log.Info("start to create stock data");
            StockData data1 = new StockData(stock, startDate, endDate, true);//(StockData)ctx.GetObject("StockData");
            StockLog.Log.Info("start to create normal data");
            NormalData gd = new NormalData(data1);//(NormalData)ctx.GetObject("NormalData");
            StockLog.Log.Info("start to create big deal data");

            BigDealData bdd = new BigDealData(data1, filter);

            //(BigDealData)ctx.GetObject("BigDealData");
            //RangeData bigdeal = new RangeData(bdd, type); //(RangeData)ctx.GetObject("BigRangeData");
            // RangeData alldeal = new RangeData(gd, type);//(RangeData)ctx.GetObject("AllRangeData");

                if (!Directory.Exists(Constant.ANALYZE_FOLDER + stock))
                {
                    // Directory.Delete(Constant.ANALYZE_FOLDER + stock, true);
                    Directory.CreateDirectory(Constant.ANALYZE_FOLDER + stock);
                }
                else
                {
                    if (Constant.CLEAN)
                    {
                        Directory.Delete(Constant.ANALYZE_FOLDER + stock, true);
                        Directory.CreateDirectory(Constant.ANALYZE_FOLDER + stock);
                    }
                }

            foreach (int type in Enum.GetValues(typeof(RangeType)))
            {
                //String filePath = string.Format(@"{0}{1}\{1}_{2}_{3}_{4}_{5}.csv", Constant.ANALYZE_FOLDER, stock, startDate, endDate, filter, (RangeType)type);
                String filePath = string.Format(@"{0}{1}\{1}_{3}_{2}.csv", Constant.ANALYZE_FOLDER, stock, (RangeType)type,filter);
                StockLog.Log.Info("start to analyze " + (RangeType)type);
                if (!File.Exists(filePath))
                {

                    RangeData bigdeal = new RangeData(bdd, type); //(RangeData)ctx.GetObject("BigRangeData");
                    RangeData alldeal = new RangeData(gd, type);//(RangeData)ctx.GetObject("AllRangeData");
                    Dictionary<string, FilterData> big = bigdeal.DataList;
                    Dictionary<string, FilterData> all = alldeal.DataList;
                    FileUtil.WriteFile(filePath, DataUtil.Compare(all, big));
                }
                StockLog.Log.Info("End to analyze " + (RangeType)type);
            }
        }
 public BigDealData(StockData data, String filter)
 {
     this.data   = data;
     this.filter = filter;
     // base.Stock = data.Stock;
 }
Beispiel #5
0
 public NormalData(StockData data)
 {
     this.data = data;
 }
Beispiel #6
0
 public NormalData(StockData data)
 {
     this.data = data;
 }
Beispiel #7
0
 public BigDealData(StockData data, String filter)
 {
     this.data = data;
     this.filter = filter;
        // base.Stock = data.Stock;
 }
 public BigDealAnalyzer(StockData stockData)
 {
     this.stockData = stockData;
 }