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

     1  package trades
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/bitfinexcom/bitfinex-api-go/pkg/convert"
     7  )
     8  
     9  // AuthTradeExecutionUpdate used for mapping authenticated trade execution update raw messages
    10  type AuthTradeExecutionUpdate struct {
    11  	ID          int64
    12  	Pair        string
    13  	MTS         int64
    14  	OrderID     int64
    15  	ExecAmount  float64
    16  	ExecPrice   float64
    17  	OrderType   string
    18  	OrderPrice  float64
    19  	Maker       int
    20  	Fee         float64
    21  	FeeCurrency string
    22  }
    23  
    24  // ATEUFromRaw authenticated trade execution update mapping to data type
    25  func ATEUFromRaw(raw []interface{}) (eu AuthTradeExecutionUpdate, err error) {
    26  	if len(raw) < 11 {
    27  		return AuthTradeExecutionUpdate{}, fmt.Errorf("data slice too short for auth trade execution update: %#v", raw)
    28  	}
    29  
    30  	eu = AuthTradeExecutionUpdate{
    31  		ID:          convert.I64ValOrZero(raw[0]),
    32  		Pair:        convert.SValOrEmpty(raw[1]),
    33  		MTS:         convert.I64ValOrZero(raw[2]),
    34  		OrderID:     convert.I64ValOrZero(raw[3]),
    35  		ExecAmount:  convert.F64ValOrZero(raw[4]),
    36  		ExecPrice:   convert.F64ValOrZero(raw[5]),
    37  		OrderType:   convert.SValOrEmpty(raw[6]),
    38  		OrderPrice:  convert.F64ValOrZero(raw[7]),
    39  		Maker:       convert.ToInt(raw[8]),
    40  		Fee:         convert.F64ValOrZero(raw[9]),
    41  		FeeCurrency: convert.SValOrEmpty(raw[10]),
    42  	}
    43  
    44  	return
    45  }