github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/pkg/models/balanceinfo/balanceinfo.go (about)

     1  package balanceinfo
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/bitfinexcom/bitfinex-api-go/pkg/convert"
     7  )
     8  
     9  type BalanceInfo struct {
    10  	TotalAUM float64
    11  	NetAUM   float64
    12  }
    13  
    14  type Update BalanceInfo
    15  
    16  func FromRaw(raw []interface{}) (o *BalanceInfo, err error) {
    17  	if len(raw) < 2 {
    18  		return o, fmt.Errorf("data slice too short for balance info: %#v", raw)
    19  	}
    20  
    21  	o = &BalanceInfo{
    22  		TotalAUM: convert.F64ValOrZero(raw[0]),
    23  		NetAUM:   convert.F64ValOrZero(raw[1]),
    24  	}
    25  
    26  	return
    27  }
    28  
    29  func UpdateFromRaw(raw []interface{}) (Update, error) {
    30  	bi, err := FromRaw(raw)
    31  	if err != nil {
    32  		return Update{}, err
    33  	}
    34  
    35  	u := Update(*bi)
    36  	return u, nil
    37  }