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

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  
     7  	"github.com/bitfinexcom/bitfinex-api-go/pkg/models/common"
     8  	"github.com/bitfinexcom/bitfinex-api-go/v2/rest"
     9  	"github.com/davecgh/go-spew/spew"
    10  )
    11  
    12  func main() {
    13  	c := rest.NewClient()
    14  	positionLast(c)
    15  	positionHistory(c)
    16  	symbolCreditSizeLast(c)
    17  	symbolCreditSizeHistory(c)
    18  	fundingLast(c)
    19  	fundingHistory(c)
    20  }
    21  
    22  func positionLast(c *rest.Client) {
    23  	resp, err := c.Stats.PositionLast("tBTCUSD", common.Long)
    24  	if err != nil {
    25  		log.Fatalf("PositionLast: %s", err)
    26  	}
    27  	fmt.Println("Position Last:")
    28  	spew.Dump(resp)
    29  }
    30  
    31  func positionHistory(c *rest.Client) {
    32  	resp, err := c.Stats.PositionHistory("tBTCUSD", common.Long)
    33  	if err != nil {
    34  		log.Fatalf("PositionHistory: %s", err)
    35  	}
    36  	fmt.Println("Position history:")
    37  	spew.Dump(resp)
    38  }
    39  
    40  func symbolCreditSizeLast(c *rest.Client) {
    41  	resp, err := c.Stats.SymbolCreditSizeLast("fUSD", "tBTCUSD")
    42  	if err != nil {
    43  		log.Fatalf("SymbolCreditSizeLast: %s", err)
    44  	}
    45  	fmt.Println("Symbol Credit Size Last:")
    46  	spew.Dump(resp)
    47  }
    48  
    49  func symbolCreditSizeHistory(c *rest.Client) {
    50  	resp, err := c.Stats.SymbolCreditSizeHistory("fUSD", "tBTCUSD")
    51  	if err != nil {
    52  		log.Fatalf("SymbolCreditSizeHistory: %s", err)
    53  	}
    54  	fmt.Println("Symbol Credit Size History:")
    55  	spew.Dump(resp)
    56  }
    57  
    58  func fundingLast(c *rest.Client) {
    59  	resp, err := c.Stats.FundingLast("fUSD")
    60  	if err != nil {
    61  		log.Fatalf("FundingLast: %s", err)
    62  	}
    63  	fmt.Println("Funding Last:")
    64  	spew.Dump(resp)
    65  }
    66  
    67  func fundingHistory(c *rest.Client) {
    68  	resp, err := c.Stats.FundingHistory("fUSD")
    69  	if err != nil {
    70  		log.Fatalf("FundingHistory: %s", err)
    71  	}
    72  	fmt.Println("Funding History:")
    73  	spew.Dump(resp)
    74  }