public OrderCreatedResult Post([FromBody] OrderCreatingInfo value) { var game = _gameStore.Get(value.GameId); if (game == null) { throw new OrderCreatingException("找不到品种."); } var creatingInfo = new OpenOrderInfo { ClientPostTime = value.ClientTime != null ? DateTimeOffset.FromUnixTimeMilliseconds(value.ClientTime.Value).DateTime : (DateTime?)null, Direction = value.Direction, Volume = value.Volume }; if (creatingInfo.TransportSeconds <= 5) { _logger.LogInformation("submit order"); var order = _orderService.CreateOrder(creatingInfo, game, User.Identity.Name); return(new OrderCreatedResult { Id = order.Id, OpenPrice = order.OpenInfo.Price.Bid, ExpireDateTime = order.CloseTime }); } throw new OrderCreatingException("市价已经变化,请确保浏览器时间和服务器一致。"); }
public void OnCreating(OpenOrderInfo openOrderInfo) { //if (openOrderInfo == null) // throw new ArgumentNullException(nameof(openOrderInfo)); //_containter.SendTo(AdminGroup, openOrderInfo); }
public void OnCreating(OpenOrderInfo openOrderInfo) { foreach (var notify in _notifies) { notify.OnCreating(openOrderInfo); } }
public bool TryGetPrice(QuotationContext context, OpenOrderInfo openOrder, Game game, out Quotation price) { if (game.Symbol == null) { throw new ArgumentNullException(nameof(game), "game.Synbol should not be null."); } var startDateTime = openOrder.ClientPostTime ?? openOrder.ArriveDateTime; //客户端提交时间。 return(context.TryGetQuotation(game.Symbol.Id, startDateTime, out price)); }
public bool IsPass(OpenOrderInfo openOrder, Game game, string user, OrderContext context) { var lastOrder = context.UncloseOrders.Statistics.GetLastOrder(game.Symbol.Id, user); if (lastOrder == null) { return(true); } return((openOrder.ArriveDateTime - lastOrder.CreateTime).TotalSeconds > _orderSeconds); }
public bool TryGetPrice(QuotationContext context, OpenOrderInfo openOrder, Game game, out Quotation price) { if (game.Symbol == null) { throw new ArgumentNullException(nameof(game), "game.Symbol should not be null."); } var startDateTime = openOrder.ClientPostTime ?? openOrder.ArriveDateTime; //客户端提交时间。 var prices = context.GetQuotationsByMaxEndTime(game.Symbol.Id, startDateTime); price = openOrder.Direction == Direction.Down ? prices.Max() : prices.Min(); return(price != null); }
/// <summary> /// </summary> /// <param name="openOrder"></param> /// <param name="user"></param> /// <param name="context"></param> /// <param name="game"></param> /// <returns></returns> public bool IsPass(OpenOrderInfo openOrder, Game game, string user, OrderContext context) { if (game == null) { throw new ArgumentNullException(nameof(game)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } decimal amount; int orderCount; context.UncloseOrders.Statistics.OrderCount(game.Symbol.Id, user, out amount, out orderCount); return(amount >= MaxAmount); }
public void OnCreating(OpenOrderInfo openOrderInfo) { throw new NotImplementedException(); }