-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquotation.go
More file actions
53 lines (42 loc) · 1.04 KB
/
quotation.go
File metadata and controls
53 lines (42 loc) · 1.04 KB
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
package upbit
import (
"log"
"encoding/json"
"fmt"
"strconv"
)
func GetTicker(client *UpbitClient,market string, minutes int,count int) ([]Candle,error) {
url := fmt.Sprintf("https://api.upbit.com/v1/candles/minutes/%v",minutes)
queries := map[string]string{}
queries["market"] = market
queries["count"] = strconv.Itoa(count)
resp, err := client.SendRequest("GET",url,queries)
if err != nil {
log.Fatalln(err)
return nil, err
}
respObj := make([]Candle,count)
err = json.Unmarshal(resp, &respObj)
if err != nil {
log.Fatalln(err)
return nil, err
}
return respObj, nil
}
func GetOrderbook(client *UpbitClient, market string) (*Orderbook,error) {
url := "https://api.upbit.com/v1/orderbook"
respObj := make([]*Orderbook,0)
queries := map[string]string{}
queries["markets"] = market
resp, err := client.SendRequest("GET",url,queries)
if err != nil {
log.Fatalln(err)
return respObj[0], err
}
err = json.Unmarshal(resp, &respObj)
if err != nil {
log.Fatalln(err)
return respObj[0], err
}
return respObj[0], nil
}