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

     1  package trades
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/bitfinexcom/bitfinex-api-go/pkg/convert"
     7  )
     8  
     9  // AuthTradeExecution used for mapping authenticated trade execution raw messages
    10  type AuthTradeExecution 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  	ClientOrderID int64
    21  }
    22  
    23  // ATEFromRaw - authenticated trade execution mapping to data type
    24  func ATEFromRaw(raw []interface{}) (e AuthTradeExecution, err error) {
    25  	if len(raw) < 12 {
    26  		return AuthTradeExecution{}, fmt.Errorf("data slice too short for auth trade execution: %#v", raw)
    27  	}
    28  
    29  	e = AuthTradeExecution{
    30  		ID:            convert.I64ValOrZero(raw[0]),
    31  		Pair:          convert.SValOrEmpty(raw[1]),
    32  		MTS:           convert.I64ValOrZero(raw[2]),
    33  		OrderID:       convert.I64ValOrZero(raw[3]),
    34  		ExecAmount:    convert.F64ValOrZero(raw[4]),
    35  		ExecPrice:     convert.F64ValOrZero(raw[5]),
    36  		OrderType:     convert.SValOrEmpty(raw[6]),
    37  		OrderPrice:    convert.F64ValOrZero(raw[7]),
    38  		Maker:         convert.ToInt(raw[8]),
    39  		ClientOrderID: convert.I64ValOrZero(raw[11]),
    40  	}
    41  
    42  	return
    43  }