10 examples of 'golang ticker' in Go

Every line of 'golang ticker' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
701func (x *PortfolioPosition_Ticker) GetTicker() string {
702 if x != nil {
703 return x.Ticker
704 }
705 return ""
706}
87func (bo *BigoneV3) GetTicker(currency goex.CurrencyPair) (*goex.Ticker, error) {
88 params := url.Values{}
89 params.Set("asset_pair_name", currency.ToSymbol("-"))
90
91 tickerURI := fmt.Sprintf("%s/asset_pairs/%s/ticker?%s", bo.baseUri, currency.ToSymbol("-"), params.Encode())
92
93 var resp TickerResp
94 //log.Printf("GetTicker -> %s", tickerURI)
95 err := goex.HttpGet4(bo.httpClient, tickerURI, nil, &resp)
96
97 if err != nil {
98 log.Printf("GetTicker - HttpGet4 failed : %v", err)
99 return nil, err
100 }
101
102 var ticker goex.Ticker
103 ticker.Pair = currency
104 ticker.Date = uint64(time.Now().Unix())
105 ticker.Last = goex.ToFloat64(resp.Data.Close)
106 ticker.Buy = goex.ToFloat64(resp.Data.Bid.Price)
107 ticker.Sell = goex.ToFloat64(resp.Data.Ask.Price)
108 ticker.Low = goex.ToFloat64(resp.Data.Low)
109 ticker.High = goex.ToFloat64(resp.Data.High)
110 ticker.Vol = goex.ToFloat64(resp.Data.Volume)
111 return &ticker, nil
112}
35func (liqui *Liqui) GetTicker(currency CurrencyPair) (*Ticker, error) {
36 cur := strings.ToLower(currency.ToSymbol("_"))
37 if cur == "nil" {
38 log.Println("Unsupport The CurrencyPair")
39 return nil, errors.New("Unsupport The CurrencyPair")
40 }
41 tickerUri := API_V1 + fmt.Sprintf(TICKER_URI, cur)
42 bodyDataMap, err := HttpGet(liqui.httpClient, tickerUri)
43 //fmt.Println("tickerUri:", tickerUri)
44 //fmt.Println("Liqui bodyDataMap:", bodyDataMap)
45 if err != nil {
46 log.Println(err)
47 return nil, err
48 }
49
50 var tickerMap map[string]interface{}
51 var ticker Ticker
52
53 switch bodyDataMap[cur].(type) {
54 case map[string]interface{}:
55 tickerMap = bodyDataMap[cur].(map[string]interface{})
56 default:
57 return nil, errors.New(fmt.Sprintf("Type Convert Error ? \n %s", bodyDataMap))
58 }
59
60 // fmt.Println(cur, " tickerMap:", tickerMap)
61 date := tickerMap["updated"].(float64)
62 ticker.Date = uint64(date)
63 ticker.Last = tickerMap["last"].(float64)
64 ticker.Buy = tickerMap["buy"].(float64)
65 ticker.Sell = tickerMap["sell"].(float64)
66 ticker.Low = tickerMap["low"].(float64)
67 ticker.High = tickerMap["high"].(float64)
68 ticker.Vol = tickerMap["vol"].(float64)
69
70 return &ticker, nil
71}
107func (hitbtc *Hitbtc) GetTicker(currency goex.CurrencyPair) (*goex.Ticker, error) {
108 currency = hitbtc.adaptCurrencyPair(currency)
109 curr := currency.ToSymbol("")
110 tickerUri := API_BASE_URL + API_V2 + TICKER_URI + curr
111 bodyDataMap, err := goex.HttpGet(hitbtc.httpClient, tickerUri)
112 if err != nil {
113 return nil, err
114 }
115
116 if result, isok := bodyDataMap["error"].(map[string]interface{}); isok == true {
117 return nil, errors.New(result["message"].(string) + ", " + result["description"].(string))
118 }
119
120 tickerMap := bodyDataMap
121 var ticker goex.Ticker
122
123 timestamp := time.Now().Unix()
124 ticker.Date = uint64(timestamp)
125 ticker.Last = goex.ToFloat64(tickerMap["last"])
126 ticker.Buy = goex.ToFloat64(tickerMap["bid"])
127 ticker.Sell = goex.ToFloat64(tickerMap["ask"])
128 ticker.Low = goex.ToFloat64(tickerMap["low"])
129 ticker.High = goex.ToFloat64(tickerMap["high"])
130 ticker.Vol = goex.ToFloat64(tickerMap["volume"])
131
132 return &ticker, nil
133}
140func (s *UpDownRate) OnTicker(data map[string]interface{}) {
141 ticker := s.Exchange.ParseTicker(data)
142 s.LatestPrice = ticker.LatestPrice
143}
180func (c *Client) GetTicker(product string) (Ticker, error) {
181 var ticker Ticker
182
183 requestURL := fmt.Sprintf("/products/%s/ticker", product)
184 _, err := c.Request("GET", requestURL, nil, &ticker)
185 return ticker, err
186}
10func main() {
11 // Get info about coin
12 ticker, err := cmc.Ticker(&cmc.TickerOptions{
13 Symbol: "ETH",
14 Convert: "EUR",
15 })
16 if err != nil {
17 log.Fatal(err)
18 }
19
20 fmt.Println(ticker.Name, ticker.Quotes["EUR"].Price)
21}
41func (s *Storage) GetTicker(coin, token string) (*blockatlas.Ticker, error) {
42 hm := createHashMap(coin, token)
43 var cd *blockatlas.Ticker
44 err := s.GetHMValue(EntityQuotes, hm, &cd)
45 if err != nil {
46 return nil, err
47 }
48 return cd, nil
49}
142func (w *WEX) GetTicker(symbol string) (map[string]Ticker, error) {
143 type Response struct {
144 Data map[string]Ticker
145 }
146
147 response := Response{}
148 req := fmt.Sprintf("%s/%s/%s/%s", w.APIUrl, wexAPIPublicVersion, wexTicker, symbol)
149
150 return response.Data, w.SendHTTPRequest(req, &response.Data)
151}
7func Ticker(cb func(), delay time.Duration, done chan bool) {
8 for {
9 select {
10 case <-done:
11 return
12
13 default:
14 cb()
15 time.Sleep(delay)
16 }
17 }
18}

Related snippets