/
quote.go
35 lines (31 loc) · 1017 Bytes
/
quote.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package api
import (
"fmt"
"time"
)
//The Quote struct contains all data that gets returned on a Quote() call.
type Quote struct {
ErrorResult
Venue string `json:"venue"`
Symbol string `json:"symbol"`
Bid int `json:"bid"`
Ask int `json:"ask"`
BidSize int `json:"bidSize"`
AskSize int `json:"askSize"`
BidDepth int `json:"bidDepth"`
AskDepth int `json:"askDepth"`
LastPrice int `json:"last"`
LastSize int `json:"lastSize"`
LastTrade time.Time `json:"lastTrade"`
QuoteTime time.Time `json:"quoteTime"`
}
//Quote returns the quote for the current stock on the current venue.
//See https://starfighter.readme.io/docs/a-quote-for-a-stock for further info about the actual API call.
//Returns an empty Oderbook struct if there was an error.
func (i *Instance) Quote() (v Quote) {
i.RLock()
url := fmt.Sprintf("%svenues/%s/stocks/%s/quote", baseURL, i.venue, i.symbol)
i.RUnlock()
i.doHTTP("GET", url, nil, &v)
return
}