stocker

package
v0.0.0-...-27a0eab Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TWSE_url = "https://isin.twse.com.tw/isin/C_public.jsp?strMode=2"
	TPEx_url = "https://isin.twse.com.tw/isin/C_public.jsp?strMode=4"
)

Variables

This section is empty.

Functions

func DecodeBig5

func DecodeBig5(s []byte) ([]byte, error)

DecodeBig5 convert BIG5 to UTF-8

Types

type Alphavantage

type Alphavantage struct {
	Service *alphavantage.Service
	// contains filtered or unexported fields
}

Alphavantage stocker

func NewAlphavantage

func NewAlphavantage(apikey string) (*Alphavantage, error)

NewAlphavantage 建立 alphavantage Service

func (*Alphavantage) PriceAdjHistory

func (av *Alphavantage) PriceAdjHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceAdjHistory 得到股票歷史 Adj 價格

func (*Alphavantage) PriceHistory

func (av *Alphavantage) PriceHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceHistory 得到股票歷史價格

func (*Alphavantage) Quote

func (av *Alphavantage) Quote(ctx context.Context, symbol string) (float64, error)

Quote 得到股票價格

type DatePrice

type DatePrice struct {
	Date     Time    `json:"Date"`
	Open     float64 `json:"Open"`
	High     float64 `json:"High"`
	Low      float64 `json:"Low"`
	Close    float64 `json:"Close"`
	CloseAdj float64 `json:"CloseAdj"`
	Volume   float64 `json:"Volume"`
}

DatePrice price with date

type ErrorFatal

type ErrorFatal struct {
	Message string
}

ErrorFatal fatal error

func (ErrorFatal) Error

func (e ErrorFatal) Error() string

type ErrorNoFound

type ErrorNoFound struct {
	Message string
}

ErrorNoFound no found

func (ErrorNoFound) Error

func (e ErrorNoFound) Error() string

type ErrorNoSupport

type ErrorNoSupport struct {
	Message string
}

ErrorNoSupport no support

func (ErrorNoSupport) Error

func (e ErrorNoSupport) Error() string

type Stocker

type Stocker interface {
	// 得到股票價格
	Quote(ctx context.Context, symbol string) (float64, error)
	// 得到股票歷史價格
	PriceHistory(ctx context.Context, symbol string) ([]*DatePrice, error)
	// 得到股票歷史 Adj 價格
	PriceAdjHistory(ctx context.Context, symbol string) ([]*DatePrice, error)
}

Stocker get stock infomation

type TDAmeritrade

type TDAmeritrade struct {
	Service *gotd.Service
}

TDAmeritrade stocker

func NewTDAmeritrade

func NewTDAmeritrade(clientsecretPath, tokenFile string) (*TDAmeritrade, error)

NewTDAmeritrade 建立 gotd Service

func NewTDAmeritradeTLS

func NewTDAmeritradeTLS(clientsecretPath, tokenFile, TLSCertPath, TLSKeyPath string) (*TDAmeritrade, error)

NewTDAmeritradeTLS 建立 gotd Service

func (*TDAmeritrade) PriceAdjHistory

func (td *TDAmeritrade) PriceAdjHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceAdjHistory 得到股票歷史 Adj 價格

func (*TDAmeritrade) PriceHistory

func (td *TDAmeritrade) PriceHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceHistory 得到股票歷史價格

func (*TDAmeritrade) Quote

func (td *TDAmeritrade) Quote(ctx context.Context, symbol string) (float64, error)

Quote 得到股票價格

type TWSE

type TWSE struct {
	Service *twse.Service
	// contains filtered or unexported fields
}

TWSE stocker

func NewTWSE

func NewTWSE(csvFolderPath string) (*TWSE, error)

NewTWSE 建立 twse Service

func (*TWSE) PriceAdjHistory

func (t *TWSE) PriceAdjHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceAdjHistory 得到股票歷史 Adj 價格

func (*TWSE) PriceHistory

func (t *TWSE) PriceHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceHistory 得到股票歷史價格

func (*TWSE) Quote

func (t *TWSE) Quote(ctx context.Context, symbol string) (float64, error)

Quote 得到股票價格

type Time

type Time time.Time

Time redefine time.Time for JSON

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON 輸出 json string 格式,兩邊加上雙引號

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON 輸入 json string 格式,兩邊有雙引號

type YahooFinance

type YahooFinance struct {
	Service *yfinance.Service
}

YahooFinance stocker

func NewYahooFinance

func NewYahooFinance() (*YahooFinance, error)

NewYahooFinance 建立 yahoofinance Service

func (*YahooFinance) PriceAdjHistory

func (yf *YahooFinance) PriceAdjHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceAdjHistory 得到股票歷史 Adj 價格

func (*YahooFinance) PriceHistory

func (yf *YahooFinance) PriceHistory(ctx context.Context, symbol string) ([]*DatePrice, error)

PriceHistory 得到股票歷史價格

func (*YahooFinance) Quote

func (yf *YahooFinance) Quote(ctx context.Context, symbol string) (float64, error)

Quote 得到股票價格

Jump to

Keyboard shortcuts

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