private void updateFundPrice(DataSet ds, SeriesFundPrice pxs) { DataRow[] rows = ds.Tables[0].Select("SYMBOL='" + pxs.Code + "'"); if (rows.Length > 0) { //基本信息 pxs.DataSource = this.DataSource; pxs.OriginalTimeSeries.Clear(); foreach (DataRow row in rows) { ExchangeTradingPrice px = new ExchangeTradingPrice(); px.TradeDate = DataManager.ConvertToDate(row[C_ColName_TradeDate]); px.PreClose = DataManager.ConvertToDouble(row[C_ColName_PreClose]); px.Close = DataManager.ConvertToDouble(row[C_ColName_Close]); px.High = DataManager.ConvertToDouble(row[C_ColName_High]); px.Low = DataManager.ConvertToDouble(row[C_ColName_Low]); px.Open = DataManager.ConvertToDouble(row[C_ColName_Open]); px.Volume = DataManager.ConvertToDouble(row[C_ColName_Volume]); px.Amount = DataManager.ConvertToDouble(row[C_ColName_Amount]); px.Average = (px.Volume == 0) ? 0 : px.Amount / px.Volume; //判断停牌 if (px.Close == 0) { px.IsTrading = false; px.Close = px.PreClose; px.Open = px.PreClose; px.High = px.PreClose; px.Low = px.PreClose; } //复权系数 double adjustedClose = DataManager.ConvertToDouble(row[C_ColName_AdjustedClose]); px.AdjustCoefficient = (px.Close == 0 || adjustedClose == 0) ? 1 : adjustedClose / px.Close; pxs.OriginalTimeSeries.Add(px); } //复权并计算涨跌幅 pxs.Adjust(); } else { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_MF3, pxs.Code); } }
public override void LoadMutualFundPrice(SeriesFundPrice pxs) { try { //读数据 string sql = C_SQL_GetFundPrice; sql += " AND " + base.BuildSQLClauseIn(pxs.Code, "A.SYMBOL"); sql += " AND A.Tdate >= '" + pxs.TimeSeriesStartExtended.ToString("yyyyMMdd") + "' AND A.Tdate <= '" + pxs.TimeSeriesEnd.ToString("yyyyMMdd") + "'"; sql += " ORDER BY A.Symbol, A.Tdate Desc"; DataSet ds = base.DBInstance.ExecuteSQL(sql); //更新数据 this.updateFundPrice(ds, pxs); } catch (Exception ex) { throw ex; } }
public abstract void LoadMutualFundPrice(SeriesFundPrice pxs);