Exemplo n.º 1
0
        public static combineRule getCombRule(string name)
        {
            string[] names    = name.Split('-');
            string   buyname  = names[0];
            string   sellname = names[1];
            Buy      bg       = StockApp.GetBuy(buyname);
            Sell     sg       = StockApp.GetSell(sellname);

            return(new combineRule(bg, sg));
        }
Exemplo n.º 2
0
        public static StockOpeItem[] GetAnalysis2List(int type, int startdate, int enddate, string buyrule, string sellrule, double goodsccore, bool applyDefaultSell, bool restrict_end_to_sell)
        {
            string sql;
            Buy    buy = StockApp.GetBuy(buyrule);


            string d_sellindex = buy.defaultSell + StockKPI.default_index;
            string d_sellprice = buy.defaultSell + StockKPI.default_price;
            string d_selldate  = buy.defaultSell + StockKPI.default_date;

            sql  = " select T1.*, T5.*," + d_sellindex + "," + d_sellprice + "," + d_selldate + " from ( ";
            sql += "select * from Ope_Analysis2 where buydate >= '" + startdate + "' ";
            //goodgrade如果选项打开, 只有在score>goodscore时才做选择
            sql += " and grade >= '" + goodsccore + "' ";

            sql += " and buydate <= '" + enddate + "' and buyrule = '" + buyrule + "' and sellrule = '" + sellrule + "' ";
            sql += " and type in (" + type + "," + Rule.STATUS_SELL + ")) T1 ";
            sql += " join stock_Full T2 on T1.stockcode = T2.code and T1.buyindex = T2.[index] ";
            sql += " join ";
            sql += " (select t3.code,t3.[index] as maxindex,t3.[date] as maxdate,t3.[end] as maxprice from stock_Full t3 join ";
            sql += " (select code, MAX([date]) as intdate from stock_full ";
            sql += " where [date]<= " + enddate;
            sql += " group by code) t4 on t3.code = t4.code and t3.[date] = t4.intdate) t5 ";
            sql += " on t1.stockcode = t5.code ";
            sql += " order by T1.stockcode, T1.[buydate];";

            System.Data.DataTable table = db.GetTable(sql);

            System.Collections.ArrayList sqllist = new System.Collections.ArrayList();

            int size = table.Rows.Count;

            StockOpeItem[] items = new StockOpeItem[size];

            for (int i = 0; i < size; i++)
            {
                System.Data.DataRow row = table.Rows[i];
                items[i]           = new StockOpeItem();
                items[i].type      = (int)row["type"];
                items[i].stockcode = (string)row["stockcode"];
                items[i].buyrule   = (string)row["buyrule"];
                items[i].sellrule  = (string)row["sellrule"];
                items[i].buydate   = (int)row["buydate"];
                items[i].buyindex  = (int)row["buyindex"];
                items[i].buyprice  = (double)row["buyprice"];
                items[i].grade     = (double)row["grade"];

                if (applyDefaultSell && (int)row["sellindex"] > Convert.ToInt32(row[d_sellindex]))
                {
                    items[i].selldate  = Convert.ToInt32(row[d_selldate]);
                    items[i].sellindex = Convert.ToInt32(row[d_sellindex]);
                    items[i].sellprice = (double)row[d_sellprice];
                }
                else
                {
                    items[i].selldate  = (int)row["selldate"];
                    items[i].sellindex = (int)row["sellindex"];
                    items[i].sellprice = (double)row["sellprice"];
                }

                if (restrict_end_to_sell && (int)row["maxindex"] < items[i].sellindex)
                {
                    items[i].selldate  = (int)row["maxdate"];
                    items[i].sellindex = (int)row["maxindex"];
                    items[i].sellprice = (double)row["maxprice"];
                }
            }

            return(items);
        }
Exemplo n.º 3
0
 public combineRule(Buy buyrule, Sell sellrule)
 {
     buy  = buyrule;
     sell = sellrule;
 }