Esempio n. 1
0
        //计算买卖数据
        private void CalBuy(StockData stock)
        {
            //由设定时间开始分析
            int analyse_startindex = StockApp.START_ANALYSIS;

            int           id       = db.GetMaxTableId(StockSQL.TABLE_RULE_BUY0);
            SQLMassImport rulefile = new SQLMassImport("RuleBuy");

            foreach (Buy rule in GetAllBuy())
            {
                int stock_length = stock.items.Length;

                for (int i = analyse_startindex; i < stock_length; i++)
                {
                    StockItem item = stock.items[i];
                    if (rule.isBuy(stock, i))
                    {
                        id++;
                        string[] attristrs = new string[21];
                        attristrs[0]  = Rule.STATUS_BUY.ToString();
                        attristrs[1]  = id.ToString();
                        attristrs[2]  = rule.ToString();
                        attristrs[3]  = stock.code;
                        attristrs[4]  = item.date.ToString();
                        attristrs[5]  = item.index.ToString();
                        attristrs[6]  = (i < stock_length - 1) ? Math.Min(item.end, stock.items[i + 1].start).ToString() : item.end.ToString();
                        attristrs[7]  = "0"; //pregrade
                        attristrs[8]  = rule.GetScore(stock, item.index).ToString();
                        attristrs[9]  = stock.getKPIs(i);
                        attristrs[10] = stock.getNumKPIs(i);
                        attristrs[11] = StockDapan.GetDaPanScore(item.date).ToString();                           //dapan
                        attristrs[12] = item.kpi[StockApp.DEFAULT_SELLs[0] + StockKPI.default_price].ToString();  //short
                        attristrs[13] = item.kpi[StockApp.DEFAULT_SELLs[1] + StockKPI.default_price].ToString();; //medium
                        attristrs[14] = item.kpi[StockApp.DEFAULT_SELLs[2] + StockKPI.default_price].ToString();; //long
                        attristrs[15] = item.kpi[StockApp.DEFAULT_SELLs[3] + StockKPI.default_price].ToString();  //end

                        int    nextday   = Convert.ToInt32(item.kpi[StockApp.DEFAULT_SELLs[2] + StockKPI.default_date].ToString());
                        double nextprice = Convert.ToDouble(item.kpi[StockApp.DEFAULT_SELLs[2] + StockKPI.default_price].ToString());
                        //去除outline
                        //if (nextprice - item.end * 2 > StockApp.MIN_ZERO
                        //    || nextday - 3000 - item.date > StockApp.MIN_ZERO) continue;
                        //发出买入信号后1~5天的表现,纯参考,未在任何地方使用
                        attristrs[16] = item.attributes[StockAttribute.POST1].ToString();
                        attristrs[17] = item.attributes[StockAttribute.POST2].ToString();;
                        attristrs[18] = item.attributes[StockAttribute.POST3].ToString();;
                        attristrs[19] = item.attributes[StockAttribute.POST4].ToString();;
                        attristrs[20] = item.attributes[StockAttribute.POST5].ToString();;
                        rulefile.AddRow(attristrs);
                    }
                }//foreach

                //UtilLog.AddInfo(TAG, rule.ToString() + " calculation finished. ");
            }
            //导入买入卖出数据
            rulefile.ImportClose(db, StockSQL.TABLE_RULE_BUY0);
            UtilLog.AddInfo(TAG, stock.code + " RuleBuy calculation finished. ");
        }
Esempio n. 2
0
        //计算买卖数据
        private void CalSell(StockData stock)
        {
            //由设定时间开始分析
            int analyse_startindex = StockApp.START_ANALYSIS;

            int           id       = db.GetMaxTableId(StockSQL.TABLE_RULE_BUY0);
            SQLMassImport rulefile = new SQLMassImport("RuleSell");

            foreach (Sell rule in GetAllSell())
            {
                int stock_length = stock.items.Length;

                for (int i = analyse_startindex; i < stock_length; i++)
                {
                    StockItem item = stock.items[i];
                    if (rule.isSell(stock, i))
                    {
                        id++;
                        string[] attristrs = new string[21];
                        attristrs[0]  = Rule.STATUS_SELL.ToString();
                        attristrs[1]  = id.ToString();
                        attristrs[2]  = rule.ToString();
                        attristrs[3]  = stock.code;
                        attristrs[4]  = item.date.ToString();
                        attristrs[5]  = item.index.ToString();
                        attristrs[6]  = (i < stock_length - 1) ? Math.Min(item.end, stock.items[i + 1].start).ToString() : item.end.ToString();
                        attristrs[7]  = "0"; //pregrade
                        attristrs[8]  = "0"; //grade
                        attristrs[9]  = "0";
                        attristrs[10] = "0";
                        attristrs[11] = "0"; //stockdapan没有用
                        attristrs[12] = "0";
                        attristrs[13] = "0";
                        attristrs[14] = "0";
                        attristrs[15] = "0";
                        //发出买入信号后1~5天的表现,纯参考,未在任何地方使用
                        attristrs[16] = item.attributes[StockAttribute.POST1].ToString();
                        attristrs[17] = item.attributes[StockAttribute.POST2].ToString();
                        attristrs[18] = item.attributes[StockAttribute.POST3].ToString();
                        attristrs[19] = item.attributes[StockAttribute.POST4].ToString();
                        attristrs[20] = item.attributes[StockAttribute.POST5].ToString();
                        rulefile.AddRow(attristrs);
                    }
                }
                //UtilLog.AddInfo(TAG, rule.ToString() + " calculation finished. ");
            }
            //导入买入卖出数据
            rulefile.ImportClose(db, StockSQL.TABLE_RULE_BUY0);
            UtilLog.AddInfo(TAG, stock.code + " RuleSell calculation finished. ");
        }