public Task <StockStatistics> GetAverage(string stockName, PriceTypes priceTypes) { return(this.Repository.GetAverage(this.UserId, stockName, priceTypes)); }
public static IEnumerable<PricingItem> GetPriceTypes(this IEnumerable<PricingItem> source_, PriceTypes type_) { return source_.Where(x => x.PriceType == (int)type_); }
public void UpdateOrder(string customerType) { var order = OrderService.GetCurrentOrder(); if (order == null) { return; } // var newPriceTypePart = PriceTypes.GetByCustomerType(customerType); /* string prevPriceTypePart; * if (order.CustomerType == null) * prevPriceTypePart = newPriceTypePart;*/ // var prevPriceTypePart = PriceTypes.GetByCustomerType( // OrderCustomerType.GetOpposite(customerType)); order.CustomerType = customerType; if (customerType == OrderCustomerType.PrivatePerson) { /* order.NumberOfStudents = null; * order.StudentFIOs = null;*/ } var forDelete = new List <decimal>(); foreach (var orderDetail in order.OrderDetails.Where(x => !x.IsTestCert)) { if (orderDetail.Group_ID.HasValue) { orderDetail.PriceType_TC = OrderService.GetPriceTypeForGroup( orderDetail.Group, PriceTypes.IsBusiness(orderDetail.PriceType_TC), order.CustomerType); } else { orderDetail.PriceType_TC = null; } var prices = PriceService .GetAllPricesForCourseFilterByCustomerTye(orderDetail.Course_TC, order.CustomerType, orderDetail.Track_TC).AsQueryable(); PriceView price = null; if (orderDetail.PriceType_TC != null) { price = prices .FirstOrDefault(p => p.PriceType_TC == orderDetail.PriceType_TC); } if (price != null) { orderDetail.Price = price.Price; } else { var maxPrice = prices.GetDefault(); if (maxPrice == null) { forDelete.Add(orderDetail.OrderDetailID); } else { orderDetail.Price = maxPrice.Price; orderDetail.PriceType_TC = maxPrice.PriceType_TC; } } } foreach (var forDeleteId in forDelete) { order.OrderDetails.Remove(order.OrderDetails.First(x => x.OrderDetailID == forDeleteId)); } OrderService.SubmitChanges(); UpdateDiscount(true); }
public static bool HasFullTimePrice(this IEnumerable <PriceView> prices) { var fullTimeTypes = PriceTypes.GetFulltime(); return(prices.Any(p => fullTimeTypes.Contains(p.CommonPriceTypeTC))); }
public Task <StockStatistics> GetMin(string userId, string stockName, PriceTypes priceTypes) { return(GetStatistics(userId, stockName, priceTypes, data => data.Min())); }
public virtual List <string> GetElearningCourses() { return (GetAllCurrent().Where(p => PriceTypes.GetElearning().Contains( p.PriceType_TC)).Select(c => c.Course_TC).Distinct().ToList()); }
private async Task <StockStatistics> GetStatistics(string userId, string stockName, PriceTypes priceTypes, Func <IEnumerable <decimal>, decimal> aggregator) { var stocksData = await GetAllStockData(userId, stockName); if (!stocksData.Any()) { return(null); } Func <PriceTypes, Func <StockDataEntity, string>, decimal?> priceTypeProcessor = (priceType, selector) => { if (!priceTypes.HasFlag(priceType)) { return(null); } return(aggregator(stocksData.Select(entity => decimal.Parse(selector(entity), CultureInfo.InvariantCulture)))); }; return(new StockStatistics { DataPointsCount = stocksData.Count, Timestamp = stocksData.Max(entity => GetDateTime(entity.RowKey)), Open = priceTypeProcessor(PriceTypes.Open, entity => entity.Open), High = priceTypeProcessor(PriceTypes.High, entity => entity.High), Low = priceTypeProcessor(PriceTypes.Low, entity => entity.Low), Close = priceTypeProcessor(PriceTypes.Close, entity => entity.Close), Volume = priceTypeProcessor(PriceTypes.Volume, entity => entity.Volume), }); }
public Task <StockStatistics> GetMedian(string userId, string stockName, PriceTypes priceTypes) { return(GetStatistics(userId, stockName, priceTypes, data => data.Quantile(0.5))); }
private PriceRecord ComposePrice(XmlNode a_ItemNode, UInt32 a_TypeID, PriceTypes a_PriceType) { PriceRecord result = GetCurrentFilter(); result.PriceType = a_PriceType; result.Price = ReadInnerDouble(a_ItemNode); result.TypeID = a_TypeID; result.UpdateTime = (UInt64)DateTime.UtcNow.ToFileTimeUtc(); return(result); }
private void ParsePriceNode(XmlNode a_ItemNode, UInt32 a_TypeID, List <PriceRecord> a_Result, PriceTypes a_MaxType, PriceTypes a_MinType, PriceTypes a_AvgType, PriceTypes a_MedType) { foreach (XmlNode childNode in a_ItemNode.ChildNodes) { switch (childNode.Name) { case "volume": case "stddev": break; case "avg": a_Result.Add(ComposePrice(childNode, a_TypeID, a_AvgType)); break; case "max": a_Result.Add(ComposePrice(childNode, a_TypeID, a_MaxType)); break; case "min": a_Result.Add(ComposePrice(childNode, a_TypeID, a_MinType)); break; case "median": a_Result.Add(ComposePrice(childNode, a_TypeID, a_MedType)); break; } } }
public Price(decimal czkWithoutVat, int vatPrecentage, VatTypes vatType = VatTypes.Czk21, PriceTypes priceType = PriceTypes.Czk) { int vatPecentage = vatPrecentage; VatPercentage = vatPecentage; CzkWithoutVat = czkWithoutVat; CzkWithVat = czkWithoutVat * (1 + (vatPecentage / 100.0M)); VatType = vatType; PriceType = priceType; }
public static IEnumerable <DatePrice> Ema(this IEnumerable <Candle> series, int period, PriceTypes priceType = PriceTypes.Close) { var result = new List <DatePrice>(); if (series.Any() == false) { return(result); } var k = ((double)2 / (period + 1)); var candles = series.ToList(); var emaPreviousValue = candles[0].GetPrice(priceType); result.Add(new DatePrice { Date = candles[0].Date, Price = emaPreviousValue }); for (int index = 1; index < candles.Count; index++) { var candle = candles[index]; var emaValue = emaPreviousValue + k * (candle.GetPrice(priceType) - emaPreviousValue); result.Add(new DatePrice { Date = candle.Date, Price = emaValue }); emaPreviousValue = emaValue; } return(result); }
private static Task <StockStatistics> GetStatistics(IService service, string stockName, RequestType requestType, PriceTypes priceTypes) { switch (requestType) { case RequestType.Min: return(service.GetMin(stockName, priceTypes)); case RequestType.Average: return(service.GetAverage(stockName, priceTypes)); case RequestType.Max: return(service.GetMax(stockName, priceTypes)); case RequestType.Median: return(service.GetMedian(stockName, priceTypes)); case RequestType.Percentile95: return(service.Get95Percentile(stockName, priceTypes)); default: throw new ArgumentOutOfRangeException(nameof(requestType), requestType, "Value should be one of Min, Average, Max, Median, Percentile95"); } }
public Price(decimal value, PriceTypes priceType = PriceTypes.Standard) { this.Value = value; this.PriceType = priceType; }
public void Export(Entities.Context.Order order, bool checkIfExists) { var alreadyInGroups = new List <decimal>(); var groups = order.OrderDetails.Where(x => x.Group_ID.HasValue) .Select(x => new { Group_ID = x.Group_ID.Value, x.PriceType_TC }).ToList(); if (checkIfExists && order.User.Student_ID.HasValue && groups.Any()) { alreadyInGroups = StudentInGroupService.GetAll(x => x.Student_ID == order.User.Student_ID.Value && groups.Contains(new { x.Group_ID, x.PriceType_TC })).Select(x => x.Group_ID).ToList(); } var student = GetOrInsertStudentByUser(order.User, order.OrderID.ToString()); var berthTypeTC = BerthTypes.NotPaid; var studentInGroupRepository = new Repository <StudentInGroup>( new SpecialistContextProvider()); var nextContactDate = DateTime.Today.AddDays(1); if (order.OrderDetails.Any(x => x.Group.GetOrDefault(g => g.DateBeg) == DateTime.Today)) { nextContactDate = DateTime.Today; } var addEduDocs = false; foreach (var orderDetail in order.OrderDetails.Where(x => !alreadyInGroups.Contains(x.Group_ID.GetValueOrDefault()))) { if (!orderDetail.IsTestCert) { addEduDocs = true; } var discount = orderDetail.GetAllDiscountsInPercent(); string presenceTypeTC; if (PriceTypes.IsDistance(orderDetail.PriceType_TC)) { presenceTypeTC = PresenceTypes.Distance; } else if (PriceTypes.Webinars.Contains(orderDetail.PriceType_TC)) { presenceTypeTC = PresenceTypes.Webinar; } else { presenceTypeTC = PresenceTypes.Intramural; } var courseOrderMangerTC = orderDetail.IsTestCert ? Employees.TestCert : Employees.Site; var isFree = orderDetail.Price == 0; var reason = orderDetail.ReasonForLearning; if (orderDetail.IsTestCert) { reason = LearningReasons.Testing; } else if (!(orderDetail.IsTrack || orderDetail.Course.GetOrDefault(x => x.FullHours >= CommonConst.LongCourseHours))) { reason = LearningReasons.Comprehensive; } var studentInGroup = new StudentInGroup { Student_ID = student.Student_ID, Group_ID = orderDetail.CalcGroupId, InputSource_TC = GetInputSource(), PriceType_TC = orderDetail.PriceType_TC, Discount = Math.Round(discount), BerthType_TC = berthTypeTC, Track_TC = orderDetail.Track_TC, SeatNumber = orderDetail.SeatNumber, Employee_TC = Employees.Site, InputDate = DateTime.Now, FavoriteTeacher1 = orderDetail.IsCourseOrder ? order.FavoriteTeacher1 : null, Debt = 100, NextContactDate = nextContactDate, Consultant_TC = courseOrderMangerTC, Router_TC = courseOrderMangerTC, PresenceType_TC = presenceTypeTC, ReasonForLearning = reason, PromoCode = orderDetail.Order.PromoCode, Charge = orderDetail.PriceWithDiscount, IsHungry = PriceTypes.IsBusiness( orderDetail.PriceType_TC) }; ; if (IsPreTestPass(orderDetail)) { studentInGroup.IsEntryTestPassed = true; } if (isFree) { studentInGroup.Debt = 0; studentInGroup.BerthType_TC = BerthTypes.Kons; studentInGroup.NextContactDate = null; } AddSource(order, studentInGroup); foreach (var extras in orderDetail.OrderExtras) { studentInGroup.StudentInGroupExtras.Add( new StudentInGroupExtras { Extras_ID = extras.Extras_ID, StudentInGroup = studentInGroup }); } studentInGroupRepository.InsertAndSubmit(studentInGroup); orderDetail.StudentInGroup_ID = studentInGroup.StudentInGroup_ID; } foreach (var orderExam in order.OrderExams) { decimal groupID = Groups.NotChoiceGroupID; if (orderExam.Group_ID.HasValue) { groupID = orderExam.Group_ID.Value; } var studentInGroup = new StudentInGroup { Student_ID = student.Student_ID, Group_ID = groupID, PriceType_TC = PriceTypes.PrivatePersonWeekend, BerthType_TC = berthTypeTC, Employee_TC = Employees.Site, InputDate = DateTime.Now, InputSource_TC = GetInputSource(), Debt = 100, ReasonForLearning = LearningReasons.Exam, Exam_ID = orderExam.Exam_ID, NextContactDate = nextContactDate, Charge = orderExam.Price, PresenceType_TC = PresenceTypes.Intramural, }; AddSource(order, studentInGroup); studentInGroupRepository.InsertAndSubmit(studentInGroup); orderExam.StudentInGroup_ID = studentInGroup.StudentInGroup_ID; } if (addEduDocs) { new PioneerDataContext().uspAutoEntryPersonalRecords(student.Student_ID, order.EduDocTypeTC); } }