联系我们 - 广告服务 - 联系电话:
您的当前位置: > 关注 > > 正文

全球报道:基金收益怎么计算?基金收益计算器

来源:CSDN 时间:2022-12-21 19:03:47


(资料图)

基金收益计算器

自己写的一个简单基金计算器,可以计算当天的基金收益,数值不同不要以为程序的错,净值都是估值,会有一点差别。如果有同行,欢迎添加几行代码润色下。

        基金计算器    

基金计算器

单个基金收益
请输入当前基金份额:
请输入当前基金估值:
请输入当前基金总额:
多个基金收益
请逐个输入当前份额:
请逐个输入当前估值:
请逐个输入当前总额:
<script> let fe = document.getElementsByClassName("fe")[0] let gz = document.getElementsByClassName("gz")[0] let TSum = document.getElementsByClassName("TSum")[0] let sum = document.getElementsByClassName("sum")[0] let amount = document.getElementsByClassName("amount")[0] let Afe = document.getElementsByClassName("Afe")[0] let Agz = document.getElementsByClassName("Agz")[0] let ATSum = document.getElementsByClassName("ATSum")[0] let ASum = document.getElementsByClassName("ASum")[0] let type = 1 function getResult(){this.check() if(this.type == 1){let nowSum = (Number(fe.value) * Number(gz.value)) let income = (nowSum - Number(TSum.value)).toFixed(2) sum.value = income } } function getResult1(){this.check() if(this.type == 1){let nowSum = Number(fe.value) * Number(gz.value) let income = nowSum - Number(TSum.value) let Num = (income / Number(gz.value)).toFixed(2) amount.value = Num } } function getAllResult(){let AfeArr = Afe.value.split(",") let AgzArr = Agz.value.split(",") let ATSumArr = ATSum.value.split(",") let MyASum = 0 for(var i = 0;i < AfeArr.length;i++){MyASum = MyASum + (Number(AfeArr[i]) * Number(AgzArr[i]) - Number(ATSumArr[i])) } console.log(MyASum.toFixed(2)) ASum.value = MyASum.toFixed(2) } function revert(){fe.value = "" gz.value = "" TSum.value = "" sum.value = "0.00" amount.value = "0.00" Afe.value = "" Agz.value = "" ATSum.value = "" ASum.value = "0.00" location.reload() } function check(){if(fe.value == "" || gz.value == "" || TSum.value == ""){alert("输入内容不能为空") this.type = 0 } else {this.type = 1 } } function filter(obj){obj.value = obj.value.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符 obj.value = obj.value.replace(/^[0]{1}/g,""); //清除只输入一个0 obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的 obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); // obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,"$1$2.$3");//只能输入两个小数 if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额 obj.value= parseFloat(obj.value); } } function filterA(obj){obj.value = obj.value.replace(/[^\d.,]/g,""); //清除“数字”和“.” ","以外的字符 } </script>

效果展示:

使用方式: 复制下来代码,放在以html后缀的空文件里,在浏览器打开就可以了,极其简单!!!

责任编辑:

标签:

相关推荐:

精彩放送:

新闻聚焦
Top