HeaderSIS.jpg

IS480 Team wiki: 2016T1 Charlies-Angels-Algorithm

From IS480
Revision as of 19:54, 13 September 2016 by Xwzheng.2014 (talk | contribs)
Jump to navigation Jump to search

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)