Skip to content

Instantly share code, notes, and snippets.

@kurokikaze
Created October 26, 2011 15:09
Show Gist options
  • Save kurokikaze/1316636 to your computer and use it in GitHub Desktop.
Save kurokikaze/1316636 to your computer and use it in GitHub Desktop.
Calculate dividends per share price and dividends per portfolio value on EmpireAvenue
$('div.item').find('li').each(function(i, el) {
var price = parseFloat($(el).find('span.float-right.large').eq(0).text().split(' ')[0]);
var dividend = $(el).find('span.portfolio-meta').eq(0).text();
var pattern = /Last Dividend: ([\d\.]+)/
var pattern_pval = /Portfolio Value:\s([\d\.,]+)e/
var nums = dividend.match(pattern);
if (nums) {
var divperprice = parseFloat(nums[1]) / price;
console.log('Dividend per price for ' + $(el).find('div.influencer-portrait').find('a').eq(0).attr('href') + ': ' + divperprice);
}
var nums2 = dividend.match(pattern_pval);
if (nums2) {
var divpervalue = parseFloat(nums[2]) / price;
console.log('Dividend per value for ' + $(el).find('div.influencer-portrait').find('a').eq(0).attr('href') + ': ' + divpervalue);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment