public static CheckFullStopViewModel Instance(PotionDetailModelViewModel pmvm) { if (pmvm == null && _CheckFullStopViewModel == null) { return(null); } if (_CheckFullStopViewModel == null) { _CheckFullStopViewModel = new CheckFullStopViewModel(pmvm); } return(_CheckFullStopViewModel); }
public void ExecuteAddData(object para) { try { List <CheckFullStopModel> cfsms = para as List <CheckFullStopModel>; if (cfsms != null && cfsms.Count > 0) { Result(cfsms); if (CheckFullStopViewModel.IsInstance()) { CheckFullStopViewModel.Instance(null).Close(); } } } catch (Exception ex) { LogHelper.Info(ex.ToString()); } }
public void ExecuteDeleteData1(object para) { try { List <RStopLossStatus> slsAll = para as List <RStopLossStatus>; foreach (RStopLossStatus sls in slsAll) { if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "B")) { CommHelper.CFSmvmList[sls.contract_id + "B"].Clear(); LogHelper.Info("止盈止损" + sls.contract_id + "B清除数据"); PotionDetailModelViewModel temp = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "B"); if (temp != null) { temp.LossVolume = null; temp.ProfitVolume = null; } break; } if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "S")) { CommHelper.CFSmvmList[sls.contract_id + "S"].Clear(); LogHelper.Info("止盈止损" + sls.contract_id + "S清除数据"); PotionDetailModelViewModel temp = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "S"); if (temp != null) { temp.LossVolume = null; temp.ProfitVolume = null; } } break; } if (CheckFullStopViewModel.IsInstance()) { CheckFullStopViewModel.Instance(null).Close(); } } catch (Exception ex) { LogHelper.Info(ex.ToString()); } }
public void ExecuteDeleteData(object para) { try { double maxprice = 99999999999; double minprice = 0; double maxprice1 = 0; double minprice1 = 99999999999; int maxnum = 0; int minnum = 0; RStopLossStatus sls = para as RStopLossStatus; LogHelper.Info("5204止盈止损" + sls.contract_id + "开始"); if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "B")) { CheckFullStopModelViewModel item = CommHelper.CFSmvmList[sls.contract_id + "B"].FirstOrDefault(x => x.StoplossId == sls.stoploss_id); if (item != null) { CommHelper.CFSmvmList[sls.contract_id + "B"].Remove(item); LogHelper.Info("5204止盈止损" + sls.contract_id + "B清除数据"); } foreach (CheckFullStopModelViewModel temp in CommHelper.CFSmvmList[sls.contract_id + "B"]) { if (temp == null) { continue; } if (temp.StoplossPrice > 0 || temp.StopprofitPrice > 0) { if (item.StopprofitPrice > 0) { if (temp.StopprofitPrice < maxprice) { maxprice = temp.StopprofitPrice; maxnum = temp.OrderVolume; } else if (temp.StopprofitPrice == maxprice) { maxnum += temp.OrderVolume; } } if (temp.StoplossPrice > 0) { if (temp.StoplossPrice > minprice) { minprice = temp.StoplossPrice; minnum = temp.OrderVolume; } else if (temp.StoplossPrice == minprice) { minnum += temp.OrderVolume; } } } } PotionDetailModelViewModel _PositionModelViewModel1 = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "B"); if (_PositionModelViewModel1 != null) { if (maxprice < 99999999999 && maxnum > 0) { _PositionModelViewModel1.ProfitVolume = maxprice + "/" + maxnum; } else { _PositionModelViewModel1.ProfitVolume = ""; } if (minprice > 0 && minnum > 0) { _PositionModelViewModel1.LossVolume = minprice + "/" + minnum; } else { _PositionModelViewModel1.LossVolume = ""; } } } if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "S")) { CheckFullStopModelViewModel item = CommHelper.CFSmvmList[sls.contract_id + "S"].FirstOrDefault(x => x.StoplossId == sls.stoploss_id); if (item != null) { CommHelper.CFSmvmList[sls.contract_id + "S"].Remove(item); LogHelper.Info("5204止盈止损" + sls.contract_id + "S清除数据"); } foreach (CheckFullStopModelViewModel temp in CommHelper.CFSmvmList[sls.contract_id + "S"]) { if (temp == null) { continue; } if (temp.StoplossPrice > 0 || temp.StopprofitPrice > 0) { if (item.StopprofitPrice > 0) { if (item.StopprofitPrice > maxprice1) { maxprice1 = item.StopprofitPrice; maxnum = item.OrderVolume; } else if (item.StopprofitPrice == maxprice1) { maxnum += item.OrderVolume; } } if (item.StoplossPrice > 0) { if (item.StoplossPrice < minprice1) { minprice1 = item.StoplossPrice; minnum = item.OrderVolume; } else if (item.StoplossPrice == minprice1) { minnum += item.OrderVolume; } } } } PotionDetailModelViewModel _PositionModelViewModel = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "S"); if (_PositionModelViewModel != null) { if (maxprice1 > 0 && maxnum > 0) { _PositionModelViewModel.ProfitVolume = maxprice1 + "/" + maxnum; } else { _PositionModelViewModel.ProfitVolume = ""; } if (minprice1 < 99999999999 && minnum > 0) { _PositionModelViewModel.LossVolume = minprice1 + "/" + minnum; } else { _PositionModelViewModel.LossVolume = ""; } } } if (CheckFullStopViewModel.IsInstance()) { CheckFullStopViewModel.Instance(null).Close(); } } catch (Exception ex) { LogHelper.Info(ex.ToString()); } }
public void ClearData() { _CheckFullStopViewModel = null; }
public void Close() { _CheckFullStopViewModel = null; CloseAction?.Invoke(); }