修改净值bug 修改美元在后对冲逻辑

pull/1/head
yz 2 years ago
parent 6327a022a6
commit 1efb1c83d0

@ -86,14 +86,15 @@ public class MemberController {
} }
member.setPositionProfitLoss(positionProfitLoss); //设置持仓盈亏 member.setPositionProfitLoss(positionProfitLoss); //设置持仓盈亏
Double initialCapital = member.getInitialCapital();//初始资金 Double initialCapital = member.getInitialCapital();//初始资金
Double totalAssets = initialCapital+positionProfitLoss;
Double netValue = bigDecimalUtils.add(totalAssets, positionProfitLoss);
member.setTotalAssets(totalAssets); //设置总资产
member.setNetValue(netValue); //设置净值
Double cumulativeProfitLoss = member.getCumulativeProfitLoss(); //累计盈亏 Double cumulativeProfitLoss = member.getCumulativeProfitLoss(); //累计盈亏
if(cumulativeProfitLoss==null){ if(cumulativeProfitLoss==null){
member.setCumulativeProfitLoss(0.0); member.setCumulativeProfitLoss(0.0);
} }
Double totalAssets = initialCapital+cumulativeProfitLoss; //总资产=初始资金+累计盈亏
Double netValue = bigDecimalUtils.add(totalAssets, positionProfitLoss);
member.setTotalAssets(totalAssets); //设置总资产
member.setNetValue(netValue); //设置净值
Double marginUsed = member.getMarginUsed(); //获取已用保证金 Double marginUsed = member.getMarginUsed(); //获取已用保证金
if (marginUsed==null || marginUsed==0.0){ if (marginUsed==null || marginUsed==0.0){
marginUsed=0.0; marginUsed=0.0;

@ -296,7 +296,7 @@ public class TakeStashController {
} }
} }
if (buyTotalVolumeTransaction>=sellTotalVolumeTransaction){ //设置sell\buy的最高交易交易总量 if (buyTotalVolumeTransaction>=sellTotalVolumeTransaction){ //设置平仓前 sell\buy的最高交易交易总量
highVolumeTransaction=buyTotalVolumeTransaction; highVolumeTransaction=buyTotalVolumeTransaction;
}else { }else {
highVolumeTransaction=sellTotalVolumeTransaction; highVolumeTransaction=sellTotalVolumeTransaction;
@ -304,12 +304,21 @@ public class TakeStashController {
//获取相同tradingCode持仓表总使用保证金 //获取相同tradingCode持仓表总使用保证金
Double totalMargin=(buyTotalMargin+sellTotalMargin)/totalVolumeTransaction*Constant.LEVERQUANTITY*highVolumeTransaction; Double totalMargin=(buyTotalMargin+sellTotalMargin)/totalVolumeTransaction*Constant.LEVERQUANTITY*highVolumeTransaction;
//获取去除平仓数据后的相同tradingCode持仓表总使用保证金 //获取去除平仓数据后的相同tradingCode持仓表总使用保证金
Double totalMarginRemoveCloseTakeStash=0.0;
if("buy".equals(buySellType)){ if("buy".equals(buySellType)){
totalMarginRemoveCloseTakeStash=((buyTotalMargin-transactionVolume*priceTransaction)+sellTotalMargin)/totalVolumeTransaction*Constant.LEVERQUANTITY*highVolumeTransaction; if (buyTotalVolumeTransaction-transactionVolume>=sellTotalVolumeTransaction){ //设置平仓后 sell\buy的最高交易交易总量
highVolumeTransaction=buyTotalVolumeTransaction;
}else {
highVolumeTransaction=sellTotalVolumeTransaction;
}
}else { }else {
totalMarginRemoveCloseTakeStash=(buyTotalMargin+(sellTotalMargin-transactionVolume*priceTransaction))/totalVolumeTransaction*Constant.LEVERQUANTITY*highVolumeTransaction; if ( sellTotalVolumeTransaction-transactionVolume>=buyTotalVolumeTransaction){ //设置平仓后 sell\buy的最高交易交易总量
highVolumeTransaction=sellTotalVolumeTransaction;
}else {
highVolumeTransaction=buyTotalVolumeTransaction;
}
} }
Double totalMarginRemoveCloseTakeStash=0.0;
totalMarginRemoveCloseTakeStash=(buyTotalMargin+sellTotalMargin-transactionVolume*priceTransaction)/(totalVolumeTransaction-transactionVolume)*Constant.LEVERQUANTITY*highVolumeTransaction;
margin=totalMargin-totalMarginRemoveCloseTakeStash; margin=totalMargin-totalMarginRemoveCloseTakeStash;
return margin; return margin;
} }

Loading…
Cancel
Save