Beispiel #1
0
func (s *SimLogger) BeforeBookUpdate(book sim.Book, operation sim.SimOperation) {
	tobOld := book.GetTop(operation.GetOptionId(), operation.GetSide(), s.supernodeLevels)
	s.tobOld = make([]sim.PriceLevel, len(tobOld))
	for i, pl := range tobOld {
		s.tobOld[i] = pl.Clone()
	}
	s.efhLogger.BeforeBookUpdate(book, operation)
}
Beispiel #2
0
func (tob *tob) update(book sim.Book, oid packet.OptionId, updateNew bool) {
	pl := &tob.Old
	if updateNew {
		pl = &tob.New
	}
	*pl = sim.EmptyPriceLevel
	if tob.Check || tob.Flags&TobUpdateBothSides != 0 && updateNew {
		if pls := book.GetTop(oid, tob.Side, 1); len(pls) > 0 {
			*pl = pls[0].Clone()
		}
	}
}
Beispiel #3
0
func (o *observer) AfterBookUpdate(book sim.Book, op sim.SimOperation) {
	oid := op.GetOptionId()
	if oid.Invalid() {
		return
	}
	o.analyzer.optionIds[oid.ToUint64()] = struct{}{}
	bs := o.analyzer.book(oid, op.GetSide())
	//bookSize := len(book.GetTop(oid, op.GetSide(), 0))
	b := book.GetTop(oid, op.GetSide(), 0)
	bookSize := len(b)
	if bs.maxLevels < bookSize {
		//log.Printf("%d %s %d: %v\n", oid, op.GetSide(), bookSize, b)
		bs.maxLevels = bookSize
	}
}
Beispiel #4
0
func (hlc *HwLimChecker) AfterBookUpdate(book sim.Book, operation sim.SimOperation) {
	opa, ok := operation.(*sim.OperationAdd)
	if !ok || operation.GetOptionId().Invalid() {
		return
	}
	if opa.Independent() {
		if book.NumOptions() == supernodes {
			log.Fatalf("reached hw supernodes limit (%d)\n", supernodes)
		}
	}
	tob := book.GetTop(operation.GetOptionId(), operation.GetSide(), 0)
	if len(tob) > supernodeLevels {
		log.Fatalf("book (oid %d, side %s) has %d levels (>%d)",
			operation.GetOptionId(), operation.GetSide(),
			len(tob), supernodeLevels)
	}
}
Beispiel #5
0
func (s *SimLogger) AfterBookUpdate(book sim.Book, operation sim.SimOperation) {
	if operation.GetOptionId().Valid() && s.supernodeLevels > 1 {
		var emptyPrice uint32
		if operation.GetSide() == packet.MarketSideAsk {
			emptyPrice -= 1
		}
		printablePriceLevel := func(pls []sim.PriceLevel, pos int) (price uint32, size int) {
			if pos < len(pls) {
				price = uint32(pls[pos].Price())
				size = pls[pos].Size(sim.SizeKindDefault)
			} else if operation.GetSide() == packet.MarketSideAsk {
				price = emptyPrice
			}
			return
		}
		s.tobNew = book.GetTop(operation.GetOptionId(), operation.GetSide(), s.supernodeLevels)
		for i := 0; i < s.accessedLevels(operation); i++ {
			priceOld, sizeOld := printablePriceLevel(s.tobOld, i)
			priceNew, sizeNew := printablePriceLevel(s.tobNew, i)
			s.printfln("SN_OLD_NEW %02d %08x %08x  %08x %08x", i, sizeOld, priceOld, sizeNew, priceNew)
		}
	}
	s.efhLogger.AfterBookUpdate(book, operation)
}