|
@@ -1,6 +1,5 @@
|
|
|
package com.smppw.analysis.application.service.style;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
@@ -9,20 +8,22 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.smppw.analysis.domain.dataobject.FundStyleStatsDO;
|
|
|
+import com.smppw.analysis.domain.dto.performance.MulSecMulIndicatorParams;
|
|
|
import com.smppw.analysis.domain.dto.style.*;
|
|
|
import com.smppw.analysis.domain.dto.style.py.PyReq;
|
|
|
import com.smppw.analysis.domain.dto.style.py.PyReqBody;
|
|
|
import com.smppw.analysis.domain.dto.style.py.PyReqParam;
|
|
|
import com.smppw.analysis.domain.dto.style.py.PyResBody;
|
|
|
+import com.smppw.analysis.domain.manager.performance.Performance;
|
|
|
+import com.smppw.analysis.domain.manager.performance.PerformanceFactory;
|
|
|
import com.smppw.analysis.domain.service.BaseInfoService;
|
|
|
import com.smppw.analysis.domain.service.FundStyleService;
|
|
|
import com.smppw.analysis.infrastructure.config.AnalysisProperty;
|
|
|
import com.smppw.analysis.infrastructure.consts.*;
|
|
|
import com.smppw.analysis.infrastructure.exception.APIException;
|
|
|
import com.smppw.common.pojo.IStrategy;
|
|
|
-import com.smppw.common.pojo.enums.CurveType;
|
|
|
-import com.smppw.common.pojo.enums.Frequency;
|
|
|
-import com.smppw.common.pojo.enums.RaiseType;
|
|
|
+import com.smppw.common.pojo.dto.calc.IndicatorCalcPropertyDto;
|
|
|
+import com.smppw.common.pojo.enums.*;
|
|
|
import com.smppw.common.pojo.enums.strategy.Strategy;
|
|
|
import com.smppw.constants.Consts;
|
|
|
import com.smppw.utils.StrategyHandleUtils;
|
|
@@ -42,6 +43,8 @@ import java.util.concurrent.Future;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.smppw.analysis.domain.manager.performance.PerformanceConstants.MUL_SEC_MUL_INDICATOR;
|
|
|
+
|
|
|
@Service
|
|
|
public class StyleServiceImpl implements StyleService {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(StyleServiceImpl.class);
|
|
@@ -149,11 +152,14 @@ public class StyleServiceImpl implements StyleService {
|
|
|
private final String pyBaseUrl;
|
|
|
private final BaseInfoService baseInfoService;
|
|
|
private final FundStyleService fundStyleService;
|
|
|
+ private final PerformanceFactory factory;
|
|
|
|
|
|
- public StyleServiceImpl(AnalysisProperty property, BaseInfoService baseInfoService, FundStyleService fundStyleService) {
|
|
|
+ public StyleServiceImpl(AnalysisProperty property, BaseInfoService baseInfoService,
|
|
|
+ FundStyleService fundStyleService, PerformanceFactory factory) {
|
|
|
this.pyBaseUrl = property.getPyUrl();
|
|
|
this.baseInfoService = baseInfoService;
|
|
|
this.fundStyleService = fundStyleService;
|
|
|
+ this.factory = factory;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -981,7 +987,9 @@ public class StyleServiceImpl implements StyleService {
|
|
|
@Override
|
|
|
public Map<String, Object> selectionTiming(SelectionTimingParams params) {
|
|
|
try {
|
|
|
- if (!CAL_RANGE_MAPPER.containsKey(params.getWinlen())) throw new APIException("窗口参数非法");
|
|
|
+ if (!CAL_RANGE_MAPPER.containsKey(params.getWinlen())) {
|
|
|
+ throw new APIException("窗口参数非法");
|
|
|
+ }
|
|
|
Map<String, String> mapper = MapUtil.<String, String>builder(MapUtil.newHashMap(true))
|
|
|
.put("alpha", "选股能力").put("beta", "择时能力").build();
|
|
|
Map<String, String> mapper1 = MapUtil.<String, String>builder(MapUtil.newHashMap(true))
|
|
@@ -1042,18 +1050,33 @@ public class StyleServiceImpl implements StyleService {
|
|
|
.put("date", "时间").put("upside", "进攻能力").put("downside", "防御能力").put("style", "风格").build();
|
|
|
Map<String, Object> chart1 = MapUtil.<String, Object>builder().put("dataset", dataset)
|
|
|
.put("chartProductNameMapping", mapper).put("tableProductNameMapping", mapper).build();
|
|
|
-
|
|
|
- List<String> secIdList = ListUtil.list(true);
|
|
|
- List<String> fundBenchmarkList = ListUtil.toList(params.getSecId(), params.getBenchmarkId());
|
|
|
- List<String> unionIds = CollUtil.addAllIfNotContains(fundBenchmarkList, secIdList);
|
|
|
+ Performance<MulSecMulIndicatorParams, Map<String, List<IndicatorCalcPropertyDto>>> instance = this.factory.getInstance(MUL_SEC_MUL_INDICATOR);
|
|
|
+ //构造请求参数
|
|
|
+ MulSecMulIndicatorParams req = buildReq(params);
|
|
|
+ Map<String, List<IndicatorCalcPropertyDto>> indicatorMap = instance.execute(req);
|
|
|
return MapUtil.<String, Object>builder().put("chart1", chart1).build();
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
logger.error("风格总览计算错误" + e.getMessage());
|
|
|
return MapUtil.empty();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private MulSecMulIndicatorParams buildReq(RzStyleParams params) {
|
|
|
+ MulSecMulIndicatorParams req = new MulSecMulIndicatorParams();
|
|
|
+// req.setIndicatorList(ListUtil.toList(Indicator.UpCaptureRatio,Indicator.UpCaptureReturn,Indicator.DownCaptureRatio,Indicator.DownCaptureReturn));
|
|
|
+ req.setIndicatorList(ListUtil.toList(Indicator.SharpeRatio));
|
|
|
+ req.setEndDate(params.getEndDate());
|
|
|
+ req.setRaiseType(params.getRaiseType());
|
|
|
+ req.setFrequency(Frequency.Weekly);
|
|
|
+ req.setBenchmarkId(params.getBenchmarkId());
|
|
|
+ req.setStrategy("All");
|
|
|
+ req.setRefIds(ListUtil.toList(params.getSecId()));
|
|
|
+ req.setTimeRangeList(ListUtil.toList(TimeRange.Last1Year,TimeRange.Last2Years,TimeRange.Last3Years,TimeRange.FromSetup));
|
|
|
+ req.setNavType(NavType.CumulativeNav);
|
|
|
+ req.setSecIds(ListUtil.toList(params.getSecId()));
|
|
|
+ return req;
|
|
|
+ }
|
|
|
+
|
|
|
private String handleFundStyle(BigDecimal upside, BigDecimal downside) {
|
|
|
String style;
|
|
|
BigDecimal standardLevel = BigDecimal.valueOf(0.5);
|