股票交易截图生成器, 股票持仓图生成器免费, 股票交割单生成器手机版

简介: 实现了完整的股票持仓截图生成功能,包含随机数据生成、表格绘制、汇总统计和水印添加。使用时只

下载地址【已上传】:https://www.pan38.com/share.php?code=JCnzE 提取码:6666
声明:所下载的文件以及如下所示代码仅供学习参考用途,作者并不提供软件的相关服务。

实现了完整的股票持仓截图生成功能,包含随机数据生成、表格绘制、汇总统计和水印添加。使用时只需创建StockPortfolioGenerator实例并调用generate()方法即可生成图片,exportAsImage()方法可导出为图片数据URL2。支持自定义股票列表、界面尺寸和颜色主题

class StockPortfolioGenerator {
constructor(options = {}) {
this.width = options.width || 800;
this.height = options.height || 600;
this.backgroundColor = options.backgroundColor || '#f5f5f5';
this.textColor = options.textColor || '#333';
this.primaryColor = options.primaryColor || '#1890ff';
this.stocks = options.stocks || this.generateRandomStocks();
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
this.canvas.width = this.width;
this.canvas.height = this.height;
}

generateRandomStocks(count = 10) {
const stocks = [];
const stockNames = ['腾讯控股','阿里巴巴','贵州茅台','美团-W',
'京东集团','中国平安','招商银行','宁德时代',
'比亚迪','小米集团'];

for(let i = 0; i < count; i++) {
  const costPrice = (Math.random() * 100 + 50).toFixed(2);
  const currentPrice = (costPrice * (0.9 + Math.random() * 0.2)).toFixed(2);
  const shares = Math.floor(Math.random() * 1000) + 100;

  stocks.push({
    name: stockNames[i % stockNames.length],
    code: `SH${600000 + i}`,
    costPrice: parseFloat(costPrice),
    currentPrice: parseFloat(currentPrice),
    shares: shares,
    marketValue: (currentPrice * shares).toFixed(2),
    profit: ((currentPrice - costPrice) * shares).toFixed(2),
    profitRate: (((currentPrice - costPrice) / costPrice) * 100).toFixed(2)
  });
}
return stocks;

}

drawHeader() {
this.ctx.fillStyle = this.primaryColor;
this.ctx.fillRect(0, 0, this.width, 60);

this.ctx.fillStyle = '#fff';
this.ctx.font = 'bold 24px Arial';
this.ctx.textAlign = 'center';
this.ctx.fillText('股票持仓明细', this.width / 2, 40);

this.ctx.font = '14px Arial';
this.ctx.fillText(`生成时间: ${new Date().toLocaleString()}`, this.width / 2, 80);

}

drawTable() {
const columns = [
{ title: '股票名称', key: 'name', width: 120 },
{ title: '股票代码', key: 'code', width: 100 },
{ title: '持仓数量', key: 'shares', width: 100 },
{ title: '成本价', key: 'costPrice', width: 100 },
{ title: '当前价', key: 'currentPrice', width: 100 },
{ title: '市值', key: 'marketValue', width: 120 },
{ title: '盈亏', key: 'profit', width: 120 },
{ title: '盈亏率', key: 'profitRate', width: 100 }
];

// 绘制表头
this.ctx.fillStyle = '#e6f7ff';
this.ctx.fillRect(0, 100, this.width, 40);

this.ctx.fillStyle = this.textColor;
this.ctx.font = 'bold 14px Arial';
this.ctx.textAlign = 'center';

let x = 20;
columns.forEach(col => {
  this.ctx.fillText(col.title, x + col.width / 2, 125);
  x += col.width;
});

// 绘制表格内容
this.ctx.font = '14px Arial';
this.ctx.textAlign = 'right';

this.stocks.forEach((stock, rowIndex) => {
  const y = 150 + rowIndex * 30;

  // 交替行颜色
  this.ctx.fillStyle = rowIndex % 2 === 0 ? '#fff' : '#f9f9f9';
  this.ctx.fillRect(0, y - 20, this.width, 30);

  // 绘制单元格内容
  this.ctx.fillStyle = this.textColor;
  let cellX = 20;

  columns.forEach(col => {
    const value = stock[col.key];
    const isProfit = col.key === 'profit' || col.key === 'profitRate';

    if(isProfit) {
      this.ctx.fillStyle = value >= 0 ? '#f5222d' : '#52c41a';
    }

    this.ctx.fillText(value, cellX + col.width - 10, y);
    cellX += col.width;
    this.ctx.fillStyle = this.textColor;
  });
});

}

drawSummary() {
const totalMarketValue = this.stocks.reduce((sum, stock) =>
sum + parseFloat(stock.marketValue), 0).toFixed(2);

const totalProfit = this.stocks.reduce((sum, stock) => 
  sum + parseFloat(stock.profit), 0).toFixed(2);

const yPos = 150 + this.stocks.length * 30 + 30;

this.ctx.fillStyle = '#e6f7ff';
this.ctx.fillRect(0, yPos - 30, this.width, 60);

this.ctx.fillStyle = this.textColor;
this.ctx.font = 'bold 16px Arial';
this.ctx.textAlign = 'left';
this.ctx.fillText('汇总统计:', 20, yPos);

this.ctx.font = '14px Arial';
this.ctx.fillText(`总市值: ${totalMarketValue}`, 20, yPos + 25);
this.ctx.fillText(`总盈亏: ${totalProfit}`, 200, yPos + 25);

}

addWatermark() {
this.ctx.fillStyle = 'rgba(0,0,0,0.1)';
this.ctx.font = 'bold 48px Arial';
this.ctx.textAlign = 'center';
this.ctx.textBaseline = 'middle';
this.ctx.save();
this.ctx.translate(this.width / 2, this.height / 2);
this.ctx.rotate(-Math.PI / 6);
this.ctx.fillText('DEMO ONLY', 0, 0);
this.ctx.restore();
}

generate() {
// 绘制背景
this.ctx.fillStyle = this.backgroundColor;
this.ctx.fillRect(0, 0, this.width, this.height);

// 绘制各组件
this.drawHeader();
this.drawTable();
this.drawSummary();
this.addWatermark();

return this.canvas;

}

exportAsImage() {
return this.canvas.toDataURL('image/png');
}
}

// 使用示例
const generator = new StockPortfolioGenerator();
document.body.appendChild(generator.generate());
const imgData = generator.exportAsImage();
console.log('图片数据URL:', imgData);

相关文章
手机号码段自动生成器
海豚号码生成器,是一个在电脑上常用的办公软件。但是有些对电脑不太会操作的朋友们还是不太明白它的操作方法。它具有多种手机号码生成功能、号码导入手机通讯录和对号码进行综合整理的功能。具体说有这七种功能:手机号码随机生成功能、手机豹子号靓号生成功能、自定义手机号段生成功能、手机号码批量导入手机通讯录功能、杂乱文本中提取手机号码功能、手机号码打印前排版功能、手机号码综合整理功能。 下面我详细讲解七大功能之一的自定义手机号段生成的操作方法,以便帮到更多不太会操作电脑软件的朋友们。 自导入号段生成的操作步骤: 第一步:导入号码段。你自己来输入某个前七位的号段,多个号段也可以批量导入,txt格式里面一个号段
手机号码段自动生成器
|
5月前
|
存储 API 数据库
自动发短信的软件,批量自动群发短信,手机号电话号生成器【python框架】
这个短信群发系统包含以下核心功能: 随机手机号生成器(支持中国号码) 批量短信发送功能(使用Twilio API)
|
5月前
|
数据安全/隐私保护 计算机视觉 Python
人脸识别图片眨眼生成器,手机制作人脸眨眼张嘴, 代替真人刷脸软件
代码实现了基于面部特征点的人脸动画生成,包括眨眼和张嘴动作。它使用dlib进行人脸检测和特征点定位
|
5月前
|
前端开发 数据安全/隐私保护
股票持仓截图生成器手机版, 股票持仓图生成器免费,交割单生成器制作工具
代码实现了一个完整的股票持仓截图生成器,包含数据模拟、表格绘制、汇总计算和水印添加功能。
1354 10
|
6月前
|
算法 前端开发 计算机视觉
在线照片眨眼生成器,一键生成眨眼照片, 手机制作人脸眨眼张嘴
本系统基于Flask、OpenCV和dlib实现,包含后端服务、前端界面和动画算法三大模块。支持上传照片实时检测人脸关键点,利用薄板样条变换生成自然眨眼动画效果
|
6月前
|
安全 测试技术 开发者
银行转账模拟器手机版app, 银行转账凭证生成器app,用autojs实现效果【逼真效果】
本内容展示了一套基于Auto.js的银行APP自动化测试脚本和框架,用于学习和研究移动应用测试技术。脚本涵盖登录、转账等功能测试
|
移动开发 JSON 编解码
Vue3+Node写个免费在线图库生成器,三步将你的手机相册搬到线上
一个 Vue3 + Node 快速生成漂亮的在线相册的项目,纯前端的项目,不需要开发后端,没有数据库,只需要把照片丢进去,Git提交一下站点就出来了。
Vue3+Node写个免费在线图库生成器,三步将你的手机相册搬到线上
手机通话记录生成器在线,批量通话记录生成器,通话记录生成器app
铁牛通话记录生成器是可以批量自动生成通话记录的app软件。如何得到“铁牛通话记录生成器”?在手机上进去佰渡baidu浏览器输入,铁牛通话记录生成器,这几个字嗖嗦下就可以,其他的不用输入。也可以看下面的图片中间的绿色模块图标和字母,自己思考一下是什么,伽一下它。
手机号码随机生成器
此功能的作用:我们工作中经常遇到一张表格里面有很多杂乱的文本,比如手机号码、座机号码、汉字、字母等混乱的文本在一起,但是我们只想要里面的手机号码,不要其他的文本,数量很大的时候,手动一个找挑出来复制粘贴,那简直是累死,那么我们的软件可以智能识别并提取里面的11位手机号码,也可以提取里面的扣扣号码,邮箱等。简直是解放双手的好工具。
手机号码随机生成器

热门文章

最新文章