开发投顾系统的重要几个点:
1.投顾管理CRM系统
2.策略分析模块
3.策略对比功能
4.策略与实盘曲线对比功能
6.策略组合功能
7.投后管理功能
得到计算策略指标源代如下:guweng22346
public static RiskIndicatorsVo calcRisk(Integer strategyId, List<Pnl> pnls) {
RiskIndicatorsVo riskIndicatorsVo = new RiskIndicatorsVo();
riskIndicatorsVo.setStrategyId(strategyId);
if (CollectionUtils.isEmpty(pnls) && CollectionUtils.isEmpty(pnls.stream().filter(f -> {
return f.getPnl() != null;}).collect(Collectors.toList()))) {
return riskIndicatorsVo;
}
double simpleYearIncomRate = 0;
try {
simpleYearIncomRate = DataUtils.calcSimpleYearIncomRate(pnls);
} catch (Exception e) {
log.info("策略id:{},计算年化收益出错, {}", strategyId, e.getMessage());
return riskIndicatorsVo;
}
riskIndicatorsVo.setAnnualizedIncomeRate(String.valueOf(DataUtils.round(simpleYearIncomRate, 2)));
List<Pnl> pnls1 = DataUtils.accumulationPnl(pnls);
//年化波动
NetworthMonth networthMonth = new NetworthMonth();
networthMonth.setStrategyId(strategyId);
double simpleFluctuatiearonByDay = 0.0;
if (pnls.size() > 2) {
//v2 = NetWorthDataUtils.getFluctuationByDaySingle(netWorthsByStrategyId);
simpleFluctuatiearonByDay = DataUtils.calcSimpleYearFluctuatiearonByDay(pnls);
}
riskIndicatorsVo.setAnnualFluctuationsRate(DataUtils.round(simpleFluctuatiearonByDay, 2) + "%");
//夏普率
double simpleSharpRate = 0.0;
if (pnls.size() > 2) {
//v4 = DataUtils.div(DataUtils.sub(DataUtils.mul(simpleYearIncomRate, 100.0), 2.0), simpleFluctuatiearonByDay, 2);
simpleSharpRate = DataUtils.calcSimpleSharp(simpleYearIncomRate, 2.0, simpleFluctuatiearonByDay);
}
riskIndicatorsVo.setSharpeRate(DataUtils.dataFormatStr(simpleSharpRate,2));
//最大回撤
//double v5 = NetWorthDataUtils.getMaxPullback(netWorthsByStrategyId);
Double maxDrawDown = DataUtils.calcSimpleMaxDrawDownIndex(pnls1);
riskIndicatorsVo.setMaximumDrawdownRate(DataUtils.round(maxDrawDown, 2) + "%");
//calmar比率
double calmar = 0.0;
if (maxDrawDown != 0.0){
//calmar = DataUtils.div(DataUtils.dataFormat(DataUtils.mul(simpleYearIncomRate, 100.0), 2), v5 ,2);
calmar = DataUtils.calcCalmarRate(simpleYearIncomRate, maxDrawDown);
}
riskIndicatorsVo.setCalmarRate(String.valueOf(calmar));
riskIndicatorsVo.setStrategyId(strategyId);
//最大回补天数
riskIndicatorsVo.setMaxBackIncomDay(NetWorthDataUtils.getPullBackDay(pnls1));
//投资胜率
riskIndicatorsVo.setInvestWinningRate(DataUtils.calcWinRate(pnls));
return riskIndicatorsVo;
}
综上所述,投顾系统源码的开发是一个复杂而重要的过程。