finmodeling 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/Gemfile +10 -0
- data/README.md +292 -0
- data/Rakefile +6 -0
- data/TODO.txt +36 -0
- data/examples/dump_report.rb +33 -0
- data/examples/lists/nasdaq-mid-to-mega-tech-symbols.txt +226 -0
- data/examples/show_report.rb +218 -0
- data/examples/show_reports.rb +77 -0
- data/finmodeling.gemspec +31 -0
- data/lib/finmodeling/annual_report_filing.rb +104 -0
- data/lib/finmodeling/array_with_stats.rb +22 -0
- data/lib/finmodeling/assets_calculation.rb +36 -0
- data/lib/finmodeling/assets_item.rb +14 -0
- data/lib/finmodeling/assets_item_vectors.rb +638 -0
- data/lib/finmodeling/balance_sheet_analyses.rb +33 -0
- data/lib/finmodeling/balance_sheet_calculation.rb +68 -0
- data/lib/finmodeling/calculation_summary.rb +148 -0
- data/lib/finmodeling/can_cache_classifications.rb +36 -0
- data/lib/finmodeling/can_cache_summaries.rb +16 -0
- data/lib/finmodeling/can_classify_rows.rb +54 -0
- data/lib/finmodeling/cash_change_calculation.rb +67 -0
- data/lib/finmodeling/cash_change_item.rb +14 -0
- data/lib/finmodeling/cash_change_item_vectors.rb +241 -0
- data/lib/finmodeling/cash_flow_statement_calculation.rb +85 -0
- data/lib/finmodeling/classifiers.rb +11 -0
- data/lib/finmodeling/company.rb +102 -0
- data/lib/finmodeling/company_filing.rb +64 -0
- data/lib/finmodeling/company_filing_calculation.rb +75 -0
- data/lib/finmodeling/company_filings.rb +100 -0
- data/lib/finmodeling/config.rb +37 -0
- data/lib/finmodeling/constant_forecasting_policy.rb +23 -0
- data/lib/finmodeling/factory.rb +27 -0
- data/lib/finmodeling/float_helpers.rb +17 -0
- data/lib/finmodeling/forecasts.rb +48 -0
- data/lib/finmodeling/generic_forecasting_policy.rb +19 -0
- data/lib/finmodeling/has_string_classifer.rb +96 -0
- data/lib/finmodeling/income_statement_analyses.rb +74 -0
- data/lib/finmodeling/income_statement_calculation.rb +71 -0
- data/lib/finmodeling/income_statement_item.rb +14 -0
- data/lib/finmodeling/income_statement_item_vectors.rb +654 -0
- data/lib/finmodeling/liabs_and_equity_calculation.rb +36 -0
- data/lib/finmodeling/liabs_and_equity_item.rb +14 -0
- data/lib/finmodeling/liabs_and_equity_item_vectors.rb +1936 -0
- data/lib/finmodeling/net_income_calculation.rb +41 -0
- data/lib/finmodeling/paths.rb +5 -0
- data/lib/finmodeling/period_array.rb +24 -0
- data/lib/finmodeling/quarterly_report_filing.rb +23 -0
- data/lib/finmodeling/rate.rb +20 -0
- data/lib/finmodeling/ratio.rb +20 -0
- data/lib/finmodeling/reformulated_balance_sheet.rb +176 -0
- data/lib/finmodeling/reformulated_cash_flow_statement.rb +140 -0
- data/lib/finmodeling/reformulated_income_statement.rb +436 -0
- data/lib/finmodeling/string_helpers.rb +26 -0
- data/lib/finmodeling/version.rb +3 -0
- data/lib/finmodeling.rb +70 -0
- data/spec/annual_report_filing_spec.rb +68 -0
- data/spec/assets_calculation_spec.rb +21 -0
- data/spec/assets_item_spec.rb +66 -0
- data/spec/balance_sheet_analyses_spec.rb +43 -0
- data/spec/balance_sheet_calculation_spec.rb +91 -0
- data/spec/calculation_summary_spec.rb +63 -0
- data/spec/can_classify_rows_spec.rb +86 -0
- data/spec/cash_change_calculation_spec.rb +56 -0
- data/spec/cash_change_item_spec.rb +66 -0
- data/spec/cash_flow_statement_calculation_spec.rb +108 -0
- data/spec/company_filing_calculation_spec.rb +74 -0
- data/spec/company_filing_spec.rb +30 -0
- data/spec/company_filings_spec.rb +55 -0
- data/spec/company_spec.rb +73 -0
- data/spec/constant_forecasting_policy_spec.rb +37 -0
- data/spec/factory_spec.rb +18 -0
- data/spec/forecasts_spec.rb +21 -0
- data/spec/generic_forecasting_policy_spec.rb +33 -0
- data/spec/income_statement_analyses_spec.rb +63 -0
- data/spec/income_statement_calculation_spec.rb +88 -0
- data/spec/income_statement_item_spec.rb +86 -0
- data/spec/liabs_and_equity_calculation_spec.rb +20 -0
- data/spec/liabs_and_equity_item_spec.rb +66 -0
- data/spec/mocks/calculation.rb +10 -0
- data/spec/mocks/income_statement_analyses.rb +93 -0
- data/spec/mocks/sec_query.rb +31 -0
- data/spec/net_income_calculation_spec.rb +23 -0
- data/spec/period_array.rb +52 -0
- data/spec/quarterly_report_filing_spec.rb +69 -0
- data/spec/rate_spec.rb +33 -0
- data/spec/ratio_spec.rb +33 -0
- data/spec/reformulated_balance_sheet_spec.rb +146 -0
- data/spec/reformulated_cash_flow_statement_spec.rb +174 -0
- data/spec/reformulated_income_statement_spec.rb +293 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/string_helpers_spec.rb +23 -0
- data/tools/create_balance_sheet_training_vectors.rb +65 -0
- data/tools/create_cash_change_training_vectors.rb +48 -0
- data/tools/create_credit_debit_training_vectors.rb +51 -0
- data/tools/create_income_statement_training_vectors.rb +48 -0
- metadata +289 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
module FinModeling
|
|
2
|
+
class CashChangeItem < String
|
|
3
|
+
TRAINING_VECTORS = [ { :klass=>:c, :item_string=>"Net Income Loss" },
|
|
4
|
+
{ :klass=>:c, :item_string=>"Depreciation" },
|
|
5
|
+
{ :klass=>:c, :item_string=>"Adjustment For Amortization" },
|
|
6
|
+
{ :klass=>:c, :item_string=>"Deferred Income Tax Expense Benefit" },
|
|
7
|
+
{ :klass=>:c, :item_string=>"Share Based Compensation" },
|
|
8
|
+
{ :klass=>:c, :item_string=>"Excess Tax Benefit From Share Based Compensation Operating Activities" },
|
|
9
|
+
{ :klass=>:c, :item_string=>"Other Noncash Income Expense" },
|
|
10
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Receivable" },
|
|
11
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Current Assets" },
|
|
12
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Noncurrent Assets" },
|
|
13
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable" },
|
|
14
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Employee Related Liabilities" },
|
|
15
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Liabilities" },
|
|
16
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Income Taxes Payable" },
|
|
17
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Revenue" },
|
|
18
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Operating Liabilities" },
|
|
19
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Property Plant And Equipment" },
|
|
20
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Software" },
|
|
21
|
+
{ :klass=>:i, :item_string=>"Alliance Technical Enablement Expenditures" },
|
|
22
|
+
{ :klass=>:d, :item_string=>"Payments To Acquire Available For Sale Securities" },
|
|
23
|
+
{ :klass=>:i, :item_string=>"Proceeds From Sale Of Other Productive Assets" },
|
|
24
|
+
{ :klass=>:f, :item_string=>"Proceeds From Issuance Of Common Stock" },
|
|
25
|
+
{ :klass=>:f, :item_string=>"Proceeds From Stock Options Exercised" },
|
|
26
|
+
{ :klass=>:f, :item_string=>"Excess Tax Benefit From Share Based Compensation Financing Activities" },
|
|
27
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Other Equity" },
|
|
28
|
+
{ :klass=>:d, :item_string=>"Repayments Of Lines Of Credit" },
|
|
29
|
+
{ :klass=>:d, :item_string=>"Proceeds From Lines Of Credit" },
|
|
30
|
+
{ :klass=>:d, :item_string=>"Repayments Of Long Term Debt And Capital Securities" },
|
|
31
|
+
{ :klass=>:d, :item_string=>"Effect Of Exchange Rate On Cash And Cash Equivalents" },
|
|
32
|
+
|
|
33
|
+
{ :klass=>:c, :item_string=>"Amortization Of Content Databases" },
|
|
34
|
+
{ :klass=>:c, :item_string=>"Net Income Loss" },
|
|
35
|
+
{ :klass=>:c, :item_string=>"Depreciation" },
|
|
36
|
+
{ :klass=>:c, :item_string=>"Amortization Of Intangible Assets" },
|
|
37
|
+
{ :klass=>:c, :item_string=>"Amortization Of Financing Costs" },
|
|
38
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Income Taxes Net" },
|
|
39
|
+
{ :klass=>:c, :item_string=>"Share Based Compensation" },
|
|
40
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Receivable" },
|
|
41
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Restricted Cash For Operating Activities" },
|
|
42
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Operating Assets" },
|
|
43
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Income Taxes Payable Net Of Income Taxes Receivable" },
|
|
44
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable And Accrued Liabilities" },
|
|
45
|
+
{ :klass=>:c, :item_string=>"Excess Tax Benefit From Share Based Compensation Operating Activities" },
|
|
46
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Revenue" },
|
|
47
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Content Data Base Costs" },
|
|
48
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Property Plant And Equipment" },
|
|
49
|
+
{ :klass=>:d, :item_string=>"Payments To Acquire Available For Sale Securities" },
|
|
50
|
+
{ :klass=>:f, :item_string=>"Proceeds From Stock Options Exercised" },
|
|
51
|
+
{ :klass=>:f, :item_string=>"Proceeds From Issuance Initial Public Offering" },
|
|
52
|
+
{ :klass=>:d, :item_string=>"Repayments Of Long Term Debt" },
|
|
53
|
+
{ :klass=>:f, :item_string=>"Excess Tax Benefit From Share Based Compensation Financing Activities" },
|
|
54
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Common Stock" },
|
|
55
|
+
{ :klass=>:d, :item_string=>"Effect Of Exchange Rate On Cash And Cash Equivalents" },
|
|
56
|
+
|
|
57
|
+
{ :klass=>:c, :item_string=>"Profit Loss" },
|
|
58
|
+
{ :klass=>:c, :item_string=>"Goodwill And Intangible Asset Impairment" },
|
|
59
|
+
{ :klass=>:c, :item_string=>"Depreciation Amortization And Impairment Of Long Lived Assets" },
|
|
60
|
+
{ :klass=>:c, :item_string=>"Gain Loss On Disposition Of Assets" },
|
|
61
|
+
{ :klass=>:c, :item_string=>"Deferred Income Tax Expense Benefit" },
|
|
62
|
+
{ :klass=>:c, :item_string=>"Share Based Compensation" },
|
|
63
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Receivable" },
|
|
64
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Charges" },
|
|
65
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Operating Assets" },
|
|
66
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable And Accrued Liabilities" },
|
|
67
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Revenue" },
|
|
68
|
+
{ :klass=>:i, :item_string=>"Payments For Proceeds From Businesses And Interest In Affiliates" },
|
|
69
|
+
{ :klass=>:i, :item_string=>"Proceeds From Sale Of Property Plant And Equipment" },
|
|
70
|
+
{ :klass=>:i, :item_string=>"Payments To Develop Capitalized Software" },
|
|
71
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Property Plant And Equipment" },
|
|
72
|
+
{ :klass=>:i, :item_string=>"Payments For Proceeds From Investments" },
|
|
73
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Other Productive Assets" },
|
|
74
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Businesses Net Of Cash Acquired" },
|
|
75
|
+
{ :klass=>:i, :item_string=>"Proceeds From Sale Of Intangible Assets" },
|
|
76
|
+
{ :klass=>:d, :item_string=>"Repayments Of Long Term Debt" },
|
|
77
|
+
{ :klass=>:d, :item_string=>"Payments Of Debt Restructuring Costs" },
|
|
78
|
+
{ :klass=>:d, :item_string=>"Payments Of Dividends" },
|
|
79
|
+
{ :klass=>:f, :item_string=>"Proceeds From Issuance Of Common Stock" },
|
|
80
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Common Stock" },
|
|
81
|
+
{ :klass=>:d, :item_string=>"Proceeds From Minority Shareholders" },
|
|
82
|
+
{ :klass=>:f, :item_string=>"Excess Tax Benefit From Share Based Compensation Financing Activities" },
|
|
83
|
+
{ :klass=>:d, :item_string=>"Effect Of Exchange Rate On Cash And Cash Equivalents" },
|
|
84
|
+
|
|
85
|
+
{ :klass=>:c, :item_string=>"Net Income Loss" },
|
|
86
|
+
{ :klass=>:c, :item_string=>"Depreciation Depletion And Amortization" },
|
|
87
|
+
{ :klass=>:c, :item_string=>"Share Based Compensation" },
|
|
88
|
+
{ :klass=>:c, :item_string=>"Deferred Income Taxes And Tax Credits" },
|
|
89
|
+
{ :klass=>:c, :item_string=>"Unrealized Gain Loss On Investments" },
|
|
90
|
+
{ :klass=>:c, :item_string=>"Tax Benefit From Stock Options Exercised" },
|
|
91
|
+
{ :klass=>:c, :item_string=>"Excess Tax Benefit From Share Based Compensation Operating Activities" },
|
|
92
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Receivables" },
|
|
93
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Prepaid Deferred Expense And Other Assets" },
|
|
94
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable" },
|
|
95
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Liabilities" },
|
|
96
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Restructuring Reserve" },
|
|
97
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Income Taxes Payable" },
|
|
98
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Revenue" },
|
|
99
|
+
{ :klass=>:c, :item_string=>"Other Noncash Income Expense" },
|
|
100
|
+
{ :klass=>:i, :item_string=>"Gain Loss On Sale Of Property Plant Equipment" },
|
|
101
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Longterm Investments" },
|
|
102
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Short Term Investments" },
|
|
103
|
+
{ :klass=>:d, :item_string=>"Proceeds From Maturities Prepayments And Calls Of Shortterm Investments" },
|
|
104
|
+
{ :klass=>:i, :item_string=>"Proceeds From Sale Of Short Term Investments" },
|
|
105
|
+
{ :klass=>:d, :item_string=>"Proceeds From Sale Of Available For Sale Securities Equity" },
|
|
106
|
+
{ :klass=>:i, :item_string=>"Payments For Proceeds From Other Investing Activities" },
|
|
107
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Businesses Net Of Cash Acquired" },
|
|
108
|
+
{ :klass=>:i, :item_string=>"Proceeds From Sale Of Property Plant And Equipment" },
|
|
109
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Property Plant And Equipment" },
|
|
110
|
+
{ :klass=>:d, :item_string=>"Payments Of Debt Issuance Costs" },
|
|
111
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Common Stock" },
|
|
112
|
+
{ :klass=>:f, :item_string=>"Proceeds From Sale Of Treasury Stock" },
|
|
113
|
+
{ :klass=>:f, :item_string=>"Excess Tax Benefit From Share Based Compensation Financing Activities" },
|
|
114
|
+
{ :klass=>:d, :item_string=>"Proceeds From Issuance Of Senior Long Term Debt" },
|
|
115
|
+
{ :klass=>:d, :item_string=>"Repayments Of Long Term Debt And Capital Securities" },
|
|
116
|
+
{ :klass=>:d, :item_string=>"Repayments Of Acquired Debt" },
|
|
117
|
+
{ :klass=>:d, :item_string=>"Effect Of Exchange Rate On Cash And Cash Equivalents" },
|
|
118
|
+
|
|
119
|
+
{ :klass=>:c, :item_string=>"Net Income Loss" },
|
|
120
|
+
{ :klass=>:c, :item_string=>"Research And Development In Process" },
|
|
121
|
+
{ :klass=>:c, :item_string=>"Depreciation And Amortization" },
|
|
122
|
+
{ :klass=>:c, :item_string=>"Asset Impairment Charges" },
|
|
123
|
+
{ :klass=>:c, :item_string=>"Restructuring Costs" },
|
|
124
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Receivable" },
|
|
125
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Income Taxes" },
|
|
126
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Prepaid Deferred Expense And Other Assets" },
|
|
127
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable And Accrued Liabilities" },
|
|
128
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Revenue" },
|
|
129
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Income Taxes Payable" },
|
|
130
|
+
{ :klass=>:d, :item_string=>"Payments To Acquire Marketable Securities" },
|
|
131
|
+
{ :klass=>:d, :item_string=>"Proceeds From Sale Of Available For Sale Securities" },
|
|
132
|
+
{ :klass=>:d, :item_string=>"Proceeds From Maturities Prepayments And Calls Of Available For Sale Securities" },
|
|
133
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Businesses Net Of Cash Acquired" },
|
|
134
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Property Plant And Equipment" },
|
|
135
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Investments" },
|
|
136
|
+
{ :klass=>:f, :item_string=>"Proceeds From Issuance Of Common Stock" },
|
|
137
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Common Stock" },
|
|
138
|
+
{ :klass=>:d, :item_string=>"Proceeds From Lines Of Credit" },
|
|
139
|
+
{ :klass=>:d, :item_string=>"Repayments Of Lines Of Credit" },
|
|
140
|
+
|
|
141
|
+
{ :klass=>:c, :item_string=>"Income Loss From Continuing Operations" },
|
|
142
|
+
{ :klass=>:c, :item_string=>"Share Based Compensation" },
|
|
143
|
+
{ :klass=>:c, :item_string=>"Depreciation Depletion And Amortization" },
|
|
144
|
+
{ :klass=>:c, :item_string=>"Excess Tax Benefit From Share Based Compensation Operating Activities" },
|
|
145
|
+
{ :klass=>:c, :item_string=>"Provision For Doubtful Accounts" },
|
|
146
|
+
{ :klass=>:c, :item_string=>"Sales Allowances Services" },
|
|
147
|
+
{ :klass=>:c, :item_string=>"Gain Loss On Sale Of Property Plant Equipment" },
|
|
148
|
+
{ :klass=>:c, :item_string=>"Asset Impairment Charges" },
|
|
149
|
+
{ :klass=>:c, :item_string=>"Gain Loss On Investments" },
|
|
150
|
+
{ :klass=>:c, :item_string=>"Deferred Income Tax Expense Benefit" },
|
|
151
|
+
{ :klass=>:c, :item_string=>"Other Noncash Income Expense" },
|
|
152
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Receivable" },
|
|
153
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Prepaid Deferred Expense And Other Assets" },
|
|
154
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable" },
|
|
155
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Liabilities" },
|
|
156
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Revenue" },
|
|
157
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Income Taxes Payable" },
|
|
158
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Businesses Net Of Cash Acquired" },
|
|
159
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Property Plant And Equipment" },
|
|
160
|
+
{ :klass=>:i, :item_string=>"Payments For Capitalized Software Development Costs" },
|
|
161
|
+
{ :klass=>:d, :item_string=>"Proceeds From Sale Maturity And Collections Of Investments" },
|
|
162
|
+
{ :klass=>:d, :item_string=>"Payments To Acquire Marketable Securities" },
|
|
163
|
+
{ :klass=>:d, :item_string=>"Proceeds From Sale And Maturity Of Marketable Securities" },
|
|
164
|
+
{ :klass=>:i, :item_string=>"Proceeds From Sale Of Productive Assets" },
|
|
165
|
+
{ :klass=>:d, :item_string=>"Increase Decrease In Restricted Cash" },
|
|
166
|
+
{ :klass=>:f, :item_string=>"Proceeds From Stock Options Exercised" },
|
|
167
|
+
{ :klass=>:f, :item_string=>"Payments Of Withholding Taxes Equity Award Share Settlement Net" },
|
|
168
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Common Stock" },
|
|
169
|
+
{ :klass=>:f, :item_string=>"Proceeds From Stock Plans" },
|
|
170
|
+
{ :klass=>:d, :item_string=>"Proceeds From Issuance Of Long Term Debt" },
|
|
171
|
+
{ :klass=>:d, :item_string=>"Repayments Of Long Term Debt" },
|
|
172
|
+
{ :klass=>:d, :item_string=>"Payments Of Debt Issuance Costs" },
|
|
173
|
+
{ :klass=>:f, :item_string=>"Excess Tax Benefit From Share Based Compensation Financing Activities" },
|
|
174
|
+
{ :klass=>:d, :item_string=>"Net Cash Transferred To From Discontinued Operations" },
|
|
175
|
+
{ :klass=>:d, :item_string=>"Effect Of Exchange Rate On Cash And Cash Equivalents Continuing Operations" },
|
|
176
|
+
|
|
177
|
+
{ :klass=>:c, :item_string=>"Profit Loss" },
|
|
178
|
+
{ :klass=>:c, :item_string=>"Depreciation Depletion And Amortization" },
|
|
179
|
+
{ :klass=>:c, :item_string=>"Amortization Of Financing Costs And Discounts" },
|
|
180
|
+
{ :klass=>:c, :item_string=>"Provision For Doubtful Accounts" },
|
|
181
|
+
{ :klass=>:c, :item_string=>"Deferred Income Tax Expense Benefit" },
|
|
182
|
+
{ :klass=>:c, :item_string=>"Income Loss From Equity Method Investments" },
|
|
183
|
+
{ :klass=>:c, :item_string=>"Gains Losses On Extinguishment Of Debt Attributable To Financing Activities" },
|
|
184
|
+
{ :klass=>:c, :item_string=>"Gain Loss On Sale Of Property Plant Equipment" },
|
|
185
|
+
{ :klass=>:c, :item_string=>"Share Based Compensation" },
|
|
186
|
+
{ :klass=>:c, :item_string=>"Other Noncash Income Expense" },
|
|
187
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Receivable" },
|
|
188
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Receivables" },
|
|
189
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Inventories" },
|
|
190
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Operating Assets" },
|
|
191
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Assets" },
|
|
192
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable" },
|
|
193
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Liabilities" },
|
|
194
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Operating Liabilities" },
|
|
195
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Property Plant And Equipment" },
|
|
196
|
+
{ :klass=>:i, :item_string=>"Proceeds From Sale Of Property Plant And Equipment" },
|
|
197
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Equity Method Investments" },
|
|
198
|
+
{ :klass=>:i, :item_string=>"Purchase Of Equipment Leased To Unconsolidated Affiliate" },
|
|
199
|
+
{ :klass=>:i, :item_string=>"Financing Lease Payment From Unconsolidated Affiliate" },
|
|
200
|
+
{ :klass=>:d, :item_string=>"Increase Decrease In Restricted Cash" },
|
|
201
|
+
{ :klass=>:i, :item_string=>"Payments For Proceeds From Other Investing Activities" },
|
|
202
|
+
{ :klass=>:d, :item_string=>"Borrowings Under Revolving Credit Facilities" },
|
|
203
|
+
{ :klass=>:d, :item_string=>"Payments Under Revolving Credit Facilities" },
|
|
204
|
+
{ :klass=>:d, :item_string=>"Proceeds From Lines Of Credit" },
|
|
205
|
+
{ :klass=>:d, :item_string=>"Repayments Of Lines Of Credit" },
|
|
206
|
+
{ :klass=>:d, :item_string=>"Proceeds From Issuance Of Other Long Term Debt" },
|
|
207
|
+
{ :klass=>:d, :item_string=>"Proceeds From Related Party Debt" },
|
|
208
|
+
{ :klass=>:d, :item_string=>"Repayments Of Long Term Debt" },
|
|
209
|
+
{ :klass=>:d, :item_string=>"Payments Of Debt Issuance Costs" },
|
|
210
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Common Stock" },
|
|
211
|
+
{ :klass=>:f, :item_string=>"Proceeds From Issuance Of Shares Under Incentive And Share Based Compensation Plans Including Stock Options" },
|
|
212
|
+
{ :klass=>:f, :item_string=>"Payments Related To Tax Withholding For Share Based Compensation" },
|
|
213
|
+
{ :klass=>:d, :item_string=>"Effect Of Exchange Rate On Cash And Cash Equivalents" },
|
|
214
|
+
|
|
215
|
+
{ :klass=>:c, :item_string=>"Net Income Loss" },
|
|
216
|
+
{ :klass=>:c, :item_string=>"Depreciation And Amortization" },
|
|
217
|
+
{ :klass=>:c, :item_string=>"Deferred Income Tax Expense Benefit" },
|
|
218
|
+
{ :klass=>:c, :item_string=>"Provision For Doubtful Accounts" },
|
|
219
|
+
{ :klass=>:c, :item_string=>"Share Based Compensation" },
|
|
220
|
+
{ :klass=>:c, :item_string=>"Excess Tax Benefit From Share Based Compensation Operating Activities" },
|
|
221
|
+
{ :klass=>:c, :item_string=>"Other Noncash Income Expense" },
|
|
222
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Receivable" },
|
|
223
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Prepaid Deferred Expense And Other Assets" },
|
|
224
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Operating Assets" },
|
|
225
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accounts Payable And Accrued Liabilities" },
|
|
226
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Deferred Revenue" },
|
|
227
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Other Operating Liabilities" },
|
|
228
|
+
{ :klass=>:c, :item_string=>"Increase Decrease In Accrued Income Taxes Payable" },
|
|
229
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Productive Assets" },
|
|
230
|
+
{ :klass=>:d, :item_string=>"Payments To Acquire Short Term Investments" },
|
|
231
|
+
{ :klass=>:d, :item_string=>"Proceeds From Sale Of Short Term Investments" },
|
|
232
|
+
{ :klass=>:i, :item_string=>"Payments To Acquire Businesses Net Of Cash Acquired" },
|
|
233
|
+
{ :klass=>:d, :item_string=>"Repayments Of Long Term Debt" },
|
|
234
|
+
{ :klass=>:i, :item_string=>"Repayments Of Long Term Capital Lease Obligations" },
|
|
235
|
+
{ :klass=>:f, :item_string=>"Payments For Repurchase Of Common Stock" },
|
|
236
|
+
{ :klass=>:f, :item_string=>"Proceeds From Issuance Of Shares Under Incentive And Share Based Compensation Plans" },
|
|
237
|
+
{ :klass=>:f, :item_string=>"Proceeds From Stock Options Exercised" },
|
|
238
|
+
{ :klass=>:f, :item_string=>"Excess Tax Benefit From Share Based Compensation Financing Activities" },
|
|
239
|
+
{ :klass=>:d, :item_string=>"Effect Of Exchange Rate On Cash And Cash Equivalents" } ]
|
|
240
|
+
end
|
|
241
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module FinModeling
|
|
2
|
+
class CashFlowStatementCalculation < CompanyFilingCalculation
|
|
3
|
+
|
|
4
|
+
def cash_change_calculation
|
|
5
|
+
if @cash_change.nil?
|
|
6
|
+
friendly_goal = "cash change"
|
|
7
|
+
label_regexes = [ /^cash and cash equivalents period increase decrease/,
|
|
8
|
+
/^(|net )(change|increase|decrease|decrease *increase|increase *decrease) in cash and cash equivalents/,
|
|
9
|
+
/^net cash provided by used in continuing operations/]
|
|
10
|
+
id_regexes = [ /^(|Locator_|loc_)(|us-gaap_)CashAndCashEquivalentsPeriodIncreaseDecrease[_a-z0-9]+/,
|
|
11
|
+
/^(|Locator_|loc_)(|us-gaap_)NetCashProvidedByUsedInContinuingOperations[_a-z0-9]+/ ]
|
|
12
|
+
|
|
13
|
+
calc = find_and_verify_calculation_arc(friendly_goal, label_regexes, id_regexes)
|
|
14
|
+
@cash_change = CashChangeCalculation.new(calc)
|
|
15
|
+
end
|
|
16
|
+
return @cash_change
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def is_valid?
|
|
20
|
+
re_cfs = reformulated(periods.last)
|
|
21
|
+
flows_are_balanced = (re_cfs.free_cash_flow.total == (-1*re_cfs.financing_flows.total))
|
|
22
|
+
none_are_zero = (re_cfs.cash_from_operations.total != 0) &&
|
|
23
|
+
(re_cfs.cash_investments_in_operations.total != 0) &&
|
|
24
|
+
(re_cfs.payments_to_debtholders.total != 0) &&
|
|
25
|
+
(re_cfs.payments_to_stockholders.total != 0)
|
|
26
|
+
return (flows_are_balanced && none_are_zero)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def reformulated(period)
|
|
30
|
+
return ReformulatedCashFlowStatement.new(period, cash_change_calculation.summary(:period => period))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def latest_quarterly_reformulated(prev_cash_flow_statement)
|
|
34
|
+
if cash_change_calculation.periods.quarterly.any? &&
|
|
35
|
+
reformulated(cash_change_calculation.periods.quarterly.last).cash_investments_in_operations.total.abs > 1.0
|
|
36
|
+
return reformulated(cash_change_calculation.periods.quarterly.last)
|
|
37
|
+
|
|
38
|
+
elsif !prev_cash_flow_statement
|
|
39
|
+
return nil
|
|
40
|
+
|
|
41
|
+
elsif cash_change_calculation.periods.halfyearly.any? &&
|
|
42
|
+
prev_cash_flow_statement.cash_change_calculation.periods.quarterly.any?
|
|
43
|
+
cfs_period = cash_change_calculation.periods.halfyearly.last
|
|
44
|
+
re_cfs = reformulated(cfs_period)
|
|
45
|
+
|
|
46
|
+
period_1q_thru_1q = prev_cash_flow_statement.cash_change_calculation.periods.quarterly.last
|
|
47
|
+
prev1q = prev_cash_flow_statement.reformulated(period_1q_thru_1q)
|
|
48
|
+
re_cfs = re_cfs - prev1q
|
|
49
|
+
|
|
50
|
+
return re_cfs
|
|
51
|
+
|
|
52
|
+
elsif cash_change_calculation.periods.threequarterly.any? &&
|
|
53
|
+
prev_cash_flow_statement.cash_change_calculation.periods.halfyearly.any?
|
|
54
|
+
cfs_period = cash_change_calculation.periods.threequarterly.last
|
|
55
|
+
re_cfs = reformulated(cfs_period)
|
|
56
|
+
|
|
57
|
+
period_1q_thru_2q = prev_cash_flow_statement.cash_change_calculation.periods.halfyearly.last
|
|
58
|
+
prev2q = prev_cash_flow_statement.reformulated(period_1q_thru_2q)
|
|
59
|
+
re_cfs = re_cfs - prev2q
|
|
60
|
+
|
|
61
|
+
return re_cfs
|
|
62
|
+
|
|
63
|
+
elsif cash_change_calculation.periods.yearly.any? &&
|
|
64
|
+
prev_cash_flow_statement.cash_change_calculation.periods.threequarterly.any?
|
|
65
|
+
cfs_period = cash_change_calculation.periods.yearly.last
|
|
66
|
+
re_cfs = reformulated(cfs_period)
|
|
67
|
+
|
|
68
|
+
period_1q_thru_3q = prev_cash_flow_statement.cash_change_calculation.periods.threequarterly.last
|
|
69
|
+
prev3q = prev_cash_flow_statement.reformulated(period_1q_thru_3q)
|
|
70
|
+
re_cfs = re_cfs - prev3q
|
|
71
|
+
|
|
72
|
+
return re_cfs
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
return nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def write_constructor(file, item_name)
|
|
79
|
+
item_calc_name = item_name + "_calc"
|
|
80
|
+
@calculation.write_constructor(file, item_calc_name)
|
|
81
|
+
file.puts "#{item_name} = FinModeling::CashFlowStatementCalculation.new(#{item_calc_name})"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
module FinModeling
|
|
3
|
+
class Classifiers
|
|
4
|
+
def self.train
|
|
5
|
+
FinModeling::AssetsItem.load_vectors_and_train
|
|
6
|
+
FinModeling::LiabsAndEquityItem.load_vectors_and_train
|
|
7
|
+
FinModeling::IncomeStatementItem.load_vectors_and_train
|
|
8
|
+
FinModeling::CashChangeItem.load_vectors_and_train
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
module SecQuery
|
|
2
|
+
class Filing
|
|
3
|
+
def write_constructor(file, item)
|
|
4
|
+
file.puts "filing = { :cik => \"#{@cik}\", :title => \"#{@title}\", :summary => \"#{@summary}\", " +
|
|
5
|
+
":link => \"#{@link.gsub(/"/, "\\\"")}\", :term => \"#{@term}\", :date => \"#{@date}\", :file_id => \"#{@file_id}\" }"
|
|
6
|
+
file.puts "#{item} = SecQuery::Filing.new(filing)"
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Entity
|
|
11
|
+
def write_constructor(filename)
|
|
12
|
+
FileUtils.mkdir_p(File.dirname(filename)) if !File.exists?(File.dirname(filename))
|
|
13
|
+
file = File.open(filename, "w")
|
|
14
|
+
filing_names = []
|
|
15
|
+
@filings.select{ |x| x.title =~ /^10-/ }.each_with_index do |filing, index|
|
|
16
|
+
filing_name = "item_#{index}"
|
|
17
|
+
filing.write_constructor(file, filing_name)
|
|
18
|
+
filing_names.push filing_name
|
|
19
|
+
end
|
|
20
|
+
file.puts "@entity = SecQuery::Entity.new({ :name => \"#{@name.gsub(/"/, "\\\"")}\", :filings => [#{filing_names.join(',')}] })"
|
|
21
|
+
file.close
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.load(filename)
|
|
25
|
+
return nil if !File.exists?(filename) || !FinModeling::Config.caching_enabled?
|
|
26
|
+
eval(File.read(filename))
|
|
27
|
+
return @entity
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
module FinModeling
|
|
33
|
+
class Company
|
|
34
|
+
def initialize(entity)
|
|
35
|
+
@entity = entity
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
BASE_FILENAME = File.join(FinModeling::BASE_PATH, "companies/")
|
|
39
|
+
def self.find(stock_symbol)
|
|
40
|
+
filename = BASE_FILENAME + stock_symbol.upcase + ".rb"
|
|
41
|
+
entity = SecQuery::Entity.load(filename)
|
|
42
|
+
return Company.new(entity) if !entity.nil?
|
|
43
|
+
begin
|
|
44
|
+
entity = SecQuery::Entity.find(stock_symbol, { :relationships => false,
|
|
45
|
+
:transactions => false,
|
|
46
|
+
:filings => true })
|
|
47
|
+
#:filings => {:start=> 0, :count=>20, :limit=> 20} })
|
|
48
|
+
return nil if !entity
|
|
49
|
+
entity.write_constructor(filename)
|
|
50
|
+
return Company.new(entity)
|
|
51
|
+
rescue Exception => e
|
|
52
|
+
puts "Warning: failed to load entity"
|
|
53
|
+
puts "\t" + e.message
|
|
54
|
+
puts "\t" + e.backtrace.inspect.gsub(/, /, "\n\t ")
|
|
55
|
+
return nil
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def name
|
|
60
|
+
@entity.name.gsub(/ \(.*/, '')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def annual_reports
|
|
64
|
+
CompanyFilings.new(sorted_reports_of_type("10-K"))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def quarterly_reports
|
|
68
|
+
CompanyFilings.new(sorted_reports_of_type("10-Q"))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def filings_since_date(start_date)
|
|
72
|
+
reports = self.annual_reports
|
|
73
|
+
reports += self.quarterly_reports
|
|
74
|
+
reports.select!{ |report| Time.parse(report.date) >= start_date }
|
|
75
|
+
reports.sort!{ |x, y| Time.parse(x.date) <=> Time.parse(y.date) }
|
|
76
|
+
|
|
77
|
+
filings = []
|
|
78
|
+
reports.each do |report|
|
|
79
|
+
begin
|
|
80
|
+
case report.term
|
|
81
|
+
when "10-Q" then filings << FinModeling::QuarterlyReportFiling.download(report.link)
|
|
82
|
+
when "10-K" then filings << FinModeling::AnnualReportFiling.download( report.link)
|
|
83
|
+
end
|
|
84
|
+
rescue Exception => e
|
|
85
|
+
# *ReportFiling.download() will throw errors if it doesn't contain xbrl data.
|
|
86
|
+
puts "Caught error in FinModeling::(.*)ReportFiling.download:"
|
|
87
|
+
puts "\t" + e.message
|
|
88
|
+
puts "\t" + e.backtrace.inspect.gsub(/, /, "\n\t ")
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
return CompanyFilings.new(filings)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
def sorted_reports_of_type(report_type)
|
|
98
|
+
@entity.filings.select{ |x| x.term == report_type }.sort{ |x,y| x.date <=> y.date }
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
module FinModeling
|
|
2
|
+
|
|
3
|
+
class CachedAnnualFiling
|
|
4
|
+
attr_accessor :balance_sheet, :income_statement, :cash_flow_statement, :disclosures
|
|
5
|
+
def initialize(bs, is, cfs, disclosures)
|
|
6
|
+
@balance_sheet = bs
|
|
7
|
+
@income_statement = is
|
|
8
|
+
@cash_flow_statement = cfs
|
|
9
|
+
@disclosures = disclosures
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def is_valid?
|
|
13
|
+
return (@income_statement.is_valid? and @balance_sheet.is_valid? and @cash_flow_statement.is_valid?)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class CachedQuarterlyFiling < CachedAnnualFiling
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class CompanyFiling
|
|
21
|
+
DOWNLOAD_PATH = File.join(FinModeling::BASE_PATH, "filings/")
|
|
22
|
+
attr_accessor :instance # FIXME: hide this
|
|
23
|
+
|
|
24
|
+
def initialize(download_dir)
|
|
25
|
+
instance_file = Xbrlware.file_grep(download_dir)["ins"]
|
|
26
|
+
if instance_file.nil?
|
|
27
|
+
raise "Filing (\"#{download_dir}\") has no instance files. No XBRL filing?"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@instance = Xbrlware.ins(instance_file)
|
|
31
|
+
@taxonomy = @instance.taxonomy
|
|
32
|
+
@taxonomy.init_all_lb
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.download(url)
|
|
36
|
+
FileUtils.mkdir_p(DOWNLOAD_PATH) if !File.exists?(DOWNLOAD_PATH)
|
|
37
|
+
download_dir = DOWNLOAD_PATH + url.split("/")[-2]
|
|
38
|
+
if !File.exists?(download_dir)
|
|
39
|
+
dl = Xbrlware::Edgar::HTMLFeedDownloader.new()
|
|
40
|
+
dl.download(url, download_dir)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
return self.new(download_dir)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def print_presentations
|
|
47
|
+
presentations = @taxonomy.prelb.presentation
|
|
48
|
+
presentations.each { |pres| pres.print_tree }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def print_calculations
|
|
52
|
+
calculations=@taxonomy.callb.calculation
|
|
53
|
+
calculations.each { |calc| calc.print_tree }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def disclosures
|
|
57
|
+
@taxonomy.callb
|
|
58
|
+
.calculation
|
|
59
|
+
.select{ |x| x.is_disclosure? }
|
|
60
|
+
.map{ |x| CompanyFilingCalculation.new(x) }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module FinModeling
|
|
2
|
+
class CompanyFilingCalculation
|
|
3
|
+
attr_accessor :calculation # FIXME: get rid of this (it was just to enable testing)
|
|
4
|
+
|
|
5
|
+
def initialize(calculation)
|
|
6
|
+
@calculation = calculation
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def label
|
|
10
|
+
@calculation.label
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def periods
|
|
14
|
+
arr = leaf_items.map{ |x| x.context.period }
|
|
15
|
+
.sort{ |x,y| x.to_pretty_s <=> y.to_pretty_s }
|
|
16
|
+
.uniq
|
|
17
|
+
PeriodArray.new(arr)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def leaf_items(args={})
|
|
21
|
+
@calculation.leaf_items(args[:period])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def leaf_items_sum(args)
|
|
25
|
+
leaves = leaf_items(:period => args[:period])
|
|
26
|
+
values = leaves.map{ |item| item.value(args[:mapping]) }
|
|
27
|
+
values.inject(:+)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def summary(args)
|
|
31
|
+
calc_summary = CalculationSummary.new
|
|
32
|
+
calc_summary.title = case
|
|
33
|
+
when @calculation.instance_variable_defined?(:@title) then @calculation.title
|
|
34
|
+
when @calculation.instance_variable_defined?(:@label) then @calculation.label
|
|
35
|
+
else "[No title]"
|
|
36
|
+
end
|
|
37
|
+
calc_summary.title += case
|
|
38
|
+
when @calculation.instance_variable_defined?(:@item_id) then " (#{@calculation.item_id})"
|
|
39
|
+
when @calculation.instance_variable_defined?(:@role) then " (#{@calculation.role })"
|
|
40
|
+
else ""
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
calc_summary.rows = leaf_items(args).collect do |item|
|
|
44
|
+
CalculationRow.new(:key => item.pretty_name,
|
|
45
|
+
:vals => [ item.value(args[:mapping] )])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
return calc_summary
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def write_constructor(file, item_name)
|
|
52
|
+
item_calc_name = item_name + "_calc"
|
|
53
|
+
@calculation.write_constructor(file, item_calc_name)
|
|
54
|
+
file.puts "#{item_name} = FinModeling::CompanyFilingCalculation.new(#{item_calc_name})"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
protected
|
|
58
|
+
|
|
59
|
+
def find_and_verify_calculation_arc(friendly_goal, label_regexes, id_regexes)
|
|
60
|
+
calc = @calculation.arcs.find{ |x| x.label.downcase.gsub(/[^a-z ]/, '').matches_regexes?(label_regexes) }
|
|
61
|
+
|
|
62
|
+
if calc.nil?
|
|
63
|
+
summary_of_arcs = @calculation.arcs.map{ |x| "\"#{x.label}\"" }.join("; ")
|
|
64
|
+
raise RuntimeError.new("Couldn't find #{friendly_goal} in: " + summary_of_arcs)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if !calc.item_id.matches_regexes?(id_regexes)
|
|
68
|
+
puts "Warning: #{friendly_goal} id is not recognized: #{calc.item_id}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
return calc
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|