go-quote

授权协议 MIT License
开发语言 Google Go
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 萧宁
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

go-quote

A free quote downloader library and cli

Downloads daily historical price quotes from Yahoo 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: 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 2018 Mark Chenoweth

Install CLI utility (quote) with:

go install github.com/markcheno/go-quote/quote
Usage:
  quote -h | -help
  quote -v | -version
  quote <market> [-output=<outputFile>]
  quote [-years=<years>|(-start=<datestr> [-end=<datestr>])] [options] [-infile=<filename>|<symbol> ...]

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]
  -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>     yahoo|tiingo|tiingo-crypto|coinbase|bittrex|binance [default=yahoo]
  -token=<tiingo_tok>  tingo api token [default=TIINGO_API_TOKEN]
  -format=<format>     (csv|json|hs|ami) [default=csv]
  -adjust=<bool>       adjust yahoo prices [default=true]
  -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

Note: not all periods work with all sources

Valid markets:
etfs:       etf
exchanges:  nasdaq,nyse,amex
market cap: megacap,largecap,midcap,smallcap,microcap,nanocap
sectors:    basicindustries,capitalgoods,consumerdurables,consumernondurable,
            consumerservices,energy,finance,healthcare,miscellaneous,
            utilities,technolog,transportation
crypto:     bittrex-btc,bittrex-eth,bittrex-usdt,
            binance-bnb,binance-btc,binance-eth,binance-usdt,
            tiingo-btc,tiingo-eth,tiingo-usd,
            coinbase
all:        allmarkets

CLI Examples

# display usage
quote -help

# downloads 5 years of Yahoo SPY history to spy.csv 
quote spy

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

# downloads 1 year of Yahoo SPY & AAPL history to quotes.csv 
quote -years=1 -all=true -outfile=quotes.csv spy aapl

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

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

# download hourly data for all Bittrex BTC markets all in one file
quote bittrex-btc && quote -source=bittrex -all=true -period=1h -outfile=bittrex-btc.csv -infile=bittrex-btc.txt

Install library

Install the package with:

go get github.com/markcheno/go-quote

Library example

package main

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

func main() {
	spy, _ := quote.NewQuoteFromYahoo("spy", "2016-01-01", "2016-04-01", quote.Daily, true)
	fmt.Print(spy.CSV())
	rsi2 := talib.Rsi(spy.Close, 2)
	fmt.Println(rsi2)
}

License

MIT License - see LICENSE for more details

  • 最新发表的GO1.14支持在生产环境中使用Module Support,此系列通过阅读官方的系列文档给出我自己的个人总结。 Part1 Using Go Modules 简单定义 ,Module是存储在文件树中的Go软件包的集合,其根目录中有go.mod文件。 go.mod文件定义模块的模块路径(这也是用于根目录的导入路径)及其依赖关系要求,这些依赖关系是为了能成功build所必须的其他模块。 每

  • 字符串操作 字符串转为整型 traint01, err := strconv.Atoi(trastr01) traint01, _ := strconv.ParseInt(trastr02, 10, 8) traint01, _ := strconv.ParseUint(trastr02, 10, 8) 字符串和浮点数之间的转换 trafloat01, err_float := strconv.

  • 目录 安装 Go(如果尚未安装) 编写Hello world 使用Golang的外部包 自动下载需要的外部包

  • strconv strconv.Quote(s string)string -> 返回字符串在go语法下的双引号字面值表示,控制字符和不可打印字符会进行转义(\t,\n等) strconv.QuoteToASCII(s string)string -> 返回字符串在go语法下的双引号字面值表示,除了上面的和非ASCII字符会进行转义 strconv.QuoteRune(r rune)string

  • golang 安装 VSCode 略 插件 Remote SSH 登录远程 ssh root@172.19.129.68 -A 免密登录 本机生成 ssh key ssh-keygen 复制pub到远程 type ~/.ssh/.rsa_pub 复制内容 远程 echo '粘贴内容' >> ~/.ssh/authorized_keys VSCode中 F1 -> Reload Window 安

  • 包strconv主要实现对字符串和基本数据类型之间的转换。基本数据类型包括:布尔、整型(包括有/无符号、二进制、八进制、十进制和十六进制)和浮点型等。 ------------------------------------------------------------------------------------------- strconv 包转换错误处理 字符串转换过程中可能出错,因此s

  • 快速上手 我们可以通过go list xx来使用go list.该指令会返回xx package的规范名字 % cd $GOPATH/src/code.google.com/p/go.crypto/ssh % go list code.google.com/p/go.crypto/ssh % go list github.com/juju/juju github.com/juju/juju 但是

  • 问题解构三步走 实践Go官方教程时,遇到发布Go模块到远程中央仓库失败。 Tutorial: Create a Go module 创建Go模块的教程 Call your code from another module 从其他模块调用代码(本地模块) 1.认识问题 参考 Publishing a module-发布模块 文档尝试发布Go模块到远程中央仓库。 Developing and publ

  • ------------------------------------------------------------ // 将布尔值转换为字符串 true 或 false func FormatBool(b bool) string // 将字符串转换为布尔值 // 它接受真值:1, t, T, TRUE, true, True // 它接受假值:0, f, F, FALSE, false,

  • Go的1.11和1.12版本包括对模块--新的Go依赖管理系统的初步支持,使依赖版本信息变得明确且更易于管理。这篇博客文章介绍了开始使用模块所需的基本操作。 模块是存储在根目录有一个 go.mod文件的文件树中的 Go 包(package)的集合。go.mod文件定义了模块的module path(也是模块根目录的导入路径)以及模块依赖的其他模块的要求,满足了依赖要求模块才能被成功构建起来。每个依

  • 本文个人博客地址:https://www.huweihuang.com/golang-notes/introduction/package/go-modules.html 1. Go modules简介 Go 1.11版本开始支持Go modules方式的依赖包管理功能,官网参考:https://github.com/golang/go/wiki/Modules。 2. go mod的使用 项目文

  • 第一个go程序 package main //引用流行的 fmt 包, 其中包含格式化文本的功能,包含打印到控制台。这个包是一个 标准库包,在安装的 Go 的时候内置的。 import "fmt" //import "rsc.io/quote" //go get rsc.io/quote //拉不下开时设置代理 //go env -w GOPROXY=https://goproxy.cn /

 相关资料
  • Go!

    Go! 是一个 PHP 5.4 库,让 PHP 支持 AOP 面向方面编程方法,无需 PECL 扩展、Runkit、evals 或者 DI 容器支持。可使用 XDebug 轻松调试。 示例代码: // Aspect/MonitorAspect.phpnamespace Aspect;use Go\Aop\Aspect;use Go\Aop\Intercept\FieldAccess;use Go\

  • 命令go vet是一个用于检查Go语言源码中静态错误的简单工具。与大多数Go命令一样,go vet命令可以接受-n标记和-x标记。-n标记用于只打印流程中执行的命令而不真正执行它们。-n标记也用于打印流程中执行的命令,但不会取消这些命令的执行。示例如下: hc@ubt:~$ go vet -n pkgtool /usr/local/go/pkg/tool/linux_386/vet golang/

  • 命令go fix会把指定代码包的所有Go语言源码文件中的旧版本代码修正为新版本的代码。这里所说的版本即Go语言的版本。代码包的所有Go语言源码文件不包括其子代码包(如果有的话)中的文件。修正操作包括把对旧程序调用的代码更换为对新程序调用的代码、把旧的语法更换为新的语法,等等。 这个工具其实非常有用。在编程语言的升级和演进的过程中,难免会对过时的和不够优秀的语法及标准库进行改进。这样的改进对于编程语

  • Pact Go的版本目前支持Pact v2规范,访问网站开始学习。 Go-Kit例子 Pact Go代码库中有一个详细的Go Kit 例子,介绍如何使用Pact去测试Go Kit微服务。 原生Go实现 还有一个Go版本的Pact(兼容pact v1.1),不需要运行一个守护进程。如果你不需要v2+的匹配以及运行守护进程,可以考虑使用或者为Pact Go贡献。

  • Panic表示的意思就是有些意想不到的错误发生了。通常我们用来表示程序正常运行过程中不应该出现的,或者我们没有处理好的错误。 package main import "os" func main() { // 我们使用panic来检查预期不到的错误 panic("a problem") // Panic的通常使用方法就是如果一个函数 // 返回一个我们不知道怎么处理

  • 使用os.Exit可以给定一个状态,然后立刻退出程序运行。 package main import "fmt" import "os" func main() { // 当使用`os.Exit`的时候defer操作不会被运行, // 所以这里的``fmt.Println`将不会被调用 defer fmt.Println("!") // 退出程序并设置退出状态值