Class: FinModeling::Forecasts
- Inherits:
-
Object
- Object
- FinModeling::Forecasts
- Defined in:
- lib/finmodeling/forecasts.rb
Instance Attribute Summary collapse
-
#reformulated_balance_sheets ⇒ Object
Returns the value of attribute reformulated_balance_sheets.
-
#reformulated_income_statements ⇒ Object
Returns the value of attribute reformulated_income_statements.
Instance Method Summary collapse
- #balance_sheet_analyses(filings) ⇒ Object
- #income_statement_analyses(filings, expected_rate_of_return) ⇒ Object
-
#initialize ⇒ Forecasts
constructor
A new instance of Forecasts.
Constructor Details
#initialize ⇒ Forecasts
Returns a new instance of Forecasts.
5 6 7 8 |
# File 'lib/finmodeling/forecasts.rb', line 5 def initialize @reformulated_income_statements = [] @reformulated_balance_sheets = [] end |
Instance Attribute Details
#reformulated_balance_sheets ⇒ Object
Returns the value of attribute reformulated_balance_sheets.
3 4 5 |
# File 'lib/finmodeling/forecasts.rb', line 3 def reformulated_balance_sheets @reformulated_balance_sheets end |
#reformulated_income_statements ⇒ Object
Returns the value of attribute reformulated_income_statements.
3 4 5 |
# File 'lib/finmodeling/forecasts.rb', line 3 def reformulated_income_statements @reformulated_income_statements end |
Instance Method Details
#balance_sheet_analyses(filings) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/finmodeling/forecasts.rb', line 10 def balance_sheet_analyses(filings) if !@balance_sheet_analyses prev_filing = filings.last prev_re_bs = prev_filing.balance_sheet.reformulated(prev_filing.balance_sheet.periods.last) @reformulated_balance_sheets.each do |re_bs| next_analysis = re_bs.analysis(prev_re_bs) @balance_sheet_analyses = @balance_sheet_analyses + next_analysis if @balance_sheet_analyses @balance_sheet_analyses = next_analysis if !@balance_sheet_analyses prev_re_bs = re_bs end @balance_sheet_analyses = BalanceSheetAnalyses.new(@balance_sheet_analyses) end return @balance_sheet_analyses end |
#income_statement_analyses(filings, expected_rate_of_return) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/finmodeling/forecasts.rb', line 26 def income_statement_analyses(filings, expected_rate_of_return) if !@income_statement_analyses prev_filing = filings.last prev_re_bs = prev_filing.balance_sheet.reformulated(prev_filing.balance_sheet.periods.last) prev_prev_is = (filings.length > 2) ? filings[-2].income_statement : nil prev_re_is = prev_filing.income_statement.latest_quarterly_reformulated(prev_cis=nil, prev_prev_is, prev_prev_cis=nil) @reformulated_income_statements.zip(@reformulated_balance_sheets).each do |re_is, re_bs| next_analysis = FinModeling::ReformulatedIncomeStatement.empty_analysis if !re_is next_analysis = re_is.analysis(re_bs, prev_re_is, prev_re_bs, expected_rate_of_return) if re_is @income_statement_analyses = @income_statement_analyses + next_analysis if @income_statement_analyses @income_statement_analyses = next_analysis if !@income_statement_analyses prev_re_bs, prev_re_is = [re_bs, re_is] end @income_statement_analyses = IncomeStatementAnalyses.new(@income_statement_analyses) end return @income_statement_analyses end |