/// <summary> /// Вспомогательный метод - закрывает позицию текушими значниями времени и катеровок /// </summary> /// <param name="closeDealIdValue"></param> /// <param name="warningList"></param> /// <param name="validationErrorList"></param> /// <param name="timeExit"></param> /// <param name="ddlExitReasonValue"></param> /// <returns></returns> private ActionResult CloseDaelCurrentTimeValues(string closeDealIdValue, List<string> warningList, List<string> validationErrorList, DateTime timeExit, PositionExitReason ddlExitReasonValue) { var strings = GetSidePriceListById(closeDealIdValue); var adoHalper = new DatabaseQuoteEnquirer(); var tickers = strings.Select(x => x.Split('_')[0]).Distinct(); var quotes = tickers.ToDictionary(x => x, x => adoHalper.GetQuoteStoredProc(x)); var lstStoragePrice = new List<Tuple<string, int, float>>(); foreach (var inp in strings) { var input = inp.Split('_'); var side = Utils.dealSide[input[1]]; var quote = quotes.Where(x => x.Key == input[0]).ToList(); if (quote.Any()) { var price = quote.First().Value.bid; if (side == -1) price = quote.First().Value.ask; lstStoragePrice.Add(new Tuple<string, int, float>(input[0], side, price)); } else { warningList.Add(String.Format("{0} : {1} {2}. {3}.", Resource.ErrorMessage, Resource.ErrorMessageQuoteNotFound, input[0], Resource.ErrorMessageTransactionsOnPairWillNotClosed)); Logger.Error(String.Format("CloseOrCancelDeal - попытка принудительно закрыть сделки администратором. " + "Ошибка: для валютной пары {0} не найдены катировка. Сделки по этой валютной паре не будут закрыты.",input[0])); } } if (validationErrorList.Count > 0) { ViewBag.ErrorList = validationErrorList; ViewBag.WarningList = warningList; var model = GetPositionsEditModel(closeDealIdValue); return View("SafePositionEdit", model); } var successCloseDeals = positionRepository.ClosingPositions(closeDealIdValue, timeExit, ddlExitReasonValue, lstStoragePrice); var msg = successCloseDeals.Count < 10 ? string.Format("{0}: {1}. {2}", Resource.MessageMarketOrderClosed, string.Join(", ", successCloseDeals), Resource.ErrorMessageClosedNotAllTransactions) : string.Format("{0} {1} {2}. {3}", Resource.MessageMarketOrderClosed, string.Join(", ", successCloseDeals.Take(10)), Resource.TextEtc, Resource.ErrorMessageClosedNotAllTransactions); return RedirectToAction("PositionList", new { message = msg, positionId = -1 }); }
public void SetupMethods() { adoHalper = new DatabaseQuoteEnquirer(); DalSpot.Instantiate(MoqTradeSharpDictionary.Mock); }