fetch

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APInone = iota
	APIalphavantage
	APIyahoo
)

API providers

Variables

View Source
var (
	// ErrFileNotFound error
	ErrFileNotFound = errors.New("file not found")
	// ErrItemNotFound for string not found on []string
	ErrItemNotFound = errors.New("item not found")
)

Functions

func CVM

func CVM(db *sql.DB, dataDir string) error

CVM fetches all statements from a range of years

func Sectors

func Sectors(yamlFile string) (err error)

Sectors checks if the configuration file is already populated. If 'force' is set or if the config is empty, it retrieves data from B3, unzip and extract a spreadsheet containing a list of companies divided by sector, subsector, and segment; then this info is set into the config file.

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2). Source: https://golangcode.com/unzip-files-in-go/

Types

type FII

type FII struct {
	// contains filtered or unexported fields
}

FII holds the infrastructure data.

func NewFII

func NewFII(parser rapina.FIIParser, log rapina.Logger) *FII

NewFII creates a new instace of FII.

func (*FII) Details

func (fii *FII) Details(fiiCode string) (*rapina.FIIDetails, error)

Details returns the FII Details from DB. If not found: fetches from server, stores it in the DB and returns the Details.

func (FII) Dividends

func (fii FII) Dividends(code string, n int) (*[]rapina.Dividend, error)

Dividends gets the report IDs for one company ('cnpj') and then the yeld montlhy report for 'n' months, starting from the latest released.

type HTTPFetch

type HTTPFetch struct {
	// contains filtered or unexported fields
}

HTTPFetch implements a generic HTTP fetcher.

func NewHTTP

func NewHTTP() *HTTPFetch

NewHTTP creates a new HTTPFetch instance.

func (HTTPFetch) JSON

func (h HTTPFetch) JSON(url string, target interface{}) error

JSON handles json responses.

type Report

type Report struct {
	Data []docID `json:"data"`
}

Report holds the result of all documents filtered by a criteria defined by a http.Get on the B3 server.

type StockFetch

type StockFetch struct {
	// contains filtered or unexported fields
}

StockFetch implements a fetcher stock quotes.

func NewStock

func NewStock(store rapina.StockParser, log rapina.Logger, apiKey, dataDir string) *StockFetch

NewStock returns a new instance of *StockServer

func (StockFetch) Quote

func (s StockFetch) Quote(code, date string) (float64, error)

Quote returns the quote for 'code' on 'date'. Date format: YYYY-MM-DD.

type WriteCounter

type WriteCounter struct {
	Total uint64
}

WriteCounter counts the number of bytes written the io.Writer. source: https://golangcode.com/download-a-file-with-progress/

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Write implements the io.Writer interface and will be passed to io.TeeReader().

Jump to

Keyboard shortcuts

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