Ejemplo n.º 1
0
Archivo: pitch.go Proyecto: ikravets/ev
func (m *PitchMessageTrade) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = PitchMessageTrade{
		PitchMessageCommon: decodePitchMessage(data),
		OrderId:            packet.OrderIdFromUint64(binary.LittleEndian.Uint64(data[6:14])),
		Side:               packet.MarketSideFromByte(data[14]),
	}
	switch m.Type {
	case PitchMessageTypeTradeShort:
		m.Size = uint32(binary.LittleEndian.Uint16(data[15:17]))
		m.Symbol = parseSymbol(data[17:23])
		m.Price = packet.PriceFrom2Dec(int(binary.LittleEndian.Uint16(data[23:25])))
		m.ExecutionId = binary.LittleEndian.Uint64(data[25:33])
	case PitchMessageTypeTradeLong:
		m.Size = binary.LittleEndian.Uint32(data[15:19])
		m.Symbol = parseSymbol(data[19:25])
		m.Price = packet.PriceFrom4Dec(int(binary.LittleEndian.Uint64(data[25:33])))
		m.ExecutionId = binary.LittleEndian.Uint64(data[33:41])
	case PitchMessageTypeTradeExpanded:
		m.Size = binary.LittleEndian.Uint32(data[15:19])
		m.Symbol = parseSymbol(data[19:27])
		m.Price = packet.PriceFrom4Dec(int(binary.LittleEndian.Uint64(data[27:35])))
		m.ExecutionId = binary.LittleEndian.Uint64(data[35:43])
	}
	return nil
}
Ejemplo n.º 2
0
Archivo: pitch.go Proyecto: ikravets/ev
func (m *PitchMessageAddOrder) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = PitchMessageAddOrder{
		PitchMessageCommon: decodePitchMessage(data),
		OrderId:            packet.OrderIdFromUint64(binary.LittleEndian.Uint64(data[6:14])),
		Side:               packet.MarketSideFromByte(data[14]),
	}
	switch m.Type {
	case PitchMessageTypeAddOrderShort:
		m.Size = uint32(binary.LittleEndian.Uint16(data[15:17]))
		m.Symbol = parseSymbol(data[17:23])
		m.Price = packet.PriceFrom2Dec(int(binary.LittleEndian.Uint16(data[23:25])))
		m.Flags = data[25]
	case PitchMessageTypeAddOrderLong:
		m.Size = binary.LittleEndian.Uint32(data[15:19])
		m.Symbol = parseSymbol(data[19:25])
		m.Price = packet.PriceFrom4Dec(int(binary.LittleEndian.Uint64(data[25:33])))
		m.Flags = data[33]
	case PitchMessageTypeAddOrderExpanded:
		m.Size = binary.LittleEndian.Uint32(data[15:19])
		m.Symbol = parseSymbol(data[19:27])
		m.Price = packet.PriceFrom4Dec(int(binary.LittleEndian.Uint64(data[27:35])))
		m.Flags = data[35]
		copy(m.ParticipantId[:], data[36:40])
	}
	return nil
}
Ejemplo n.º 3
0
Archivo: itto.go Proyecto: ikravets/ev
func (m *IttoMessageOptionsTrade) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = IttoMessageOptionsTrade{
		IttoMessageCommon: decodeIttoMessage(data),
		Side:              packet.MarketSideFromByte(data[5]),
		OId:               packet.OptionIdFromUint32(binary.BigEndian.Uint32(data[6:10])),
		Cross:             binary.BigEndian.Uint32(data[10:14]),
		Match:             binary.BigEndian.Uint32(data[14:18]),
		Price:             packet.PriceFrom4Dec(int(binary.BigEndian.Uint32(data[18:22]))),
		Size:              int(binary.BigEndian.Uint32(data[22:26])),
	}
	return nil
}
Ejemplo n.º 4
0
Archivo: itto.go Proyecto: ikravets/ev
func (m *IttoMessageNoii) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = IttoMessageNoii{
		IttoMessageCommon: decodeIttoMessage(data),
		AuctionId:         binary.BigEndian.Uint32(data[5:9]),
		AuctionType:       data[9],
		Size:              binary.BigEndian.Uint32(data[10:14]),
		Imbalance: OrderSide{
			Side:  packet.MarketSideFromByte(data[14]),
			Price: packet.PriceFrom4Dec(int(binary.BigEndian.Uint32(data[19:23]))),
			Size:  int(binary.BigEndian.Uint32(data[23:27])),
		},
		OId: packet.OptionIdFromUint32(binary.BigEndian.Uint32(data[15:19])),
	}
	return nil
}
Ejemplo n.º 5
0
Archivo: itto.go Proyecto: ikravets/ev
func (m *IttoMessageAddOrder) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = IttoMessageAddOrder{
		IttoMessageCommon: decodeIttoMessage(data),
		OrderSide: OrderSide{
			RefNumD: packet.OrderIdFromUint32(binary.BigEndian.Uint32(data[5:9])),
			Side:    packet.MarketSideFromByte(data[9]),
		},
		OId: packet.OptionIdFromUint32(binary.BigEndian.Uint32(data[10:14])),
	}
	if m.Type.IsShort() {
		m.Price = packet.PriceFrom2Dec(int(binary.BigEndian.Uint16(data[14:16])))
		m.Size = int(binary.BigEndian.Uint16(data[16:18]))
	} else {
		m.Price = packet.PriceFrom4Dec(int(binary.BigEndian.Uint32(data[14:18])))
		m.Size = int(binary.BigEndian.Uint32(data[18:22]))
	}
	return nil
}
Ejemplo n.º 6
0
Archivo: tom.go Proyecto: ikravets/ev
func (m *TomMessageLiquiditySeeking) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = TomMessageLiquiditySeeking{
		TomMessageCommon: decodeTomMessage(data),
		ProductId:        parseProductId(data[5:9]),
		EventType:        data[9],
		EventId:          binary.LittleEndian.Uint32(data[10:14]),
		Price:            packet.PriceFrom4Dec(int(binary.LittleEndian.Uint32(data[14:18]))),
		Side:             packet.MarketSideFromByte(data[18]),
		Quantity: [4]uint32{
			binary.LittleEndian.Uint32(data[19:23]),
			binary.LittleEndian.Uint32(data[23:27]),
			binary.LittleEndian.Uint32(data[27:31]),
			binary.LittleEndian.Uint32(data[31:35]),
		},
		AttributableId: [4]byte{data[35], data[36], data[37], data[38]},
		//Reserved:       data[39:43],
	}
	return nil
}