java股市分析
用java定义一个股票类Stock,该类包括如右图所示
public class Stock {
private String store;// 股票类属性
private String symbol;// 股票代号
private String name;// 股票名称
private BigDecimal currentPrice;// 当前时间的股票价格
private BigDecimal previouClosingPrice;// 前一天的股票值
/**
* 返回前一天变到当前时间的百分比
* @return 百分比
*/
public double getChangePercent() {
return this.currentPrice.subtract(this.previouClosingPrice).abs()
.divide(this.currentPrice, 2, BigDecimal.ROUND_HALF_EVEN)
.doubleValue();
}
/**
* 返回前一天变到当前时间的百分比
* @param currentPrice 当前时间的股票价格
* @param previouClosingPrice 前一天的股票值
* @return 百分比
*/
public double getChangePercent(BigDecimal currentPrice,
BigDecimal previouClosingPrice) {
return currentPrice.subtract(previouClosingPrice).abs()
.divide(currentPrice, 2, BigDecimal.ROUND_HALF_EVEN)
.doubleValue();
}
public String getStore() {
return store;
}
public void setStore(String store) {
this.store = store;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BigDecimal getCurrentPrice() {
return currentPrice;
}
public void setCurrentPrice(BigDecimal currentPrice) {
this.currentPrice = currentPrice;
}
public BigDecimal getPreviouClosingPrice() {
return previouClosingPrice;
}
public void setPreviouClosingPrice(BigDecimal previouClosingPrice) {
this.previouClosingPrice = previouClosingPrice;
}
}
拥有java基础,怎样编写一个股票分析软件
你得有选股的算法,实时调取所有股票所有信息的途径。。。然后就可以做了
java 谁能给我画图组成的股市分析代码?
package com.hbsoft; import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.PrintWriter; import java.util.HashSet; import java.util.Iterator; import java.util.Random; import javax.imageio.ImageIO; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; public class CaptchaServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("pragma","no-cache"); response.setHeader("cache-control","no-cache"); response.setHeader("expires","0"); response.setContentType("image/jpeg"); BufferedImage image = new BufferedImage(100,20,BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); Random random = new Random(); g.setColor(Color.pink); g.fillRect(0,0,100,80); int[] m = new int[4]; String[] str = new String[4]; for(int i = 0; i < 4; i ++){ m[i] = random.nextInt(10); System.out.println(m[i]); } for(int i = 0; i < 4; i ++){ int itemp = random.nextInt(26) + 65; char temp = (char)itemp; str[i] = String.valueOf(temp); System.out.println(str[i]); } String strx = ""; for(int i = 0; i < 4;i++){ strx = strx + str[i] + m[i]; } HashSet hs = new HashSet(); for(int i = 0;i < 8; i++){ hs.add(String.valueOf(strx.charAt(i))); } Iterator ite = hs.iterator(); String strmm = ""; while(ite.hasNext()){ strmm = strmm + ite.next(); } System.out.println(strmm); g.setColor(Color.white); g.drawString(""+strmm, 10,10); HttpSession session = request.getSession(); session.setAttribute("hand",strmm); ImageIO.write(image, "JPEG",response.getOutputStream()); } }
采纳哦
如何用java读取股票数据
股票实时行情,可以通过两个方法来进行查看: 第一种,在百度搜索页面直接输入股票代码,如:000717,百度输入后,即可在搜索结果中看到,其中分时,就是该股票在当天的实时走向。 第二种,通过炒股软件,如东财,同花顺等,在开启后,直接输入
Java 实现股票走势对比分析 ,功能就是实现 各只股票与大盘的对比 选出最优股
圣杯
java 如何实现 获取实时股票数据
用网抓的方式,开源的有框架。