github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/examples/v2/rest-market/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 averagePrice(c) 14 foreignExchangeRate(c) 15 } 16 17 func averagePrice(c *rest.Client) { 18 args := rest.AveragePriceRequest{ 19 Symbol: "fUSD", 20 Amount: "100", 21 Period: 2, 22 } 23 24 avgPrice, err := c.Market.AveragePrice(args) 25 if err != nil { 26 log.Fatalf("AveragePrice err: %s", err) 27 } 28 29 spew.Dump(avgPrice) 30 } 31 32 func foreignExchangeRate(c *rest.Client) { 33 args := rest.ForeignExchangeRateRequest{ 34 FirstCurrency: "BTC", 35 SecondCurrency: "USD", 36 } 37 38 fxRate, err := c.Market.ForeignExchangeRate(args) 39 if err != nil { 40 log.Fatalf("ForeignExchangeRate err: %s", err) 41 } 42 43 spew.Dump(fxRate) 44 }