github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v1/pairs.go (about)

     1  package bitfinex
     2  
     3  type PairsService struct {
     4  	client *Client
     5  }
     6  
     7  // Get all Pair names as array of strings
     8  func (p *PairsService) All() ([]string, error) {
     9  	req, err := p.client.newRequest("GET", "symbols", nil)
    10  	if err != nil {
    11  		return nil, err
    12  	}
    13  
    14  	var v []string
    15  
    16  	_, err = p.client.do(req, &v)
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  
    21  	return v, nil
    22  }
    23  
    24  // Detailed Pair
    25  type Pair struct {
    26  	Pair             string
    27  	PricePrecision   int     `json:"price_precision,int"`
    28  	InitialMargin    float64 `json:"initial_margin,string"`
    29  	MinimumMargin    float64 `json:"minimum_margin,string"`
    30  	MaximumOrderSize float64 `json:"maximum_order_size,string"`
    31  	MinimumOrderSize float64 `json:"minimum_order_size,string"`
    32  	Expiration       string
    33  	Margin           bool
    34  }
    35  
    36  // Return a list of detailed pairs
    37  func (p *PairsService) AllDetailed() ([]Pair, error) {
    38  	req, err := p.client.newRequest("GET", "symbols_details", nil)
    39  	if err != nil {
    40  		return nil, err
    41  	}
    42  
    43  	var v []Pair
    44  	_, err = p.client.do(req, &v)
    45  	if err != nil {
    46  		return nil, err
    47  	}
    48  
    49  	return v, nil
    50  }