fetch

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APInone = iota
	APIalphavantage
	APIyahoo
)

API providers

View Source
const MAX_N = 200

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, verbose bool) ([]string, error)

UnzipVerbosity 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(db *sql.DB, log rapina.Logger) (*FII, error)

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.

func (*FII) MonthlyReportIDs added in v1.1.0

func (fii *FII) MonthlyReportIDs(code string, n int) ([]id, error)

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 Stock added in v1.1.0

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

Stock implements a fetcher for stock info.

func NewStock

func NewStock(db *sql.DB, log rapina.Logger, apiKey, dataDir string) (*Stock, error)

NewStock returns a new instance of *Stock

func (*Stock) Code added in v1.1.0

func (s *Stock) Code(companyName, stockType string) (string, error)

func (*Stock) Quote added in v1.1.0

func (s *Stock) Quote(code, date string) (float64, error)

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

func (*Stock) UpdateStockCodes added in v1.1.0

func (s *Stock) UpdateStockCodes() error

UpdateStockCodes get the most recent file from B3.com.br with the stock trading code and saves them on the storage.

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