/// <summary> /// 判断大盘突破 /// </summary> /// <param name="dp"></param> /// <returns></returns> public static bool isBuyXH(GuoPiao dp) { if (!isDpContionDown()) { return false; } //大盘涨幅达到1的时候买入头寸 if (dp.zf >=1) { return true; } return false; }
/// <summary> /// /// 优选实时股票获取 7最高 (1-7) 档 /// </summary> /// <returns></returns> public static List<GuoPiao> getYXRealGuoPiao(int lev) { if (lev < 0 || lev > 7) { return null; } List<GuoPiao> rntGps = new List<GuoPiao>(); //初始化, HisDataAPI.saveTodayHisDataFromSina(); MySqlParameter lev_param = new MySqlParameter("?lev", MySqlDbType.VarChar, 1); lev_param.Value = lev; MySqlParameter[] parms = new MySqlParameter[] { lev_param }; DataSet ds = GPUtil.helper.ExecuteProc("gp_sort", parms); DataTable result = ds.Tables[0]; GuoPiao gp = null; foreach (DataRow r in result.Rows) { gp = new GuoPiao(); gp.code = r["code"].ToString(); gp.name = r["name"].ToString(); gp.zf = Convert.ToDouble(r["zf"]); gp.jrzgj = Convert.ToDouble(r["jrzgj"]); gp.jrzdj = Convert.ToDouble(r["jrzdj"]); gp.dqj = Convert.ToDouble(r["dqj"]); gp.jj = Convert.ToDouble(r["jj"]); gp.hsl = Convert.ToDouble(r["hsl"]); gp.zhengf = Convert.ToDouble(r["zhengf"]); gp.ltsz = Convert.ToDouble(r["ltsz"]); gp.syl = Convert.ToDouble(r["syl"]); rntGps.Add(gp); } return rntGps; }
/** * * 股票成本价涨幅 * */ public static void setGpCostPriceZf(GuoPiao gp) { if (GPTotalAPI.gpMap.ContainsKey(gp.code)) { GpTotal total = GPTotalAPI.gpMap[gp.code]; if (total != null) { total.dqj = gp.dqj; total.buyzf = Math.Round(((gp.dqj - total.costPrice) / total.costPrice) * 100, 3); gp.total = total; } } }
/** * * 获取子集合 * */ private static List<GuoPiao> getSubGPList(string[] fieldList, string codes) { string[] fields = null; string[] codeslist = codes.Split(",".ToCharArray()); List<GuoPiao> gpList = new List<GuoPiao>(); GuoPiao gp = null; for (int i = 0; i < fieldList.Length; i++) { fields = fieldList[i].Split(",".ToCharArray()); if (fields.Length <= 1) { continue; } gp = new GuoPiao(); gp.code = codeslist[i]; gp.name = fields[0]; if (gp.name.IndexOf("道琼斯") != -1 || gp.name.IndexOf("纳斯达克") != -1 || gp.name.IndexOf("恒生指数") != -1) { gp.zf = Convert.ToDouble(fields[3].Replace("\"","")); continue; } gp.kpj = Convert.ToDouble(fields[1]); //1:”27.55″,今日开盘价; gp.zrspj = Convert.ToDouble(fields[2]); //2:”27.25″,昨日收盘价; gp.dqj = Convert.ToDouble(fields[3]); //3:”26.91″,当前价格; gp.jrzgj = Convert.ToDouble(fields[4]);//4:”27.55″,今日最高价; gp.jrzdj = Convert.ToDouble(fields[5]);//5:”26.20″,今日最低价; gp.b_now = Convert.ToDouble(fields[6]);//6:”26.91″,竞买价,即“买一”报价; gp.s_now = Convert.ToDouble(fields[7]);//7:”26.92″,竞卖价,即“卖一”报价; gp.cj_num = Convert.ToDouble(fields[8]);//8:”22114263″,成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百; gp.cj_amt = Convert.ToDouble(fields[9]);//9:”589824680″,成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万; gp.b1_num = Convert.ToDouble(fields[10]);//10:”4695″,“买一”申请4695股,即47手; gp.b1_price = Convert.ToDouble(fields[11]);//11:”26.91″,“买一”报价; gp.b2_num = Convert.ToDouble(fields[12]);//12:”57590″,“买二” gp.b2_price = Convert.ToDouble(fields[13]);//13:”26.90″,“买二” gp.b3_num = Convert.ToDouble(fields[14]);//14:”14700″,“买三” gp.b3_price = Convert.ToDouble(fields[15]);//15:”26.89″,“买三” gp.b4_num = Convert.ToDouble(fields[16]);//16:”14300″,“买四” gp.b4_price = Convert.ToDouble(fields[17]);//17:”26.88″,“买四” gp.b5_num = Convert.ToDouble(fields[18]); //18:”15100″,“买五” gp.b5_price = Convert.ToDouble(fields[19]); //19:”26.87″,“买五” gp.s1_num = Convert.ToDouble(fields[20]);//20:”3100″,“卖一”申报3100股,即31手; gp.s1_price = Convert.ToDouble(fields[21]);//21:”26.92″,“卖一”报价 gp.s2_num = Convert.ToDouble(fields[22]);//20:”3100″,“卖一”申报3100股,即31手; gp.s2_price = Convert.ToDouble(fields[23]);//21:”26.92″,“卖一”报价 gp.s3_num = Convert.ToDouble(fields[24]);//20:”3100″,“卖一”申报3100股,即31手; gp.s3_price = Convert.ToDouble(fields[25]);//21:”26.92″,“卖一”报价 gp.s4_num = Convert.ToDouble(fields[26]);//20:”3100″,“卖一”申报3100股,即31手; gp.s4_price = Convert.ToDouble(fields[27]);//21:”26.92″,“卖一”报价 gp.s5_num = Convert.ToDouble(fields[28]);//20:”3100″,“卖一”申报3100股,即31手; gp.s5_price = Convert.ToDouble(fields[29]);//21:”26.92″,“卖一”报价 gp.date = fields[30];//30:”2008-01-11″,日期; gp.time = fields[31];//31:”15:05:32″,时间; //振幅 gp.zhengf = Math.Round(((gp.jrzgj - gp.jrzdj) / gp.zrspj) * 100, 2); //分时均价 if (gp.cj_num > 0) { gp.jj = Math.Round(gp.cj_amt / gp.cj_num, 2); } //涨幅 if (gp.zrspj > 0) { gp.zf = Math.Round(((gp.dqj - gp.zrspj) / gp.zrspj) * 100,2); //涨幅 } //统计信息 GPUtil.setGpCostPriceZf(gp); //tr 计算 if (((gp.jrzgj - gp.jrzdj) > Math.Abs(gp.zrspj - gp.jrzgj)) ) { if ((gp.jrzgj - gp.jrzdj) > Math.Abs(gp.zrspj - gp.jrzdj)) { gp.tr = gp.jrzgj - gp.jrzdj; } else { gp.tr = Math.Abs(gp.zrspj - gp.jrzdj); } } else { if (Math.Abs(gp.zrspj - gp.jrzgj) > Math.Abs(gp.zrspj - gp.jrzdj)) { gp.tr = Math.Abs(gp.zrspj - gp.jrzgj); } else { gp.tr = Math.Abs(gp.zrspj - gp.jrzdj); } } gpList.Add(gp); } return gpList; }