Esempio n. 1
0
File: itto.go Progetto: ikravets/ev
func (m *IttoMessageQuoteReplace) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = IttoMessageQuoteReplace{
		IttoMessageCommon: decodeIttoMessage(data),
		Bid: ReplaceOrderSide{
			OrigRefNumD: packet.OrderIdFromUint32(binary.BigEndian.Uint32(data[5:9])),
			OrderSide:   OrderSide{Side: packet.MarketSideBid, RefNumD: packet.OrderIdFromUint32(binary.BigEndian.Uint32(data[9:13]))},
		},
		Ask: ReplaceOrderSide{
			OrigRefNumD: packet.OrderIdFromUint32(binary.BigEndian.Uint32(data[13:17])),
			OrderSide:   OrderSide{Side: packet.MarketSideAsk, RefNumD: packet.OrderIdFromUint32(binary.BigEndian.Uint32(data[17:21]))},
		},
	}
	if m.Type.IsShort() {
		m.Bid.Price = packet.PriceFrom2Dec(int(binary.BigEndian.Uint16(data[21:23])))
		m.Bid.Size = int(binary.BigEndian.Uint16(data[23:25]))
		m.Ask.Price = packet.PriceFrom2Dec(int(binary.BigEndian.Uint16(data[25:27])))
		m.Ask.Size = int(binary.BigEndian.Uint16(data[27:29]))
	} else {
		m.Bid.Price = packet.PriceFrom4Dec(int(binary.BigEndian.Uint32(data[21:25])))
		m.Bid.Size = int(binary.BigEndian.Uint32(data[25:29]))
		m.Ask.Price = packet.PriceFrom4Dec(int(binary.BigEndian.Uint32(data[29:33])))
		m.Ask.Size = int(binary.BigEndian.Uint32(data[33:37]))
	}
	return nil
}
Esempio n. 2
0
File: pitch.go Progetto: 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
}
Esempio n. 3
0
File: pitch.go Progetto: 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
}
Esempio n. 4
0
File: pitch.go Progetto: ikravets/ev
func (m *PitchMessageModifyOrder) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = PitchMessageModifyOrder{
		PitchMessageCommon: decodePitchMessage(data),
		OrderId:            packet.OrderIdFromUint64(binary.LittleEndian.Uint64(data[6:14])),
	}
	switch m.Type {
	case PitchMessageTypeModifyOrderLong:
		m.Size = binary.LittleEndian.Uint32(data[14:18])
		m.Price = packet.PriceFrom4Dec(int(binary.LittleEndian.Uint64(data[18:26])))
		m.Flags = data[26]
	case PitchMessageTypeModifyOrderShort:
		m.Size = uint32(binary.LittleEndian.Uint16(data[14:16]))
		m.Price = packet.PriceFrom2Dec(int(binary.LittleEndian.Uint16(data[16:18])))
		m.Flags = data[18]
	}
	return nil
}
Esempio n. 5
0
File: itto.go Progetto: ikravets/ev
func (m *IttoMessageSingleSideReplace) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = IttoMessageSingleSideReplace{
		IttoMessageCommon: decodeIttoMessage(data),
		ReplaceOrderSide: ReplaceOrderSide{
			OrigRefNumD: packet.OrderIdFromUint32(binary.BigEndian.Uint32(data[5:9])),
			OrderSide:   OrderSide{RefNumD: packet.OrderIdFromUint32(binary.BigEndian.Uint32(data[9:13]))},
		},
	}
	if m.Type.IsShort() {
		m.Price = packet.PriceFrom2Dec(int(binary.BigEndian.Uint16(data[13:15])))
		m.Size = int(binary.BigEndian.Uint16(data[15:17]))
	} else {
		m.Price = packet.PriceFrom4Dec(int(binary.BigEndian.Uint32(data[13:17])))
		m.Size = int(binary.BigEndian.Uint32(data[17:21]))
	}
	return nil
}
Esempio n. 6
0
File: itto.go Progetto: 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
}
Esempio n. 7
0
File: tom.go Progetto: ikravets/ev
func (s *TomSide) parseTomSideCompact(data []byte) {
	s.Price = packet.PriceFrom2Dec(int(binary.LittleEndian.Uint16(data[0:2])))
	s.Size = int(binary.LittleEndian.Uint16(data[2:4]))
	s.PriorityCustomerSize = int(binary.LittleEndian.Uint16(data[4:6]))
	s.Condition = data[6]
}