Documentation ¶
Overview ¶
Example (GenerateURLs) ¶
urls, urlSymbolMap := GenerateURLs(testSymbols, testURL) for _, url := range urls { fmt.Printf("%s\n", url) } fmt.Printf("urlSymbolMap: %+v", urlSymbolMap)
Output: https://query1.finance.yahoo.com/v7/finance/download/dia?period1=631152000&period2=1672531200&interval=1d&events=history&includeAdjustedClose=true https://query1.finance.yahoo.com/v7/finance/download/qqq?period1=631152000&period2=1672531200&interval=1d&events=history&includeAdjustedClose=true urlSymbolMap: map[https://query1.finance.yahoo.com/v7/finance/download/dia:dia https://query1.finance.yahoo.com/v7/finance/download/qqq:qqq]
Index ¶
- Constants
- Variables
- func BaseURL(url string) string
- func GenerateURLs(symbols []string, url string) (urls []string, urlSymbolMap map[string]string)
- func Init(appNameInit string)
- func LoadURLCollectionDataFromFile(dataFilePath string) (urlData []httph.URLCollectionData, err error)
- func StringRecordToFloat64Record(record []string, skipIndices []int, symbol string) (out []float64, nulls int, err error)
- func URLCollectionDataDateOrder(records [][]string, urlCollectionDataHeaderIndicesMap map[string]int) (orderAsc bool, dateFirst time.Time, dateLast time.Time)
- type Data
- type DatasetAsColumns
- type Downloader
- type Group
- type Issue
- type URLCollectionDataToGroup
Examples ¶
Constants ¶
View Source
const ( BinaryExtension = ".bin" CSVExtension = ".csv" DateFormat = "2006-01-02" // Floats are rounded to this number of decimal points. Yahoo will slightly alter some values // with each call, but only at very high numbers of decimal places. That makes debugging // difficult. InputPrecision = 4 // err on the side of caution; if yahoo sees to much traffic from the same user, it may block. Threads = 1 )
Variables ¶
Functions ¶
func BaseURL ¶
Example ¶
urls, _ := GenerateURLs([]string{"qqq"}, testURL) fmt.Printf("%s\n", urls[0]) fmt.Printf("%s\n", BaseURL(urls[0]))
Output: https://query1.finance.yahoo.com/v7/finance/download/qqq?period1=631152000&period2=1672531200&interval=1d&events=history&includeAdjustedClose=true https://query1.finance.yahoo.com/v7/finance/download/qqq
func GenerateURLs ¶
GenerateURLs generates URLs for the symbols as well as a symbol to URL map for use with data returned from collectGroup
func LoadURLCollectionDataFromFile ¶
func LoadURLCollectionDataFromFile(dataFilePath string) (urlData []httph.URLCollectionData, err error)
Types ¶
type Data ¶
type Data struct { Date time.Time Open float64 High float64 Low float64 Close float64 Volume float64 AdjOpen float64 AdjHigh float64 AdjLow float64 AdjClose float64 AdjVolume float64 }
Data is used to Unmarshal data. This structure must match the JSON returned from finance.yahoo. Returned data is always sorted in Date ascending order.
type DatasetAsColumns ¶
type DatasetAsColumns struct { Date []time.Time Open []float64 High []float64 Low []float64 Close []float64 Volume []float64 AdjOpen []float64 AdjHigh []float64 AdjLow []float64 AdjClose []float64 AdjVolume []float64 }
func (DatasetAsColumns) String ¶
func (dac DatasetAsColumns) String() string
type Downloader ¶
type Group ¶
Group is a collection of Issues (stocks, ETFs, etc.)
func NewGroup ¶
func NewGroup(liveData bool, dataFilePath string, name string, symbols []string, url string, callbackURLCollectionDataToGroup URLCollectionDataToGroup) (*Group, error)
NewGroup is a factory for Group. liveData == true, data is downloaded from Yahoo; otherwise it is loaded from a file saved from the prior call.
type Issue ¶
type Issue struct { Symbol string URL string // Dataset is row based data, as source data is row based. Dataset []Data // DatasetAsColumns is column based data as that is sometimes easier to work with. DatasetAsColumns DatasetAsColumns }
Issue is an item for which Data is collected. I.E. a stock, ETF, etc.
func (Issue) ToDatasetAsColumns ¶
func (iss Issue) ToDatasetAsColumns() DatasetAsColumns
ToDatasetAsColumns converts an issue from a row format to column format
Click to show internal directories.
Click to hide internal directories.