private void UpdateSecurityPricesWithReceivedPrices(ISession session, SecurityPriceResponse response, IList <PortfolioNavDateSecurityPrice> securityPriceList) { using (var transaction = session.BeginTransaction()) { foreach (PortfolioNavDateSecurityPrice securityPrice in securityPriceList) { if (securityPrice.PriceStatus == PriceStatus.Received) { continue; } securityPrice.OpenPrice = response.OpenPrice; securityPrice.ClosePrice = response.ClosePrice; securityPrice.PriceStatus = PriceStatus.Received; securityPrice.UpdateDate = DateTime.Now; logger.Log(LogLevel.Info, $"[SecurityPriceResponse: Symbol {response.Symbol}, NavDate {response.NavDate.Date}, MessageId {response.MessageId}]: updating [PortfolioNavSecurityPrice: Id {securityPrice.PortfolioNavDateSecurityPriceId}, PortfolioId {securityPrice.PortfolioNavDate.Portfolio.PortfolioId}, Symbol {securityPrice.PortfolioSecurity.Security.Symbol}, NavDate {securityPrice.PortfolioNavDate.NavDate.Date}] with Status {securityPrice.PriceStatus}, OpenPrice {securityPrice.OpenPrice}, ClosePrice {securityPrice.ClosePrice}"); portfolioNavDateSecurityPriceRepository.SaveOrUpdate(session, securityPrice); logger.Log(LogLevel.Info, $"[SecurityPriceResponse: Symbol {response.Symbol}, NavDate {response.NavDate.Date}, MessageId {response.MessageId}]: updated [PortfolioNavSecurityPrice: Id {securityPrice.PortfolioNavDateSecurityPriceId}, PortfolioId {securityPrice.PortfolioNavDate.Portfolio.PortfolioId}, Symbol {securityPrice.PortfolioSecurity.Security.Symbol}, NavDate {securityPrice.PortfolioNavDate.NavDate.Date}]"); } transaction.Commit(); } }
public SecurityPriceResponse BuildSecurityPriceResponse(SecurityPrice securityPrice) { var securityPriceResponse = new SecurityPriceResponse() { ClosePrice = securityPrice.ClosePrice, OpenPrice = securityPrice.OpenPrice, Currency = securityPrice.Security.Currency, NavDate = securityPrice.NavDate, Symbol = securityPrice.Security.Symbol }; return(securityPriceResponse); }