⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processdata.java

📁 一个画股票曲线并发送邮件的程序。 采用freechart和javamail技术。
💻 JAVA
字号:
package com.shfe.mail;

import java.util.*;
import java.text.*;
import com.shfe.mail.*;

public class ProcessData {
    final int yLength = 200; //y scale length
    final int xLength = 500; //x scale length
    final int amountLength = 100; //amount y scale length
    final long maxOptionSecond = 16200; //4.5 hours
    final long maxStockSecond = 14400; //4 hours

    public ScaleBean computScale(List data, double closePrice) {
        if (data.size() < 1)return null;
        double maxPrice = 0.0;
        double minPrice = ((GraphBean) data.get(0)).getPrice();
        long maxAmount = 0;

        for (int i = 0; i < data.size(); i++) {
            GraphBean graph = (GraphBean) data.get(i);
            double price = graph.getPrice();
            long amount = graph.getAmount();
            if (price > maxPrice) maxPrice = price;
            if (price < minPrice) minPrice = price;
            if (amount > maxAmount) maxAmount = amount;
        }
        if (Math.abs(maxPrice - closePrice) >= Math.abs(closePrice - minPrice)) {
            minPrice = closePrice - Math.abs(maxPrice - closePrice);
        } else {
            maxPrice = closePrice + Math.abs(closePrice - minPrice);
        }
        double priceYLength = maxPrice - minPrice;
        if (priceYLength == 0) priceYLength = 1;
        ScaleBean scale = new ScaleBean();
        scale.setClosePrice(closePrice);
        scale.setMaxPrice(maxPrice);
        scale.setMinPrice(minPrice);
        scale.setPriceYLength(priceYLength);
        scale.setMaxAmount(maxAmount);
        return scale;

    }

    public List computePoint(List quotes, double openPrice, ScaleBean scale) {
        if (quotes == null || quotes.size() < 1)return null;
        List points = new ArrayList();

        for (int i = 0; i < quotes.size(); i++) {
            GraphBean graph = (GraphBean) quotes.get(i);
            String tradeTime = graph.getTime();
            GregorianCalendar tempDate = ProcessTime.convertTime(tradeTime);
            double tempPrice = graph.getPrice();
            long tempAmount = graph.getAmount();

            //the first point
            if (i == 0) {
                tempDate = ProcessTime.getCaleDate(9, 15);
                tempPrice = openPrice;
            }
            long tempLong = ProcessTime.judgeTime(tempDate);
            if (i > 0 && tempLong == 0) continue; //except break time;

            PointBean point = new PointBean();
            point.setPointTime(tempLong);
            point.setPointPrice(tempPrice);
            point.setPointAmount(tempAmount);
            points.add(point);
        }
        return points;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -