Files
zszq-trs/YLErpDAL/Modules/ToolsModule/EodExchangeOptionPriceService.cs
T
2024-05-09 14:06:26 +08:00

26 lines
815 B
C#

namespace YLErp.Modules.ToolsModule
{
public class EodExchangeOptionPriceService : YLBaseService
{
public EodExchangeOptionPriceService(OptUserInfo userInfo) : base(userInfo)
{
}
/// <summary>
/// 获取完结盈亏
/// </summary>
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;
}
}
}