//private readonly Dictionary<string, ShortOrderInfo> ordersByCode = new Dictionary<string, ShortOrderInfo>(); //private readonly Dictionary<string, SortedList<decimal, int>> ordersBySecurityAndPrice = new Dictionary<string, SortedList<decimal, int>>(); //private sealed class ShortOrderInfo //{ // public string Security { get; set; } // public BuySell Operation { get; set; } // public long Quantity { get; set; } // public decimal Price { get; set; } //} private void InfoClient_OnInfoOrder(InfoOrder order) { var security = order.security + "|" + order.board; if (string.IsNullOrEmpty(security)) { //Logger.DebugFormat("Получено обновление заявки с пустым полем security. OrderId: {0}", order.code); return; } if (!buildersMap.TryGetValue(security, out var builder)) { var instrument = connector.ResolveSymbolAsync(security).Result; if (instrument == null) { return; } builder = new OrderBookBuilder(instrument); buildersMap[security] = builder; } if (!builder.ProcessOrder(order)) { return; } if (subscribedBooks.Contains(security)) { OnMessageReceived(builder.BuildBook()); //TODO fire } }
public bool ProcessOrder(InfoOrder order) { var code = order.code; var price = PriceHelper.ToPrice(order.price); var sorted = order.buy_sell == BuySell.BUY ? bids : asks; if (!mapOrders.TryGetValue(code, out var info)) { //if (string.IsNullOrEmpty(order.security)) //{ // //Logger.DebugFormat("Получено обновление заявки с пустым полем security. OrderId: {0}", order.code); // return false; //} if (order.qtyLeft == 0 || order.status == OrderStatus.CANCELED || order.status == OrderStatus.MATCHED) { // TODO Проверить частичное return(false); } info = new ShortOrderInfo(code, price, order.buy_sell); mapOrders[order.code] = info; List <ShortOrderInfo> list; if (!sorted.TryGetValue(price, out list)) { sorted[price] = list = new List <ShortOrderInfo>(); } list.Add(info); } info.Quantity = order.qtyLeft; // Очищаем лишние заявки (в статусах Matched и Cancelled) if (order.qtyLeft == 0 || order.status == OrderStatus.CANCELED || order.status == OrderStatus.MATCHED) // TODO Проверить частичное { mapOrders.Remove(order.code); if (sorted.TryGetValue(price, out var list)) { list.Remove(info); if (!list.Any()) { sorted.Remove(price); } } } return(true); }
public static void MappingInfoOrder(this InfoOrderDTO infoOrderDto, InfoOrder infoOrder) { infoOrder.IDP = infoOrderDto.IDP; infoOrder.IDSP = infoOrderDto.IDSP; infoOrder.Amount = infoOrderDto.Amount; infoOrder.Size = infoOrderDto.Size; infoOrder.Price = infoOrderDto.Price; infoOrder.IntoMoney = infoOrderDto.IntoMoney; }
private void InfoClient_OnInfoOrder(InfoOrder order) { if (!accounts.ContainsKey(order.account)) { return; } var activeQuantity = order.qtyLeft; OrderState state; switch (order.status) { case OrderStatus.CANCELED: state = !string.IsNullOrEmpty(order.res_code) && order.res_code != "ENF_CANC" // TODO Hardcode волшебной строки ? OrderState.Error : OrderState.Cancelled; activeQuantity = 0; break; case OrderStatus.MATCHED: state = OrderState.Filled; break; case OrderStatus.FREEZED: case OrderStatus.QUEUED: state = order.qty_executed > 0 ? OrderState.PartiallyFilled : OrderState.Active; break; case OrderStatus.WAIT_APPROVAL: default: return; } //long filledQty = order.ActiveQty - (long)infoOrder.qtyLeft; Guid.TryParseExact(order.trn, "N", out var trId); var oscm = new OrderStateChangeMessage { TransactionId = trId, OrderExchangeId = order.code, Quantity = order.qty, ActiveQuantity = activeQuantity, FilledQuantity = order.qty_executed, // TODO Price = PriceHelper.ToPrice(order.price), ChangeTime = DateTime.Now, // TODO State = state }; OnMessageReceived(oscm); }
public static InfoOrderDTO MappingInfoOrderDto(this InfoOrder infoOrder) { var value = new InfoOrderDTO { IDP = infoOrder.IDP, IDSP = infoOrder.IDSP, Amount = infoOrder.Amount, Size = infoOrder.Size, Price = infoOrder.Price, IntoMoney = infoOrder.IntoMoney }; return(value); }
public static InfoOrder MappingInfoOrder(this InfoOrderDTO infoOrderDto) { var infoOrder = new InfoOrder { IDP = infoOrderDto.IDP, IDSP = infoOrderDto.IDSP, Amount = infoOrderDto.Amount, Size = infoOrderDto.Size, Price = infoOrderDto.Price, IntoMoney = infoOrderDto.IntoMoney }; return(infoOrder); }
public async Task <IActionResult> Info(InfoOrder order) { ContainInfoViewModel containInfo = new ContainInfoViewModel(); if (order.Function == "WarehouseId") { var warehouse = await _adminRepository.GetRelatedWarehouseAsync(order.IntId); containInfo.InfoItems = new List <InfoItem>() { new InfoItem() { Title = warehouse.Name, Description = $"آدرس:{warehouse.Adress}<br />شماره:{warehouse.Telephone}" + $"<br />مدیر:{warehouse.Manager}<br />شناسه:{warehouse.WarehouseId}" } }; int i = 1; foreach (var item in await _adminRepository.GetRelatedWarehouseItemAsync(warehouse.WarehouseId)) { var newInfoItem = new InfoItem() { Title = $"{i} : شناسه آیتم" + item.WraehouseItemId.ToString(), Description = $"شناسه محصول:{item.Product.ProductId.ToString()}<br />تعداد:{item.NumberInWarehouse}" }; containInfo.InfoItems.Add(newInfoItem); i++; } } if (containInfo.Title != null || containInfo.InfoItems != null) { return(View(containInfo)); } var defaultContainInfo = new ContainInfoViewModel() { InfoItems = new List <InfoItem>() { new InfoItem() { Title = "کاربر عزیز", Description = "موردی برای نمایش نیست" } } }; return(View(defaultContainInfo)); }
public List <InfoOrder> GetGridInfo(List <OrdersToReservations> ordersList) { List <InfoOrder> infoOrders = new List <Hotel_Project.Model.InfoOrder>(); Hotels hotel = new Hotels(); Rooms room = new Rooms(); for (int i = 0; i < ordersList.Count; i++) { try { room = (Rooms)db.Rooms.Find(ordersList[i].RoomID); hotel = (Hotels)db.Hotels.Find(room.HotelsID); InfoOrder ord = new InfoOrder(); ord.HotelName = hotel.Name; ord.RoomNum = room.Number; ord.DateStartOrd = ordersList[i].DateStart; ord.DateEndOrd = ordersList[i].DateEnd; infoOrders.Add(ord); } catch (Exception ex) { } } return(infoOrders); }