public override void LoadData(DataInfoType type) { switch (type) { case DataInfoType.SecurityInfo: base.LoadSecurityInfo(); break; case DataInfoType.TradingPrice: DataManager.GetDataLoader().LoadMutualFundPrice(this); break; case DataInfoType.FundNetAssetValue: DataManager.GetDataLoader().LoadMutualFundNAV(this); break; case DataInfoType.SecurityReport: DataManager.GetDataLoader().LoadMutualFundReport(this); break; default: MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_GE1, type.ToString()); break; } }
private void updateFundNAV(DataSet ds, SeriesNetAssetValue navs) { DataRow[] rows = ds.Tables[0].Select("SYMBOL='" + navs.Code + "'"); if (rows.Length > 0) { //基本信息 navs.DataSource = this.DataSource; navs.OriginalTimeSeries.Clear(); foreach (DataRow row in rows) { NetAssetValue nav = new NetAssetValue(); nav.TradeDate = DataManager.ConvertToDate(row[C_ColName_PublishDate]); nav.UnitNAV = DataManager.ConvertToDouble(row[C_ColName_UnitNAV]); nav.AccumUnitNAV = DataManager.ConvertToDouble(row[C_ColName_AccumUnitNAV]); //复权系数 navs.OriginalTimeSeries.Add(nav); } //交易日校验,复权并计算涨跌幅 navs.Adjust(); } else { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_MF4, navs.Code); } }
public override void LoadEquityInfo(Equity e) { try { if (_EquityInfo == null) { string sql = @"SELECT SYMBOL, Exchange, SNAME, LISTDATE, ENDDATE FROM SECURITYCODE A WHERE STYPE = 'EQA' "; //获得所有股票的信息做缓存 _EquityInfo = base.DBInstance.ExecuteSQL(sql); } //更新数据 DataRow[] rows = _EquityInfo.Tables[0].Select("SYMBOL='" + e.Code + "'"); if (rows.Length >= 1) { DataRow row = rows[0]; e.Name = row[C_ColName_Name].ToString(); e.ListedDate = DataManager.ConvertToDate(row[C_ColName_ListedDate]); e.DelistedDate = DataManager.ConvertToDate(row[C_ColName_EndDate]); e.Exchange = this.GetExchange(row[C_ColName_Exchange].ToString()); e.DataSource = this.DataSource; } else { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_EQ5, e.Code); } } catch (Exception ex) { throw ex; } }
public static AFundCategory GetFundCategory(FundCategoryType type) { switch (type) { case FundCategoryType.GalaxySecurity: return(new FundCategoryGS()); default: MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_MF7, type.ToString()); return(null); } }
public override void LoadData(DataInfoType type) { try { switch (type) { case DataInfoType.SecurityInfo: DataManager.GetDataLoader().LoadMutualFundInfo(this); break; case DataInfoType.FundNetAssetValue: if (this.TradingNAV == null) { this.TradingNAV = new SeriesNetAssetValue(base.Code, base.TimeSeriesStart, base.TimeSeriesEnd); } //仅对非货币基金 if (this.Category.AssetCategory != FundAssetCategory.Monetory) { this.TradingNAV.Load(); } break; case DataInfoType.TradingPrice: if (base.TradingPrice == null) { base.TradingPrice = new SeriesFundPrice(base.Code, base.TimeSeriesStart, base.TimeSeriesEnd); } base.TradingPrice.Load(); break; case DataInfoType.SecurityReport: if (this.FundReport == null) { this.FundReport = new SeriesFundReport(base.Code, base.TimeSeriesStart, base.TimeSeriesEnd); } this.FundReport.Load(); break; default: MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_GE1, type.ToString()); return; } } catch (Exception ex) { throw new Exception("读取基金数据时出错!", ex);; } }
public override void LoadData(DataInfoType type) { switch (type) { case DataInfoType.SecurityInfo: base.LoadSecurityInfo(); break; case DataInfoType.TradingPrice: DataManager.GetDataLoader().LoadIndexPrice(this); break; default: MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_GE1, type.ToString()); return; } }
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 LoadData(DataInfoType type) { switch (type) { case DataInfoType.SecurityInfo: DataManager.GetDataLoader().LoadIndexInfo(this); break; case DataInfoType.TradingPrice: if (base.TradingPrice == null) { base.TradingPrice = new SeriesIndexPrice(base.Code, base.TimeSeriesStart, base.TimeSeriesEnd); } base.TradingPrice.Load(); break; default: MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_GE1, type.ToString()); return; } }
public static ExchangeType GetEquityExchange(string code, ref EquityBoardType boardtype) { if (code == null || code.Length == 0) { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_EQ3, "(null)"); return(ExchangeType.OTC); } string code3 = code.Substring(0, 3); string code2 = code.Substring(0, 2); switch (code2) { case "60": //沪市 boardtype = EquityBoardType.Main; return(ExchangeType.SSE); default: //深市 switch (code3) { case "000": case "001": boardtype = EquityBoardType.Main; break; case "002": boardtype = EquityBoardType.SmallMedium; break; case "300": boardtype = EquityBoardType.StartUp; break; default: break; } return(ExchangeType.SZSE); } }
public override void LoadIndexInfo(Index i) { try { if (_IndexInfo == null) { string sql = @"SELECT Symbol, Iname, Ianame, Bdate, Bpoint, Stopdate, Iprofile6, Iprofile7, stocknum, Exchange FROM IPROFILE A WHERE Status = -1 AND currency='CNY' AND IPROFILE7 in ('申万一级行业指数', '中信一级行业指数','中证规模指数','申万风格指数', '巨潮规模指数','巨潮风格指数','巨潮行业指数','中证债券指数','上证综合指数','深证规模指数')"; //获得所有指数的信息做缓存 _IndexInfo = base.DBInstance.ExecuteSQL(sql); } //更新数据 DataRow[] rows = _IndexInfo.Tables[0].Select("SYMBOL='" + i.Code + "'"); if (rows.Length >= 1) { DataRow row = rows[0]; i.Name = row[C_ColName_IndexName].ToString(); i.ListedDate = DataManager.ConvertToDate(row[C_ColName_IndexBaseDate]); i.DelistedDate = DataManager.ConvertToDate(row[C_ColName_IndexStopDate]); i.Category = row[C_ColName_IndexCategory].ToString(); i.Exchange = this.GetExchange(row[C_ColName_Exchange].ToString()); i.DataSource = this.DataSource; } else { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_ID5, i.Code); } } catch (Exception ex) { throw ex; } }
public virtual void Adjust() { //======================================== //1)按交易日补齐数据并作复权调整 //======================================== #region 交易日补齐数据并作复权调整 if (this.TradingDates.Count == 0) { DataManager.GetDataLoader().LoadTradingDate(this); } if (TradingDates == null || TradingDates.Count == 0 || this.OriginalTimeSeries == null || this.OriginalTimeSeries.Count == 0) { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_GE2, ""); return; } if (this.AdjustedTimeSeries == null) { this.AdjustedTimeSeries = new List <ATimeItem>(); } else { this.AdjustedTimeSeries.Clear(); } //找到缺失的交易日并补齐数据 int iOriginalCnt = 0; for (int iTradeDayCount = 0; iTradeDayCount < this.TradingDates.Count;) { DateTime tradeday = this.TradingDates[iTradeDayCount]; if (iOriginalCnt < this.OriginalTimeSeries.Count) { ATimeItem item = this.OriginalTimeSeries[iOriginalCnt]; //判断是否是样本外数据 if (item.TradeDate < this.TimeSeriesStart) { item.IsOutsideSamplePeriod = true; } else { InsideSampleLength++; } if (tradeday >= item.TradeDate) { //交易日不在净值数据中则加入前一交易日的数据 ATimeItem newItem = (ATimeItem)item.Clone(); newItem.TradeDate = tradeday; if (tradeday == item.TradeDate) { newItem.IsTrading = true; } else { newItem.IsTrading = false; } //复权调整 newItem.Adjust(); this.AdjustedTimeSeries.Add(newItem); if (tradeday == item.TradeDate) { iOriginalCnt++; } //计数器加1 iTradeDayCount++; } else { iOriginalCnt++; } } else { //OriginalTimeSeries更早交易日的数据 break; } } #endregion //======================================== //2)计算涨跌幅数据 //======================================== this.Calculate(); }
public override void LoadMutualFundInfo(MutualFund f) { try { //读取数据库 this.LoadMutualFundInfo(); //更新数据 DataRow[] rows = _FundInfo.Tables[0].Select("SYMBOL='" + f.Code + "'"); if (rows.Length >= 1) { f.DataSource = this.DataSource; f.Category.DataSource = this.DataSource; DataRow row = rows[0]; f.Name = row[C_ColName_Name].ToString(); f.ListedDate = DataManager.ConvertToDate(row[C_ColName_ListedDate]); f.DelistedDate = DataManager.ConvertToDate(row[C_ColName_DelistedDate]); f.Category.SetupCategory(row[C_ColName_GSFundType].ToString(), 3); if (row[C_ColName_ParentCode] == DBNull.Value) { //非分级基金 f.IsStructured = false; f.Category.StructureCategory = FundStructureCategory.Parent; } else { //分级基金 f.IsStructured = true; f.ParentFundCode = row[C_ColName_ParentCode].ToString(); if (row[C_ColName_ParentCode].ToString() == row[C_ColName_Code].ToString()) { f.Category.StructureCategory = FundStructureCategory.Parent; //查找子基金 string sql = @"Select SYMBOL From CURFSCODE WHERE Symbol_Comp = '" + f.Code + "' AND Symbol <> Symbol_Comp"; DataSet ds = base.DBInstance.ExecuteSQL(sql); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_MF8, f.Code); } else { if (f.SubFundCodes == null) { f.SubFundCodes = new List <string>(); } foreach (DataRow rowsub in ds.Tables[0].Rows) { string code = rowsub[C_ColName_Code].ToString(); f.SubFundCodes.Add(code); } } } else { f.Category.StructureCategory = FundStructureCategory.Child; } } } else { MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_MF5, f.Code); } } catch (Exception ex) { throw ex; } }
private void updateCategory3(string text) { base.Name3 = text; base.OperationCategory = FundOperationCategory.OpenEnd; base.InvestmentCategory = FundInvestmentCategory.Active; base.StructureCategory = FundStructureCategory.Parent; switch (text) { case "标准股票型基金": case "普通股票型基金": base.AssetCategory = FundAssetCategory.Equity; base.Name1 = "股票基金"; base.Name2 = "股票型基金"; break; case "标准指数股票型基金": case "增强指数股票型基金": case "标准指数型股票基金": case "增强指数型股票基金": case "ETF联接基金": base.InvestmentCategory = FundInvestmentCategory.Passive; base.AssetCategory = FundAssetCategory.Equity; base.Name1 = "股票基金"; base.Name2 = "指数股票型基金"; break; case "股票型分级子基金(优先份额)": case "股票型分级子基金(进取份额)": base.StructureCategory = FundStructureCategory.Child; base.AssetCategory = FundAssetCategory.Equity; base.Name1 = "股票基金"; base.Name2 = "股票型分级子基金"; break; case "偏股型基金(股票上限95%)": case "偏股型基金(股票上限80%)": base.AssetCategory = FundAssetCategory.Hybrid; base.Name1 = "混合基金"; base.Name2 = "偏股型基金"; break; case "灵活配置型基金(股票上限95%)": case "灵活配置型基金(股票上限80%)": base.AssetCategory = FundAssetCategory.Hybrid; base.Name1 = "混合基金"; base.Name2 = "灵活配置型基金"; break; case "股债平衡型基金": base.AssetCategory = FundAssetCategory.Hybrid; base.Name1 = "混合基金"; base.Name2 = "股债平衡型基金"; break; case "偏债型基金": case "保本型基金": case "特定策略混合型基金": base.AssetCategory = FundAssetCategory.Hybrid; base.Name1 = "混合基金"; base.Name2 = base.Name3; break; case "长期标准债券型基金(A类)": case "长期标准债券型基金(B/C类)": case "中短期标准债券型基金(A类)": case "中短期标准债券型基金(B类)": base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "债券基金"; base.Name2 = "标准债券型基金"; break; case "普通债券型基金(一级A类)": case "普通债券型基金(一级B/C类)": case "普通债券型基金(二级A类)": case "普通债券型基金(二级B/C类)": base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "债券基金"; base.Name2 = "普通债券型基金"; break; case "可转换债券型基金(A类)": case "可转换债券型基金(B/C类)": base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "债券基金"; base.Name2 = "可转换债券型基金"; break; case "指数债券型基金(A类)": case "指数债券型基金(B/C类)": base.InvestmentCategory = FundInvestmentCategory.Passive; base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "债券基金"; base.Name2 = "指数债券型基金"; break; case "债券型分级子基金(优先份额)": case "债券型分级子基金(进取份额)": base.StructureCategory = FundStructureCategory.Child; base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "债券基金"; base.Name2 = "债券型分级子基金"; break; case "短期理财债券型基金(A类)": case "短期理财债券型基金(B类)": base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "债券基金"; base.Name2 = "短期理财债券型基金"; break; case "货币市场基金(A类)": case "货币市场基金(B类)": base.AssetCategory = FundAssetCategory.Monetory; base.Name1 = "货币市场基金"; base.Name2 = base.Name3; break; case "QDII全球股票型基金": case "QDII亚太股票型基金": case "QDII新兴市场股票型基金": case "QDII成熟市场股票型基金": case "QDII大中华股票型基金": case "QDII全球股票基金": case "QDII亚太股票基金": case "QDII新兴市场股票基金": case "QDII成熟市场股票基金": case "QDII大中华股票基金": base.AssetCategory = FundAssetCategory.QDII; base.Name1 = "QDII基金"; base.Name2 = "QDII股票基金"; break; case "QDII指数股票型基金": case "QDII指数型股票基金": case "QDII-ETF联接基金": base.InvestmentCategory = FundInvestmentCategory.Passive; base.AssetCategory = FundAssetCategory.QDII; base.Name1 = "QDII基金"; base.Name2 = "QDII股票基金"; break; case "QDII混合基金": case "QDII债券基金": case "QDII商品基金": base.AssetCategory = FundAssetCategory.QDII; base.Name1 = "QDII基金"; base.Name2 = base.Name3; break; case "封闭式标准股票型基金": case "封闭式普通股票型基金": base.OperationCategory = FundOperationCategory.CloseEnd; base.AssetCategory = FundAssetCategory.Equity; base.Name1 = "封闭式股票基金"; base.Name2 = "封闭式股票型基金"; break; case "封闭式标准指数型股票基金": base.InvestmentCategory = FundInvestmentCategory.Passive; base.OperationCategory = FundOperationCategory.CloseEnd; base.AssetCategory = FundAssetCategory.Equity; base.Name1 = "封闭式股票基金"; base.Name2 = "封闭式指数型股票基金"; break; case "封闭式股票型分级子基金(优先份额)": case "封闭式股票型分级子基金(进取份额)": base.StructureCategory = FundStructureCategory.Child; base.OperationCategory = FundOperationCategory.CloseEnd; base.AssetCategory = FundAssetCategory.Equity; base.Name1 = "封闭式股票基金"; base.Name2 = "封闭式股票型分级子基金"; break; case "封闭式长期标准债券型基金": base.OperationCategory = FundOperationCategory.CloseEnd; base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "封闭式债券基金"; base.Name2 = "封闭式标准债券型基金"; break; case "封闭式普通债券型基金(一级)": case "封闭式普通债券型基金(二级)": base.OperationCategory = FundOperationCategory.CloseEnd; base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "封闭式债券基金"; base.Name2 = "封闭式普通债券基金"; break; case "封闭式债券型分级子基金(优先份额)": case "封闭式债券型分级子基金(进取份额)": base.StructureCategory = FundStructureCategory.Child; base.OperationCategory = FundOperationCategory.CloseEnd; base.AssetCategory = FundAssetCategory.Bond; base.Name1 = "封闭式债券基金"; base.Name2 = "封闭式债券型分级子基金"; break; case "": base.Name1 = "未分类"; base.Name2 = "未分类"; base.Name3 = "未分类"; base.AssetCategory = FundAssetCategory.Undefined; base.OperationCategory = FundOperationCategory.Undefined; base.StructureCategory = FundStructureCategory.Undefined; base.InvestmentCategory = FundInvestmentCategory.Undefined; break; default: base.AssetCategory = FundAssetCategory.Other; MessageManager.GetInstance().AddMessage(MessageType.Warning, Message.C_Msg_MF6, text); break; } }