股票板块指数算法代码 C#
代码如下请高手告诉更好的算法优级,总感到太费时如何优化,/// <summary>
/// 统计算法
/// </summary>
public class Statistics
{
private List<Plate> _Plates=new List<Plate>(); //板块表
private Dictionary<string,Item> NewData=new Dictionary<string, Item>(); //最新记录
private Dictionary<string, PlateM> _PlateMs = new Dictionary<string, PlateM>(); //板块指数
/// <summary>
/// 数据 进入
/// </summary>
/// <param name="mItem"></param>
public void PostData(Item mItem)
{
//判断数据是否变化
if (!NewData.ContainsKey(mItem.Code))
{
NewData.Add(mItem.Code,mItem);
RefPlateM();
return;
}
if (NewData[mItem.Code].Val != mItem.Val)
{
NewData[mItem.Code] = mItem;
RefPlateM();
}
}
/// <summary>
/// 更新板块数据
/// </summary>
public void RefPlateM()
{
double dPM = 0;
PlateM m=new PlateM();
foreach (Plate plate in _Plates)
{
m = new PlateM();
m.Name = plate.Name;
dPM = 0;
foreach (string code in plate.Codes)
{
dPM += NewData[code].Val;
}
m.Val = dPM;
m.DateTime = DateTime.Now;
if (!_PlateMs.ContainsKey(plate.Name))
{
_PlateMs.Add(plate.Name,m);
continue;
}
if (_PlateMs[plate.Name].Val != dPM)
_PlateMs[plate.Name] = m;
}
}
}
public struct Item
{
public string Code; //代码
public double Val; //值
public DateTime @DateTime; //日期,时间
}
/// <summary>
/// 板块
/// </summary>
public struct Plate
{
public string Name; //板块名
public List<string> Codes; //代码表
}
/// <summary>
/// 板块指数
/// </summary>
public struct PlateM
{
public string Name; //板块名
public double Val; //值
public DateTime @DateTime; //日期,时间
}
C# 股票 算法 优化 指数 --------------------编程问答-------------------- 求解!!!!!!!! --------------------编程问答-------------------- 求解!!!!!!!!
补充:.NET技术 , C#