Пример #1
0
        public Deal[] GetAllExpiredDeals()
        {
            var stopwatch = new Stopwatch();

            Deal[] res;

            using (var db = new DevDbContext())
            {
                IQueryable <Deal> query = from b in db.Deal
                                          where b.Status == "Expired"
                                          orderby b.TradeDate
                                          select b;

                query = query.Include(i => i.Instrument);
                query = query.Include(p => p.Instrument.Product);

                res = query.ToArray();
            }

            stopwatch.Stop();
            log.Info($"{res.Length} expired deals loaded in: {stopwatch.Elapsed}");
            return(res);
        }
Пример #2
0
        public void UpdateDeal(Deal updatedDeal)
        {
            using (var db = new DevDbContext())
            {
                Deal deal = db.Deal.First(i => i.DealId == updatedDeal.DealId);
                deal.TraderId        = updatedDeal.TraderId;
                deal.Quantity        = updatedDeal.Quantity;
                deal.ExecPrice       = updatedDeal.ExecPrice;
                deal.BookId          = updatedDeal.BookId;
                deal.InstrumentId    = updatedDeal.InstrumentId;
                deal.ClearingFee     = updatedDeal.ClearingFee;
                deal.TransactionFee  = updatedDeal.TransactionFee;
                deal.Broker          = updatedDeal.Broker;
                deal.Counterparty    = updatedDeal.Counterparty;
                deal.Comment         = updatedDeal.Comment;
                deal.Status          = updatedDeal.Status;
                deal.ForwardLevel    = updatedDeal.ForwardLevel;
                deal.VolatilityLevel = updatedDeal.VolatilityLevel;
                db.SaveChanges();
            }

            log.Info($"Update deal instru: {updatedDeal.InstrumentId} price: {updatedDeal.ExecPrice} " +
                     $"quantity: {updatedDeal.Quantity} by: {updatedDeal.TraderId}");
        }