private void LoadDailyReportData(string keyID) { string remarks = string.Empty; string result = string.Empty; string message = string.Empty; if (keyID.Trim() != string.Empty) { try { AISTOCK_CALENDAR_DATA data = new StockSystem().GetCalendarByID(keyID.Trim()); if (data.AISTOCK_CALENDAR.Rows.Count == 1) { remarks = ((AISTOCK_CALENDAR_DATA.AISTOCK_CALENDARRow)data.AISTOCK_CALENDAR.Rows[0]).remark.Trim(); } } catch (Exception ex) { message = "系统出现未知异常,请联系管理员!" + ex.Message; } } if (message == string.Empty) { //传入参数,用于回调数据,取消修改,恢复原数据 result = "{IsSuccess:true, keyID:'" + keyID.Trim() + "', projectData:'" + remarks.Trim() + "'}"; } else { result = "{IsSuccess:false, Message:'" + message + "'}"; } Response.Write(result); Response.End(); }
private void DataUpdate() { AISTOCK_STOCK_IMPORT_DATA stocks = new StockSystem().GetStockImport(); WebClient client = new WebClient(); client.Headers.Add("Content-Type", "text/html; charset=gb2312"); Stream stockData; StreamReader reader; string returnData; int start; int end; string[] tradeData; foreach (AISTOCK_STOCK_IMPORT_DATA.AISTOCK_STOCK_IMPORTRow row in stocks.AISTOCK_STOCK_IMPORT.Rows) { stockData = client.OpenRead("http://hq.sinajs.cn/list=" + row.STOCK_CODE.ToString()); reader = new StreamReader(stockData, System.Text.Encoding.GetEncoding("gb2312")); returnData = reader.ReadToEnd(); start = returnData.IndexOf('"'); end = returnData.LastIndexOf('"'); returnData = returnData.Substring(start + 1, end - start - 1); tradeData = returnData.Split(','); if (tradeData.Length == 33) { string stockName = tradeData[0].ToString(); UpdateData(row.STOCK_CODE.ToString(), stockName); } } }
private void SaveDailyReportData(string keyID) { string result = string.Empty; string message = string.Empty; if (keyID.Trim() != string.Empty) { try { if (this.hiddenSelectedValue.Value.Trim() == string.Empty) { message = "没有要保存的数据!"; } else { //根据主键ID取得数据 string remarks = this.hiddenSelectedValue.Value.Trim(); AISTOCK_CALENDAR_DATA data = new StockSystem().GetCalendarByID(keyID.Trim()); if (data.AISTOCK_CALENDAR.Count == 1) { #region 修改数据 AISTOCK_CALENDAR_DATA.AISTOCK_CALENDARRow row = data.AISTOCK_CALENDAR[0]; row.remark = remarks; #endregion } else { message += "根据项目主键ID无法取得项目信息,请联系管理员!"; } new StockSystem().SaveDailyReport(data); } } catch (Exception ex) { message += "系统出现未知异常,请联系管理员!" + ex.Message; } } else { message += "没有要保存的数据!"; } if (message == string.Empty) { //传入参数,用于回调数据,将修改后的数据更新显示于页面中 result = "{IsSuccess:true, savedKeyID:'" + keyID.Trim() + "'}"; } else { result = "{IsSuccess:false, Message:'" + message + "'}"; } Response.Write(result); Response.End(); //保存数据之后,将Hidden中的数据清空 this.hiddenSelectedValue.Value = string.Empty; }
private void StockWords() { int total = new StockSystem().GetTotalWords(); Random ran = new Random(); int id = ran.Next(1, total + 1); string words = new StockSystem().GetWords(id); SendEmail("战术上的重视表现在对敌的主动权,可以试探,可以深入,可以围而不公,可以坚守以待,每次只做一只,而不致于被敌人牵着鼻子走,若无必胜把握,可撤;凡战,则必胜,可大胜,可小胜,故谓之'常胜'", words); }
private void InitPage() { //初始化日期 this.DatePickerFrom.DateTime = DateTime.Now.ToShortDateString(); this.DatePickerTo.DateTime = DateTime.Now.ToShortDateString(); //市场 AISTOCK_FIELD_DOMAIN_VALUE_DATA market = new StockSystem().GetDropDownList("market"); this.DropDownListCategory.Items.Clear(); this.DropDownListCategory.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in market.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListCategory.Items.Add(new ListItem(item.Text, item.Value)); } //行业 AISTOCK_FIELD_DOMAIN_VALUE_DATA field = new StockSystem().GetDropDownList("field"); this.DropDownListField.Items.Clear(); this.DropDownListField.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in field.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListField.Items.Add(new ListItem(item.Text, item.Value)); } //省份 AISTOCK_FIELD_DOMAIN_VALUE_DATA province = new StockSystem().GetDropDownList("province"); this.DropDownListProvince.Items.Clear(); this.DropDownListProvince.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in province.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListProvince.Items.Add(new ListItem(item.Text, item.Value)); } //K线图 AISTOCK_FIELD_DOMAIN_VALUE_DATA chart = new StockSystem().GetDropDownList("chart"); this.DropDownListChart.Items.Clear(); this.DropDownListChart.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in chart.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListChart.Items.Add(new ListItem(item.Text, item.Value)); } }
private void Refresh() { AISTOCK_CALENDAR_DATA data = new AISTOCK_CALENDAR_DATA(); data = new StockSystem().GetAllCalendarData(); this.BmBlafTable.Clear(); this.DrawTableHeader(); this.DrawTableBody(data); }
private void Refresh() { string dateFrom = Request.QueryString["datefrom"] == null ? string.Empty : Request.QueryString["datefrom"]; string dateTo = Request.QueryString["dateto"] == null ? string.Empty : Request.QueryString["dateto"]; string market = Request.QueryString["market"] == null ? string.Empty : Request.QueryString["market"]; string field = Request.QueryString["field"] == null ? string.Empty : Request.QueryString["field"]; string chart = Request.QueryString["chart"] == null ? string.Empty : Request.QueryString["chart"]; string province = Request.QueryString["province"] == null ? string.Empty : Request.QueryString["province"]; string stockName = Request.QueryString["stockName"] == null ? string.Empty : Request.QueryString["stockName"].ToString().Trim(); string stockcode = Request.QueryString["stockcode"] == null ? string.Empty : Request.QueryString["stockcode"]; string MarketName = Request.QueryString["MarketName"] == "--请选择--" ? string.Empty : Request.QueryString["MarketName"]; string FieldName = Request.QueryString["FieldName"] == "--请选择--" ? string.Empty : Request.QueryString["FieldName"].Trim(); string ChartName = Request.QueryString["ChartName"] == "--请选择--" ? string.Empty : Request.QueryString["ChartName"]; string ProvinceName = Request.QueryString["ProvinceName"] == "--请选择--" ? string.Empty : Request.QueryString["ProvinceName"].Trim(); StockQueryCondition qc = new StockQueryCondition(); qc.DatePickerFrom = dateFrom; qc.DatePickerTo = dateTo; qc.StockCode = stockcode; qc.StockName = stockName; qc.Market = MarketName; qc.Field = FieldName; qc.Chart = ChartName; qc.Province = ProvinceName; this.ViewState["_StockQueryCondition"] = qc.SerializeToString(); AISTOCK_STOCK_DAILY_DATA_V_DATA data = new AISTOCK_STOCK_DAILY_DATA_V_DATA(); data = new StockSystem().GetStockHistory(qc); AISTOCK_STOCK_AVG_PRICE_DATA avgData = new AISTOCK_STOCK_AVG_PRICE_DATA(); avgData = new StockSystem().GetStockAvgHistory(qc); this.BmBlafTableHistory.Clear(); this.BmBlafTableHistory.BorderColor = Color.Black; this.BmBlafTableHistory.BorderWidth = Unit.Point(1); this.DrawBlafTableHeader(); this.DrawBlafTableBody(data, avgData); this.LabelTitle.Text = "名称:查询股票历史记录<br>" + "创建时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "<br>" + "时间:" + qc.DatePickerFrom + "至" + qc.DatePickerTo + "<br>" + "所属证券市场:" + (qc.Market == string.Empty ? "ALL" : qc.Market) + "<br>" + "所属证监会行业:" + (qc.Field == string.Empty ? "ALL" : qc.Field) + "<br>" + "所属省份:" + (qc.Province == string.Empty ? "ALL" : qc.Province) + "<br>" + "K线图:" + (qc.Chart == string.Empty ? "ALL" : qc.Chart) + "<br>" + "股票代码:" + (qc.StockCode == string.Empty ? "ALL" : qc.StockCode) + "<br>" + "股票名称:" + (qc.StockName == string.Empty ? "ALL" : qc.StockName); }
private void Refresh() { StockQueryCondition qc = new StockQueryCondition(); qc.DeserializeFromString(this.ViewState["_StockQueryCondition"].ToString()); this.labPrompt.Text = ""; //查询日前两天 string dateTo2 = new StockSystem().GetIndexDay(qc.DatePickerFrom, 2); dateTo2 = DateTimeFunction.ConvertDate(DateTime.Parse(dateTo2).ToShortDateString()); string date2RSI6 = new StockSystem().GetIndexDay(qc.DatePickerFrom, 8); date2RSI6 = DateTimeFunction.ConvertDate(DateTime.Parse(date2RSI6).ToShortDateString()); string date2RSI12 = new StockSystem().GetIndexDay(qc.DatePickerFrom, 14); date2RSI12 = DateTimeFunction.ConvertDate(DateTime.Parse(date2RSI12).ToShortDateString()); //string date2RSI24 = new StockSystem().GetIndexDay(qc.DatePickerFrom, 26); //date2RSI24 = DateTimeFunction.ConvertDate(DateTime.Parse(date2RSI24).ToShortDateString()); //查询日 string dateTo = DateTimeFunction.ConvertDate(qc.DatePickerFrom); string dateRSI6 = new StockSystem().GetIndexDay(qc.DatePickerFrom, 6); dateRSI6 = DateTimeFunction.ConvertDate(DateTime.Parse(dateRSI6).ToShortDateString()); string dateRSI12 = new StockSystem().GetIndexDay(qc.DatePickerFrom, 12); dateRSI12 = DateTimeFunction.ConvertDate(DateTime.Parse(dateRSI12).ToShortDateString()); //string dateRSI24 = new StockSystem().GetIndexDay(qc.DatePickerFrom, 24); //dateRSI24 = DateTimeFunction.ConvertDate(DateTime.Parse(dateRSI24).ToShortDateString()); AISTOCK_STOCK_STATS_DATA stockData = new StockSystem().GetStockData(dateTo2, txtStockCode.Text.Trim()); string today = DateTimeFunction.ConvertDate(DateTime.Now.ToShortDateString()); today = new StockSystem().GetToday(today); bool flag = false; if (int.Parse(dateTo) < int.Parse(today)) { flag = true; } AISTOCK_STOCK_INDEX_V_DATA data2RSI6 = new AISTOCK_STOCK_INDEX_V_DATA(); data2RSI6 = new StockSystem().GetStockDataIndex(date2RSI6, dateTo2, txtStockCode.Text.Trim()); this.BmBlafTable.Clear(); DrawRsiTableHeader(); DrawRsiTableBody(data2RSI6, stockData, txtStockCode.Text.Trim(), flag, today, dateTo2, date2RSI12, dateTo, dateRSI6, dateRSI12); }
private void Refresh() { if (this.ViewState["_StockQueryCondition"] == null) { this.RecordQueryCondition(); } StockQueryCondition qc = new StockQueryCondition(); qc.DeserializeFromString(this.ViewState["_StockQueryCondition"].ToString()); AISTOCK_STOCK_BASEINFO_DATA data = new StockSystem().GetStockBaseInfo(qc); this.BmBlafTableStock.Clear(); this.DrawBmTableHeader(); this.DrawBmTableBody(data); }
private void Refresh() { StockQueryCondition qc = new StockQueryCondition(); qc.DeserializeFromString(this.ViewState["_StockQueryCondition"].ToString()); string date = DateTimeFunction.ConvertDate(qc.DatePickerFrom); AISTOCK_STATS_PERCENT_V_DATA data = new StockSystem().GetStockStatsVData(date); DataTable leader = new StockSystem().GetLeaderStock(date); this.BmBlafTable.Clear(); DrawTableHeader(); DrawTableBody(data, leader); this.RestoreQueryCondition(); }
private void InitPage() { //初始化日期 this.DatePickerFrom.DateTime = DateTime.Now.ToShortDateString(); //买入类型 AISTOCK_FIELD_DOMAIN_VALUE_DATA market = new StockSystem().GetDropDownList("buy"); this.DropDownListType.Items.Clear(); this.DropDownListType.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in market.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListType.Items.Add(new ListItem(item.Text, item.Value)); } }
private void Refresh() { StockQueryCondition qc = new StockQueryCondition(); qc.DeserializeFromString(this.ViewState["_StockQueryCondition"].ToString()); DateTime dateFrom = DateTime.Parse(this.DatePickerFrom.DateTime.ToString()); DateTime dateTo = DateTime.Parse(this.DatePickerTo.DateTime.ToString()); if (dateFrom > dateTo) { this.RestoreQueryCondition(); this.labScript.Text = JavaScriptFunction.Alert("选择的查询时间段不对,请重新选择。"); return; } AISTOCK_STOCK_DAILY_DATA_V_DATA data = new AISTOCK_STOCK_DAILY_DATA_V_DATA(); data = new StockSystem().GetStockHistory(qc); AISTOCK_STOCK_AVG_PRICE_DATA avgData = new AISTOCK_STOCK_AVG_PRICE_DATA(); avgData = new StockSystem().GetStockAvgHistory(qc); this.BmBlafTableHistory.Clear(); this.BmBlafTableHistory.IsEnableScroll = true; this.BmBlafTableHistory.FreezeColumnCount = 6; if (data == null || data.AISTOCK_STOCK_DAILY_DATA_V.Count <= 0) { //this.BmBlafTableHistory.TitleRowCount = 1; this.DrawBlafTableHeader(); } else { //this.BmBlafTableHistory.TitleRowCount = 2; this.DrawBlafTableHeader(); this.DrawBlafTableBody(data, avgData); } //恢复记录 this.RestoreQueryCondition(); }
/// <summary> ///传入一个起始日期和一个结束日期,返回一个这个时间段的数组. /// </summary> /// <param name="yearMonthFrom"></param> /// <param name="yearMonthTo"></param> /// <returns></returns> private ArrayList SplitDate(string dateFrom, string dateTo) { ArrayList arrayListDate = new ArrayList(); DateTime dtFrom = DateTime.Parse(dateFrom); DateTime dtTo = DateTime.Parse(dateTo); DataTable data = new StockSystem().GetDates(dtFrom, dtTo); if (data.Rows.Count == 1) { arrayListDate.Add(dateFrom); } else { for (int i = 0; i < data.Rows.Count; i++) { arrayListDate.Add(((DateTime)data.Rows[i][0]).ToShortDateString()); } } return(arrayListDate); }
private void InitDropDownList() { //市场 AISTOCK_FIELD_DOMAIN_VALUE_DATA market = new StockSystem().GetDropDownList("market"); this.DropDownListCategory.Items.Clear(); this.DropDownListCategory.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in market.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListCategory.Items.Add(new ListItem(item.Text, item.Value)); } //行业 AISTOCK_FIELD_DOMAIN_VALUE_DATA field = new StockSystem().GetDropDownList("field"); this.DropDownListField.Items.Clear(); this.DropDownListField.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in field.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListField.Items.Add(new ListItem(item.Text, item.Value)); } //省份 AISTOCK_FIELD_DOMAIN_VALUE_DATA province = new StockSystem().GetDropDownList("province"); this.DropDownListProvince.Items.Clear(); this.DropDownListProvince.Items.Add(new ListItem("--请选择--", "")); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in province.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { ListItem item = new ListItem(); item.Text = row.FIELD_DOMAIN_VALUE; item.Value = row.FIELD_DOMAIN_VALUE; this.DropDownListProvince.Items.Add(new ListItem(item.Text, item.Value)); } }
private void Qushi(string date) { AISTOCK_STOCK_STATS_DATA data = new StockSystem().GetStockData(date, ""); int HL = 0; int LH = 0; foreach (var item in data.AISTOCK_STOCK_INFORMATION) { if (item.TODAY_BEGIN > item.YESTERDAY_END && item.TODAY_END < item.YESTERDAY_END) { HL++; } if (item.TODAY_BEGIN < item.YESTERDAY_END && item.TODAY_END > item.YESTERDAY_END) { LH++; } } decimal ratio = (decimal)LH / (decimal)(LH + HL) * 100; string content = "低开高走" + LH + "家,高开低走" + HL + "家,低开高走占比" + ratio.ToString("0.00") + "%"; SendEmail("今日趋势", content); }
private void Refresh() { string dateFrom = Request.QueryString["datefrom"] == null ? string.Empty : Request.QueryString["datefrom"]; string dateTo = Request.QueryString["dateto"] == null ? string.Empty : Request.QueryString["dateto"]; string dateSearch = Request.QueryString["datesearch"] == null ? string.Empty : Request.QueryString["datesearch"]; string type = Request.QueryString["type"] == null ? string.Empty : Request.QueryString["type"]; string stockName = Request.QueryString["stockName"] == null ? string.Empty : Request.QueryString["stockName"].ToString().Trim(); string stockcode = Request.QueryString["stockcode"] == null ? string.Empty : Request.QueryString["stockcode"]; string TypeName = Request.QueryString["TypeName"] == "--请选择--" ? string.Empty : Request.QueryString["TypeName"]; StockQueryCondition qc = new StockQueryCondition(); qc.DatePickerFrom = dateFrom; qc.DatePickerTo = dateTo; qc.DatePickerSearch = dateSearch; qc.StockCode = stockcode; qc.StockName = stockName; qc.BuyPoint = TypeName; this.ViewState["_StockQueryCondition"] = qc.SerializeToString(); AISTOCK_STOCK_BUY_HISTORY_DATA data = new StockSystem().GetBuyHistoryData(qc); this.BmBlafTableHistory.Clear(); this.BmBlafTableHistory.BorderColor = Color.Black; this.BmBlafTableHistory.BorderWidth = Unit.Point(1); this.DrawBlafTableHeader(); this.DrawBlafTableBody(data); this.LabelTitle.Text = "名称:查询买入股票历史记录<br>" + "创建时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "<br>" + "时间:" + qc.DatePickerFrom + "至" + qc.DatePickerTo + "<br>" + "买股类型:" + (qc.BuyPoint == string.Empty ? "ALL" : qc.BuyPoint) + "<br>" + "查询时间:" + qc.DatePickerFrom + "<br>" + "股票代码:" + (qc.StockCode == string.Empty ? "ALL" : qc.StockCode) + "<br>" + "股票名称:" + (qc.StockName == string.Empty ? "ALL" : qc.StockName); }
private void Refresh() { StockQueryCondition qc = new StockQueryCondition(); qc.DeserializeFromString(this.ViewState["_StockQueryCondition"].ToString()); AISTOCK_STOCK_BASEINFO_DATA baseData = new StockSystem().GetStockBaseInfoWithoutCondition(); int indexDay = 5; if (qc.BuyPoint.Equals("低档五连阳")) { indexDay = 4; } else if (qc.BuyPoint.Equals("双针探底") || qc.BuyPoint.Equals("锤子线探底")) { indexDay = 1; } else if (qc.BuyPoint.Equals("十字星探底")) { indexDay = 3; } else if (qc.BuyPoint.Equals("早晨之星")) { indexDay = 2; } string dateTo = DateTimeFunction.ConvertDate(qc.DatePickerFrom); string date = new StockSystem().GetIndexDay(qc.DatePickerFrom, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); if (qc.BuyPoint.Equals("低档五连阳")) { AISTOCK_STOCK_LOW_FIVE_V_DATA data = new StockSystem().GetLowFiveData(date, dateTo); this.BmBlafTable.Clear(); DrawLowFiveTableHeader(); DrawLowFiveTableBody(data, baseData); } else if (qc.BuyPoint.Equals("双针探底")) { AISTOCK_STOCK_TWO_PIN_V_DATA data = new StockSystem().GetTwoPinData(date, dateTo); this.BmBlafTable.Clear(); DrawTwoPinTableHeader(); DrawTwoPinTableBody(data); } else if (qc.BuyPoint.Equals("十字星探底")) { AISTOCK_STOCK_SINGLE_PIN_V_DATA data = new StockSystem().GetSinglePinData(date, dateTo); this.BmBlafTable.Clear(); DrawSinglePinTableHeader(); DrawSinglePinTableBody(data); } else if (qc.BuyPoint.Equals("锤子线探底")) { AISTOCK_STOCK_HAMMER_V_DATA data = new StockSystem().GetHammerData(date, dateTo); this.BmBlafTable.Clear(); DrawHammerHeader(); DrawHammerTableBody(data); } else if (qc.BuyPoint.Equals("早晨之星")) { string twoDate = new StockSystem().GetIndexDay(qc.DatePickerFrom, 1); twoDate = DateTimeFunction.ConvertDate(DateTime.Parse(twoDate).ToShortDateString()); AISTOCK_STOCK_MORNING_STAR_V_DATA data = new StockSystem().GetMorningStarData(date, twoDate, dateTo); this.BmBlafTable.Clear(); DrawMorningStarHeader(); DrawMorningStarTableBody(data); } }
private void Stats() { StockQueryCondition qc = new StockQueryCondition(); qc.DeserializeFromString(this.ViewState["_StockQueryCondition"].ToString()); AISTOCK_FIELD_DOMAIN_VALUE_DATA buy = new StockSystem().GetDropDownList("buy"); int indexDay = 5; string dateTo = DateTimeFunction.ConvertDate(qc.DatePickerFrom); string date = string.Empty; AISTOCK_STOCK_BUY_STATS_DATA stats = new AISTOCK_STOCK_BUY_STATS_DATA(); AISTOCK_STOCK_BASEINFO_DATA baseData = new StockSystem().GetStockBaseInfoWithoutCondition(); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow row in buy.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { string value = row.FIELD_DOMAIN_VALUE; if (value.Equals("低档五连阳")) { indexDay = 4; date = new StockSystem().GetIndexDay(qc.DatePickerFrom, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); AISTOCK_STOCK_LOW_FIVE_V_DATA data = new StockSystem().GetLowFiveData(date, dateTo); foreach (AISTOCK_STOCK_LOW_FIVE_V_DATA.AISTOCK_STOCK_LOW_FIVE_VRow dataRow in data.AISTOCK_STOCK_LOW_FIVE_V.Rows) { AISTOCK_STOCK_BUY_STATS_DATA.AISTOCK_STOCK_BUY_STATSRow saveRow = stats.AISTOCK_STOCK_BUY_STATS.NewAISTOCK_STOCK_BUY_STATSRow(); Guid id = Guid.NewGuid(); saveRow.STOCK_BUY_ID = id.ToString().ToUpper(); saveRow.STOCK_CODE = dataRow.STOCK_CODE; DataRow[] tmpRow = baseData.AISTOCK_STOCK_BASEINFO.Select("STOCK_CODE = '" + dataRow.STOCK_CODE + "'"); saveRow.STOCK_NAME = ((AISTOCK_STOCK_BASEINFO_DATA.AISTOCK_STOCK_BASEINFORow)tmpRow[0]).STOCK_NAME; saveRow.STOCK_TYPE = "低档五连阳"; saveRow.STOCK_DAY = dateTo; stats.AISTOCK_STOCK_BUY_STATS.AddAISTOCK_STOCK_BUY_STATSRow(saveRow); } } else if (value.Equals("双针探底")) { indexDay = 1; date = new StockSystem().GetIndexDay(qc.DatePickerFrom, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); AISTOCK_STOCK_TWO_PIN_V_DATA data = new StockSystem().GetTwoPinData(date, dateTo); foreach (AISTOCK_STOCK_TWO_PIN_V_DATA.AISTOCK_STOCK_TWO_PIN_VRow dataRow in data.AISTOCK_STOCK_TWO_PIN_V.Rows) { AISTOCK_STOCK_BUY_STATS_DATA.AISTOCK_STOCK_BUY_STATSRow saveRow = stats.AISTOCK_STOCK_BUY_STATS.NewAISTOCK_STOCK_BUY_STATSRow(); Guid id = Guid.NewGuid(); saveRow.STOCK_BUY_ID = id.ToString().ToUpper(); saveRow.STOCK_CODE = dataRow.STOCK_CODE; saveRow.STOCK_NAME = dataRow.STOCK_NAME; saveRow.STOCK_TYPE = "双针探底"; saveRow.STOCK_DAY = dateTo; stats.AISTOCK_STOCK_BUY_STATS.AddAISTOCK_STOCK_BUY_STATSRow(saveRow); } } else if (value.Equals("十字星探底")) { indexDay = 3; date = new StockSystem().GetIndexDay(qc.DatePickerFrom, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); AISTOCK_STOCK_SINGLE_PIN_V_DATA data = new StockSystem().GetSinglePinData(date, dateTo); foreach (AISTOCK_STOCK_SINGLE_PIN_V_DATA.AISTOCK_STOCK_SINGLE_PIN_VRow dataRow in data.AISTOCK_STOCK_SINGLE_PIN_V.Rows) { AISTOCK_STOCK_BUY_STATS_DATA.AISTOCK_STOCK_BUY_STATSRow saveRow = stats.AISTOCK_STOCK_BUY_STATS.NewAISTOCK_STOCK_BUY_STATSRow(); Guid id = Guid.NewGuid(); saveRow.STOCK_BUY_ID = id.ToString().ToUpper(); saveRow.STOCK_CODE = dataRow.STOCK_CODE; saveRow.STOCK_NAME = dataRow.STOCK_NAME; saveRow.STOCK_TYPE = "十字星探底"; saveRow.STOCK_DAY = dateTo; stats.AISTOCK_STOCK_BUY_STATS.AddAISTOCK_STOCK_BUY_STATSRow(saveRow); } } else if (value.Equals("锤子线探底")) { indexDay = 1; date = new StockSystem().GetIndexDay(qc.DatePickerFrom, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); AISTOCK_STOCK_HAMMER_V_DATA data = new StockSystem().GetHammerData(date, dateTo); foreach (AISTOCK_STOCK_HAMMER_V_DATA.AISTOCK_STOCK_HAMMER_VRow dataRow in data.AISTOCK_STOCK_HAMMER_V.Rows) { AISTOCK_STOCK_BUY_STATS_DATA.AISTOCK_STOCK_BUY_STATSRow saveRow = stats.AISTOCK_STOCK_BUY_STATS.NewAISTOCK_STOCK_BUY_STATSRow(); Guid id = Guid.NewGuid(); saveRow.STOCK_BUY_ID = id.ToString().ToUpper(); saveRow.STOCK_CODE = dataRow.STOCK_CODE; saveRow.STOCK_NAME = dataRow.STOCK_NAME; saveRow.STOCK_TYPE = "锤子线探底"; saveRow.STOCK_DAY = dateTo; stats.AISTOCK_STOCK_BUY_STATS.AddAISTOCK_STOCK_BUY_STATSRow(saveRow); } } else if (value.Equals("早晨之星")) { indexDay = 2; date = new StockSystem().GetIndexDay(qc.DatePickerFrom, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); string twoDate = new StockSystem().GetIndexDay(qc.DatePickerFrom, 1); twoDate = DateTimeFunction.ConvertDate(DateTime.Parse(twoDate).ToShortDateString()); AISTOCK_STOCK_MORNING_STAR_V_DATA data = new StockSystem().GetMorningStarData(date, twoDate, dateTo); foreach (AISTOCK_STOCK_MORNING_STAR_V_DATA.AISTOCK_STOCK_MORNING_STAR_VRow dataRow in data.AISTOCK_STOCK_MORNING_STAR_V.Rows) { AISTOCK_STOCK_BUY_STATS_DATA.AISTOCK_STOCK_BUY_STATSRow saveRow = stats.AISTOCK_STOCK_BUY_STATS.NewAISTOCK_STOCK_BUY_STATSRow(); Guid id = Guid.NewGuid(); saveRow.STOCK_BUY_ID = id.ToString().ToUpper(); saveRow.STOCK_CODE = dataRow.STOCK_CODE; saveRow.STOCK_NAME = dataRow.STOCK_NAME; saveRow.STOCK_TYPE = "早晨之星"; saveRow.STOCK_DAY = dateTo; stats.AISTOCK_STOCK_BUY_STATS.AddAISTOCK_STOCK_BUY_STATSRow(saveRow); } } } new StockSystem().SaveStockStatsData(stats); }
private void DrawRsiTableBody(AISTOCK_STOCK_INDEX_V_DATA data2RSI, AISTOCK_STOCK_STATS_DATA stockData, string code, bool isToday, string today, string dateTo2, string date2RSI12, string dateTo, string dateRSI6, string dateRSI12) { if (data2RSI == null || data2RSI.AISTOCK_STOCK_INDEX_V.Count <= 0) { return; } TableRow bodyRow; for (int i = 0; i < stockData.AISTOCK_STOCK_INFORMATION.Rows.Count; i++) { decimal sumA = 0; decimal sumB = 0; decimal index = 0; AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow stockRow = ((AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow)stockData.AISTOCK_STOCK_INFORMATION.Rows[i]); string stockCode = stockRow.STOCK_CODE.ToString(); DataRow[] rows = data2RSI.AISTOCK_STOCK_INDEX_V.Select("STOCK_CODE = '" + stockCode + "'"); if (rows.Length <= 0) { continue; } for (int j = 0; j < rows.Length; j++) { AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow row = (AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow)rows[j]; if (row.DIFF > 0) { sumA += row.DIFF; } else { sumB += row.DIFF; } } if (sumA - sumB != 0) { index = sumA / (sumA - sumB) * 100; } if (index > 40) { continue; } else { //符合条件,计算12日RSI decimal sumA12 = 0; decimal sumB12 = 0; decimal index12 = 0; AISTOCK_STOCK_INDEX_V_DATA data2RSI12 = new AISTOCK_STOCK_INDEX_V_DATA(); data2RSI12 = new StockSystem().GetStockDataIndex(date2RSI12, dateTo2, stockCode); foreach (var row2RSI12 in data2RSI12.AISTOCK_STOCK_INDEX_V) { if (row2RSI12.DIFF > 0) { sumA12 += row2RSI12.DIFF; } else { sumB12 += row2RSI12.DIFF; } } if (sumA12 - sumB12 != 0) { index12 = sumA12 / (sumA12 - sumB12) * 100; if (index12 > index) { //符合条件,计算查询日RSI6 decimal sumARSI6 = 0, sumBRSI6 = 0, indexRSI6 = 0; AISTOCK_STOCK_INDEX_V_DATA dataRSI6 = new AISTOCK_STOCK_INDEX_V_DATA(); dataRSI6 = new StockSystem().GetStockDataIndex(dateRSI6, dateTo, stockCode); foreach (var rowRSI6 in dataRSI6.AISTOCK_STOCK_INDEX_V) { if (rowRSI6.DIFF > 0) { sumARSI6 += rowRSI6.DIFF; } else { sumBRSI6 += rowRSI6.DIFF; } } if (sumARSI6 - sumBRSI6 != 0) { indexRSI6 = sumARSI6 / (sumARSI6 - sumBRSI6) * 100; decimal sumARSI12 = 0, sumBRSI12 = 0, indexRSI12 = 0; AISTOCK_STOCK_INDEX_V_DATA dataRSI12 = new AISTOCK_STOCK_INDEX_V_DATA(); dataRSI12 = new StockSystem().GetStockDataIndex(dateRSI12, dateTo, stockCode); foreach (var rowRSI12 in dataRSI12.AISTOCK_STOCK_INDEX_V) { if (rowRSI12.DIFF > 0) { sumARSI12 += rowRSI12.DIFF; } else { sumBRSI12 += rowRSI12.DIFF; } } if (sumARSI12 - sumBRSI12 != 0) { indexRSI12 = sumARSI12 / (sumARSI12 - sumBRSI12) * 100; if (indexRSI6 > indexRSI12) { //符合条件,输出 //成交量指标 int quantity = new StockSystem().GetQuantity(stockCode); decimal ratio; if (quantity == 0) { ratio = -1; } ratio = (decimal)stockRow.QUANTITY / (decimal)quantity; if (ratio < 2) { continue; } if (index == 0) { continue; } bodyRow = this.BmBlafTable.AddBodyRow(); this.BmBlafTable.AddCell(bodyRow, url.Replace("stockcode", stockRow.STOCK_CODE), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.STOCK_NAME, HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, index.ToString("0.00"), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, ratio.ToString("0.00"), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsTODAY_BEGINNull() ? string.Empty : stockRow.TODAY_BEGIN.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsYESTERDAY_ENDNull() ? string.Empty : stockRow.YESTERDAY_END.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsTODAY_ENDNull() ? string.Empty : stockRow.TODAY_END.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsINCREASE_PERCENTNull() ? string.Empty : stockRow.INCREASE_PERCENT.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsCHARTNull() ? string.Empty : stockRow.CHART.ToString(), HorizontalAlign.Left); #region [取当天数据] if (isToday) { AISTOCK_STOCK_STATS_DATA todayData = new StockSystem().GetStockDataJingQue(today, stockCode); AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow todayRow = ((AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow)todayData.AISTOCK_STOCK_INFORMATION.Rows[0]); this.BmBlafTable.AddCell(bodyRow, todayRow.IsTODAY_BEGINNull() ? string.Empty : todayRow.TODAY_BEGIN.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, todayRow.IsTODAY_ENDNull() ? string.Empty : todayRow.TODAY_END.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, todayRow.IsINCREASE_PERCENTNull() ? string.Empty : todayRow.INCREASE_PERCENT.ToString(), HorizontalAlign.Left); decimal relativePercent = 0; if (stockRow.TODAY_END > 0) { relativePercent = (todayRow.TODAY_END - stockRow.TODAY_END) / stockRow.TODAY_END * 100; } this.BmBlafTable.AddCell(bodyRow, relativePercent.ToString("0.0000"), HorizontalAlign.Left); } else { this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); } #endregion } } } else { continue; } } else { continue; } } } } }
private void RSIData(string dateTo, string date1) { int indexDay = 14; string date = new StockSystem().GetIndexDay(date1, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); AISTOCK_STOCK_INDEX_V_DATA dataRSI = new AISTOCK_STOCK_INDEX_V_DATA(); dataRSI = new StockSystem().GetStockDataIndex(date, dateTo, ""); AISTOCK_STOCK_STATS_DATA stockData = new StockSystem().GetStockData(dateTo, ""); AISTOCK_STOCK_WMS_V_DATA dataWms = new AISTOCK_STOCK_WMS_V_DATA(); dataWms = new StockSystem().GetStockWmsData(date, dateTo, ""); if (dataRSI == null) { return; } if (dataRSI.AISTOCK_STOCK_INDEX_V.Count <= 0) { return; } int count = 0; StringBuilder sb = new StringBuilder(); AISTOCK_STOCK_COMMAND_DATA saveData = new AISTOCK_STOCK_COMMAND_DATA(); for (int i = 0; i < stockData.AISTOCK_STOCK_INFORMATION.Rows.Count; i++) { decimal sumA = 0; decimal sumB = 0; decimal index = 0; AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow stockRow = ((AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow)stockData.AISTOCK_STOCK_INFORMATION.Rows[i]); string stockCode = stockRow.STOCK_CODE.ToString(); DataRow[] rows = dataRSI.AISTOCK_STOCK_INDEX_V.Select("STOCK_CODE = '" + stockCode + "'"); if (!stockCode.ToLower().StartsWith("sz002")) { continue; } if (rows.Length <= 0) { continue; } for (int j = 0; j < rows.Length; j++) { AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow row = (AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow)rows[j]; if (row.DIFF > 0) { sumA += row.DIFF; } else { sumB += row.DIFF; } } if (sumA - sumB != 0) { index = sumA / (sumA - sumB) * 100; } if (index == 0 || index > 10) { continue; } //WM Index DataRow[] wmrow = dataWms.AISTOCK_STOCK_WMS_V.Select("STOCK_CODE = '" + stockCode + "'"); decimal max_price = 0; decimal min_price = 0; decimal end_price = 0; decimal wmindex = 0; max_price = ((AISTOCK_STOCK_WMS_V_DATA.AISTOCK_STOCK_WMS_VRow)wmrow[0]).MAX_PRICE; min_price = ((AISTOCK_STOCK_WMS_V_DATA.AISTOCK_STOCK_WMS_VRow)wmrow[0]).MIN_PRICE; end_price = stockRow.TODAY_END; if (max_price - min_price != 0) { wmindex = (max_price - end_price) / (max_price - min_price) * 100; } if (wmindex > 0) { continue; } int quantity = new StockSystem().GetQuantity(stockCode); decimal ratio; if (quantity == 0) { ratio = -1; } else { ratio = (decimal)stockRow.QUANTITY / (decimal)quantity; } count++; AISTOCK_STOCK_COMMAND_DATA.AISTOCK_STOCK_COMMANDRow saveRow = saveData.AISTOCK_STOCK_COMMAND.NewAISTOCK_STOCK_COMMANDRow(); saveRow.STOCK_ID = Guid.NewGuid().ToString(); saveRow.STOCK_CODE = stockCode; saveRow.STOCK_NAME = stockRow.STOCK_NAME; saveRow.STOCK_DAY = stockRow.STOCK_DAY; saveRow.TODAY_BEGIN = stockRow.TODAY_BEGIN; saveRow.TODAY_END = stockRow.TODAY_END; saveRow.MAX_PRICE = stockRow.MAX_PRICE; saveRow.MIN_PRICE = stockRow.MIN_PRICE; saveRow.RSI = index; saveRow.WM = wmindex; saveRow.RATIO = ratio; saveData.AISTOCK_STOCK_COMMAND.AddAISTOCK_STOCK_COMMANDRow(saveRow); sb.Append("@" + stockCode + "@" + index.ToString("0.00") + "\n"); } if (count > 0) { new StockSystem().SaveRSIData(saveData); SendEmail("敌情资讯", sb.ToString()); } }
private void Form1_Load(object sender, EventArgs e) { //string date = DateTime.Now.Year.ToString() + (DateTime.Now.Month < 10 ? "0" + DateTime.Now.Month.ToString() : DateTime.Now.Month.ToString()) + (DateTime.Now.Day < 10 ? "0" + DateTime.Now.Day.ToString() : DateTime.Now.Day.ToString()); //string date1 = DateTime.Now.Year.ToString() + "-" + (DateTime.Now.Month < 10 ? "0" + DateTime.Now.Month.ToString() : DateTime.Now.Month.ToString()) + "-" + (DateTime.Now.Day < 10 ? "0" + DateTime.Now.Day.ToString() : DateTime.Now.Day.ToString()); //AISTOCK_STOCK_LOG_DATA data = new AISTOCK_STOCK_LOG_DATA(); //AISTOCK_STOCK_LOG_DATA.AISTOCK_STOCK_LOGRow row = data.AISTOCK_STOCK_LOG.NewAISTOCK_STOCK_LOGRow(); //if (IsValidDay(date1))//判断是否休市日 //{ // if (!HasImport(date)) // { // ImportData(date); // //暂时没有用处 // //CalculateAvgPriceData(date); // RSIData(date, date1); // Qushi(date); // row.RUNNER = "[Robot]"; // row.RUNTIME = DateTime.Now; // row.STATUS = "[Robot] finish data collection :)"; // } // else // { // row.RUNNER = "[Robot]"; // row.RUNTIME = DateTime.Now; // row.STATUS = "[Robot] data had been collected"; // } //} //else //{ // row.RUNNER = "[Robot]"; // row.RUNTIME = DateTime.Now; // row.STATUS = "[Robot] today is holiday :-"; //} //data.AISTOCK_STOCK_LOG.AddAISTOCK_STOCK_LOGRow(row); ////删除超过30天之前的数据 //string dateFrom = DateTime.Now.Year.ToString() + "-01-01"; //bool hasdelete = false; //new StockSystem().DeleteData(dateFrom, date1, out hasdelete); //if (hasdelete) //{ // row = data.AISTOCK_STOCK_LOG.NewAISTOCK_STOCK_LOGRow(); // row.RUNNER = "[Robot]"; // row.RUNTIME = DateTime.Now; // row.STATUS = "[Robot] destroy data less than " + date1 + " :-"; // data.AISTOCK_STOCK_LOG.AddAISTOCK_STOCK_LOGRow(row); //} //new StockSystem().SaveStockLog(data); #region [获取股东人数和十大流通股数据--来自一点仓位] AISTOCK_STOCK_IMPORT_DATA baseData = new StockSystem().GetStockImport(true); AISTOCK_FIELD_DOMAIN_VALUE_DATA optionDate = new StockSystem().GetDropDownList("date"); foreach (AISTOCK_STOCK_IMPORT_DATA.AISTOCK_STOCK_IMPORTRow row in baseData.AISTOCK_STOCK_IMPORT.Rows) { string code = row.STOCK_CODE.ToString(); if (code.Equals("sz000488")) { continue; } CatchCangWeiData(code); foreach (AISTOCK_FIELD_DOMAIN_VALUE_DATA.AISTOCK_FIELD_DOMAIN_VALUERow option in optionDate.AISTOCK_FIELD_DOMAIN_VALUE.Rows) { CatchCangWeiData(code, option.FIELD_DOMAIN_VALUE.ToString()); } SaveJobFinished(code); } #endregion this.Dispose(); this.Close(); }
private void Refresh() { StockQueryCondition qc = new StockQueryCondition(); qc.DeserializeFromString(this.ViewState["_StockQueryCondition"].ToString()); this.labPrompt.Text = ""; int indexDay = 14; if (qc.Index.Equals("RSI(5)")) { indexDay = 5; } else if (qc.Index.Equals("RSI(9)")) { indexDay = 9; } else if (qc.Index.Equals("RSI(14)") || qc.Index.Equals("ADR(14)")) { indexDay = 11; } else if (qc.Index.Equals("WMS(10)") || qc.Index.Equals("ADR(10)")) { indexDay = 10; } else if (qc.Index.Equals("WMS(20)")) { indexDay = 20; } string dateTo = DateTimeFunction.ConvertDate(qc.DatePickerFrom); string date = new StockSystem().GetIndexDay(qc.DatePickerFrom, indexDay); date = DateTimeFunction.ConvertDate(DateTime.Parse(date).ToShortDateString()); AISTOCK_STOCK_STATS_DATA stockData = new StockSystem().GetStockData(dateTo, txtStockCode.Text.Trim()); if (qc.Index.Equals("RSI(5)") || qc.Index.Equals("RSI(9)") || qc.Index.Equals("RSI(14)")) { string today = DateTimeFunction.ConvertDate(DateTime.Now.ToShortDateString()); today = new StockSystem().GetToday(today); bool flag = false; if (int.Parse(dateTo) < int.Parse(today)) { flag = true; } AISTOCK_STOCK_INDEX_V_DATA dataRSI = new AISTOCK_STOCK_INDEX_V_DATA(); dataRSI = new StockSystem().GetStockDataIndex(date, dateTo, txtStockCode.Text.Trim()); this.BmBlafTable.Clear(); DrawRsiTableHeader(); DrawRsiTableBody(dataRSI, stockData, txtStockCode.Text.Trim(), flag, today, qc.DatePickerFrom, indexDay); } else if (qc.Index.Equals("WMS(10)") || qc.Index.Equals("WMS(20)")) { AISTOCK_STOCK_WMS_V_DATA dataWms = new AISTOCK_STOCK_WMS_V_DATA(); dataWms = new StockSystem().GetStockWmsData(date, dateTo, txtStockCode.Text.Trim()); this.BmBlafTable.Clear(); DrawWmsTableHeader(); DrawWmsTableBody(stockData, dataWms); } else if (qc.Index.Equals("ADR(10)") || qc.Index.Equals("ADR(14)")) { AISTOCK_STOCK_ADR_INDEX_V_DATA dataAdr = new AISTOCK_STOCK_ADR_INDEX_V_DATA(); dataAdr = new StockSystem().GetStockAdrData(date, dateTo, txtStockCode.Text.Trim()); this.BmBlafTable.Clear(); DrawAdrTableHeader(); DrawAdrTableBody(dataAdr); } }
private void DrawRsiTableBody(AISTOCK_STOCK_INDEX_V_DATA dataRSI, AISTOCK_STOCK_STATS_DATA stockData, string code, bool isToday, string today, string date, int indexDay) { int sh = 0, sz = 0, zx = 0, bj = 0; if (dataRSI == null) { return; } if (dataRSI.AISTOCK_STOCK_INDEX_V.Count <= 0) { return; } TableRow bodyRow; for (int i = 0; i < stockData.AISTOCK_STOCK_INFORMATION.Rows.Count; i++) { decimal sumA = 0; decimal sumB = 0; decimal index = 0; decimal sumAB = 0; decimal sumBB = 0; decimal indexB = 0; AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow stockRow = ((AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow)stockData.AISTOCK_STOCK_INFORMATION.Rows[i]); string stockCode = stockRow.STOCK_CODE.ToString(); if (stockCode.ToLower().StartsWith("sz300") && string.IsNullOrEmpty(txtStockCode.Text)) { continue; } DataRow[] rows = dataRSI.AISTOCK_STOCK_INDEX_V.Select("STOCK_CODE = '" + stockCode + "'"); if (rows.Length <= 0) { continue; } for (int j = 0; j < rows.Length; j++) { AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow row = (AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow)rows[j]; if (row.DIFF > 0) { sumA += row.DIFF; } else { sumB += row.DIFF; } } if (sumA - sumB != 0) { index = sumA / (sumA - sumB) * 100; } if ((index > 80 || index < 75) && string.IsNullOrEmpty(txtStockCode.Text)) { continue; } //计算昨天的指标是否也在75-80之间,不是则抛弃 #region [开始计算] string dateTo = new StockSystem().GetIndexDay(date, 1); dateTo = DateTimeFunction.ConvertDate(DateTime.Parse(dateTo).ToShortDateString()); string dateFrom = new StockSystem().GetIndexDay(date, indexDay + 1); dateFrom = DateTimeFunction.ConvertDate(DateTime.Parse(dateFrom).ToShortDateString()); AISTOCK_STOCK_INDEX_V_DATA dataRSIB = new StockSystem().GetStockDataIndex(dateFrom, dateTo, stockCode); DataRow[] rowRSIB = dataRSIB.AISTOCK_STOCK_INDEX_V.Select("STOCK_CODE = '" + stockCode + "'"); if (rowRSIB.Length <= 0) { continue; } for (int j = 0; j < rowRSIB.Length; j++) { AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow row = (AISTOCK_STOCK_INDEX_V_DATA.AISTOCK_STOCK_INDEX_VRow)rowRSIB[j]; if (row.DIFF > 0) { sumAB += row.DIFF; } else { sumBB += row.DIFF; } } if (sumAB - sumBB != 0) { indexB = sumAB / (sumAB - sumBB) * 100; } if ((indexB > 80 || indexB < 75) && string.IsNullOrEmpty(txtStockCode.Text)) { continue; } #endregion [结束计算] bodyRow = this.BmBlafTable.AddBodyRow(); if (stockRow.STOCK_CODE.Contains("sh600")) { sh++; } else if (stockRow.STOCK_CODE.Contains("sz000")) { sz++; } else if (stockRow.STOCK_CODE.Contains("sz002")) { zx++; } else if (stockRow.STOCK_CODE.Contains("sh601") || stockRow.STOCK_CODE.Contains("sh603")) { bj++; } this.BmBlafTable.AddCell(bodyRow, url.Replace("stockcode", stockRow.STOCK_CODE), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.STOCK_NAME, HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, index.ToString("0.00"), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, indexB.ToString("0.00"), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsTODAY_BEGINNull() ? string.Empty : stockRow.TODAY_BEGIN.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsYESTERDAY_ENDNull() ? string.Empty : stockRow.YESTERDAY_END.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsTODAY_ENDNull() ? string.Empty : stockRow.TODAY_END.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsINCREASE_PERCENTNull() ? string.Empty : stockRow.INCREASE_PERCENT.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, stockRow.IsCHARTNull() ? string.Empty : stockRow.CHART.ToString(), HorizontalAlign.Left); #region [取当天数据] if (isToday) { AISTOCK_STOCK_STATS_DATA todayData = new StockSystem().GetStockDataJingQue(today, stockCode); AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow todayRow = ((AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow)todayData.AISTOCK_STOCK_INFORMATION.Rows[0]); this.BmBlafTable.AddCell(bodyRow, todayRow.IsTODAY_BEGINNull() ? string.Empty : todayRow.TODAY_BEGIN.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, todayRow.IsTODAY_ENDNull() ? string.Empty : todayRow.TODAY_END.ToString(), HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, todayRow.IsINCREASE_PERCENTNull() ? string.Empty : todayRow.INCREASE_PERCENT.ToString(), HorizontalAlign.Left); decimal relativePercent = 0; if (stockRow.TODAY_END > 0) { relativePercent = (todayRow.TODAY_END - stockRow.TODAY_END) / stockRow.TODAY_END * 100; } this.BmBlafTable.AddCell(bodyRow, relativePercent.ToString("0.0000"), HorizontalAlign.Left); } else { this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); this.BmBlafTable.AddCell(bodyRow, "", HorizontalAlign.Left); } #endregion } int sum = sh + sz + zx + bj; this.labPrompt.Text = "渐强状态:共" + sum + "支,其中上市" + sh + "支,深市" + sz + "支,中小板" + zx + ",北京" + bj + "支<br/>"; }
private void ImportData(string date) { AISTOCK_STOCK_STATS_DATA data = new AISTOCK_STOCK_STATS_DATA(); AISTOCK_STOCK_IMPORT_DATA stocks = new StockSystem().GetStockImport(); string stockCode = string.Empty; WebClient client = new WebClient(); client.Headers.Add("Content-Type", "text/html; charset=gb2312"); Stream stockData; StreamReader reader; string returnData; int start; int end; string[] tradeData; string stockName = string.Empty; decimal todayBegin; decimal yesterdayEnd; decimal current; decimal max; decimal min; decimal buy; decimal sell; int quantity; decimal money; decimal[] buyer_price; int[] buyer_quantity; decimal[] seller_price; int[] seller_quanlity; foreach (var item in stocks.AISTOCK_STOCK_IMPORT) { AISTOCK_STOCK_STATS_DATA.AISTOCK_STOCK_INFORMATIONRow row = data.AISTOCK_STOCK_INFORMATION.NewAISTOCK_STOCK_INFORMATIONRow(); stockCode = item.STOCK_CODE.ToString(); Guid stock_id = Guid.NewGuid(); buyer_price = new decimal[5]; buyer_quantity = new int[5]; seller_price = new decimal[5]; seller_quanlity = new int[5]; stockData = client.OpenRead("http://hq.sinajs.cn/list=" + stockCode); reader = new StreamReader(stockData, System.Text.Encoding.GetEncoding("gb2312")); returnData = reader.ReadToEnd(); start = returnData.IndexOf('"'); end = returnData.LastIndexOf('"'); returnData = returnData.Substring(start + 1, end - start - 1); tradeData = returnData.Split(','); if (tradeData.Length == 33) { stockName = tradeData[0].ToString(); todayBegin = decimal.Parse(tradeData[1].ToString()); yesterdayEnd = decimal.Parse(tradeData[2].ToString()); current = decimal.Parse(tradeData[3].ToString()); max = decimal.Parse(tradeData[4].ToString()); min = decimal.Parse(tradeData[5].ToString()); buy = decimal.Parse(tradeData[6].ToString()); sell = decimal.Parse(tradeData[7].ToString()); quantity = int.Parse(tradeData[8].ToString()); money = decimal.Parse(tradeData[9].ToString()); buyer_quantity[0] = int.Parse(tradeData[10].ToString()); buyer_price[0] = decimal.Parse(tradeData[11].ToString()); buyer_quantity[1] = int.Parse(tradeData[12].ToString()); buyer_price[1] = decimal.Parse(tradeData[13].ToString()); buyer_quantity[2] = int.Parse(tradeData[14].ToString()); buyer_price[2] = decimal.Parse(tradeData[15].ToString()); buyer_quantity[3] = int.Parse(tradeData[16].ToString()); buyer_price[3] = decimal.Parse(tradeData[17].ToString()); buyer_quantity[4] = int.Parse(tradeData[18].ToString()); buyer_price[4] = decimal.Parse(tradeData[19].ToString()); seller_quanlity[0] = int.Parse(tradeData[20].ToString()); seller_price[0] = decimal.Parse(tradeData[21].ToString()); seller_quanlity[1] = int.Parse(tradeData[22].ToString()); seller_price[1] = decimal.Parse(tradeData[23].ToString()); seller_quanlity[2] = int.Parse(tradeData[24].ToString()); seller_price[2] = decimal.Parse(tradeData[25].ToString()); seller_quanlity[3] = int.Parse(tradeData[26].ToString()); seller_price[3] = decimal.Parse(tradeData[27].ToString()); seller_quanlity[4] = int.Parse(tradeData[28].ToString()); seller_price[4] = decimal.Parse(tradeData[29].ToString()); } else { todayBegin = 0; yesterdayEnd = 0; current = 0; max = 0; min = 0; buy = 0; sell = 0; quantity = 0; money = 0; for (int i = 0; i < 5; i++) { buyer_quantity[i] = 0; buyer_price[i] = 0; seller_quanlity[i] = 0; seller_price[i] = 0; } } reader.Close(); stockData.Close(); decimal percent; string chart; if (yesterdayEnd > 0) { percent = (current - yesterdayEnd) / yesterdayEnd * 100; } else { percent = 0; } chart = this.GetChart(todayBegin, current, max, min, yesterdayEnd); row.STOCK_ID = stock_id.ToString().ToUpper(); row.STOCK_CODE = stockCode; row.STOCK_NAME = stockName; row.STOCK_DAY = date; row.TODAY_BEGIN = todayBegin; row.YESTERDAY_END = yesterdayEnd; row.TODAY_END = current; row.MAX_PRICE = max; row.MIN_PRICE = min; row.BUY_PRICE = buy; row.SELL_PRICE = sell; row.QUANTITY = quantity; row.TOTAL_MONEY = money; row.BUY_ONE_QUANTITY = buyer_quantity[0]; row.BUY_ONE_PRICE = buyer_price[0]; row.BUY_TWO_QUANTITY = buyer_quantity[1]; row.BUY_TWO_PRICE = buyer_price[1]; row.BUY_THD_QUANTITY = buyer_quantity[2]; row.BUY_THD_PRICE = buyer_price[2]; row.BUY_FOU_QUANTITY = buyer_quantity[3]; row.BUY_FOU_PRICE = buyer_price[3]; row.BUY_FIF_QUANTITY = buyer_quantity[4]; row.BUY_FIF_PRICE = buyer_price[4]; row.SELL_ONE_QUANTITY = seller_quanlity[0]; row.SELL_ONE_PRICE = seller_price[0]; row.SELL_TWO_QUANTITY = seller_quanlity[1]; row.SELL_TWO_PRICE = seller_price[1]; row.SELL_THD_QUANTITY = seller_quanlity[2]; row.SELL_THD_PRICE = seller_price[2]; row.SELL_FOU_QUANTITY = seller_quanlity[3]; row.SELL_FOU_PRICE = seller_price[3]; row.SELL_FIF_QUANTITY = seller_quanlity[4]; row.SELL_FIF_PRICE = seller_price[4]; row.INCREASE_PERCENT = percent; row.CHART = chart; data.AISTOCK_STOCK_INFORMATION.Rows.Add(row); } new StockSystem().ImportStockData(data); }