From 9efb45b133e0a2a37f0545f139cd7cbc3e7e6332 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 23 May 2021 00:42:44 +0800 Subject: [PATCH] reduce side book copy --- pkg/bbgo/twap_order_executor.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/pkg/bbgo/twap_order_executor.go b/pkg/bbgo/twap_order_executor.go index d4cc9e6c3..b4aa0933b 100644 --- a/pkg/bbgo/twap_order_executor.go +++ b/pkg/bbgo/twap_order_executor.go @@ -63,19 +63,9 @@ func (e *TwapExecution) connectUserData(ctx context.Context) { } } -func (e *TwapExecution) getSideBook() (pvs types.PriceVolumeSlice, err error) { - book := e.orderBook.Copy() - pvs = book.SideBook(e.Side) - return pvs, err -} - func (e *TwapExecution) newBestPriceOrder() (orderForm types.SubmitOrder, err error) { book := e.orderBook.Copy() - - sideBook, err := e.getSideBook() - if err != nil { - return orderForm, err - } + sideBook := book.SideBook(e.Side) first, ok := sideBook.First() if !ok { @@ -212,11 +202,8 @@ func (e *TwapExecution) newBestPriceOrder() (orderForm types.SubmitOrder, err er } func (e *TwapExecution) updateOrder(ctx context.Context) error { - - sideBook, err := e.getSideBook() - if err != nil { - return err - } + book := e.orderBook.Copy() + sideBook := book.SideBook(e.Side) first, ok := sideBook.First() if !ok {