/// <summary> /// 初始化熔断实体把列表数据组装成新的实体 /// </summary> private void InitializeFuseEntity() { //ShowMessage.Instanse.ShowFormTitleMessage("正在初始化熔断"); List <CM_CommodityFuse> list = CommonDataCacheProxy.Instanse.GetCacheCommodityFuse(); if (Utils.IsNullOrEmpty(list)) { return; } MatchCenterManager.Instance.FuseHanderEntityList.Clear(); foreach (var fuse in list) { FuseHanderEntity fuseHanderEntity = new FuseHanderEntity(); fuseHanderEntity.IsFuse = false; fuseHanderEntity.PriorFuse = false; fuseHanderEntity.StockCode = fuse.CommodityCode; fuseHanderEntity.FuseCount = 0; if (!MatchCenterManager.Instance.FuseHanderEntityList.ContainsKey(fuse.CommodityCode)) { MatchCenterManager.Instance.FuseHanderEntityList.Add(fuse.CommodityCode, fuseHanderEntity); } } //ShowMessage.Instanse.ShowFormTitleMessage("初始化熔断(完)"); }
/// <summary> /// 根据商品判断当前时间是否是否发生熔断如果发生返回缓存中熔断的标识是否发生熔断 /// </summary> /// <param name="code">代码</param> /// <returns></returns> public bool IsFuse(string code) { //判断当前时间是否启动熔断时间 if (!FuseManager.Instanse.CompareNowTimeIsFuseTime(code)) { return(false); } //熔断实体 FuseHanderEntity entity = null; lock (((ICollection)MatchCenterManager.Instance.FuseHanderEntityList).SyncRoot) { if (MatchCenterManager.Instance.FuseHanderEntityList.ContainsKey(code)) { entity = MatchCenterManager.Instance.FuseHanderEntityList[code]; } //实体不能为空 if (entity == null) { return(false); } //返回熔断标志 return(entity.IsFuse); } }
/// <summary> /// 修改涨跌幅状态 /// </summary> /// <param name="code">代码</param> public void ModifyState(string code) { //熔断实体是否存在 //判断当前时间是否启动熔断时间 if (!FuseManager.Instanse.CompareNowTimeIsFuseTime(code)) { //初始化熔断 InitFuseEntity(code); return; } //管理中心熔断初始化数据 CM_CommodityFuse fuse = CommonDataCacheProxy.Instanse.GetCacheCommodityFuseByCode(code); if (fuse == null) { return; } //修改熔断实体 lock (((ICollection)MatchCenterManager.Instance.FuseHanderEntityList).SyncRoot) { FuseHanderEntity entity = MatchCenterManager.Instance.FuseHanderEntityList[code]; if (entity == null) { return; } //是否产生熔断 if (entity.IsFuse) { //熔断持续时间 // int FuseContinuTime = CalculationTime(entity.FuseTime); int FuseContinuTime = (int)Utils.TimeSpanSecondsToNowDateTime(entity.FuseTime); if (FuseContinuTime >= fuse.FuseDurationLimit * 60) { //是否产生熔断 entity.IsFuse = false; entity.PriorFuse = false; } } else { //涨跌幅判断标志 if (entity.PriorFuse) { //if (JudgePrice((decimal) fuse.TriggeringScale, code)) if (FuseManager.Instanse.CompareHQScaleIsFuse((decimal)fuse.TriggeringScale, code)) { //int contrinueTime = CalculationTime(entity.FuseTime); int contrinueTime = (int)Utils.TimeSpanSecondsToNowDateTime(entity.FuseTime); if (contrinueTime >= fuse.TriggeringDuration * 60 && entity.FuseCount < fuse.FuseTimeOfDay) { //熔断数量 entity.FuseCount = entity.FuseCount + 1; //熔断标志 entity.IsFuse = true; //熔断启动时间 entity.StartFuseTime = DateTime.Now; } } } else { //熔断涨跌幅度判断 if (FuseManager.Instanse.CompareHQScaleIsFuse((decimal)fuse.TriggeringScale, code)) { entity.PriorFuse = true; entity.FuseTime = DateTime.Now; } } } } }