IPO Trading Calculator

Source: Internet
Author: User

Today is a day to celebrate, my stock play new adhere to the big six months, the first check, the stock for the name of the Eagle shares (0002830), although only 500 shares of the quota, but also a very exciting thing. Generally speaking, the new check usually has 10 or so of the trading version, how much money can be made? Miss no sister, so try to use JS to write a calculation method to calculate the expected income.

Don't say much nonsense, first look at the code:

1 /*initial funds in the checkout*/2 varMoney = 8265;3 /*estimated number of trades*/4 varn=10;5 6 7 //Method One8 varMoney1 =Money ;9  for(i=1;i<=n;i++){Ten     if(i==1){ OneMoney1 = money1* (1+0.44); A}Else{ -Money1 = money1* (1+0.1); -     } the } - document.write (money1); -  -document.write ("<br/>");

This is a very common calculation code, by controlling the number of cycles to calculate the final value of n times after money1, this practice of the shortcomings of the code is large, not thin enough, and the performance is relatively poor (to cycle 10 times).

Then think of the use of power "(1+0.1) N-Square" method, where the key code is the MATH.POW,MATH.POWX (x, Y) method can return the value of the Y-power of X, it is much easier to construct the code.

1 // Method Two: 2 var first = money* (1+0.44); 3 var money2 = First * (Math.pow ((1+0.1), n-1)); 4 document.write (money2); 5 6 document.write ("<br/>");

But in the actual application, we may need to query and return different limit times, that the use of functions to construct the method is the most appropriate way.

1 // Method 3 uses a function to calculate 2 function Getgpup (m,n) {3     var f = m* (1+0.44);//Calculate the stock market value of the first day of listing 4     return f* (Math.pow (1+0.1), n-1 ) ;//Calculate the stock market value of the listing n days and return 5}6var money3 = getgpup (money,n); Call the function to get the initial market start of money Stock n a trading edition of the new market value of 7 document.write (Money3);

The results of the three method outputs are:

1 28063.3502392056252 28063.3502392056183 28063.350239205618

If you can get 10 trading version, I won the stock has nearly 20,000 of the return on investment, the expected return is good, no wonder Chinese investors are kept to play new ^_^. Well, as the end of the year to send their own bonuses, I wish "Famous Eagle Shares" soar, the wash sleep!

IPO Trading Calculator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.