Skip to content

Instantly share code, notes, and snippets.

@amolpujari
Created April 13, 2016 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amolpujari/15ebc07f3a69c19930f40319008bb992 to your computer and use it in GitHub Desktop.
Save amolpujari/15ebc07f3a69c19930f40319008bb992 to your computer and use it in GitHub Desktop.
annualized_return
if investment and investment.deal and investment.deal.annual_return.present?
return investment.deal.annual_return.to_i
end
return 0 if projected_earnings.blank?
return 0 if percent_profit.blank?
return 0 if percent_profit.to_f < 1
year_diff = projected_earnings.last.distribution_date.d_date.year.to_i - DateTime.now.year.to_i
year_diff = 1 if year_diff < 1
(( (projected_earnings_amount.dollars.to_f / committed_capital.dollars.to_f ).to_f ** ( 1/(year_diff) ) - 1 )*100 ).to_i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment