股票收益图生成器,股票持仓图生成器免费,股票账户模拟生成器【装逼娱乐必备】

下载地址:https://www.pan38.com/share.php?code=HJmmK

声明:仅用于学习参考以及娱乐使用

  1. 股票收益图生成器

`import java.awt.;
import javax.swing.
;
import java.util.Random;

public class StockChartGenerator {
public static void main(String[] args) {
JFrame frame = new JFrame("股票收益图");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);

    JPanel chartPanel = new JPanel() {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Random rand = new Random();
            int width = getWidth();
            int height = getHeight();
            
            // 绘制网格线
            g.setColor(Color.LIGHT_GRAY);
            for (int i = 0; i < width; i += 50) {
                g.drawLine(i, 0, i, height);
            }
            for (int i = 0; i < height; i += 50) {
                g.drawLine(0, i, width, i);
            }
            
            // 绘制随机股票曲线
            g.setColor(Color.RED);
            int prevY = height / 2;
            for (int x = 0; x < width; x += 5) {
                int y = prevY + rand.nextInt(20) - 10;
                if (x > 0) {
                    g.drawLine(x - 5, prevY, x, y);
                }
                prevY = y;
            }
            
            // 添加标签
            g.setColor(Color.BLACK);
            g.drawString("我的股票收益曲线 (假装很专业)", 50, 30);
            g.drawString("+256.78% (2025年)", width - 150, 30);
        }
    };
    
    frame.add(chartPanel);
    frame.setVisible(true);
}

}`

  1. 股票持仓图生成器

import javax.swing.;
import java.awt.
;
import java.util.Random;

public class StockPortfolioGenerator {
public static void main(String[] args) {
String[] stocks = {"腾讯控股", "贵州茅台", "宁德时代", "美团-W", "比亚迪"};
double[] percentages = new double[stocks.length];
Random rand = new Random();

    // 生成随机持仓比例
    double total = 0;
    for (int i = 0; i < percentages.length; i++) {
        percentages[i] = rand.nextDouble() * 30 + 10;
        total += percentages[i];
    }
    
    // 标准化比例
    for (int i = 0; i < percentages.length; i++) {
        percentages[i] = Math.round(percentages[i] * 100 / total);
    }
    
    // 创建饼图
    JFrame frame = new JFrame("我的股票持仓");
    frame.setSize(600, 500);
    
    JPanel panel = new JPanel() {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            int width = getWidth();
            int height = getHeight();
            
            // 绘制饼图
            int arcStart = 0;
            Color[] colors = {Color.RED, Color.BLUE, Color.GREEN, Color.ORANGE, Color.MAGENTA};
            for (int i = 0; i < stocks.length; i++) {
                g.setColor(colors[i]);
                int arcAngle = (int) (360 * percentages[i] / 100);
                g.fillArc(50, 50, 300, 300, arcStart, arcAngle);
                arcStart += arcAngle;
            }
            
            // 添加图例
            g.setColor(Color.BLACK);
            g.drawString("我的股票持仓 (假装很富有)", 150, 30);
            
            int yPos = 400;
            for (int i = 0; i < stocks.length; i++) {
                g.setColor(colors[i]);
                g.fillRect(50, yPos, 20, 20);
                g.setColor(Color.BLACK);
                g.drawString(stocks[i] + ": " + percentages[i] + "%", 80, yPos + 15);
                yPos += 30;
            }
        }
    };
    
    frame.add(panel);
    frame.setVisible(true);
}

}

  1. 股票账户模拟生成器

import java.text.DecimalFormat;
import java.util.Random;

public class StockAccountSimulator {
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat("#,###.00");
Random rand = new Random();

    // 生成随机数据
    double totalAssets = 1000000 + rand.nextDouble() * 9000000;
    double todayProfit = totalAssets * (rand.nextDouble() * 0.1 - 0.02);
    double totalProfit = totalAssets * (rand.nextDouble() * 0.5 + 0.2);
    
    // 打印模拟账户信息
    System.out.println("════════════ 我的股票账户 ════════════");
    System.out.println("总资产: ¥" + df.format(totalAssets));
    System.out.println("今日盈亏: " + (todayProfit >= 0 ? "+" : "") + df.format(todayProfit) + 
                      " (" + df.format(todayProfit/totalAssets*100) + "%)");
    System.out.println("累计收益: " + (totalProfit >= 0 ? "+" : "") + df.format(totalProfit) + 
                      " (" + df.format(totalProfit/(totalAssets-totalProfit)*100) + "%)");
    System.out.println("═══════════════════════════════════");
    System.out.println("持仓股票         数量     成本价     现价     盈亏");
    System.out.println("腾讯控股       500     320.50    450.80   +65,150.00 (+40.66%)");
    System.out.println("贵州茅台       200     1800.00   2500.00  +140,000.00 (+38.89%)");
    System.out.println("宁德时代       300     220.00    350.50   +39,150.00 (+59.32%)");
    System.out.println("═══════════════════════════════════");
    System.out.println("(本数据纯属虚构,仅供娱乐装逼使用)");
}

}

posted @ 2025-06-12 13:37  爷很困扰  阅读(628)  评论(0)    收藏  举报