保证金算法&资金计算
This commit is contained in:
@@ -253,7 +253,7 @@ namespace YLErp.Modules.SwapModule
|
||||
bool cashNeedAfter = false)
|
||||
{
|
||||
var td = PrepareTrade(flowMerge, client, asset, underlying, clientMarginTemplate?.SwapEndDays??14, structureType);
|
||||
PrepareTradeExtend(flowMerge, td, underlying, swapFloatRate, clientMarginTemplate);
|
||||
PrepareTradeExtend(flowMerge, td, underlying, swapFloatRate);
|
||||
td.TradeNumber = BizLogicSingleton.Instance.GenerateTradeNumberBeforeConfirm(td, DbContext);
|
||||
flowMerge.SwapTradeNo = td.TradeNumber;
|
||||
PrepareSwapTrade(td, TradeSourceEnum.系统交易, underlying);
|
||||
@@ -359,7 +359,7 @@ namespace YLErp.Modules.SwapModule
|
||||
/// <param name="td"></param>
|
||||
/// <param name="underlying"></param>
|
||||
/// <param name="swapFloatRate"></param>
|
||||
private void PrepareTradeExtend(swap_flow_merge flowMerge, trade td, underlying_manager underlying, SwapFloatRate swapFloatRate, client_marginrate clientMarginTemplate)
|
||||
private void PrepareTradeExtend(swap_flow_merge flowMerge, trade td, underlying_manager underlying, SwapFloatRate swapFloatRate)
|
||||
{
|
||||
swap_position floatPosition = new swap_position()
|
||||
{
|
||||
@@ -387,53 +387,6 @@ namespace YLErp.Modules.SwapModule
|
||||
UnderlyingInstrumentType = underlying.UnderlyingInstrumentType
|
||||
};
|
||||
td.swap_positions.Add(floatPosition);
|
||||
if (clientMarginTemplate != null)
|
||||
{
|
||||
decimal initMarginRate = Convert.ToDecimal(clientMarginTemplate.InitMarginRate);
|
||||
if (td.StructureType != "普通债券类收益互换")
|
||||
{
|
||||
if (floatPosition.PositionType == (int)PositionTypeFlag.Long)
|
||||
{
|
||||
initMarginRate = clientMarginTemplate.LongInitMarginRate ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
initMarginRate = clientMarginTemplate.ShortInitMarginRate ?? 0;
|
||||
}
|
||||
}
|
||||
bool year20 = true;
|
||||
if (underlying.MaturityDate.HasValue && underlying.MaturityDate < DateTime.Now.AddDays(20 * 365))
|
||||
{
|
||||
year20 = false;
|
||||
}
|
||||
initMarginRate = year20 ? 0.05m : initMarginRate;
|
||||
swap_position marginPosition = new swap_position()
|
||||
{
|
||||
InterestDirection = (int)SwapDirectionEnum.收取,
|
||||
InterestRateDefault = clientMarginTemplate.InitMarginRebateRate ?? 0,
|
||||
InterestMode = (int)InterestModeEnum.初始预付金,
|
||||
InterestPrincipalFix = initMarginRate * Convert.ToDecimal(td.StockEqvNotional),
|
||||
HappenDate = td.TradeDate.Value,
|
||||
PosiMatuirityDate = td.ExerciseDate.Value,
|
||||
PosiStartDate = td.StartDate.Value,
|
||||
Currency = "CNY",
|
||||
IsAnnualized = true,
|
||||
SwapTradeId = td.id,
|
||||
IsInitial = true,
|
||||
OptTime = DateTime.Now,
|
||||
OptId = UserInfo.UserId,
|
||||
OptName = UserInfo.UserName,
|
||||
};
|
||||
var marginInterval = new IntervalModel()
|
||||
{
|
||||
Date = td.ExerciseDate.Value,
|
||||
Rate = marginPosition.InterestRateDefault,
|
||||
Settlement = 0
|
||||
};
|
||||
List<IntervalModel> marginIntervalModels = new List<IntervalModel>() { marginInterval };
|
||||
marginPosition.InterestSwapInterval = JsonConvert.SerializeObject(marginIntervalModels);
|
||||
td.swap_positions.Add(marginPosition);
|
||||
}
|
||||
swap_position interestPosition = new swap_position()
|
||||
{
|
||||
InterestDirection = flowMerge.BsType == (int)PositionTypeFlag.Long ? (int)SwapDirectionEnum.收取 : (int)SwapDirectionEnum.支付,
|
||||
@@ -818,7 +771,10 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
throw new ServiceException($"客户'{client.Name}'的'交易资产'属性不包括'权益',不能进行收益互换交易");
|
||||
}
|
||||
|
||||
if (client.EvaluateExpireDate < req.TradeDate)
|
||||
{
|
||||
throw new ServiceException("适当性评估已经过期,只有在适当性有效期内才可以新开仓");
|
||||
}
|
||||
req.ClientName = client.Name;
|
||||
req.SettlementCurrency = client.SettlementCurrency;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user