yahoo-finance-api
Motivation
- I used to write Python programs and use Yahoo Finance data. The yfinance library is an awesome library which I enjoyed a lot.
- Could not find similar packages in Go.
- Learn Go
- Able to use this package on my other Go projects
If you love this project, please consider giving it a ⭐.
Installation
go get github.com/oscarli916/yahoo-finance-api
Example
package main
import (
"fmt"
yfa "github.com/oscarli916/yahoo-finance-api"
)
func main() {
t := yfa.NewTicker("AAPL")
quote, err := t.Quote()
if err != nil {
fmt.Println("Error fetching quote:", err)
return
}
fmt.Println(quote.Close)
history, err := t.History(yfa.HistoryQuery{Range: "1d", Interval: "1m"})
if err != nil {
fmt.Println("Error fetching history:", err)
return
}
fmt.Println(history)
e := t.ExpirationDates()
oc := t.OptionChainByExpiration(e[2])
fmt.Println(oc)
info, err := t.GetInfo()
if err != nil {
fmt.Println("GetInfo returned error:", err)
}
fmt.Println(info)
}
Contributing
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.