finance

package module
v0.0.0-...-1666625 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

README

Yahoo Finance HTML Scraper

Scrape data for stock symbol and analyze result.

Usage

  • go build cmd/finance-scraper/finance-scraper.go
  • ./finance-scraper -analyzer=asana -symbol=NCNO
  • symbol beeing stock symbol and asana is the only analzyer supported right now

example output:

PE Ratio 0.00 -> ⭕
Enterprise Value 6.28 B < Market Cap 6.50 B -> ✅
Return on Equity -13.74 -> ⭕
Insider Ownership 2.17 -> ⭕

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtWithSuffix

func FmtWithSuffix(value float64, p *message.Printer) string

FmtWithSuffix format big numbers to the following: Thousand, 1 000 -> 1 k Million, 1 000 000 -> 1 M Billion, 1 000 000 000 -> 1 B Trillion, 1 000 000 000 000 -> 1 T

Types

type Analyzer

type Analyzer interface {
	Analyze(quote Quote) (string, error)
}

Analyzer analyzes given quote and returns a result.

func CreateAnalyzer

func CreateAnalyzer(analyzer string) Analyzer

CreateAnalyzer returns an Analyzer for given string. DefaultAnalyzer just prints the result.

type AsanaAnalyzer

type AsanaAnalyzer struct {
}

AsanaAnalyzer analyses quotes and returns the result in copy paste friendly asana ticket format.

func (*AsanaAnalyzer) Analyze

func (aa *AsanaAnalyzer) Analyze(quote Quote) (string, error)

Analyze analyzes quotes with following criteria: P/E Ratio -> if its blank it is not yet profitable. Above 0 -> Green check, otherwise not ok. Enterprise Value < Market Cap = More Cash than Debt -> If so green check, otherwise not ok. Return on Equity -> 20%+ is great, green check. Above 0 ok, below 0 not ok. Held by insiders -> 5 to 40% green check, otherwise not ok.

type DefaultAnalyzer

type DefaultAnalyzer struct {
}

DefaultAnalyzer just prints given quote.

func (*DefaultAnalyzer) Analyze

func (da *DefaultAnalyzer) Analyze(quote Quote) (string, error)

Analyze just formats numbers and prints the quote.

type Quote

type Quote struct {
	PERatio          float64
	EnterpriseValue  float64
	MarketCap        float64
	ReturnOnEquity   float64
	InsiderOwnership float64
}

Quote is the mapped result of ScrapeResult, for calculation purposes.

type ScrapeResult

type ScrapeResult struct {
	PERatio          string
	EnterpriseValue  string
	MarketCap        string
	ReturnOnEquity   string
	InsiderOwnership string
}

ScrapeResult holds the result data from a scraping run.

type Scraper

type Scraper interface {
	Scrape(symbol string) (ScrapeResult, error)
}

Scraper scrapes a data source.

type YahooMapper

type YahooMapper struct {
}

YahooMapper maps ScrapeResult, if its source is also Yahoo finance, to a quote.

func (*YahooMapper) Map

func (ym *YahooMapper) Map(result ScrapeResult) (Quote, error)

Map maps ScrapeResult to a quote.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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