edgar

package module
v0.0.0-...-9e6dc22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2019 License: Apache-2.0 Imports: 16 Imported by: 1

README

Edgar

A crawler to get company filing data from XBRL filings. The fetcher parses through the HTML pages and extracts data based on the XBRL tags that it finds and collects it into filing data arranged by filing date.

Goals

The primary requirement of any stock analysis is the data that the comapny files with the SEC. The filings, starting from 2010-11 required to be done using XBRL tags which required the filer to tag each data point with a tag. This made identifying and classifying the data a lot easier for machines.

The goal of this package is to get publically available filings on sec.gov and parse the filings to get data origanized into queriable data points. This package is being ddeveloped with the goal to provide an interface for other packages to get filing data for a company and use that data to create insights such as valuations and trends.

Design

The package is primarily organized as multiple interfaces into the provided functionality. The user is expected to make use of these interfaces to gather the data and query it as needed

Interfaces

All interfaces needed to use this package is defined in edgar.go and described below.

FilingFetcher

This is the starting point for use of this package. The package is initialized with a fetcher. The user will use the fetcher interface to provide a ticker and filing type to startup a company folder. The user has an additional API in the interface to initialize a company folder with a saved folder.

CompanyFolder

A user will be given a company folder with the filings (retrieved ones) for every company (ticker). The user uses the folder to get any filing information related to that company. The filings are indexed internally based on filing type and the date of filing. When a user of the package requests a filing, the filing is looked up in the cache and if not available, will be retrieved from edgar and populated into the folder.

Filing

Filing is an interface to get filing data related to a specific filing. The user uses this interface to extract required data. The Filing is retrieved from the company folder as needed. An error is returned if the data was unavailable.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompanyFolder

type CompanyFolder interface {

	// Ticker gets the ticker of this company
	Ticker() string

	// CIK gets the CIK assigned to the company
	CIK() string

	// AvailableFilings gets the list of dates of available filings
	AvailableFilings(FilingType) []time.Time

	// Filing gets a filing given a filing type and date of filing.
	Filing(FilingType, time.Time) (Filing, error)

	// Filings gets a list of filings. Parallel fetch.
	Filings(FilingType, ...time.Time) ([]Filing, error)

	// SaveFolder persists the data from the company folder into a writer
	// provided by the user. This stored info can be presented back to
	// the fetcher (using CreateFolder API in fetcher) to recreate the
	// company folder with already parsed data
	SaveFolder(w io.Writer) error

	// String is a dump routine to view the contents of the folder
	String() string
}

CompanyFolder interface used to get filing information about a company

type Filing

type Filing interface {
	Ticker() string
	FiledOn() time.Time
	Type() (FilingType, error)
	ShareCount() (float64, error)
	Revenue() (float64, error)
	CostOfRevenue() (float64, error)
	GrossMargin() (float64, error)
	OperatingIncome() (float64, error)
	OperatingExpense() (float64, error)
	NetIncome() (float64, error)
	TotalEquity() (float64, error)
	ShortTermDebt() (float64, error)
	LongTermDebt() (float64, error)
	CurrentLiabilities() (float64, error)
	CurrentAssets() (float64, error)
	DeferredRevenue() (float64, error)
	RetainedEarnings() (float64, error)
	OperatingCashFlow() (float64, error)
	CapitalExpenditure() (float64, error)
	Dividend() (float64, error)
	WAShares() (float64, error)
	DividendPerShare() (float64, error)
	Interest() (float64, error)
	Cash() (float64, error)
	Securities() (float64, error)
	Goodwill() (float64, error)
	Intangibles() (float64, error)
	Assets() (float64, error)
	Liabilities() (float64, error)
	CollectedData() []string
}

Filing interface for fetching financial data from a collected filing

type FilingFetcher

type FilingFetcher interface {

	// CompanyFolder creates a folder for the company with a list of
	// available filings. No financial data is pulled and the user
	// of the interface can selectively pull financial data into the
	// folder using the CompanyFolder interface
	CompanyFolder(string, ...FilingType) (CompanyFolder, error)

	// CreateFolder creates a company folder using a Reader
	// User can provoder a store of edgar data previous stored
	// by this package (using the Store function of the Company Folder)
	// This function is used to avoid reparsing edgar data and reusing
	// already parsed and stored information.
	CreateFolder(io.Reader, ...FilingType) (CompanyFolder, error)
}

FilingFetcher fetches the filing requested

func NewFilingFetcher

func NewFilingFetcher() FilingFetcher

NewFilingFetcher creates a new empty filing fetcher

type FilingType

type FilingType string

FilingType is the type definition of various filing types

const FilingType10K FilingType = "10-K"

FilingType10K is a 10-K annual filing of a company with the SEC

const FilingType10Q FilingType = "10-Q"

FilingType10Q is a 10-Q quarterly filing of a company with the SEC

type Timestamp

type Timestamp time.Time

Timestamp is the edgar package representation of time.Time

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON marshals Timestamp in a specific format for JSON marsahlling

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals Timestamp in a specific format for JSON unmarshal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL