https://github.com/horacehylee/aastocks
AAStocks financial market data extractor
https://github.com/horacehylee/aastocks
aastocks extractor finance financial go golang
Last synced: over 1 year ago
JSON representation
AAStocks financial market data extractor
- Host: GitHub
- URL: https://github.com/horacehylee/aastocks
- Owner: horacehylee
- License: mit
- Created: 2020-08-25T05:40:07.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-02T06:09:47.000Z (almost 6 years ago)
- Last Synced: 2025-01-24T08:43:42.952Z (over 1 year ago)
- Topics: aastocks, extractor, finance, financial, go, golang
- Language: Go
- Homepage:
- Size: 285 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aastocks : AAStocks financial market data extractor
## Overview
[](https://godoc.org/github.com/horacehylee/aastocks)
[](https://goreportcard.com/report/github.com/horacehylee/aastocks)
[](https://codecov.io/gh/horacehylee/aastocks)
[](https://sourcegraph.com/github.com/horacehylee/aastocks?badge)
AAStocks financial market data extractor
## Install
```
go get github.com/horacehylee/aastocks
```
## Example
```Go
package main
import (
"context"
"log"
"os"
"time"
"github.com/horacehylee/aastocks"
)
// Example demonstrates getting financial data of quote from AAStocks
func Example() {
logger := log.New(os.Stdout, "", log.Flags())
// Getting quote from AAStocks
symbol := "00006"
quote, err := aastocks.Get(symbol)
if err != nil {
logger.Fatal(err)
}
logger.Printf("Quote: %+v\n", quote)
// Getting dividends of the quote from AAStocks
d, err := quote.Dividends()
if err != nil {
logger.Fatal(err)
}
logger.Printf("Dividends count: %v\n", len(d))
// Getting historical prices of the quote from AAStocks
prices, err := quote.HistoricalPrices(aastocks.Hourly)
if err != nil {
logger.Fatal(err)
}
logger.Printf("Historical prices count: %v\n", len(prices))
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
// Continuously serving latest price of the quote from AAStocks
priceChan, errChan := quote.ServePrices(ctx, 2*time.Second)
for {
select {
case p := <-priceChan:
logger.Printf("Price: %+v\n", p)
case err = <-errChan:
logger.Printf("Error: %v\n", err)
case <-ctx.Done():
return
}
}
}
func main() {
Example()
}
```
## License
MIT.