HeaderSIS.jpg

Difference between revisions of "IS480 Team wiki: 2016T1 Charlies-Angels-Algorithm"

From IS480
Jump to navigation Jump to search
Line 54: Line 54:
 
</div>
 
</div>
 
===CPF Calculations===
 
===CPF Calculations===
<div style="margin-top:10px;">
+
<div style="margin-top:5px;">
 
 
  
 
<ol>
 
<ol>

Revision as of 21:40, 13 September 2016


Charlies Angels Logo.png


Charlies Angels Home.png  HOME

 

Charlies Angels About Us.png  ABOUT US

 

Charlies Angels Project Overview.png  PROJECT OVERVIEW

 

Charlies Angels Project Management.png  PROJECT MANAGEMENT

 

Charlies Angels Project Documentation.png  DOCUMENTATION

 
X-Factor Project Description & Motivation Charlies Angels Current Stage.png Algorithm Scope Technologies Used

Pseudo Codes

Pseudo Codes

CPF Calculations

  1. Calculate amount needed from current age to death age by looping current age to death age.
  2. For each year, multiply inflation rate with target pension.
  3. Sum them up and you get the amount needed from current to death age.
  4. Next, calculate the total amount of money in ordinary and special account when retirement account opens. This is done by looping from current age to open retirement account.
  5. For each age, check if the age is below 35/45/50 and multiply by the respective percentage as different age has different contribution.
  6. While looping, the amount of house loan needed to pay per month is subtracted from ordinary account.
  7. In addition, both ordinary and special account are multiply by their respective interest rate.
  8. As the amount of monthly salary that can be contributed to CPF is capped at 6000, a check has to be done to make sure that the maximum contribution to CPF is capped.
  9. The user’s savings in bank is also looped from current age to retirement age to calculate the interest rate. The amount of money is multiply by the bank’s interest rate each year.
  10. Retirement account is calculated by adding special account and ordinary account at age 55.
  11. Lastly, loop from open retirement account age to pay out age. This is to calculate the amount of money in retirement age with interest rate. It is done by multiply the amount of money in retirement account with retirement account interest rate.
  12. With all the calculations above, the amount of money needed to earn from stocks is calculated by taking the current amount needed till death subtract amount of money in retirement account. The answer is then subtracted by current savings and divided by 12. This will give you the amount of money needed to earn from stocks every month.

For more information such as the variables involved in these calculation, please view our document here: Pseudo Code for CPF Calculations


Scheduler (Data Crawling)

On a particular date & time, cronjob (a process by Linux) will automatically execute a script file that contains a java command. The java command will run the class upon executing and the following code will run.

  1. Loop the list of symbols
  2. For each symbol, access the website URL.
  3. Select the code pattern that we have identified to crawl.
  4. Retrieve the texts that were retrieved.
  5. Initialize an object class that stores all the retrieved information.
  6. Add the object class into an array list.
  7. Pass the array list to a data access object class.
  8. Loop the array list and adds all the information into the database.


This pseudo code will run for each information that needs to be crawled/scraped off the website.
As we need to modify a file called crontab, the following statements have to be added into the file.

  1. 0 0 1 4 * XX (yearly task)
  2. */5 9-16 * * XX (five minutes’ task)
  3. 0 0 1 3/3 * XX (quarterly task)
  4. 0 5 * * * XX (daily task)

^ Where XX is the path/location of the script

For more information such as the pattern recognition that the system utilizies, please view our document here: Pseudo Code for Scheduler (Data Crawling)

Formula List

Formula List

During the course of development for this project, the team has been exposed to numerous formulas that are required for the calculations of certain attributes in a User's portfolio. The two highlights for us are:

  • Average Annual Return
  • Year to Date Return

The following sub-sections would explain on how we achieve the formula for the two:

Average Annual Return

[(Total Value Sold + Total Current Value – Total Value Bought/Total Value Bought +1) ^ 12/n-1] * 100
This formula represents the Average return of investment in a year. And the formula is calculated using Geometric Average.

Year to Date Return

Total Value of Stocks Sold + Total Current Value – Total Value of Stocks bought on first trading day of the year + sumOfYearToDateDividend / Total Value of Stocks bought on first trading day of the year * 100
YTD return refers to the amount of profit made by an investment since the first day of the calendar year.


More formulas and explanations can be found at this following document: Charlies Angels Formula List

Geometric Average

There is known to be two forms of calculation that can be taken into consideration which are namely Arithmetic Average and Geometric Average. Upon extensive research, for the goal of achieving accuracy so as to aid the user with making more informed choices. The team has decided to adopt Geometric Average for all of its calculations.

Explanation of Geometric Average is as follows:
Suppose you have invested your savings in the stock market for five years. If your returns each year were 90%, 10%, 20%, 30% and -90%, what would your average return be during this period? Well, taking the simple arithmetic average, you would get an answer of 12%. Not too shabby, you might think.

However, when it comes to annual investment returns, the numbers are not independent of each other. If you lose a ton of money one year, you have that much less capital to generate returns during the following years, and vice versa. Because of this reality, we need to calculate the geometric average of your investment returns in order to get an accurate measurement of what your actual average annual return over the five-year period is.

To do this, we simply add one to each number (to avoid any problems with negative percentages). Then, multiply all the numbers together, and raise their product to the power of one divided by the count of the numbers in the series. And you're finished - just don't forget to subtract one from the result!

That's quite a mouthful, but on paper it's actually not that complex. Returning to our example, let's calculate the geometric average: Our returns were 90%, 10%, 20%, 30% and -90%, so we plug them into the formula as [(1.9 x 1.1 x 1.2 x 1.3 x 0.1) ^ 1/5] - 1. This equals a geometric average annual return of -20.08%. That's a heck of a lot worse than the 12% arithmetic average we calculated earlier, and unfortunately it's also the number that represents reality in this case.