예제 #1
0
파일: efh.go 프로젝트: ikravets/ev
func (l *EfhLogger) genUpdateTrades(oid packet.OptionId, price packet.Price, size int) {
	m := efhm_trade{
		efhm_header: l.genUpdateHeaderForOption(EFHM_TRADE, oid),
		Price:       uint32(packet.PriceTo4Dec(price)),
		Size:        uint32(size),
	}
	errs.CheckE(l.printer.PrintMessage(m))
}
예제 #2
0
파일: itto.go 프로젝트: ikravets/ev
func (m *IttoMessageAddOrder) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) (err error) {
	defer errs.PassE(&err)
	errs.CheckE(m.IttoMessageCommon.SerializeTo(b, opts))
	buf, err := b.AppendBytes(9)
	errs.CheckE(err)
	binary.BigEndian.PutUint32(buf, m.RefNumD.ToUint32())
	buf[4], err = m.Side.ToByte()
	errs.CheckE(err)
	binary.BigEndian.PutUint32(buf[5:9], m.OId.ToUint32())
	if m.Type.IsShort() {
		buf, err := b.AppendBytes(4)
		errs.CheckE(err)
		binary.BigEndian.PutUint16(buf, uint16(packet.PriceTo2Dec(m.Price)))
		binary.BigEndian.PutUint16(buf[2:], uint16(m.Size))
	} else {
		buf, err := b.AppendBytes(8)
		errs.CheckE(err)
		binary.BigEndian.PutUint32(buf, uint32(packet.PriceTo4Dec(m.Price)))
		binary.BigEndian.PutUint32(buf[4:], uint32(m.Size))
	}
	return
}
예제 #3
0
파일: vsim.go 프로젝트: ikravets/ev
func (s *SimLogger) MessageArrived(idm *sim.SimMessage) {
	outItto := func(name string, typ nasdaq.IttoMessageType, f string, vs ...interface{}) {
		s.printf("NORM %s %c ", name, typ)
		s.printfln(f, vs...)
	}
	outBats := func(f string, vs ...interface{}) {
		s.printf("NORM ORDER %02x ", idm.Pam.Layer().(bats.PitchMessage).Base().Type.ToInt())
		s.printfln(f, vs...)
	}
	outMiax := func(name string, f string, vs ...interface{}) {
		s.printf("NORM %s %02x ", name, idm.Pam.Layer().(miax.TomMessage).Base().Type.ToInt())
		s.printfln(f, vs...)
	}
	sideChar := func(s packet.MarketSide) byte {
		if s == packet.MarketSideAsk {
			return 'S'
		}
		return byte(s)
	}
	switch im := idm.Pam.Layer().(type) {
	case *nasdaq.IttoMessageAddOrder:
		outItto("ORDER", im.Type, "%c %012x %016x %08x %08x", sideChar(im.Side), im.OId.ToUint64(), im.RefNumD.ToUint32(), im.Size, im.Price)
	case *nasdaq.IttoMessageAddQuote:
		outItto("QBID", im.Type, "%012x %016x %08x %08x", im.OId.ToUint64(), im.Bid.RefNumD.ToUint32(), im.Bid.Size, im.Bid.Price)
		outItto("QASK", im.Type, "%012x %016x %08x %08x", im.OId.ToUint64(), im.Ask.RefNumD.ToUint32(), im.Ask.Size, im.Ask.Price)
	case *nasdaq.IttoMessageSingleSideExecuted:
		outItto("ORDER", im.Type, "%016x %08x", im.OrigRefNumD.ToUint32(), im.Size)
	case *nasdaq.IttoMessageSingleSideExecutedWithPrice:
		outItto("ORDER", im.Type, "%016x %08x", im.OrigRefNumD.ToUint32(), im.Size)
	case *nasdaq.IttoMessageOrderCancel:
		outItto("ORDER", im.Type, "%016x %08x", im.OrigRefNumD.ToUint32(), im.Size)
	case *nasdaq.IttoMessageSingleSideReplace:
		outItto("ORDER", im.Type, "%016x %016x %08x %08x", im.RefNumD.ToUint32(), im.OrigRefNumD.ToUint32(), im.Size, im.Price)
	case *nasdaq.IttoMessageSingleSideDelete:
		outItto("ORDER", im.Type, "%016x", im.OrigRefNumD.ToUint32())
	case *nasdaq.IttoMessageSingleSideUpdate:
		outItto("ORDER", im.Type, "%016x %08x %08x", im.RefNumD.ToUint32(), im.Size, im.Price)
	case *nasdaq.IttoMessageQuoteReplace:
		outItto("QBID", im.Type, "%016x %016x %08x %08x", im.Bid.RefNumD.ToUint32(), im.Bid.OrigRefNumD.ToUint32(), im.Bid.Size, im.Bid.Price)
		outItto("QASK", im.Type, "%016x %016x %08x %08x", im.Ask.RefNumD.ToUint32(), im.Ask.OrigRefNumD.ToUint32(), im.Ask.Size, im.Ask.Price)
	case *nasdaq.IttoMessageQuoteDelete:
		outItto("QBID", im.Type, "%016x", im.BidOrigRefNumD.ToUint32())
		outItto("QASK", im.Type, "%016x", im.AskOrigRefNumD.ToUint32())
	case *nasdaq.IttoMessageBlockSingleSideDelete:
		for _, r := range im.RefNumDs {
			outItto("ORDER", im.Type, "%016x", r.ToUint32())
		}

	case *bats.PitchMessageAddOrder:
		outBats("%c %012x %016x %08x %08x", sideChar(im.Side), im.Symbol.ToUint64(), im.OrderId.ToUint64(), im.Size, packet.PriceTo4Dec(im.Price))
	case *bats.PitchMessageDeleteOrder:
		outBats("%016x", im.OrderId.ToUint64())
	case *bats.PitchMessageOrderExecuted:
		outBats("%016x %08x", im.OrderId.ToUint64(), im.Size)
	case *bats.PitchMessageOrderExecutedAtPriceSize:
		outBats("%016x %08x", im.OrderId.ToUint64(), im.Size)
	case *bats.PitchMessageReduceSize:
		outBats("%016x %08x", im.OrderId.ToUint64(), im.Size)
	case *bats.PitchMessageModifyOrder:
		outBats("%016x %08x %08x", im.OrderId.ToUint64(), im.Size, packet.PriceTo4Dec(im.Price))
	case *miax.TomMessageTom:
		outMiax("TOM", "%c %08x %08x %08x %08x", sideChar(im.Side), im.ProductId.ToUint32(), packet.PriceTo4Dec(im.Price), im.Size, im.PriorityCustomerSize)
	case *miax.TomMessageQuote:
		outMiax("QBID", "%08x %08x %08x %08x", im.ProductId.ToUint32(), packet.PriceTo4Dec(im.Bid.Price), im.Bid.Size, im.Bid.PriorityCustomerSize)
		outMiax("QASK", "%08x %08x %08x %08x", im.ProductId.ToUint32(), packet.PriceTo4Dec(im.Ask.Price), im.Ask.Size, im.Ask.PriorityCustomerSize)
	}
	s.efhLogger.MessageArrived(idm)
}
예제 #4
0
파일: operation.go 프로젝트: ikravets/ev
func (o *OperationTop) GetPrice() int {
	return packet.PriceTo4Dec(o.price)
}
예제 #5
0
파일: operation.go 프로젝트: ikravets/ev
func (o *OperationUpdate) GetPrice() int {
	o.Operation.populate()
	errs.Check(o.origOrder != nil)
	return packet.PriceTo4Dec(o.origOrder.Price)
}
예제 #6
0
파일: operation.go 프로젝트: ikravets/ev
func (o *OperationAdd) GetPrice() int {
	return packet.PriceTo4Dec(o.Price)
}