Exemplo n.º 1
0
        /// <summary>
        /// 创建委托
        /// </summary>
        /// <param name="who"></param>
        /// <param name="contract"></param>
        /// <param name="dir"></param>
        /// <param name="pos"></param>
        /// <param name="orderType"></param>
        /// <param name="policy"></param>
        /// <param name="count"></param>
        /// <param name="price"></param>
        /// <returns></returns>
        public Order CreateOrder(int who, int contract, TradeDirectType dir, OrderType orderType, OrderPolicy policy, int count, decimal price)
        {
            var w = Traders.Where(a => a.Id == who).FirstOrDefault();

            if (w == null)
            {
                return(null);
            }
            var c = Contracts.Where(a => a.Id == contract).FirstOrDefault();

            if (c == null)
            {
                return(null);
            }

            return(EntityFactory.CreateOrder(w, c, dir, orderType, policy, count, price));
        }
Exemplo n.º 2
0
        public Task SaveTraderAsync(Trader trader)
        {
            var items = Traders.Where(x => x.Identifier == trader.Identifier).ToList();

            if (items.Count > 0)
            {
                foreach (var item in items)
                {
                    Traders.Remove(item);
                }

                Traders.Add(trader);
            }
            else
            {
                Traders.Add(trader);
            }

            return(Task.FromResult(true));
        }
Exemplo n.º 3
0
 public Task <List <Trader> > GetBusyTradersAsync()
 {
     return(Task.FromResult(Traders.Where(x => x.IsBusy).ToList()));
 }