Skip to main content

No project description provided

Project description

secapi

This module provides a set of functions that can be used to query company submissions from the sec. As well as some utility functions that can be used to get sec related information about companies.

Technical information

The module was developed with python 2.7.18 and only uses build-in python packages as well as the packages typing, requests, ratelimiter and OpenDateRange.

Installation

$ pip install secapi-tl

core functions

sec_request

The sec_request method is used to make requests to the sec. It has a rate limit mechanism implemented that ensures that the amount of requests stays in the boundaries set by the sec. All methods from this module use this method internally for their requests. Thereby your own requests to the sec will be compatible if you use this method. Furthermore, the sec_request method will automatically create a header with a valid User-Agent. You can also pass your own header to the method. If this header does not contain a User-Agent, the method will add a valid User-Agent to the header.

from secapi_tl import sec_request

raw_data = sec_request(url="https://www.sec.gov/Archives/edgar/data/320193/000032019323000070/xslF345X04/wf-form4_168444912415136.xml")

get_submissions

The get_submissions function queries company submissions via the data.sec.gov/submissions/ endpoint as recommended here. The method takes parameters that can be used to filter the queried submissions. A query accepts the following parameters:

  • ticker_symbol_or_cik: The ticker symbol or cik of the company you want to query submissions for. Takes lowercase and uppercase letters for ticker symbols. Ciks must be passed as strings but leading zeros are not required.
  • start_date: Only submissions that have been published at or after this date will be queried. The date must be passed as a string of format YYYY-MM-DD.
  • end_date: Only submissions that have been published at or before this date will be queried. The date must be passed as a string of format YYYY-MM-DD.
  • form_type: Only submissions that have one of the specified form types will be queried. You can pass a form type as a string or a list of form types as a list of strings.

The method returns a list of Submission objects. Each submission object holds the data for one submission. The data can be accessed via properties of the object.

from secapi_tl import get_submissions

# query form 4 submissions for apple in january 2021
submissions = get_submissions(
    ticker_symbol_or_cik="AAPL",
    start_date="2021-01-01",
    end_date="2021-01-31",
    form_type="4"
)

!!! WARNING !!! Since the data.sec.gov/submissions/ endpoint is constantly under a high load, it can happen that a TooManyRequestsError is raised. Since the method does use the sec_request method there is no violation of the rate limit. Requests to other endpoints will therefore still work. The occurrence of this error is highly dependent on the usage of this method. So you might need to implement a mechanism that handles this error depending on your use case. The TooManyRequests error is part of this module and can be imported from the module.

from secapi_tl import TooManyRequestsError

utility functions

Most of the utility functions are based on the company tickers file. They use this file for transitions between cik and ticker symbol or to proof if a ticker symbol is registered at the sec or not.

is_registered

This method takes a ticker symbol and returns True if the ticker symbol is registered at the sec and False if it is not registered. If the method returns True the ticker symbol can be used with all other methods of this module. The ticker symbol can be uppercase and lowercase. The method will automatically convert the ticker symbol to uppercase letters.

from secapi_tl import is_registered

is_registered("AAPL") # True
is_registered("aapl") # True
is_registered("AAP") # False

ticker_to_cik

This method takes a ticker symbol and returns the cik of the company to which the ticker symbol belongs. If the ticker symbol is not found a ValueError is raised. The ticker symbol can be uppercase and lowercase. The method will automatically convert the ticker symbol to uppercase letters.

from secapi_tl import ticker_to_cik

ticker_to_cik("AAPL") # "320193"

filter_tickers_registered

Takes a list of ticker symbols and returns a list of those ticker symbols that are found to be registered at the sec. The ticker symbols can be uppercase and lowercase. The returned ticker symbols are uppercase.

from secapi_tl import filter_tickers_registered

filter_tickers_registered(["AAPL", "TSLA", "AAP"]) # ["AAPL", "TSLA"]

This method is useful if you want to query submissions for a list of companies and you dont know if all of the companies are registered at the sec. All the returned ticker symbols will work with the get_submissions method.

get_registered_tickers

Returns a list of all ticker symbols that are found in the company tickers file.

get_registered_ciks

Returns a list of all ciks that are found in the company tickers file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secapi-tl-1.2.3.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secapi_tl-1.2.3-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file secapi-tl-1.2.3.tar.gz.

File metadata

  • Download URL: secapi-tl-1.2.3.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for secapi-tl-1.2.3.tar.gz
Algorithm Hash digest
SHA256 1073d711213a5cbe255f3eed688dea134261e1a40a4c68cba5be2ad22701582b
MD5 2d08d597cc23b3d9b9f7b885ca5f85f4
BLAKE2b-256 4ecddefff189ded63c7d701a8bc12504e85d53fe817cb3915b397fb40600a7c5

See more details on using hashes here.

File details

Details for the file secapi_tl-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: secapi_tl-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for secapi_tl-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2bdd8634fc65f05b0c694bfa59a1dfc1f97e836b8fc016dd1af429444ccd0c03
MD5 468464a236e9da0c2e2c9c3ba64756eb
BLAKE2b-256 932aa99be0b1d0e188e999f4802474c0d467a1011bcdcb6cfe58e5af9eb90433

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page