Giter Site home page Giter Site logo

sec-client's Introduction

SEC Client

This is an unofficial client for accessing the filing APIs that the Securities and Exchange Commision provides.

NOTE: This is a work in progress and is subject to change.

Installation

go get github.com/pixelguy95/sec

Built using golang version 1.18

Usage

Create a new client instance using sec.NewClient(), then use the client to access the ticker and filing data. Below is an example where all Non-current liabilities (See US-GAAP, and XBRL) are fetched for Apple Inc.

secClient := sec.NewClient()

appleTicker, err := secClient.GetTickerForSymbol("AAPL")
if err != nil {
    panic(err)
}

appleFacts, err := secClient.GetAllFactsForTicker(appleTicker)
if err != nil {
    panic(err)
}

nonCurrentLiabilities := appleFacts.Facts.UsGAAP["LiabilitiesNoncurrent"].Units["USD"]
for _, unit := range nonCurrentLiabilities {
    fmt.Printf("Non-current liabilities @ %s: %12.2f$\n", unit.End, unit.Value)
}
...
Non-current liabilities @ 2020-09-26: 153157000000.00$
Non-current liabilities @ 2020-12-26: 155323000000.00$
Non-current liabilities @ 2021-03-27: 161595000000.00$
Non-current liabilities @ 2021-06-26: 157806000000.00$
Non-current liabilities @ 2021-09-25: 162431000000.00$
Non-current liabilities @ 2021-12-25: 161685000000.00$
Non-current liabilities @ 2022-03-26: 155755000000.00$
...

To get a list of all possible tickers use secClient.GetAllTickers()

Persistence layer

This client intends to follow the compliance guidance set by SEC (See next section). One of the more significant limits set, is the limit to the number of data requests you can do per second. To mitigate this the client supports a persistence layer that will be hit first before going to the actual source.

You can create your own persistence layer using the simple interface provided

type PersistenceLayer interface {
    SaveFacts(Ticker, *CompanyFacts) error
    LoadFacts(Ticker) (*CompanyFacts, error)
}

The default behaviour of sec.NewClient() is to always go to the source (SEC). To create a client with persistence use sec.NewClientWithPersistence()

A basic persistence layer using bbolt is provided out of the box. For example:

persistenceLayerConfig := BoltPersistenceLayerConfig{Path: tempFile.Name(), ExpiresAfter: time.Hour}
bolt, err = NewBoltPersistenceLayer(persistenceLayerConfig)
if err != nil {
    panic(err)
}

clientWithPersistenceLayer := sec.NewClientWithPersistence(bolt)

Bulk data

Getting filing data from all companies individually would be very time consuming with the rate limit set by SEC. Becasue of that a bulk function is provided that gets fetches ALL company data in one go. client.GetBulk() returns a channel that will eventually contain all the data.

The latency and throughput of the bulk function is highly bandwidth and processing speed dependent. You can expect that it will take ~1 minute or so before the first ticker fact pair appears on the channel.

client := NewClient()
factChannel, err := client.GetBulk()
if err != nil {
    panic(err)
}

for tickerFact := range factChannel {
    fmt.Println(tickerFact)
}

Compliance

Coming soon

sec-client's People

Contributors

pixelguy95 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.