MoneyGo

用 Go 和 React/Bootstrap 编写的跟踪个人财务状况的会计网络应用。「An accounting web application to track personal finances written in Go and React/Bootstrap」

Github星跟踪图

go-finance

GoDoc
Build Status codecov.io
Go Report Card
License MIT

codecov.io

go-finance is a Go library for retrieving financial data for quantitative analysis.

Deprecation Warning!

This library will no longer be maintained due to several breaking yahoo finance api changes (surprise). The next gen iteration of this library that uses the newer apis (as well as a few other api integrations) will exist here - https://github.com/piquette/finance-go and is currently in early stages of development. Have an idea or want to get involved? @ me on twitter, @michael_ack. In the meantime, browse some memes - https://reddit.com/r/memes

---Deprecated---

To install go-finance, use the following command:

go get github.com/FlashBoys/go-finance

Features

Single security quotes

package main

import (
	"fmt"

	"github.com/FlashBoys/go-finance"
)

func main() {
	// 15-min delayed full quote for Apple.
	q, err := finance.GetQuote("AAPL")
	if err == nil {
		fmt.Println(q)
	}
}

Multiple securities quotes

package main

import (
	"fmt"

	"github.com/FlashBoys/go-finance"
)

func main() {
	// 15-min delayed full quotes for Apple, Twitter, and Facebook.
	symbols := []string{"AAPL", "TWTR", "FB"}
	quotes, err := finance.GetQuotes(symbols)
	if err == nil {
		fmt.Println(quotes)
	}
}

Currency pair quote

package main

import (
	"fmt"

	"github.com/FlashBoys/go-finance"
)

func main() {
	// Predefined pair constants
	// e.g
	//
	// USDJPY
	// EURUSD
	// NZDUSD
	//
	pairquote, err := finance.GetCurrencyPairQuote(finance.USDJPY)
	if err == nil {
		fmt.Println(pairquote)
	}
}

Quote history

package main

import (
	"fmt"

	"github.com/FlashBoys/go-finance"
)

func main() {
	// Set time frame to 1 month starting Jan. 1.
	start := finance.ParseDatetime("1/1/2017")
	end := finance.ParseDatetime("2/1/2017")

	// Request daily history for TWTR.
	// IntervalDaily OR IntervalWeekly OR IntervalMonthly are supported.
	bars, err := finance.GetHistory("TWTR", start, end, finance.Day)
	if err == nil {
		fmt.Println(bars)
	}
}

Dividend/Split event history

package main

import (
	"fmt"
	"time"

	"github.com/FlashBoys/go-finance"
)

func main() {
	// Set time range from Jan 2010 up to the current date.
	// This example will return a slice of either dividends or splits.
	start := finance.ParseDatetime("1/1/2010")
	end := finance.NewDatetime(time.Now())

	// Request event history for AAPL.
	events, err := finance.GetEventHistory("AAPL", start, end, finance.Dividends)
	if err == nil {
		fmt.Println(events)
	}
}

Symbols download

package main

import (
	"fmt"

	"github.com/FlashBoys/go-finance"
)

func main() {
	// Request all BATS symbols.
	symbols, err := finance.GetUSEquitySymbols()
	if err == nil {
		fmt.Println(symbols)
	}
}

Options chains

package main

import (
	"fmt"

	"github.com/FlashBoys/go-finance"
)

func main() {
	// Fetches the available expiration dates.
	c, err := finance.NewCycle("AAPL")
	if err != nil {
		panic(err)
	}

	// Some examples - see docs for full details.

	// Fetches the chain for the front month.
	calls, puts, err := c.GetFrontMonth()
	if err == nil {
		panic(err)
	}
	fmt.Println(calls)
	fmt.Println(puts)

	// Fetches the chain for the specified expiration date.
	calls, puts, err := c.GetChainForExpiration(chain.Expirations[1])
	if err == nil {
		panic(err)
	}
	fmt.Println(calls)
	fmt.Println(puts)

	// Fetches calls for the specified expiration date.
	calls, err := c.GetCallsForExpiration(chain.Expirations[1])
	if err == nil {
		panic(err)
	}
	fmt.Println(calls)
}

Intentions

The primary technical tenants of this project are:

  • Make financial data easy and fun to work with in Go.
  • Abstract the burden of non-sexy model serialization away from the end-user.
  • Provide a mature framework where the end-user needs only be concerned with analysis instead of data sourcing.

There are several applications for this library. It's intentions are to be conducive to the following activities:

  • Quantitative financial analysis in Go.
  • Academic study/comparison in a clean, easy language.
  • Algorithmic/Statistical-based strategy implementation.

API Changes

Yahoo decided to deprecate the ichart API for historical data. A few things to note:

  • Dividends and Splits got separated into their own calls, use finance.Dividends or finance.Splits.
  • A cookie and a crumb are now needed in the new historical API. This requires 2 calls, slowing down the response time/quality.
  • Continuation of the historical data funcs were made possible by the solution proposed by pandas contributors here, so thanks for the help!
    • That PR is also reporting a degradation of data quality in the responses, so watch out for that.

You can use the new health checking command to determine if all the endpoints are responding appropriately. Run go run main.go in the cmd/health directory and report any failures!

Contributing

If you find this repo helpful, please give it a star! If you wish to discuss changes to it, please open an issue. This project is not as mature as it could be, and financial projects in Go are in drastic need of some basic helpful dependencies.

Similar Projects

主要指标

概览
名称与所有者FlashBoys/go-finance
主编程语言Go
编程语言Go (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2016-02-28 00:37:46
推送于2018-03-09 02:50:46
最后一次提交2018-03-08 21:50:38
发布数0
用户参与
星数537
关注者数26
派生数53
提交数49
已启用问题?
问题数6
打开的问题数4
拉请求数9
打开的拉请求数0
关闭的拉请求数2
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?