github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/examples/v2/rest-ticker/main.go (about)

     1  package main
     2  
     3  import (
     4  	"log"
     5  
     6  	"github.com/bitfinexcom/bitfinex-api-go/v2/rest"
     7  	"github.com/davecgh/go-spew/spew"
     8  )
     9  
    10  func main() {
    11  	c := rest.NewClient()
    12  
    13  	getSingle(c)
    14  	getMulti(c)
    15  	all(c)
    16  }
    17  
    18  func getSingle(c *rest.Client) {
    19  	t, err := c.Tickers.Get("tBTCUSD")
    20  
    21  	if err != nil {
    22  		log.Fatalf("getSingle: %s", err)
    23  	}
    24  
    25  	spew.Dump("getSingle:> ", t)
    26  }
    27  
    28  func getMulti(c *rest.Client) {
    29  	symbols := []string{"tBTCUSD", "fUSD"}
    30  	tm, err := c.Tickers.GetMulti(symbols)
    31  
    32  	if err != nil {
    33  		log.Fatalf("getMulti: %s", err)
    34  	}
    35  
    36  	spew.Dump("getMulti:> ", tm)
    37  }
    38  
    39  func all(c *rest.Client) {
    40  	t, err := c.Tickers.All()
    41  
    42  	if err != nil {
    43  		log.Fatalf("all: %s", err)
    44  	}
    45  
    46  	spew.Dump("all:> ", t)
    47  }