@@ -48,8 +48,8 @@ def _calcbench_session():
4848 return session
4949
5050def _rig_for_testing ():
51- _SESSION_STUFF ['api_url_base' ] = 'https://localhost:444 /api/{0}'
52- _SESSION_STUFF ['logon_url' ] = 'https://localhost:444 /account/LogOnAjax'
51+ _SESSION_STUFF ['api_url_base' ] = 'https://localhost/api/{0}'
52+ _SESSION_STUFF ['logon_url' ] = 'https://localhost/account/LogOnAjax'
5353 _SESSION_STUFF ['ssl_verify' ] = False
5454 _SESSION_STUFF ['session' ] = None
5555
@@ -305,7 +305,45 @@ def breakouts_raw(company_identifiers=None, metrics=[], start_year=None,
305305 'periodType' : period_type },
306306 'pageParameters' : {'metrics' : metrics }}
307307 return _json_POST ('breakouts' , payload )
308+
309+ def text_search (company_identifiers = None , full_text_search_term = None ,
310+ year = None , period = 0 , period_type = 'annual' , all_footnotes = False ):
311+ '''
312+ Footnotes and other text
313+
314+ Search for footnotes and other , see https://www.calcbench.com/footnote.
308315
316+ Args:
317+ company_identifiers : list of tickers or CIK codes
318+ start_year: first year of data to get
319+ start_period: first period of data to get. 0 for annual data, 1, 2, 3, 4 for quarterly data.
320+ end_year: last year of data to get
321+ end_period: last period of data to get. 0 for annual data, 1, 2, 3, 4 for quarterly data.
322+ period_type: quarterly or annual, only applicable when other period data not supplied.
323+
324+ Returns:
325+ A list of text documents (footnotes)
326+
327+
328+ '''
329+ if not any ([full_text_search_term , all_footnotes ]):
330+ raise (ValueError ("Need to supply at least one search parameter." ))
331+ if period_type not in ('annual' , 'quarterly' ):
332+ raise (ValueError ("period_type must be in ('annual', 'quarterly'))" ))
333+ payload = {'companiesParameters' : {'entireUniverse' : len (company_identifiers ) == 0 ,
334+ 'companyIdentifiers' : company_identifiers },
335+ 'periodParameters' : {'year' : year ,
336+ 'period' : period ,
337+ 'periodType' : period_type },
338+ 'pageParameters' : {'fullTextQuery' : full_text_search_term ,
339+ 'allFootnotes' : all_footnotes }}
340+ more_results = True
341+ while more_results :
342+ results = _json_POST ('footnoteSearch' , payload )
343+ for result in results ['footnotes' ]:
344+ yield result
345+ payload ['pageParameters' ]['startEntityID' ] = results ['nextGroupStartEntityID' ]
346+ more_results = results ['moreResults' ]
309347
310348def tickers (SIC_codes = [], index = None , company_identifiers = [], entire_universe = False ):
311349 '''Return a list of tickers in the peer-group'''
@@ -368,9 +406,9 @@ def available_metrics():
368406 return r .json ()
369407
370408if __name__ == '__main__' :
371-
372- disclosure_text ( 25975228 )
373- company_disclosures ( ticker = 'msft' )
409+ _rig_for_testing ()
410+ print ( text_search ( company_identifiers = [ 'msft' ], full_text_search_term = 'revenue' , year = 2014 , period = 0 ) )
411+
374412 data = normalized_data (entire_universe = True ,
375413 metrics = ['current_assets' ,
376414 'current_liabilities' ,
0 commit comments