85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using YLErp.Modules.TradeModule;
|
|
using YLErp.Modules.TradeModule.QueryModule;
|
|
using YLErp.QdpModule;
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class trade_volatilityController : BaseController
|
|
{
|
|
public ActionResult trade_volatilityList()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult trade_volatilityQuery(TradeVolatilityQueryModel req)
|
|
{
|
|
var sList = new TradeVolatilityQueryService(CurUser).SearchList(req);
|
|
return Json(sList);
|
|
}
|
|
|
|
public ActionResult trade_volatilityView(string enid)
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(enid);
|
|
var r = yldb.TradeVolatility.Find(intid);
|
|
return View(r);
|
|
}
|
|
|
|
public ActionResult trade_volatilityEdit(int tradeId)
|
|
{
|
|
var r = yldb.TradeVolatility.Where(x => x.TradeId == tradeId).OrderByDescending(x => x.ValueDate).FirstOrDefault();
|
|
if (r == null)
|
|
{
|
|
r = new TradeVolatility()
|
|
{
|
|
TradeId = tradeId
|
|
};
|
|
}
|
|
else
|
|
{
|
|
var valueDate = valuedateBLL.ValueDate;
|
|
var vol = yldb.realtime_trade_risk.Where(x => x.VolType == "持仓" && x.TradeId == tradeId && x.ValueDate == valueDate)
|
|
.Select(n => n.Vol).FirstOrDefault();
|
|
|
|
if (vol.HasValue)
|
|
{
|
|
r.TradePositionVolatility = vol;
|
|
}
|
|
|
|
var days = QdpCalendarHelper.GetNonHolidayDaysBetween(r.ValueDate, valuedateBLL.ValueDate);
|
|
|
|
//新增的交易持仓波动率需要往后推一天,剩余平滑天数也往后推一天
|
|
if (r.IsFromTradeAdd)
|
|
{
|
|
days += 1;
|
|
}
|
|
|
|
r.NumOfSmoothingDays = r.NumOfSmoothingDays > days ? r.NumOfSmoothingDays - days : 1;
|
|
}
|
|
|
|
return View(r);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult trade_volatilityEditJson(TradeVolatilityDto req)
|
|
{
|
|
new TradeHisDataService(CurUser).SaveTradeVolatility(req, true);
|
|
return JsonSuccess();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Deletetrade_volatility(string id)
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(id);
|
|
var r = yldb.TradeVolatility.Find(intid);
|
|
if (r == null)
|
|
{
|
|
return JsonError("找不到交易波动率");
|
|
}
|
|
yldb.TradeVolatility.Remove(r);
|
|
yldb.SaveChanges();
|
|
return JsonSuccess("删除成功");
|
|
}
|
|
}
|
|
}
|