source

package
v0.0.0-...-c2121da Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2018 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

type Source interface {
	// 数据能报保存多长时间(能查到的最早数据距今多长时间)
	Expiration() time.Duration
	// 获取公司每日报价
	Crawl(_market market.Market, company market.Company, date time.Time) (*market.CompanyDailyQuote, error)
	// 最大并发数
	ParallelMax() int
	// 失败重试次数
	RetryCount() int
	// 失败重试时间间隔
	RetryInterval() time.Duration
}

Source 数据源

type YahooFinance

type YahooFinance struct{}

YahooFinance 雅虎财经数据源

func NewYahooFinance

func NewYahooFinance() YahooFinance

NewYahooFinance 新建雅虎财经数据源

func (YahooFinance) Crawl

func (yahoo YahooFinance) Crawl(_market market.Market, company market.Company, date time.Time) (*market.CompanyDailyQuote, error)

Crawl 获取公司每天的报价

func (YahooFinance) Expiration

func (yahoo YahooFinance) Expiration() time.Duration

Expiration 最早能查到60天前的数据

func (YahooFinance) ParallelMax

func (yahoo YahooFinance) ParallelMax() int

ParallelMax 最大并发数

func (YahooFinance) RetryCount

func (yahoo YahooFinance) RetryCount() int

RetryCount 失败重试次数

func (YahooFinance) RetryInterval

func (yahoo YahooFinance) RetryInterval() time.Duration

RetryInterval 失败重试时间间隔

type YahooQuote

type YahooQuote struct {
	Chart struct {
		Result []struct {
			Meta struct {
				Currency             string  `json:"currency"`
				Symbol               string  `json:"symbol"`
				ExchangeName         string  `json:"exchangeName"`
				InstrumentType       string  `json:"instrumentType"`
				FirstTradeDate       int64   `json:"firstTradeDate"`
				GMTOffset            int64   `json:"gmtoffset"`
				Timezone             string  `json:"timezone"`
				PreviousClose        float32 `json:"previousClose"`
				Scale                int     `json:"scale"`
				CurrentTradingPeriod struct {
					Pre struct {
						Timezone  string `json:"timezone"`
						Start     int64  `json:"start"`
						End       int64  `json:"end"`
						GMTOffset int64  `json:"gmtoffset"`
					} `json:"pre"`
					Regular struct {
						Timezone  string `json:"timezone"`
						Start     int64  `json:"start"`
						End       int64  `json:"end"`
						GMTOffset int64  `json:"gmtoffset"`
					} `json:"regular"`
					Post struct {
						Timezone  string `json:"timezone"`
						Start     int64  `json:"start"`
						End       int64  `json:"end"`
						GMTOffset int64  `json:"gmtoffset"`
					} `json:"post"`
				} `json:"currentTradingPeriod"`
				TradingPeriods struct {
					Pres [][]struct {
						Timezone  string `json:"timezone"`
						Start     int64  `json:"start"`
						End       int64  `json:"end"`
						GMTOffset int64  `json:"gmtoffset"`
					} `json:"pre"`
					Regulars [][]struct {
						Timezone  string `json:"timezone"`
						Start     int64  `json:"start"`
						End       int64  `json:"end"`
						GMTOffset int64  `json:"gmtoffset"`
					} `json:"regular"`
					Posts [][]struct {
						Timezone  string `json:"timezone"`
						Start     int64  `json:"start"`
						End       int64  `json:"end"`
						GMTOffset int64  `json:"gmtoffset"`
					} `json:"post"`
				} `json:"tradingPeriods"`
				DataGranularity string   `json:"dataGranularity"`
				ValidRanges     []string `json:"validRanges"`
			} `json:"meta"`
			Timestamp  []int64 `json:"timestamp"`
			Indicators struct {
				Quotes []struct {
					Open   []float32 `json:"open"`
					Close  []float32 `json:"close"`
					High   []float32 `json:"high"`
					Low    []float32 `json:"low"`
					Volume []int64   `json:"volume"`
				} `json:"quote"`
			} `json:"indicators"`
		} `json:"result"`
		Err *struct {
			Code        string `json:"code"`
			Description string `json:"description"`
		} `json:"error"`
	} `json:"chart"`
}

YahooQuote 雅虎财经返回的json

Jump to

Keyboard shortcuts

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