修改持仓更新止损止盈后 不自动平仓的问题

pull/1/head
yz 2 years ago
parent 3b946c1e13
commit ac28d010be

@ -112,7 +112,7 @@ public class MemberController {
member.setAvailableFunds(bigDecimalUtils.sub(netValue, marginUsed)); //设置可用资金
//特殊处理 占用ReportScore 传递美元转换rmb
ForexMarketData usdcnh = forexMarketDateUtil.getForexMarketDateByCode("USDCNY");
member.setReportScore(bigDecimalUtils.mul(Double.parseDouble(forexMarketDateUtil.getForexMarketDateByCode("USDCNY").getSellPic())*totalAssets,1,2));
member.setReportScore(bigDecimalUtils.mul(Double.parseDouble(usdcnh.getSellPic())*totalAssets,1,2));
return new ResultEntity(HttpStatus.OK, "获取成员ID", member);
}

@ -190,6 +190,7 @@ public class TakeStashController {
ForexMarketData forexData = tradingController.getMarketQuotationByCode(tradingCode).getBody().getData();
TakeStash takeStash = new TakeStash();
takeStash.setStashId(stashId);
boolean flag=false;
if (null != stopLoss || null != stopWin) { //判断止损止赢是否合理 如果stopLoss stopWin都为null则跳过
boolean winOrLossStopBoolean = tradingController.getWinOrLossStop(stopLoss, stopWin, buySellType, forexData);
if (winOrLossStopBoolean == false) {
@ -197,11 +198,39 @@ public class TakeStashController {
}
if (null != stopLoss) {
takeStash.setStopLoss(stopLoss);
flag=true;
}
if (null != stopWin) {
takeStash.setStopWin(stopWin);
flag=true;
}
}
TakeStash takeStashGet = takeStashService.selectByPrimaryKey(stashId);
if(flag==true){ //代表需要新增到redis中
redisUtil.del("*stashId_" + stashId + "*");
Set<String> keys = redisUtil.keys("*stashId_" + stashId + "*");
Map map=new HashMap();
if(stopLoss==null){
map.put("stopLoss",-1.0);
}else {
map.put("stopLoss",stopLoss);
}
if(stopWin==null){
map.put("stopWin",-1.0);
}else {
map.put("stopWin",stopWin);
}
map.put("stashId",stashId);
map.put("buySellType",buySellType);
map.put("tradingCode",tradingCode);
map.put("transactionVolume",takeStashGet.getVolumeTransaction());
map.put("priceTransaction",takeStashGet.getPriceTransaction());
map.put("memberId",takeStashGet.getMemberId());
map.put("trainingId",takeStashGet.getTrainingId());
redisUtil.hmset("trainingId_"+takeStashGet.getTrainingId()+"_stashId_"+stashId,map);
}else {
redisUtil.del("trainingId_"+takeStashGet.getTrainingId()+"_stashId_"+stashId);
}
takeStashService.updateWinLossByPrimaryKey(takeStash);
return new ResultEntity(HttpStatus.OK, "修改持仓成功");
}

@ -106,7 +106,7 @@ public class TradingController {
String memberId = jsonObject.getString("memberId");
String trainingId = jsonObject.getString("trainingId");
if(trainingId==null){
trainingId="999999999";
trainingId=Constant.PRACTICE_TRAINING_ID;
}
Double priceCommission = jsonObject.getDouble("priceCommission"); //获取挂单开仓用户输入的价位
ForexMarketData forexData = getMarketQuotationByCode(tradingCode).getBody().getData();//获取当前买卖价格

Loading…
Cancel
Save