This script needs BeautifulSoup, Pandas, and lxml to run
$ pip install beautifulsoup4
$ pip install pandas
$ pip install lxml
The Behavior of the script is can be broken down into a few parts:
- First fetch the CIK data from the user parameters or from
cik.csv
. If getting fromcik.csv
, pickle the dataframe for faster future queries. - Search the pickled SEC DataFrame based on parameters (cik, start date, end date, position) for
P-Purchase
transactions. If unable to find the data based on parameters, query the SEC Edgar site, adding the pulled data to the pickle. - Return an html table (
--html
) with data found in parameters, an.html
is created. If no data is found, message indicating situation is printed. - Headers can be dynamically sorted. More info about that here
E.G for querying Forward Industries Inc
$ python program.py FORD --html
Full argument parameters listed below
$ python program.py -h
usage: program.py [-h] [-c CIK] [--html] [-p POSITION] [-s [Date]] [-e [Date]]
[--cikpath [Path]]
stock
positional arguments:
stock Stock symbol e.g. AAL, AAPL
optional arguments:
-h, --help show this help message and exit
-c CIK, --cik CIK Company's CIK identifier
--html Return sql to html table.
-p POSITION, --position POSITION
Restrict search by position e.g. CEO
-s [Date], --startdate [Date]
Choose a start date in format YYYY-MM-DD. Default is 1
year prior.
-e [Date], --enddate [Date]
Choose a start date in format YYYY-MM-DD. Default is
today.
--cikpath [Path] Path to cik.csv. Default location is
/.../.../.../.../.../cik.csv
--transaction-type Transaction
Specify what transaction type to parse on. Default is
'P-Purchase'.
--flush Delete preexisting pickle files.