quote

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 20 Imported by: 49 modules, 62 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-quote

GoDoc

A free quote downloader library and cli

Downloads daily historical price quotes from Tiingo and daily/intraday data from various api's. Written in pure Go. No external dependencies. Now downloads crypto coin historical data from various exchanges.

  • Update: 08/19/2026 - Added Binance symbol lists: binance-usdt, binance-usdc, binance-btc, binance-eth. market.go is now a table rather than a switch plus a dispatch chain, so market lists are testable and a market can no longer be listed as valid without a way to fetch it. ValidMarkets is deprecated in favor of Markets()

  • Update: 08/19/2026 - Added Binance support (-source=binance), restoring the source removed in 2024. Uses data-api.binance.vision, which needs no API key and is not geo-restricted; api.binance.com returns 451 outside eligible regions. Supports every period the package defines, including 3d, which no other source offers

  • Update: 08/19/2026 - Modernization: added Client (context, retries, shared HTTP client) and a Provider registry; split the library into topic files; requires Go 1.24+. Fixes: EUR/GBP-quoted Coinbase pairs were rounded to 2 decimals and lost their price data, all timestamps are now UTC, -markets=etf works from the library API, multi-symbol CSV parsing no longer scrambles symbols, and CSV round-trips no longer append a phantom zero bar. Existing API is unchanged; older entry points still work and are marked deprecated

  • Update: 09/04/2025 - added Tiingo CSV update mode (-update) with 10-day backfill, optional full re-download on corporate actions, and -concurrency for faster updates

  • Update: 04/01/2025 - added markets flag, wildcard input files, multiple inputs

  • Update: 03/02/2025 - Removed obsolete Yahoo support

  • Update: 02/15/2024 - Major update: updated to Go 1.22, removed bittrex/binance support, fixed nasdaq/tiingo markets

  • Update: 11/15/2021 - Removed obsolete markets, converted to go modules

  • Update: 7/18/2021 - Removed obsolete Google support

  • Update: 6/26/2019 - updated GDAX to Coinbase, added coinbase market

  • Update: 4/26/2018 - Added preliminary tiingo CRYPTO support. Use -source=tiingo-crypto -token=<your_tingo_token> You can also set env variable TIINGO_API_TOKEN. To get symbol lists, use market: tiingo-btc, tiingo-eth or tiingo-usd

  • Update: 12/21/2017 - Added Amibroker format option (creates csv file with separate date and time). Use -format=ami

  • Update: 12/20/2017 - Added Binance exchange support. Use -source=binance

  • Update: 12/18/2017 - Added Bittrex exchange support. Use -source=bittrex

  • Update: 10/21/2017 - Added Coinbase GDAX exchange support. Use -source=gdax All times are in UTC. Automatically rate limited.

  • Update: 7/19/2017 - Added preliminary tiingo support. Use -source=tiingo -token=<your_tingo_token> You can also set env variable TIINGO_API_TOKEN

  • Update: 5/24/2017 - Now works with the new Yahoo download format. Beware - Yahoo data quality is now questionable and the free Yahoo quotes are likely to permanently go away in the near future. Use with caution!

Still very much in alpha mode. Expect bugs and API changes. Comments/suggestions/pull requests welcome!

Copyright 2025 Mark Chenoweth

Install CLI utility (quote) with:

go install github.com/markcheno/go-quote/quote@latest
Usage:
  quote -h | -help
  quote -v | -version
  quote [-outfile=<outputFile>] <market>
  quote [-years=<years>|(-start=<datestr> [-end=<datestr>])] [options] [-infile=<filename>|<symbol> ...]
  quote -update=<path> [-end=<datestr>] [-backfill-days=<n>] [-full-redownload-on-ca] [-concurrency=<n>] [-token=<tiingo_token>]

Options:
  -h -help             show help
  -v -version          show version
  -years=<years>       number of years to download [default=5]
  -start=<datestr>     yyyy[-[mm-[dd]]]
  -end=<datestr>       yyyy[-[mm-[dd]]] [default=today]
  -markets=<list>      list of valid markets to download (comma separated)
  -infile=<filename>   list of symbols to download
  -outfile=<filename>  output filename
  -period=<period>     1m|3m|5m|15m|30m|1h|2h|4h|6h|8h|12h|d|3d|w|m [default=d]
  -source=<source>     tiingo|tiingo-crypto|coinbase|binance [default=tiingo]
  -token=<tiingo_tok>  tingo api token [default=TIINGO_API_TOKEN]
  -format=<format>     (csv|json|hs|ami) [default=csv]
  -all=<bool>          all in one file (true|false) [default=false]
  -log=<dest>          filename|stdout|stderr|discard [default=stdout]
  -delay=<ms>          delay in milliseconds between quote requests
  -update=<path>       update an existing Tiingo CSV (single or -all multi) in place
  -backfill-days=<n>   days of overlap to rewrite [default=10]
  -full-redownload-on-ca  if splits/dividends detected, fully redownload the symbol block
  -concurrency=<n>     concurrent symbol fetches in update mode [default=1]

Note: not all periods work with all sources

Valid markets:
etf,nasdaq,nasdaq100,amex,nyse,megacap,largecap,midcap,smallcap,microcap,nanocap,
telecommunications,health_care,finance,real_estate,consumer_discretionary,
consumer_staples,industrials,basic_materials,energy,utilities,technology
coinbase,tiingo-usd,tiingo-btc,tiingo-eth
binance-usdt,binance-usdc,binance-btc,binance-eth

CLI Examples

# display usage
quote -help

# downloads 10 years of smallcap, midcap, largecap and megacap stocks to stocks.csv
quote -markets=smallcap,midcap,largecap,megacap -all=true -years=10 -outfile=stocks.csv

# downloads 10 years of spy,qqq and djia to indexes.csv
quote -years=10 -outfile=indexes.csv -all=true spy qqq djia

# downloads 5 years of Tiingo SPY history to spy.csv (TIINGO_API_TOKEN must be set)
quote spy

# downloads 1 year of bitcoin history to BTC-USD.csv
quote -years=1 -source=coinbase BTC-USD

# downloads 1 year of bitcoin history from Binance (no api key needed)
quote -years=1 -source=binance BTCUSDT

# 3-day bars, a period only Binance supports
quote -years=1 -source=binance -period=3d BTCUSDT


# downloads full etf symbol list to etf.txt, also works for nasdaq,nasdaq100,nyse,amex
quote etf

# download fresh etf list and 5 years of etf data all in one file
quote -markets=etf -all=true -outfile=etf.csv

# update a large multi-symbol CSV in place (Tiingo), 4 concurrent fetchers
quote -update=stocks.csv -concurrency=4

# update a single-symbol CSV inferred from filename (e.g., spy.csv)
quote -update=spy.csv -backfill-days=10 -full-redownload-on-ca

# control request pacing with -delay and concurrency
quote -delay=100 -update=stocks.csv -concurrency=8

Update mode rate limiting

  • -delay=0: no global throttle; workers issue requests immediately.
  • -delay>0: a single global limiter spaces requests across all workers by ~delay ms. Use higher -concurrency to overlap work while keeping polite pacing.

Tiingo rate limit guidance

  • Start conservatively: -delay=100..250 and -concurrency=2..4.
  • Increase gradually and watch for 429 Too Many Requests responses.
  • Leave -delay > 0 to be polite; set -delay=0 only if your plan allows higher throughput.

Install library

Requires Go 1.24 or later. Install the package with:

go get github.com/markcheno/go-quote@latest

Library example

package main

import (
	"fmt"
	"github.com/markcheno/go-quote"
	"github.com/markcheno/go-talib"
)

func main() {
	spy, _ := quote.NewQuoteFromTiingo("spy", "2016-01-01", "2016-04-01", quote.Daily, "your-tiingo-token")
	fmt.Print(spy.CSV())
	rsi2 := talib.Rsi(spy.Close, 2)
	fmt.Println(rsi2)
}
Using a Client

The package-level functions above still work, but new code should prefer a Client. It takes a context.Context, so requests can be cancelled or given a deadline, and it lets you set the request delay, retry policy, and HTTP client per caller instead of through package globals:

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/markcheno/go-quote"
)

func main() {
	c := &quote.Client{
		Token: "your-tiingo-token",
		Delay: 250 * time.Millisecond,
		Retry: quote.RetryPolicy{Max: 3}, // backs off on 429 and 5xx
	}

	p, err := c.Provider("tiingo") // or "tiingo-crypto", "coinbase", "binance"
	if err != nil {
		panic(err)
	}

	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancel()

	spy, err := p.Fetch(ctx, quote.Request{
		Symbol: "spy",
		From:   quote.ParseDateString("2016-01-01"),
		To:     quote.ParseDateString("2016-04-01"),
		Period: quote.Daily,
	})
	if err != nil {
		panic(err)
	}

	fmt.Print(spy.CSV())
}

Fetch many symbols with Client.FetchSymbols, which paces requests by Client.Delay and skips symbols that fail:

quotes, err := c.FetchSymbols(ctx, p, []string{"spy", "qqq", "dia"}, quote.Request{
	From:   quote.ParseDateString("2024-01-01"),
	To:     quote.ParseDateString("2024-12-31"),
	Period: quote.Daily,
})
if err != nil {
	panic(err)
}
err = quotes.WriteFile("indexes.csv", quote.FormatCSV)

Client.Provider reports the valid sources and Provider.Periods the periods each one supports, so an unsupported combination is an error rather than a silent fallback to daily bars.

Notes

Timestamps are UTC. Every source returns UTC, so a Coinbase file and a Tiingo file label the same instant identically. The CSV format carries no timezone, so this also means a file written and read back keeps its instants.

Decimal places come from the data source: 2 for equities, 8 for cryptocurrencies, recorded in Quote.Precision. CSV parsing infers it from the decimals present in the file, so reading a file and writing it out again does not round it.

Adding a data source means implementing quote.Provider and calling quote.RegisterProvider. That is enough for -source dispatch and period validation, which are registry-driven. A source added to the package itself also needs a base-URL seam so it can be tested, Quote.Precision stamped, UTC timestamps, and updates to three tests that know the set of sources - docs/adding-a-provider.md is the full checklist.

Upgrading

Three changes need attention if you have existing data or scripts:

  • EUR/GBP-quoted Coinbase pairs (DOGE-EUR, ADA-GBP, and ~48 others) were written with 2 decimal places, which rounded sub-euro prices away entirely - a full day of DOGE-EUR came out as 0.08,0.08,0.08,0.08. The data in those files is gone and needs refetching, not reformatting.
  • Coinbase timestamps were written in local time and are now UTC. If you are not in UTC they will shift by your offset, so refetch whole ranges rather than diffing old files against new ones. Tiingo files are unaffected - they were already UTC.
  • ValidMarkets grew from 26 to 30 entries. It is an array, so its type changed from [26]string to [30]string. Ranging over it, indexing it, and len all still compile; only an explicit var m [26]string = quote.ValidMarkets breaks. Use the new Markets() []string instead, which is a slice and will not change type when markets are added.
  • The CLI now exits 1 on a bad flag instead of 0. A script written as quote -source=bogus && next-step will now stop where it used to continue.

License

MIT License - see LICENSE for more details

Documentation

Overview

Package quote is a free quote downloader library and cli.

It downloads historical price quotes from Tiingo and Coinbase.

Copyright 2025 Mark Chenoweth Licensed under terms of MIT license (see LICENSE)

Index

Constants

View Source
const (
	// PrecisionEquity - decimal places for equities
	PrecisionEquity = 2
	// PrecisionCrypto - decimal places for cryptocurrencies
	PrecisionCrypto = 8
)

Decimal places used when formatting prices.

View Source
const ClientTimeout = 10 * time.Second

ClientTimeout - connect/read timeout for client requests

Deprecated: set Client.HTTP with the timeout you want.

Variables

View Source
var DefaultClient = &Client{}

DefaultClient backs all package-level functions.

Delay - time delay in milliseconds between quote requests (default=100) Be nice, don't get blocked

Note the units: despite the time.Duration type this holds a raw millisecond count, so Delay = 100 means 100ms. Client.Delay is an honest duration instead.

Deprecated: set Client.Delay instead. This is shared mutable state, read without synchronization by the concurrent update workers.

Log - standard logger, disabled by default

Deprecated: set Client.Log instead. This package-level logger is shared mutable state; a Client carries its own.

View Source
var ValidMarkets = [...]string{
	"etf",
	"nasdaq",
	"nasdaq100",
	"amex",
	"nyse",
	"megacap",
	"largecap",
	"midcap",
	"smallcap",
	"microcap",
	"nanocap",
	"telecommunications",
	"health_care",
	"finance",
	"real_estate",
	"consumer_discretionary",
	"consumer_staples",
	"industrials",
	"basic_materials",
	"energy",
	"utilities",
	"technology",
	"tiingo-btc",
	"tiingo-eth",
	"tiingo-usd",
	"coinbase",
	"binance-usdt",
	"binance-usdc",
	"binance-btc",
	"binance-eth",
}

ValidMarkets list of markets that can be downloaded

Deprecated: use Markets, which returns a slice. The length of an array is part of its type, so every market added here changes the type of this variable.

Functions

func CheckPeriod added in v0.2.0

func CheckPeriod(p Provider, period Period) error

CheckPeriod reports whether p supports period.

func FormatNames added in v0.2.0

func FormatNames() []string

FormatNames lists the supported format names in sorted order.

func MarketRequiresToken added in v0.2.0

func MarketRequiresToken(market string) bool

MarketRequiresToken - reports whether a market needs TIINGO_API_TOKEN set. ValidMarket answers only "is this a known market name"; the credential check is separate so callers can report it themselves.

func Markets added in v0.2.0

func Markets() []string

Markets lists the downloadable markets in sorted order.

func NewEtfFile

func NewEtfFile(filename string) error

NewEtfFile - download a list of etf symbols to a file

func NewEtfList

func NewEtfList() ([]string, error)

NewEtfList - download a list of etf symbols to an array of strings

func NewMarketFile

func NewMarketFile(market, filename string) error

NewMarketFile - download a list of market symbols to a file

func NewMarketList deprecated

func NewMarketList(market string) ([]string, error)

NewMarketList - download a list of market symbols to an array of strings

Deprecated: use Client.MarketList, which takes a context.Context.

func NewSymbolsFromFile

func NewSymbolsFromFile(filename string) ([]string, error)

NewSymbolsFromFile - read symbols from a file

func ParseDateString

func ParseDateString(dt string) time.Time

ParseDateString - parse a potentially partial date string to Time

func PeriodNames added in v0.2.0

func PeriodNames() []string

PeriodNames lists the accepted period spellings, shortest first.

func PeriodString added in v0.2.0

func PeriodString(p Period) string

PeriodString returns the canonical spelling of p.

func ProviderNames added in v0.2.0

func ProviderNames() []string

ProviderNames lists the registered sources in sorted order.

func RegisterProvider added in v0.2.0

func RegisterProvider(name string, f providerFactory)

RegisterProvider adds a named source to the registry, replacing any existing entry with the same name.

func UpdateFileTiingo

func UpdateFileTiingo(path string, token string, backfillDays int, fullRedownload bool, concurrency int, end time.Time) error

UpdateFileTiingo updates an existing CSV (single or multi-symbol) in place using Tiingo daily data. It preserves original symbol order, rewrites a small overlap window (backfillDays), and optionally fully re-downloads a symbol's history if a corporate action is detected in the overlap.

func ValidMarket

func ValidMarket(market string) bool

ValidMarket - validate market string

Types

type Client added in v0.2.0

type Client struct {
	// HTTP is the underlying client. Defaults to a shared client with
	// ClientTimeout.
	HTTP *http.Client

	// Delay is the pause between consecutive symbol requests. Unlike the
	// deprecated package-level Delay, this is a real duration: use
	// 100*time.Millisecond, not 100.
	Delay time.Duration

	// Log receives progress and error messages. Defaults to the package-level
	// Log, which discards output unless SetOutput is called.
	Log *log.Logger

	// Token is the Tiingo API token used when a call does not supply one.
	Token string

	// UserAgent is sent with every request when non-empty.
	UserAgent string

	// Retry controls retry behavior. The zero value does not retry.
	Retry RetryPolicy
	// contains filtered or unexported fields
}

Client holds the configuration for fetching quotes: which HTTP client to use, how long to pause between requests, credentials, and where to log.

The package-level functions delegate to DefaultClient, so existing code keeps working unchanged. Prefer a Client for new code: it accepts a context.Context, allows a per-caller timeout and retry policy, and does not rely on mutable package state.

func (*Client) Binance added in v0.2.0

func (c *Client) Binance(ctx context.Context, symbol string, start, end time.Time, period Period) (Quote, error)

Binance returns Binance historical prices for a symbol.

func (*Client) BinanceSyms added in v0.2.0

func (c *Client) BinanceSyms(ctx context.Context, symbols []string, from, to time.Time, period Period) (Quotes, error)

BinanceSyms fetches Binance prices for a list of symbols.

func (*Client) Coinbase added in v0.2.0

func (c *Client) Coinbase(ctx context.Context, symbol string, start, end time.Time, period Period) (Quote, error)

Coinbase returns Coinbase historical prices for a symbol, paging through the 200-bar limit imposed by the candles endpoint.

func (*Client) CoinbaseSyms added in v0.2.0

func (c *Client) CoinbaseSyms(ctx context.Context, symbols []string, from, to time.Time, period Period) (Quotes, error)

CoinbaseSyms fetches Coinbase prices for a list of symbols.

func (*Client) FetchAll added in v0.2.0

func (c *Client) FetchAll(ctx context.Context, symbols []string, fetch FetchFunc) (Quotes, error)

FetchAll fetches every symbol in order, pausing Client.Delay between requests and skipping symbols that fail. It replaces four copies of the same append/log/sleep loop, one per data source.

func (*Client) FetchSymbols added in v0.2.0

func (c *Client) FetchSymbols(ctx context.Context, p Provider, symbols []string, req Request) (Quotes, error)

FetchSymbols fetches every symbol through p, pausing Client.Delay between requests and skipping symbols that fail.

func (*Client) MarketList added in v0.2.0

func (c *Client) MarketList(ctx context.Context, market string) ([]string, error)

MarketList downloads the list of symbols for a market.

func (*Client) Provider added in v0.2.0

func (c *Client) Provider(name string) (Provider, error)

Provider returns the named source bound to c.

func (*Client) TiingoCrypto added in v0.2.0

func (c *Client) TiingoCrypto(ctx context.Context, symbol string, from, to time.Time, period Period, token string) (Quote, error)

TiingoCrypto returns Tiingo crypto historical prices for a symbol.

func (*Client) TiingoCryptoSyms added in v0.2.0

func (c *Client) TiingoCryptoSyms(ctx context.Context, symbols []string, from, to time.Time, period Period, token string) (Quotes, error)

TiingoCryptoSyms fetches Tiingo crypto prices for a list of symbols.

func (*Client) TiingoDaily added in v0.2.0

func (c *Client) TiingoDaily(ctx context.Context, symbol string, from, to time.Time, period Period, token string) (Quote, error)

TiingoDaily returns Tiingo daily historical prices for a symbol.

func (*Client) TiingoDailySyms added in v0.2.0

func (c *Client) TiingoDailySyms(ctx context.Context, symbols []string, from, to time.Time, period Period, token string) (Quotes, error)

TiingoDailySyms fetches Tiingo daily prices for a list of symbols.

type FetchFunc added in v0.2.0

type FetchFunc func(ctx context.Context, symbol string) (Quote, error)

FetchFunc fetches one symbol. FetchAll drives it across a symbol list.

type Format added in v0.2.0

type Format string

Format identifies an output encoding.

const (
	// FormatCSV - comma separated values
	FormatCSV Format = "csv"
	// FormatJSON - json
	FormatJSON Format = "json"
	// FormatHighstock - Highstock json
	FormatHighstock Format = "hs"
	// FormatAmibroker - Amibroker csv
	FormatAmibroker Format = "ami"
)

Supported output formats.

func ParseFormat added in v0.2.0

func ParseFormat(s string) (Format, error)

ParseFormat converts a user-supplied format string to a Format.

The CLI previously matched formats with an if/else chain that had no final else, so an unrecognized -format silently wrote nothing and reported success.

type HTTPError added in v0.2.0

type HTTPError struct {
	StatusCode int
	Status     string
	URL        string
	Body       []byte
	// contains filtered or unexported fields
}

HTTPError reports a non-2xx response from a data source.

func (*HTTPError) Error added in v0.2.0

func (e *HTTPError) Error() string

type Period

type Period string

Period - for quote history

const (
	// Min1 - 1 Minute time period
	Min1 Period = "60"
	// Min3 - 3 Minute time period
	Min3 Period = "3m"
	// Min5 - 5 Minute time period
	Min5 Period = "300"
	// Min15 - 15 Minute time period
	Min15 Period = "900"
	// Min30 - 30 Minute time period
	Min30 Period = "1800"
	// Min60 - 60 Minute time period
	Min60 Period = "3600"
	// Hour2 - 2 hour time period
	Hour2 Period = "2h"
	// Hour4 - 4 hour time period
	Hour4 Period = "4h"
	// Hour6 - 6 hour time period
	Hour6 Period = "6h"
	// Hour8 - 8 hour time period
	Hour8 Period = "8h"
	// Hour12 - 12 hour time period
	Hour12 Period = "12h"
	// Daily time period
	Daily Period = "d"
	// Day3 - 3 day time period
	Day3 Period = "3d"
	// Weekly time period
	Weekly Period = "w"
	// Monthly time period
	Monthly Period = "m"
)

func ParsePeriod added in v0.2.0

func ParsePeriod(s string) (Period, error)

ParsePeriod converts a user-supplied period string to a Period.

Unlike the CLI helper it replaces, an unrecognized period is an error rather than a silent fallback to Daily - which previously meant asking for "6h" from Coinbase quietly returned daily bars.

type Provider added in v0.2.0

type Provider interface {
	// Name is the source identifier, e.g. "tiingo".
	Name() string
	// Periods lists the periods this source supports.
	Periods() []Period
	// Fetch returns the bars for one symbol.
	Fetch(ctx context.Context, req Request) (Quote, error)
}

Provider fetches quotes from a single data source.

Adding a source means implementing this and calling RegisterProvider; it no longer requires editing parallel if/else chains in the CLI.

type Quote

type Quote struct {
	Symbol    string      `json:"symbol"`
	Precision int64       `json:"-"`
	Date      []time.Time `json:"date"`
	Open      []float64   `json:"open"`
	High      []float64   `json:"high"`
	Low       []float64   `json:"low"`
	Close     []float64   `json:"close"`
	Volume    []float64   `json:"volume"`
}

Quote - structure for historical price data

func NewQuote

func NewQuote(symbol string, bars int) Quote

NewQuote - new empty Quote struct

func NewQuoteFromBinance deprecated added in v0.2.0

func NewQuoteFromBinance(symbol string, startDate, endDate string, period Period) (Quote, error)

NewQuoteFromBinance - Binance historical prices for a symbol

Deprecated: use Client.Binance, which takes a context.Context.

func NewQuoteFromCSV

func NewQuoteFromCSV(symbol, csv string) (Quote, error)

NewQuoteFromCSV - parse csv quote string into Quote structure

func NewQuoteFromCSVDateFormat

func NewQuoteFromCSVDateFormat(symbol, csv string, format string) (Quote, error)

NewQuoteFromCSVDateFormat - parse csv quote string into Quote structure with specified DateTime format

func NewQuoteFromCSVFile

func NewQuoteFromCSVFile(symbol, filename string) (Quote, error)

NewQuoteFromCSVFile - parse csv quote file into Quote structure

func NewQuoteFromCSVFileDateFormat

func NewQuoteFromCSVFileDateFormat(symbol, filename string, format string) (Quote, error)

NewQuoteFromCSVFileDateFormat - parse csv quote file into Quote structure with specified DateTime format

func NewQuoteFromCoinbase deprecated

func NewQuoteFromCoinbase(symbol, startDate, endDate string, period Period) (Quote, error)

NewQuoteFromCoinbase - Coinbase historical prices for a symbol

Deprecated: use Client.Coinbase, which takes a context.Context.

func NewQuoteFromJSON

func NewQuoteFromJSON(jsn string) (Quote, error)

NewQuoteFromJSON - parse json quote string into Quote structure

func NewQuoteFromJSONFile

func NewQuoteFromJSONFile(filename string) (Quote, error)

NewQuoteFromJSONFile - parse json quote string into Quote structure

func NewQuoteFromTiingo deprecated

func NewQuoteFromTiingo(symbol, startDate, endDate string, period Period, token string) (Quote, error)

NewQuoteFromTiingo - Tiingo daily historical prices for a symbol

Deprecated: use Client.TiingoDaily, which takes a context.Context.

func NewQuoteFromTiingoCrypto deprecated

func NewQuoteFromTiingoCrypto(symbol, startDate, endDate string, period Period, token string) (Quote, error)

NewQuoteFromTiingoCrypto - Tiingo crypto historical prices for a symbol

Deprecated: use Client.TiingoCrypto, which takes a context.Context.

func (Quote) Amibroker

func (q Quote) Amibroker() string

Amibroker - convert Quote structure to csv string

func (Quote) CSV

func (q Quote) CSV() string

CSV - convert Quote structure to csv string

func (Quote) Encode added in v0.2.0

func (q Quote) Encode(f Format) (string, error)

Encode renders the Quote in the given format.

func (Quote) Highstock

func (q Quote) Highstock() string

Highstock - convert Quote structure to Highstock json format

func (Quote) JSON

func (q Quote) JSON(indent bool) string

JSON - convert Quote struct to json string

func (Quote) WriteAmibroker deprecated

func (q Quote) WriteAmibroker(filename string) error

WriteAmibroker - write Quote struct to csv file

Deprecated: use Quote.WriteFile(filename, FormatAmibroker).

func (Quote) WriteCSV deprecated

func (q Quote) WriteCSV(filename string) error

WriteCSV - write Quote struct to csv file

Deprecated: use Quote.WriteFile(filename, FormatCSV).

func (Quote) WriteFile added in v0.2.0

func (q Quote) WriteFile(filename string, f Format) error

WriteFile writes the Quote to filename in the given format. An empty filename derives one from the symbol.

This replaces the per-format WriteCSV/WriteJSON/WriteHighstock/WriteAmibroker methods, each of which repeated the same default-filename-then-WriteFile body.

func (Quote) WriteHighstock deprecated

func (q Quote) WriteHighstock(filename string) error

WriteHighstock - write Quote struct to Highstock json format

Deprecated: use Quote.WriteFile(filename, FormatHighstock).

func (Quote) WriteJSON

func (q Quote) WriteJSON(filename string, indent bool) error

WriteJSON - write Quote struct to json file Deprecated: use Quote.WriteFile(filename, FormatJSON).

type Quotes

type Quotes []Quote

Quotes - an array of historical price data

func NewQuotesFromBinance added in v0.2.0

func NewQuotesFromBinance(filename string, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromBinance - create a list of prices from symbols in file

func NewQuotesFromBinanceSyms deprecated added in v0.2.0

func NewQuotesFromBinanceSyms(symbols []string, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromBinanceSyms - create a list of prices from symbols in string array

Deprecated: use Client.BinanceSyms.

func NewQuotesFromCSV

func NewQuotesFromCSV(csv string) (Quotes, error)

NewQuotesFromCSV - parse csv quote string into Quotes array

func NewQuotesFromCSVFile

func NewQuotesFromCSVFile(filename string) (Quotes, error)

NewQuotesFromCSVFile - parse csv quote file into Quotes array

func NewQuotesFromCoinbase

func NewQuotesFromCoinbase(filename, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromCoinbase - create a list of prices from symbols in file

func NewQuotesFromCoinbaseSyms deprecated

func NewQuotesFromCoinbaseSyms(symbols []string, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromCoinbaseSyms - create a list of prices from symbols in string array

Deprecated: use Client.CoinbaseSyms.

func NewQuotesFromJSON

func NewQuotesFromJSON(jsn string) (Quotes, error)

NewQuotesFromJSON - parse json quote string into Quote structure

func NewQuotesFromJSONFile

func NewQuotesFromJSONFile(filename string) (Quotes, error)

NewQuotesFromJSONFile - parse json quote string into Quote structure

func NewQuotesFromTiingoCryptoSyms deprecated

func NewQuotesFromTiingoCryptoSyms(symbols []string, startDate, endDate string, period Period, token string) (Quotes, error)

NewQuotesFromTiingoCryptoSyms - create a list of prices from symbols in string array

Deprecated: use Client.TiingoCryptoSyms.

func NewQuotesFromTiingoSyms deprecated

func NewQuotesFromTiingoSyms(symbols []string, startDate, endDate string, period Period, token string) (Quotes, error)

NewQuotesFromTiingoSyms - create a list of prices from symbols in string array

Deprecated: use Client.TiingoDailySyms.

func (Quotes) Amibroker

func (q Quotes) Amibroker() string

Amibroker - convert Quotes structure to csv string

func (Quotes) CSV

func (q Quotes) CSV() string

CSV - convert Quotes structure to csv string

func (Quotes) Encode added in v0.2.0

func (q Quotes) Encode(f Format) (string, error)

Encode renders the Quotes in the given format.

func (Quotes) Highstock

func (q Quotes) Highstock() string

Highstock - convert Quotes structure to Highstock json format

func (Quotes) JSON

func (q Quotes) JSON(indent bool) string

JSON - convert Quotes struct to json string

func (Quotes) WriteAmibroker

func (q Quotes) WriteAmibroker(filename string) error

WriteAmibroker - write Quotes structure to file Deprecated: use Quotes.WriteFile(filename, FormatAmibroker).

func (Quotes) WriteCSV

func (q Quotes) WriteCSV(filename string) error

WriteCSV - write Quotes structure to file Deprecated: use Quotes.WriteFile(filename, FormatCSV).

func (Quotes) WriteFile added in v0.2.0

func (q Quotes) WriteFile(filename string, f Format) error

WriteFile writes the Quotes to filename in the given format. An empty filename defaults to "quotes" with the format's extension.

func (Quotes) WriteHighstock

func (q Quotes) WriteHighstock(filename string) error

WriteHighstock - write Quote struct to json file in Highstock format Deprecated: use Quotes.WriteFile(filename, FormatHighstock).

func (Quotes) WriteJSON

func (q Quotes) WriteJSON(filename string, indent bool) error

WriteJSON - write Quote struct to json file Deprecated: use Quotes.WriteFile(filename, FormatJSON).

type Request added in v0.2.0

type Request struct {
	Symbol string
	From   time.Time
	To     time.Time
	Period Period
	// Token overrides Client.Token for sources that need credentials.
	Token string
}

Request describes one symbol fetch.

type RetryPolicy added in v0.2.0

type RetryPolicy struct {
	// Max is the number of additional attempts after the first.
	Max int
	// Backoff is the base delay, doubled after each attempt. Defaults to
	// 500ms when Max > 0 and Backoff is zero.
	Backoff time.Duration
}

RetryPolicy controls retries for transport errors, 429, and 5xx responses. The zero value performs no retries, which is the historical behavior; opt in by setting Max. A Retry-After header on a 429 takes precedence over Backoff.

type SymbolNotFoundError

type SymbolNotFoundError struct {
	Symbol string
}

SymbolNotFoundError indicates that a symbol was not found in the data source. This error type allows callers to distinguish "not found" from other errors.

func (*SymbolNotFoundError) Error

func (e *SymbolNotFoundError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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