GithubHelp home page GithubHelp logo

sunhaibo2004 / finance-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from piquette/finance-go

0.0 1.0 0.0 149 KB

:bar_chart: Financial markets data library implemented in go.

Home Page: https://piquette.io/projects/finance-go/

License: MIT License

Makefile 0.51% Go 99.49%

finance-go's Introduction

finance-go

GoDoc Build Status Coverage Status

Summary

This go package aims to provide a go application with access to current and historical financial markets data in streamlined, well-formatted structures.

Check out the qtrn cli application, which is intended as a living example of this package. It prints quotes/options info in your favorite command-line in a few keystrokes!

Features

Description Source
Quote(s) Yahoo finance
Equity quote(s) Yahoo finance
Index quote(s) Yahoo finance
Option quote(s) Yahoo finance
Forex pair quote(s) Yahoo finance
Cryptocurrency pair quote(s) Yahoo finance
Futures quote(s) Yahoo finance
ETF quote(s) Yahoo finance
Mutual fund quote(s) Yahoo finance
Historical quotes Yahoo finance
Options straddles Yahoo finance

Documentation

A neatly formatted detailed list of implementation instructions and examples will be available on the piquette website.

For now, for details on all the functionality in this library, see the GoDoc documentation.

Installation

It is best to use a dependency management tool, but if you want to retrieve it manually, use -

go get github.com/piquette/finance-go

Usage example

Library usage is meant to be very specific about the user's intentions.

Quote

q, err := quote.Get("AAPL")
if err != nil {
  // Uh-oh.  
  panic(err)
}

// Success!
fmt.Println(q)

Equity quote (more fields)

q, err := equity.Get("AAPL")
if err != nil {
  // Uh-oh.  
  panic(err)
}

// Success!
fmt.Println(q)

Historical quotes (OHLCV)

params := &chart.Params{
  Symbol:   "TWTR",
  Interval: datetime.OneHour,
}
iter := chart.Get(params)

for iter.Next() {
  fmt.Println(iter.Bar())
}
if err := iter.Err(); err != nil {
  fmt.Println(err)
}

Development

Pull requests from the community are welcome. If you submit one, please keep the following guidelines in mind:

  1. All types, structs and funcs should be documented.
  2. Ensure that make test succeeds.

Test

The test suite needs testify's require package to run:

github.com/stretchr/testify/require

It also depends on a running instance of a test server finance-mock, so make sure to fetch that project and run the application from another terminal session (finance-mock's README contains more information).

Docker

  docker run -p 12111:12111 piquette/finance-mock:latest

Brew

brew tap piquette/finance-mock
brew install finance-mock
finance-mock

Go

go get -u github.com/piquette/finance-mock
finance-mock

Run all tests:

go test ./...

Run tests for one package:

go test ./equity

Run a single test:

go test ./equity -run TestGet

For any requests, bug or comments, please open an issue or submit a pull request. Also please email or tweet me as needed.

Notes

  • Yahoo changes their finance APIs without warning, which is their right to do so. However, its annoying and leads to some instability in this project..
  • Big shoutout to Stripe and the team working on the stripe-go project, I took a lot of library design / implementation hints from them.

finance-go's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.