namespace YLErp.Modules.ToolsModule { public class EodExchangeOptionPriceService : YLBaseService { public EodExchangeOptionPriceService(OptUserInfo userInfo) : base(userInfo) { } /// /// 获取完结盈亏 /// public double GetEndPnl(DateTime endDate, DateTime? startDate = null) { if (startDate == null) { startDate = endDate; } var query = from db in DbContext.Exchange_Option_Trade where db.ExerciseDate <= endDate && db.ExerciseDate >= startDate.Value select (db.ExercisePrice - db.TradePrice) * (db.TradeType == "多头" ? 1 : -1); return query.Any() ? query.Sum() : 0; } } }