yf

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

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

Go to latest
Published: Oct 28, 2017 License: MIT Imports: 5 Imported by: 1

README

go-yf

go-yf is a small wrapper around the Yahoo Finance v8 API written in Go.

The Yahoo Finance API is known to be unstable with breaking changes introduced without notice, and is not officially supported for external use, so use at your own risk.

Installation

$ go get github.com/KyleBanks/go-yf

Usage

The library exposes a single GetStock function that accepts a stock symbol, range, and interval:

import (
	"fmt"
	"yf"
)

stock, err := yf.GetStock("GOOG", yf.RangeOneYear, yf.IntervalOneDay)
if err != nil {
	panic(err)
}

fmt.Printf("%v: %v", stock.Meta.Symbol, stock.Indicators.Quote[0].Close)

License

MIT License

Copyright (c) 2017 Kyle Banks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Documentation

Index

Constants

View Source
const (
	IntervalOneMinute      = "1m"
	IntervalTwoMinutes     = "2m"
	IntervalFiveMinutes    = "5m"
	IntervalFifteenMinutes = "15m"
	IntervalThirtyMinutes  = "30m"
	IntervalSixtyMinutes   = "60m"
	IntervalNintyMinutes   = "90m"
	IntervalOneHour        = "1h"
	IntervalOneDay         = "1d"
	IntervalFiveDays       = "5d"
	IntervalOneWeek        = "1w"
	IntervalOneMonth       = "1mo"
	IntervalThreeMonths    = "3mo"
)
View Source
const (
	RangeOneDay      = "1d"
	RangeFiveDays    = "5d"
	RangeOneMonth    = "1mo"
	RangeThreeMonths = "3mo"
	RangeSixMonths   = "6mo"
	RangeOneYear     = "1y"
	RangeTwoYears    = "2y"
	RangeFiveYears   = "5y"
	RangeTenYears    = "10y"
	RangeYTD         = "ytd"
	RangeMax         = "max"
)

Variables

View Source
var (
	// DebugLogging enables verbose output from the yf package when set to true.
	DebugLogging = false
)

Functions

This section is empty.

Types

type Stock

type Stock struct {
	Meta struct {
		Currency             string
		Symbol               string
		ExchangeName         string
		InstrumentType       string
		FirstTradeDate       int64
		GmtOffset            int64 `json:"gmtoffset"`
		Timezone             string
		ExchangeTimezoneName string
		CurrentTradingPeriod struct {
			Pre     TradingPeriod
			Regular TradingPeriod
			Post    TradingPeriod
		}
		DataGranularity string
		ValidRanges     []string
	}
	Timestamp  []int64
	Indicators struct {
		Quote []struct {
			Low    []float64
			Volume []float64
			High   []float64
			Open   []float64
			Close  []float64
		}
		Unadjclose []struct {
			Unadjclose []float64
		}
		Adjclose []struct {
			Adjclose []float64
		}
	}
}

func GetStock

func GetStock(symbol, dateRange, interval string) (*Stock, error)

GetStock returns stock details for a particular symbol from the Yahoo Finance API.

type TradingPeriod

type TradingPeriod struct {
	Timezone  string
	End       int64
	Start     int64
	GmtOffset int64 `json:"gmtoffset"`
}

Jump to

Keyboard shortcuts

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