-
Notifications
You must be signed in to change notification settings - Fork 29
/
pricing.go
63 lines (59 loc) · 1.58 KB
/
pricing.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package goanda
import (
"net/url"
"strings"
"time"
)
// Supporting OANDA docs - http://developer.oanda.com/rest-live-v20/pricing-ep/
type Pricings struct {
Prices []struct {
Asks []struct {
Liquidity int `json:"liquidity"`
Price string `json:"price"`
} `json:"asks"`
Bids []struct {
Liquidity int `json:"liquidity"`
Price string `json:"price"`
} `json:"bids"`
CloseoutAsk string `json:"closeoutAsk"`
CloseoutBid string `json:"closeoutBid"`
Instrument string `json:"instrument"`
QuoteHomeConversionFactors struct {
NegativeUnits string `json:"negativeUnits"`
PositiveUnits string `json:"positiveUnits"`
} `json:"quoteHomeConversionFactors"`
Status string `json:"status"`
Time time.Time `json:"time"`
UnitsAvailable struct {
Default struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"default"`
OpenOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"openOnly"`
ReduceFirst struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceFirst"`
ReduceOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceOnly"`
} `json:"unitsAvailable"`
} `json:"prices"`
}
func (c *Connection) GetPricingForInstruments(instruments []string) (Pricings, error) {
pr := Pricings{}
err := c.getAndUnmarshal(
"/accounts/"+
c.accountID+
"/pricing?instruments="+
url.QueryEscape(
strings.Join(instruments, ","),
),
&pr,
)
return pr, err
}