本文整理汇总了Golang中my/ev/sim.SimOperation.GetPrice方法的典型用法代码示例。如果您正苦于以下问题:Golang SimOperation.GetPrice方法的具体用法?Golang SimOperation.GetPrice怎么用?Golang SimOperation.GetPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类my/ev/sim.SimOperation
的用法示例。
在下文中一共展示了SimOperation.GetPrice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: accessedLevels
func (s *SimLogger) accessedLevels(operation sim.SimOperation) (levels int) {
levels = SimLoggerUpperSupernodeLevels
if s.supernodeLevels <= levels {
return s.supernodeLevels
}
if operation.GetPrice() == 0 {
// TODO hw can skip SN access at all
return
}
lenOld, lenNew := len(s.tobOld), len(s.tobNew)
if lenOld < levels {
return
}
if lenOld == lenNew {
for i := 0; i < levels; i++ {
if !s.tobOld[i].Equals(s.tobNew[i]) {
return
}
}
}
return s.supernodeLevels
}
示例2: 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)
}
}