示例#1
0
文件: pitch.go 项目: ikravets/ev
func (m *PitchMessageDeleteOrder) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = PitchMessageDeleteOrder{
		PitchMessageCommon: decodePitchMessage(data),
		OrderId:            packet.OrderIdFromUint64(binary.LittleEndian.Uint64(data[6:14])),
	}
	return nil
}
示例#2
0
文件: pitch.go 项目: 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
}
示例#3
0
文件: pitch.go 项目: 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
}
示例#4
0
文件: pitch.go 项目: ikravets/ev
func (m *PitchMessageOrderExecuted) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = PitchMessageOrderExecuted{
		PitchMessageCommon: decodePitchMessage(data),
		OrderId:            packet.OrderIdFromUint64(binary.LittleEndian.Uint64(data[6:14])),
		Size:               binary.LittleEndian.Uint32(data[14:18]),
		ExecutionId:        binary.LittleEndian.Uint64(data[18:26]),
	}
	return nil
}
示例#5
0
文件: pitch.go 项目: ikravets/ev
func (m *PitchMessageReduceSize) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = PitchMessageReduceSize{
		PitchMessageCommon: decodePitchMessage(data),
		OrderId:            packet.OrderIdFromUint64(binary.LittleEndian.Uint64(data[6:14])),
	}
	switch m.Type {
	case PitchMessageTypeReduceSizeLong:
		m.Size = binary.LittleEndian.Uint32(data[14:18])
	case PitchMessageTypeReduceSizeShort:
		m.Size = uint32(binary.LittleEndian.Uint16(data[14:16]))
	}
	return nil
}
示例#6
0
文件: pitch.go 项目: ikravets/ev
func (m *PitchMessageOrderExecutedAtPriceSize) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	*m = PitchMessageOrderExecutedAtPriceSize{
		PitchMessageOrderExecuted: PitchMessageOrderExecuted{
			PitchMessageCommon: decodePitchMessage(data),
			OrderId:            packet.OrderIdFromUint64(binary.LittleEndian.Uint64(data[6:14])),
			Size:               binary.LittleEndian.Uint32(data[14:18]),
			ExecutionId:        binary.LittleEndian.Uint64(data[22:30]),
		},
		RemainingSize: binary.LittleEndian.Uint32(data[18:22]),
		Price:         packet.PriceFrom4Dec(int(binary.LittleEndian.Uint64(data[30:38]))),
	}
	return nil
}
示例#7
0
文件: pitch.go 项目: 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
}