1、(本源代码转载自迅动股票分析平台,了解更多请访问 )基于 Java 语言开发的个性化股票分析技术:量能突破模型(Energ e-Break)一个用量能指标作为判定依据的条件分析模型,根据最近 5天内是否有量能平台的突破以及涨跌幅的大小给每只股票评分评价,给用户明确的建议。迅动股票分析平台在此基础上利用Java 语言开发了量能突破模型(Energe-Break ),源代码如下:XML 描述:一个用量能指标作为判定依据的条件分析模型,根据最近 5天内是否有量能平台的突破以及涨跌幅的大小给每只股票评分评价,给用户明确的建议。Java 代码:/* (#)EBnalyser.java* Copyrigh
2、t Hangzhou Shengren Software Tech. Co., Ltd.*/package u008660011.model.analyser.eb;(本源代码转载自迅动股票分析平台,了解更多请访问 )import java.rmi.RemoteException;import java.util.List;import mons.lang.math.NumberUtils;import mon.util.DateUtil;import mon.util.StkAnalysisUtil;import com.shengrensoft.stock.center.data.Data
3、;import com.shengrensoft.stock.center.data.StkDailyK.StkDailyKData;import com.shengrensoft.stock.center.data.IdxDailyK.IdxDailyKData;import com.shengrensoft.stock.center.data.BlkDailyK.BlkDailyKData;import com.shengrensoft.stock.center.model.ModelParam;import com.shengrensoft.stock.center.model.anal
4、yser.AbstractAnalyser;import com.shengrensoft.stock.center.model.analyser.AnalysisValue;/* EB量能突破分析模型的实现类。* * author 迅动平台 2012/09/20 新建*/public class EBAnalyser extends AbstractAnalyser /* 序列版本 ID */private static final long serialVersionUID = -732447148977150017L;/ 参数名定义/* 参数名:N 天数 */private static
5、 final String PARAM_N = “N“;/* 参数名:加减分系数 */private static final String PARAM_CONFICENT = “C“;/* 构造方法。*/public EBAnalyser() throws RemoteException /* 分析买入点的变化。* * param stkCode 证券代码* param transDate 交易日期* param paramsList 模型参数列表(本源代码转载自迅动股票分析平台,了解更多请访问 )* * return 分析结果(含评分和评 价)*/public AnalysisValue
6、doAnalysis(String stkCode,java.util.Date transDate,List paramsList) throws RemoteException AnalysisValue analysisValue = null;/ 股票代码合法性检查if (stkCode = null) analysisValue = new AnalysisValue();analysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“股票代码不合法,分析失败
7、。“);return analysisValue;/ 交易日期合法性检查if (transDate = null) analysisValue = new AnalysisValue();analysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“交易日期不合法,分析失败。“);return analysisValue;/ 参数列表合法性检查if (paramsList = null) analysisValue = new AnalysisValue();anal
8、ysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“参数列表不合法,分析失败。“);return analysisValue;/ 取得分析所需的模型参数int paramN = 0;int paramCONFICENT = 0;for (ModelParam param : paramsList) if (PARAM_N.equals(param.getShortName() paramN = NumberUtils.toInt(param.getValue();
9、else if (PARAM_CONFICENT.equals(param.getShortName() (本源代码转载自迅动股票分析平台,了解更多请访问 )paramCONFICENT = NumberUtils.toInt(param.getValue(); else return null; / 发现一个意外的模型参数/ 天数的合法性检查if (paramN 99) analysisValue = new AnalysisValue();analysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisVa
10、lue.setResultDesc(“加减分系数,分析失败。“);return analysisValue;/ 判别证券代码类型(是否为股票代码,股指代码,板指代码) ,分别进行分析StkAnalysisUtil stkAnalysisUtil = super.getStkAnalysisUtil();if (stkAnalysisUtil.isStkCode(stkCode) analysisValue = this.analyseStk(stkCode, transDate, paramN, paramCONFICENT);if (analysisValue = null)analysis
11、Value = new AnalysisValue();analysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“公司新上市或该天缺少数据,分析失败!“);return analysisValue; else if (stkAnalysisUtil.isIdxCode(stkCode) analysisValue = this.analyseIdx(stkCode, transDate, paramN, paramCONFICENT);if (analysisVa
12、lue = null)analysisValue = new AnalysisValue();(本源代码转载自迅动股票分析平台,了解更多请访问 )analysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“公司新上市或该天缺少数据,分析失败!“);return analysisValue; else if (stkAnalysisUtil.isBlkCode(super.getUserId(), stkCode) analysisValue = this.analy
13、seBlk(stkCode, transDate, paramN, paramCONFICENT);if (analysisValue = null)analysisValue = new AnalysisValue();analysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“公司新上市或该天缺少数据,分析失败!“);return analysisValue; else analysisValue = new AnalysisValue();analysisVa
14、lue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“证劵代码类型不符,分析失败!“);return analysisValue;/* 根据能量突破提示的不同,对股票进行分析、评分、评价。* * param stkCode 股票代码* param transDate 交易日期* param paramN 天数* param paramCONFICENT (%)加减分系数* * return 返回结果(含评分和评 价)*/ private AnalysisValue analyse
15、Stk(String stkCode,java.util.Date transDate,int paramN,int paramCONFICENT)(本源代码转载自迅动股票分析平台,了解更多请访问 )AnalysisValue analysisValue = null;/ 计算 TTJ值Integer TTJ = calcStkTTJ(stkCode, transDate, paramN);if (TTJ = null)analysisValue = new AnalysisValue();analysisValue.setStkCode(stkCode);analysisValue.setR
16、esultScore(0);analysisValue.setResultDesc(“数据不足,分析失败“);return analysisValue;/ 计算资金增幅百分比Double pricePerct = calcStkPricePerct(stkCode, transDate);if (pricePerct = null)analysisValue = new AnalysisValue();analysisValue.setStkCode(stkCode);analysisValue.setResultScore(0);analysisValue.setResultDesc(“数据
17、不足,分析失败“);return analysisValue;/ 近几日出现量能平台if (TTJ =1 int count = 0;/ 将 date移至量能突破的当天do date = super.getStkTransDateUtil().getBeforeTransDate(stkCode, date);count +; while (count halfPlatform)score += intRange; else score -= intRange; else / 看涨if(score = null)(本源代码转载自迅动股票分析平台,了解更多请访问 )score = 90; els
18、e score -= intRange; else / 量能平台当天 K 线为阴线if (doubleRange =1 int count = 0;/ 将 date移至量能突破的当天do date = super.getStkTransDateUtil().getBeforeTransDate(date);count +;(本源代码转载自迅动股票分析平台,了解更多请访问 ) while (count halfPlatform)score += intRange; else score -= intRange; else / 看涨if(score = null)score = 90; else
19、score -= intRange; else / 量能平台当天 K 线为阴线if (doubleRange =1 int count = 0;/ 将 date移至量能突破的当天do date = super.getStkTransDateUtil().getBeforeTransDate(date);count +; while (count halfPlatform)score += intRange; else score -= intRange; else / 看涨if(score = null)score = 90; else score -= intRange; else / 量能
20、平台当天 K 线为阴线if (doubleRange open)param1 = QJJ * (high - low) / 100.0; / 消除数据库中存放的 100 倍 else if (close open)param2 = 0 - QJJ * (high - close + open - low) / 100.0; else (本源代码转载自迅动股票分析平台,了解更多请访问 )if (close open)param1 = QJJ * (high - low) / 100.0; / 消除数据库中存放的 100 倍 else if (close open)param2 = 0 - QJJ
21、 * (high - close + open - low) / 100.0; else if (close open)param1 = QJJ * (high - low) / 100.0; / 消除数据库中存放的 100 倍 else if (close open)param2 = 0 - QJJ * (high - close + open - low) / 100.0; else if (close open)param2 = 0 - QJJ * (high - low) / 100.0; else param2 = 0 - volume / 2.0;(本源代码转载自迅动股票分析平台,
22、了解更多请访问 )XVL = param1 + param2;Double HSL = XVL / 20 / 1.15;return HSL;/* 计算 AT(Attack traffic)攻击流量的值* * params stkCode 股票代码* params transDate 交易日期* * params 返回 AT 的值*/private Double calcStkAT(String stkCode,java.util.Date transDate) java.util.Date date = transDate;Double refHSL_1 = null; /REF(HSL,1
23、)Double refHSL_2 = null; /REF(HSL,2)date = super.getStkTransDateUtil().getBeforeTransDate(stkCode, date);if (date = null)return null;refHSL_1 = calcStkHSL(stkCode, date);date = super.getStkTransDateUtil().getBeforeTransDate(stkCode, date);if (date = null)return null;refHSL_2 = calcStkHSL(stkCode, da
24、te);Double HSL = calcStkHSL(stkCode, transDate);Double AT = (HSL*0.55 + refHSL_1*0.33 + refHSL_2*0.22);return AT;/* 计算 AT(Attack traffic)攻击流量的值(本源代码转载自迅动股票分析平台,了解更多请访问 )* * params idxCode 股指代码* params transDate 交易日期* * params 返回 AT 的值*/private Double calcIdxAT(String idxCode,java.util.Date transDate
25、) java.util.Date date = transDate;Double refHSL_1 = null; /REF(HSL,1)Double refHSL_2 = null; /REF(HSL,2)date = super.getStkTransDateUtil().getBeforeTransDate(date);if (date = null)return null;refHSL_1 = calcIdxHSL(idxCode, date);date = super.getStkTransDateUtil().getBeforeTransDate(date);if (date =
26、null)return null;refHSL_2 = calcIdxHSL(idxCode, date);Double HSL = calcIdxHSL(idxCode, transDate);Double AT = (HSL*0.55 + refHSL_1*0.33 + refHSL_2*0.22);return AT;/* 计算 AT(Attack traffic)攻击流量的值* * params blkCode 板指代码* params transDate 交易日期* * params 返回 AT 的值*/private Double calcBlkAT(String blkCode,
27、java.util.Date transDate) java.util.Date date = transDate;(本源代码转载自迅动股票分析平台,了解更多请访问 )Double refHSL_1 = null; /REF(HSL,1)Double refHSL_2 = null; /REF(HSL,2)date = super.getStkTransDateUtil().getBeforeTransDate(date);if (date = null)return null;refHSL_1 = calcBlkHSL(blkCode, date);date = super.getStkTr
28、ansDateUtil().getBeforeTransDate(date);if (date = null)return null;refHSL_2 = calcBlkHSL(blkCode, date);Double HSL = calcBlkHSL(blkCode, transDate);Double AT = (HSL*0.55 + refHSL_1*0.33 + refHSL_2*0.22);return AT;/* 计算 LLJX 的值(资金流向)* * params stkCode 股票代码* params transDate 交易日期* * params 返回 LLJX 的值*
29、/private Double calcStkLLJX(String stkCode,java.util.Date transDate) final int N = 3;java.util.Date date = transDate;int count = 0 ;do date = super.getStkTransDateUtil().getBeforeTransDate(stkCode, date);if (date = null)return null;count +; while (count 2*N-1);(本源代码转载自迅动股票分析平台,了解更多请访问 )Double totalA
30、T = 0.0;Double AT = null;count = 0;do AT = calcStkAT(stkCode, date);if (AT = null)return null;totalAT += AT;date = super.getStkTransDateUtil().getNextTransDate(stkCode, date);if (date = null)return null;count +; while (count N);Double LLJX = totalAT / N;count = 0;do AT = calcStkAT(stkCode, date);if
31、(AT = null)return null;LLJX = 2.0/(N+1)*AT + (N-1)/(N+1)*LLJX;date = super.getStkTransDateUtil().getNextTransDate(stkCode, date);if (date = null)return null;count +; while (count N); return LLJX;/* 计算 LLJX 的值(资金流向)* * params idxCode 股指代码* params transDate 交易日期* * params 返回 LLJX 的值*/private Double ca
32、lcIdxLLJX((本源代码转载自迅动股票分析平台,了解更多请访问 )String idxCode,java.util.Date transDate) final int N = 3;java.util.Date date = transDate;int count = 0 ;do date = super.getStkTransDateUtil().getBeforeTransDate(date);if (date = null)return null;count +; while (count 2*N-1);Double totalAT = 0.0;Double AT = null;co
33、unt = 0;do AT = calcIdxAT(idxCode, date);if (AT = null)return null;totalAT += AT;date = super.getStkTransDateUtil().getNextTransDate(date);if (date = null)return null;count +; while (count N);Double LLJX = totalAT / N;count = 0;do AT = calcIdxAT(idxCode, date);if (AT = null)return null;LLJX = 2.0/(N
34、+1)*AT + (N-1)/(N+1)*LLJX;date = super.getStkTransDateUtil().getNextTransDate(date);if (date = null)return null;count +; while (count N); (本源代码转载自迅动股票分析平台,了解更多请访问 )return LLJX;/* 计算 LLJX 的值(资金流向)* * params blkCode 板指代码* params transDate 交易日期* * params 返回 LLJX 的值*/private Double calcBlkLLJX(String bl
35、kCode,java.util.Date transDate) final int N = 3;java.util.Date date = transDate;int count = 0 ;do date = super.getStkTransDateUtil().getBeforeTransDate(date);if (date = null)return null;count +; while (count 2*N-1);Double totalAT = 0.0;Double AT = null;count = 0;do AT = calcBlkAT(blkCode, date);if (
36、AT = null)return null;totalAT += AT;date = super.getStkTransDateUtil().getNextTransDate(date);if (date = null)return null;count +; while (count N);Double LLJX = totalAT / N;(本源代码转载自迅动股票分析平台,了解更多请访问 )count = 0;do AT = calcBlkAT(blkCode, date);if (AT = null)return null;LLJX = 2.0/(N+1)*AT + (N-1)/(N+1
37、)*LLJX;date = super.getStkTransDateUtil().getNextTransDate(date);if (date = null)return null;count +; while (count N); return LLJX;/* 计算 ZJLL 的值* * params stkCode 股票代码* params transDate 交易日期* * params 返回 ZJLL 的值*/private Double calcStkZJLL(String stkCode,java.util.Date transDate) java.util.Date date = super.getStkTransDateUtil().getBeforeTransDate(stkCode, transDate);if (date = null)return null;Double ZJLL = calcStkLLJX(stkCode, date);return ZJLL;/* 计算 ZJLL 的值