def test_get_cik_map_bad_keys(self, key): with pytest.raises(ValueError): get_cik_map(key=key)
def test_get_company_name_map(self, name, cik, monkeypatch): monkeypatch.setattr(requests, 'get', MockCIKMapResponse) name_map = get_cik_map(key="title") assert name_map[name] == cik
def test_get_cik_map(self, ticker, cik, monkeypatch): monkeypatch.setattr(requests, 'get', MockCIKMapResponse) cik_map = get_cik_map() assert cik_map[ticker] == cik
from secedgar.utils import get_cik_map from secedgar.filings import Filing, FilingType print(list(get_cik_map().items())[:5]) my_filings = Filing(cik_lookup='aapl', filing_type=FilingType.FILING_10Q, count=1) my_filings.save('/home/sroot/kaizha/temp')
from secedgar.filings import Filing, FilingType from secedgar.utils import get_cik_map import pandas as pd import os path = 'E:\stockdata3' df = pd.DataFrame() map = get_cik_map() map2 = get_cik_map(key='title') keys = list(map.keys()) values = list(map.values()) keys2 = list(map2.keys()) values2 = list(map2.values()) tv = values + values2 fullciks = list(sorted(list(set(tv)))) fulltitles = [] fulltickers = [] for vi in fullciks: if vi in values: tidx = values.index(vi) ticker = keys[tidx] fulltickers.append(ticker) else: fulltickers.append('') if vi in values2: tkidx = values2.index(vi) title = keys2[tkidx] fulltitles.append(title) else: fulltitles.append('')
from datetime import datetime #my_filings = Filing(cik_lookup='aapl', # filing_type=FilingType.FILING_10Q, # count=15) #my_filings.save('C:\\Users\\happy\\OneDrive - California Institute of Technology\\Desktop\\SEC files') #lookups = CIKLookup(['aapl', 'MSFT', 'faceBook']) #print(lookups.lookup_dict) a=get_cik_map(key='title') def get_most_recent_10_K(firms, fp): for firm in firms: my_filings = Filing(cik_lookup=firm, filing_type=FilingType.FILING_10K, count=1) my_filings.save(fp) return #####get INTC and GOOG for now firms = ['GOOG', 'INTC'] fp = 'C:\\Users\\happy\\OneDrive - California Institute of Technology\\Desktop\\SEC files' get_most_recent_10_K(firms, fp)