跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
根类
所有页面
统计信息
分类树
特殊页面
FC
搜索
搜索
外观
登录
个人工具
登录
查看“︁股票交易计算器”︁的源代码
页面
讨论
简体中文
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
股票交易计算器
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
<html> <head> <title>股票交易计算器</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; } h1 { text-align: center; } .form-container { display: flex; flex-direction: row; justify-content: center; align-items: center; margin-top: 20px; } .form-container label { margin-right: 10px; } .form-container input { width: 100px; padding: 5px; } .form-container button { padding: 5px 10px; } .results-container { text-align: center; margin-top: 20px; } </style> </head> <body> <h1>股票交易计算器</h1> <div class="form-container"> <label for="totalShares">总股数:</label> <input type="number" id="totalShares" required> <label for="buyPrice">买入价格:</label> <input type="number" id="buyPrice" step="0.01" required> <label for="sellPrice">卖出价格:</label> <input type="number" id="sellPrice" step="0.01" required> <button type="button" onclick="calculateTradingMetrics()">计算</button> </div> <div class="results-container"> <h2>交易指标</h2> <p>买入金额:<span id="buyAmount"></span></p> <p>卖出金额:<span id="sellAmount"></span></p> <p>买入佣金:<span id="buyCommission"></span></p> <p>卖出佣金:<span id="sellCommission"></span></p> <p>印花税:<span id="stampTax"></span></p> <p>利润:<span id="profit"></span></p> <p>总额外收费:<span id="totalFees"></span></p> <p>波动率:<span id="volatility"></span></p> <p>保本金额:<span id="breakEvenAmount"></span></p> <p>保本单价:<span id="breakEvenPrice"></span></p> </div> <script> function calculateTradingMetrics() { const totalShares = parseInt(document.getElementById('totalShares').value) || 0; const buyPrice = parseFloat(document.getElementById('buyPrice').value) || 0; const sellPrice = parseFloat(document.getElementById('sellPrice').value) || 0; // 计算买入金额和卖出金额 const buyAmount = totalShares * buyPrice; const sellAmount = totalShares * sellPrice; // 计算买入佣金和卖出佣金,同时确保它们不小于5 const buyCommission = Math.max(buyAmount * 0.0000841, 5); const sellCommission = Math.max(sellAmount * 0.0000841, 5); // 计算印花税 const stampTax = sellAmount * 0.0005; // 计算利润 const profit = sellAmount - buyAmount - buyCommission - sellCommission - stampTax; // 计算总额外收费 const totalFees = buyCommission + sellCommission + stampTax; // 计算波动率 const volatility = 1 - (buyPrice / sellPrice); // 计算保本金额和保本单价 const breakEvenAmount = buyAmount + buyCommission + sellCommission + stampTax; const breakEvenPrice = totalShares > 0 ? breakEvenAmount / totalShares : 0; // 更新页面上的值 document.getElementById('buyAmount').textContent = buyAmount.toFixed(2); document.getElementById('sellAmount').textContent = sellAmount.toFixed(2); document.getElementById('buyCommission').textContent = buyCommission.toFixed(2); document.getElementById('sellCommission').textContent = sellCommission.toFixed(2); document.getElementById('stampTax').textContent = stampTax.toFixed(2); document.getElementById('profit').textContent = profit.toFixed(2); document.getElementById('totalFees').textContent = totalFees.toFixed(2); document.getElementById('volatility').textContent = (volatility * 100).toFixed(2) + '%'; document.getElementById('breakEvenAmount').textContent = breakEvenAmount.toFixed(2); document.getElementById('breakEvenPrice').textContent = breakEvenPrice.toFixed(2); } </script> </body> </html> [[分类:在线工具集]]
返回
股票交易计算器
。
搜索
搜索
查看“︁股票交易计算器”︁的源代码
添加话题