
/// TEAM ZEN REC BUYS
// Version 1.1

http://teamzen.org/
http://apidocs.empireavenue.com/v1/
http://empireavenue.com/community/zen/
http://www.facebook.com/home.php?sk=group_160861073976561

01.
Copy files in your web directory.
You need PHP 5.
Your directory needs to be writable by Apache
Because we will copy .dat files as database caches.
There is no SQL just .dat data files.

02.
Change the config values in the CRON script with yours.
You will need an API Key from Empire Avenue.
You also need to enter your ticker and your password.

03.
You need to import your portfolio first.
Call the following URL on your site:
/cron.php?portfolio
This can take a little while because it calls 100 at the time.
It needs to take a 1 second pause between calls.
When the script is done loading you can verify
If the database was correctly written locally with:
/cron.php?showdatabase
The second object should contain a SHARES array with many entries.

04.
Then you can test a first simple dividends data fetch
By just calling the main URL:
/cron.php
This will select 10 shares from the database
And make individual calls to the API
To get the latest dividends.
It should show which 10 shares were chosen.
Then those shares are taken off the database.
The site then displays the info in recs.dat not database.dat.

05.
If this works you should be able to call the script 4-5 times in a row
And this would generate a 40-50 Leaderboard with different shares.
You are limited to 150 calls per hour so don't abuse the manual calls.

06.
Add the CRON to automate the data crunching every 5 minutes.
Change the URL in recbuys.sh.
This is the shell script that is called by CRON.
Use your own URL in this script.
Then you will need to create a CRON entry to this script.
Something like:
/home/3856/domains/teamzen.org/html/recbuys.sh


// DATA

config
  updatetime
  applicationkey
  applicationsecret

database
  updatetime
  meta
  shares
    ticker
      updatetime
      dividend
      data

recs
  updatetime
  shares
    ticker
      updatetime
      name
      dividend
      number
      price
      yield
      score


// VERSION 1.1

Added list pruning for entries older than a day
Various bug fixes
Added e(ZEN) calls to include owner in list
Fixed bug non-update on no-dividend day


// TODO

Show more stats
Keep an history of dividends and show averages data
Add an easy way to export lists (custom output for copy and paste)
Maybe have a system for multiple sites sharing data in a master database? xD


// Frédéric e(ZEN) Dénommé / frederic.denomme@gmail.com
