Created
October 26, 2011 15:09
-
-
Save kurokikaze/1316636 to your computer and use it in GitHub Desktop.
Calculate dividends per share price and dividends per portfolio value on EmpireAvenue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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