using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MarketData.Generator
{
  public class GrahamGenerator
  {
// EPS: Earnings per share
// Growth: eps growth in decimal percent  (i.e.) .25 represents 25%
// Benjamin Graham Formula.  EPS=Trailing Twelve month, 8.5=PE base for no growth company, g=reasonably expected 7-10 year growth rate
    public static double IntrinsicValue(double eps,double growth)
    {
      return eps * (8.5 + (2 * (growth * 100)));
    }
// Grahams revision which includes a required rate of return of 4.4% which is what the going risk free rate was.  Today we divied by AAA Corporate Bond Rate
    public static double IntrinsicValueRevised(double eps,double growth,double riskFreeRate)
    {
      double requiredReturn=4.4;
      return (eps * (8.5 + (2 * (growth * 100))) * requiredReturn) / riskFreeRate;
    }
//  The Graham number is a figure that measures a stock's fundamental value by taking into account the company's earnings per share and book value per share.
//  The Graham number is the upper bound of the price range that a defensive investor should pay for the stock. According to the theory, any stock price below
//    the Graham number is considered undervalued and thus worth investing in. The formula is as follows:
    public static double GrahamNumber(double eps,double bvps)
    {
      return Math.Sqrt(22.5*eps*bvps);
    }
  }
}
