mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
Merge pull request #688 from zenixls2/fix/print_error
fix: drift window in factorzoo, order_execution print order, refactor…
This commit is contained in:
commit
93ad895bcd
|
@ -85,9 +85,9 @@ func (e *ExchangeOrderExecutor) notifySubmitOrders(orders ...types.SubmitOrder)
|
|||
// pass submit order as an interface object.
|
||||
channel, ok := e.RouteObject(&order)
|
||||
if ok {
|
||||
e.NotifyTo(channel, ":memo: Submitting %s %s %s order with quantity: %f @ %f", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), order.Price.Float64(), &order)
|
||||
e.NotifyTo(channel, ":memo: Submitting %s %s %s order with quantity: %f @ %f, order: %v", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), order.Price.Float64(), &order)
|
||||
} else {
|
||||
e.Notify(":memo: Submitting %s %s %s order with quantity: %f @ %f", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), order.Price.Float64(), &order)
|
||||
e.Notify(":memo: Submitting %s %s %s order with quantity: %f @ %f, order: %v", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), order.Price.Float64(), &order)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ func (e *ExchangeOrderExecutor) SubmitOrders(ctx context.Context, orders ...type
|
|||
// pass submit order as an interface object.
|
||||
channel, ok := e.RouteObject(&order)
|
||||
if ok {
|
||||
e.NotifyTo(channel, ":memo: Submitting %s %s %s order with quantity: %f", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), order)
|
||||
e.NotifyTo(channel, ":memo: Submitting %s %s %s order with quantity: %f, order: %v", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), &order)
|
||||
} else {
|
||||
e.Notify(":memo: Submitting %s %s %s order with quantity: %f", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), order)
|
||||
e.Notify(":memo: Submitting %s %s %s order with quantity: %f: %v", order.Symbol, order.Type, order.Side, order.Quantity.Float64(), &order)
|
||||
}
|
||||
|
||||
log.Infof("submitting order: %s", order.String())
|
||||
|
|
|
@ -94,6 +94,7 @@ func (b *Buffer) AddUpdate(o types.SliceOrderBook, firstUpdateID int64, finalArg
|
|||
// we lock here because there might be 2+ calls to the AddUpdate method
|
||||
// we don't want to reset sync.Once 2 times here
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
select {
|
||||
case <-b.resetC:
|
||||
log.Warnf("received depth reset signal, resetting...")
|
||||
|
@ -109,7 +110,6 @@ func (b *Buffer) AddUpdate(o types.SliceOrderBook, firstUpdateID int64, finalArg
|
|||
b.once.Do(func() {
|
||||
go b.tryFetch()
|
||||
})
|
||||
b.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,6 @@ func (b *Buffer) AddUpdate(o types.SliceOrderBook, firstUpdateID int64, finalArg
|
|||
finalUpdateID = b.finalUpdateID
|
||||
b.resetSnapshot()
|
||||
b.emitReset()
|
||||
b.mu.Unlock()
|
||||
return fmt.Errorf("found missing update between finalUpdateID %d and firstUpdateID %d, diff: %d",
|
||||
finalUpdateID+1,
|
||||
u.FirstUpdateID,
|
||||
|
@ -130,7 +129,6 @@ func (b *Buffer) AddUpdate(o types.SliceOrderBook, firstUpdateID int64, finalArg
|
|||
log.Debugf("depth update id %d -> %d", b.finalUpdateID, u.FinalUpdateID)
|
||||
b.finalUpdateID = u.FinalUpdateID
|
||||
b.EmitPush(u)
|
||||
b.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -143,13 +141,13 @@ func (b *Buffer) fetchAndPush() error {
|
|||
log.Debugf("fetched depth snapshot, final update id %d", finalUpdateID)
|
||||
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
if len(b.buffer) > 0 {
|
||||
// the snapshot is too early
|
||||
if finalUpdateID < b.buffer[0].FirstUpdateID {
|
||||
b.resetSnapshot()
|
||||
b.emitReset()
|
||||
b.mu.Unlock()
|
||||
return fmt.Errorf("depth snapshot is too early, final update %d is < the first update id %d", finalUpdateID, b.buffer[0].FirstUpdateID)
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +162,6 @@ func (b *Buffer) fetchAndPush() error {
|
|||
if u.FirstUpdateID > finalUpdateID+1 {
|
||||
b.resetSnapshot()
|
||||
b.emitReset()
|
||||
b.mu.Unlock()
|
||||
return fmt.Errorf("there is a missing depth update, the update id %d > final update id %d + 1", u.FirstUpdateID, finalUpdateID)
|
||||
}
|
||||
|
||||
|
@ -183,7 +180,6 @@ func (b *Buffer) fetchAndPush() error {
|
|||
// set the snapshot
|
||||
b.snapshot = &book
|
||||
|
||||
b.mu.Unlock()
|
||||
b.EmitReady(book, pushUpdates)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -154,7 +154,11 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
// s.pvDivergence.OnUpdate(func(corr float64) {
|
||||
// //fmt.Printf("now we've got corr: %f\n", corr)
|
||||
// })
|
||||
drift := &indicator.Drift{IntervalWindow: types.IntervalWindow{Window: 14, Interval: s.Interval}}
|
||||
windowSize := 360/s.Interval.Minutes()
|
||||
if windowSize == 0 {
|
||||
windowSize = 3
|
||||
}
|
||||
drift := &indicator.Drift{IntervalWindow: types.IntervalWindow{Window: windowSize, Interval: s.Interval}}
|
||||
drift.Bind(st)
|
||||
|
||||
s.Alpha = [][]float64{{}, {}, {}, {}, {}, {}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user