parsers

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: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNDEF uint32 = iota
	SPACE

	// Balance Sheet
	Caixa
	AplicFinanceiras
	Estoque
	Equity
	ContasARecebCirc
	ContasARecebNCirc
	AtivoCirc
	AtivoNCirc
	AtivoTotal
	PassivoCirc
	PassivoNCirc
	PassivoTotal
	DividaCirc
	DividaNCirc
	DividendosJCP
	DividendosMin

	// Income Statement
	Vendas
	CustoVendas
	DespesasOp
	EBIT
	ResulFinanc
	ResulOpDescont
	LucLiq

	// DFC
	FCO
	FCI
	FCF

	// Value Added Statement
	Deprec
	JurosCapProp
	Dividendos

	// Values stored on table 'fre'
	Shares
	FreeFloat

	// Financial ratios
	EstoqueMedio
	EquityAvg

	// Financial scale (unit, thousand)
	Escala

	// Stock quote from last day of year
	Quote
)

Bookkeeping account codes If you add new const values, run 'go generate' to update the generated code

Variables

View Source
var (
	ErrDBUnset  = errors.New("database not set")
	ErrNotFound = errors.New("not found")
)

Error codes

View Source
var (
	// ErrAccumITR error for accumulatd quarterly results
	ErrAccumITR = fmt.Errorf("accumulated quarterly results")
)
View Source
var (
	// ErrCNPJNotFound error
	ErrCNPJNotFound = fmt.Errorf("CNPJ not found")
)

Functions

func FromSector added in v0.8.1

func FromSector(company, yamlFile string) (companies []string, sectorName string, err error)

FromSector returns all companies from the same sector as the 'company'

func FuzzyFind added in v0.8.1

func FuzzyFind(source string, targets []string, maxDistance int) (found string)

FuzzyFind returns the most approximate string inside 'list' that matches the 'src' string within a maximum 'distance'.

func FuzzyMatch added in v0.8.1

func FuzzyMatch(src string, list []string, distance int) bool

FuzzyMatch measures the Levenshtein distance between the source and the list, returning true if the distance is less or equal the 'distance'. Diacritics are removed from 'src' and 'list'.

func Hash added in v0.10.0

func Hash(s string) uint32

Hash returns the FNV-1 non-cryptographic hash

func ImportCsv added in v0.9.0

func ImportCsv(db *sql.DB, dataType string, file string) (err error)

ImportCsv start the data import process, including the database creation if necessary

func RemoveDiacritics added in v0.8.1

func RemoveDiacritics(original string) (result string)

RemoveDiacritics transforms, for example, "žůžo" into "zuzo"

func SectorsToYaml added in v0.8.1

func SectorsToYaml(yamlFile string) (err error)

SectorsToYaml grab data from B3 website and prints out to a yaml file with all companies grouped by sector, subsector, segment

Types

type FIIParser added in v1.0.0

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

FIIParser implements sqlite storage for a rapina.FIIParser object.

func NewFII added in v1.0.0

func NewFII(db *sql.DB, log rapina.Logger) (*FIIParser, error)

NewFII creates a new instace of FII.

func (*FIIParser) Details added in v1.0.0

func (fii *FIIParser) Details(code string) (*rapina.FIIDetails, error)

Details returns the FII Details for the 'code' or an empty string if not found in the db.

func (*FIIParser) Dividends added in v1.0.0

func (fii *FIIParser) Dividends(code, monthYear string) (*[]rapina.Dividend, error)

Dividends returns the dividend from the db.

func (*FIIParser) SaveDetails added in v1.1.0

func (fii *FIIParser) SaveDetails(stream []byte) error

StoreFIIDetails parses the stream data into FIIDetails and returns the *FIIDetails.

func (*FIIParser) SaveDividend added in v1.0.0

func (fii *FIIParser) SaveDividend(stream map[string]string) (*rapina.Dividend, error)

SaveDividend parses and stores the map in the db. Returns the parsed stream.

func (*FIIParser) SelectFIIDetails added in v1.0.0

func (fii *FIIParser) SelectFIIDetails(code string) (*rapina.FIIDetails, error)

type S added in v0.8.1

type S struct {
	Sectors []Sector `yaml:"Setores"`
}

S contains the sectors

type Sector added in v0.8.1

type Sector struct {
	Name       string      `yaml:"Setor"`
	Subsectors []Subsector `yaml:"Subsetores"`
}

Sector is divided into subsectors

type Segment added in v0.8.1

type Segment struct {
	Name      string   `yaml:"Segmento"`
	Companies []string `yaml:"Empresas"`
}

Segment contains companies from the same sector/subsector/segment

type StockParser added in v1.0.0

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

func NewStock added in v1.0.0

func NewStock(db *sql.DB, log rapina.Logger) (*StockParser, error)

NewStock creates the required tables, if necessary, and returns a StockParser instance.

func (*StockParser) Code added in v1.1.0

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

Quote returns the company ON stock code, where stockType is: ON, PN, UNT, CI [CI = FII]

func (*StockParser) Quote added in v1.0.0

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

Quote returns the quote from DB.

func (*StockParser) Save added in v1.0.0

func (s *StockParser) Save(stream io.Reader, code string) (int, error)

Save parses the 'stream', get the 'code' stock quotes and store it on 'db'. Returns the number of registers saved.

func (*StockParser) SaveB3Quotes added in v1.0.0

func (s *StockParser) SaveB3Quotes(filename string) error

type Subsector added in v0.8.1

type Subsector struct {
	Name     string    `yaml:"Subsetor"`
	Segments []Segment `yaml:"Segmentos"`
}

Subsector is divided into segments

Jump to

Keyboard shortcuts

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