|
| 1 | +# Getting Started |
| 2 | + |
| 3 | +This page is dedicated to helping you get started with go-nyse-stocks. |
| 4 | +Once you've done that please don't forget to submit it to the |
| 5 | +[Awesome go-nyse-stocks] list :). |
| 6 | + |
| 7 | +**First, lets cover a few topics so you can make the best choices on how to |
| 8 | +move forward from here.** |
| 9 | + |
| 10 | +## Requirements |
| 11 | + |
| 12 | +go-nyse-stocks requires Go version 1.19 or higher. It has been tested to compile and |
| 13 | +run successfully on Debian Linux 8, FreeBSD 10, and Windows 7. It is expected |
| 14 | +that it should work anywhere Go 1.19 or higher works. If you run into problems |
| 15 | +please let me know :). |
| 16 | + |
| 17 | +You must already have a working Go environment setup to use go-nyse-stocks. If you |
| 18 | +are new to Go and have not yet installed and tested it on your computer then |
| 19 | +please visit the [Go Install Page] first then I highly |
| 20 | +recommend you walk though [A Tour of Go] to |
| 21 | +help get your familiar with the Go language. Also checkout the relevant Go plugin |
| 22 | +for your editor — they are hugely helpful when developing Go code. |
| 23 | + |
| 24 | +* Visual Studio — [vscode-go] |
| 25 | +* Vim — [vim-go] |
| 26 | +* Sublime — [GoSublime] |
| 27 | + |
| 28 | +## Install go-nyse-stocks |
| 29 | + |
| 30 | +Like any other Go package the fist step is to `go get` the package. This will |
| 31 | +always pull the latest tagged release from the master branch. Then run |
| 32 | +`go install` to compile and install the libraries on your system. |
| 33 | + |
| 34 | +### Windows |
| 35 | + |
| 36 | +Simply run the following command in a command prompt or powershell instance to download, compile, and install the package. |
| 37 | + |
| 38 | +Make sure you are in your project's directory before running the command. |
| 39 | + |
| 40 | +```plain |
| 41 | +go get github.com/ggoodwin/go-nyse-stocks |
| 42 | +``` |
| 43 | + |
| 44 | +### Linux/BSD/MacOS |
| 45 | + |
| 46 | +Run go get to download the package to your GOPATH/src folder. |
| 47 | + |
| 48 | +```sh |
| 49 | +go get github.com/ggoodwin/go-nyse-stocks |
| 50 | +``` |
| 51 | + |
| 52 | +Finally, compile and install the package into the GOPATH/pkg folder. This isn't |
| 53 | +absolutely required but doing this will allow the Go plugin for your editor to |
| 54 | +provide autocomplete for all go-nyse-stocks functions. |
| 55 | + |
| 56 | +```sh |
| 57 | +cd $GOPATH/src/github.com/ggoodwin/go-nyse-stocks |
| 58 | +go install |
| 59 | +``` |
| 60 | + |
| 61 | +## Use go-nyse-stocks |
| 62 | + |
| 63 | +### Importing |
| 64 | + |
| 65 | +Add the import to your `.go` file |
| 66 | + |
| 67 | +```go |
| 68 | +import "github.com/ggoodwin/go-nyse-stocks" |
| 69 | +``` |
| 70 | + |
| 71 | +### Commands |
| 72 | + |
| 73 | +#### Stock Price and Percentage Change |
| 74 | + |
| 75 | +Add this to your `.go` file |
| 76 | + |
| 77 | +```go |
| 78 | +// Parameter: Stock Symbol |
| 79 | +// Returns: strings ex: `$123.45`, `1.23%`, `↑` |
| 80 | +price, percent, direction := go_nyse_stocks.GetPriceAndPercentage("AAPL") |
| 81 | +``` |
| 82 | + |
| 83 | +#### Get full stock details |
| 84 | + |
| 85 | +```go |
| 86 | +// Parameter: Stock Symbol |
| 87 | +// Returns `Result` struct |
| 88 | +stock := go_nyse_stocks.GetFullDetails("AAPL") |
| 89 | +``` |
| 90 | + |
| 91 | +### Result struct |
| 92 | + |
| 93 | +```go |
| 94 | +type Result struct { |
| 95 | + Symbol string `json:"symbol"` |
| 96 | + ShortName string `json:"shortName"` |
| 97 | + QuoteSourceName string `json:"quoteSourceName"` |
| 98 | + Language string `json:"language"` |
| 99 | + Region string `json:"region"` |
| 100 | + QuoteType string `json:"quoteType"` |
| 101 | + Triggerable bool `json:"triggerable"` |
| 102 | + Currency string `json:"currency"` |
| 103 | + Exchange string `json:"exchange"` |
| 104 | + MessageBoardID string `json:"messageBoardId"` |
| 105 | + ExchangeTimezoneName string `json:"exchangeTimezoneName"` |
| 106 | + ExchangeTimezoneShortName string `json:"exchangeTimezoneShortName"` |
| 107 | + GmtOffSetMilliseconds int `json:"gmtOffSetMilliseconds"` |
| 108 | + Market string `json:"market"` |
| 109 | + EsgPopulated bool `json:"esgPopulated"` |
| 110 | + FirstTradeDateMilliseconds int64 `json:"firstTradeDateMilliseconds"` |
| 111 | + RegularMarketChange float64 `json:"regularMarketChange"` |
| 112 | + RegularMarketChangePercent float64 `json:"regularMarketChangePercent"` |
| 113 | + RegularMarketTime int `json:"regularMarketTime"` |
| 114 | + RegularMarketPrice float64 `json:"regularMarketPrice"` |
| 115 | + RegularMarketDayHigh float64 `json:"regularMarketDayHigh"` |
| 116 | + RegularMarketDayRange string `json:"regularMarketDayRange"` |
| 117 | + RegularMarketDayLow float64 `json:"regularMarketDayLow"` |
| 118 | + RegularMarketVolume int64 `json:"regularMarketVolume"` |
| 119 | + RegularMarketPreviousClose float64 `json:"regularMarketPreviousClose"` |
| 120 | + FullExchangeName string `json:"fullExchangeName"` |
| 121 | + RegularMarketOpen float64 `json:"regularMarketOpen"` |
| 122 | + AverageDailyVolume3Month int64 `json:"averageDailyVolume3Month"` |
| 123 | + AverageDailyVolume10Day int64 `json:"averageDailyVolume10Day"` |
| 124 | + StartDate int `json:"startDate"` |
| 125 | + CoinImageURL string `json:"coinImageUrl"` |
| 126 | + FiftyTwoWeekLowChange float64 `json:"fiftyTwoWeekLowChange"` |
| 127 | + FiftyTwoWeekLowChangePercent float64 `json:"fiftyTwoWeekLowChangePercent"` |
| 128 | + FiftyTwoWeekRange string `json:"fiftyTwoWeekRange"` |
| 129 | + FiftyTwoWeekHighChange float64 `json:"fiftyTwoWeekHighChange"` |
| 130 | + FiftyTwoWeekHighChangePercent float64 `json:"fiftyTwoWeekHighChangePercent"` |
| 131 | + FiftyTwoWeekLow float64 `json:"fiftyTwoWeekLow"` |
| 132 | + FiftyTwoWeekHigh float64 `json:"fiftyTwoWeekHigh"` |
| 133 | + FiftyDayAverage float64 `json:"fiftyDayAverage"` |
| 134 | + FiftyDayAverageChange float64 `json:"fiftyDayAverageChange"` |
| 135 | + FiftyDayAverageChangePercent float64 `json:"fiftyDayAverageChangePercent"` |
| 136 | + TwoHundredDayAverage float64 `json:"twoHundredDayAverage"` |
| 137 | + TwoHundredDayAverageChange float64 `json:"twoHundredDayAverageChange"` |
| 138 | + TwoHundredDayAverageChangePercent float64 `json:"twoHundredDayAverageChangePercent"` |
| 139 | + MarketCap int64 `json:"marketCap"` |
| 140 | + SourceInterval int `json:"sourceInterval"` |
| 141 | + ExchangeDataDelayedBy int `json:"exchangeDataDelayedBy"` |
| 142 | + Tradeable bool `json:"tradeable"` |
| 143 | + MarketState string `json:"marketState"` |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +<!-- Links --> |
| 148 | +[Awesome go-nyse-stocks]: https://github.com/ggoodwin/go-nyse-stocks/wiki/Awesome-go-nyse-stocks |
| 149 | +[Go Install Page]: https://golang.org/doc/install |
| 150 | +[A Tour of Go]: https://tour.golang.org/welcome/1 |
| 151 | +[vim-go]: https://github.com/fatih/vim-go |
| 152 | +[GoSublime]: https://github.com/DisposaBoy/GoSublime |
| 153 | +[vscode-go]: https://github.com/golang/vscode-go |
0 commit comments