当前位置: 首页>>代码示例>>Golang>>正文


Golang SimOperation.GetOptionId方法代码示例

本文整理汇总了Golang中my/ev/sim.SimOperation.GetOptionId方法的典型用法代码示例。如果您正苦于以下问题:Golang SimOperation.GetOptionId方法的具体用法?Golang SimOperation.GetOptionId怎么用?Golang SimOperation.GetOptionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在my/ev/sim.SimOperation的用法示例。


在下文中一共展示了SimOperation.GetOptionId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: BeforeBookUpdate

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)
}
开发者ID:ikravets,项目名称:ev,代码行数:8,代码来源:vsim.go

示例2: AfterBookUpdate

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
	}
}
开发者ID:ikravets,项目名称:ev,代码行数:15,代码来源:anal.go

示例3: BeforeBookUpdate

func (l *TobLogger) BeforeBookUpdate(book sim.Book, operation sim.SimOperation) {
	errs.Check(l.consumeOps != 0)
	if l.hasOldTob {
		return
	}
	l.lastOptionId = operation.GetOptionId()
	if l.lastOptionId.Invalid() {
		return
	}
	switch operation.GetSide() {
	case packet.MarketSideBid:
		l.bid.Check = true
	case packet.MarketSideAsk:
		l.ask.Check = true
	default:
		log.Fatalln("wrong operation side")
	}
	l.bid.update(book, l.lastOptionId, false)
	l.ask.update(book, l.lastOptionId, false)
	l.hasOldTob = true
}
开发者ID:ikravets,项目名称:ev,代码行数:21,代码来源:tob.go

示例4: AfterBookUpdate

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)
}
开发者ID:ikravets,项目名称:ev,代码行数:24,代码来源:vsim.go

示例5: AfterBookUpdate

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)
	}
}
开发者ID:ikravets,项目名称:ev,代码行数:17,代码来源:hwlim.go

示例6: OperationAppliedToOrders

func (s *SimLogger) OperationAppliedToOrders(operation sim.SimOperation) {
	type ordrespLogInfo struct {
		notFound, addOp   int
		orderId           packet.OrderId
		optionId          packet.OptionId
		side, price, size int
		ordlSuffix        string
	}
	type orduLogInfo struct {
		orderId           packet.OrderId
		optionId          packet.OptionId
		side, price, size int
	}

	var or ordrespLogInfo
	var ou orduLogInfo
	switch op := operation.(type) {
	case *sim.OperationAdd:
		var oid packet.OptionId
		if op.Independent() {
			oid = op.GetOptionId()
		}
		or = ordrespLogInfo{
			addOp:      1,
			orderId:    op.OrderId,
			optionId:   oid,
			ordlSuffix: fmt.Sprintf(" %012x", oid.ToUint64()),
		}
		ou = orduLogInfo{
			orderId:  or.orderId,
			optionId: op.GetOptionId(),
			price:    op.GetPrice(),
			size:     op.GetNewSize(sim.SizeKindDefault),
		}
		if op.GetSide() == packet.MarketSideAsk {
			ou.side = 1
		}
	case *sim.OperationRemove, *sim.OperationUpdate:
		if operation.GetOptionId().Invalid() {
			or = ordrespLogInfo{notFound: 1}
		} else {
			newSize := operation.GetNewSize(sim.SizeKindDefault)
			or = ordrespLogInfo{
				optionId: operation.GetOptionId(),
				price:    operation.GetPrice(),
				size:     newSize - operation.GetDefaultSizeDelta(),
			}
			if operation.GetSide() == packet.MarketSideAsk {
				or.side = 1
			}
			if newSize != 0 {
				ou = orduLogInfo{
					optionId: or.optionId,
					side:     or.side,
					price:    or.price,
					size:     newSize,
				}
			}
		}
		or.orderId = operation.GetOrigOrderId()
		ou.orderId = or.orderId
	default:
		errs.Check(false)
	}
	s.printfln("ORDL %d %016x%s", or.addOp, or.orderId.ToUint64(), or.ordlSuffix)
	s.printfln("ORDRESP %d %d %d %08x %08x %012x %016x", or.notFound, or.addOp, or.side, or.size, or.price, or.optionId.ToUint64(), or.orderId.ToUint64())
	if operation.GetOptionId().Valid() {
		s.printfln("ORDU %016x %012x %d %08x %08x", ou.orderId.ToUint64(), ou.optionId.ToUint64(), ou.side, ou.price, ou.size)
	}
}
开发者ID:ikravets,项目名称:ev,代码行数:70,代码来源:vsim.go


注:本文中的my/ev/sim.SimOperation.GetOptionId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。