mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
types: add slice book test for copy depth
This commit is contained in:
parent
98468b39c7
commit
8c13092d8b
27
pkg/types/sliceorderbook_test.go
Normal file
27
pkg/types/sliceorderbook_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSliceOrderBook_CopyDepth(t *testing.T) {
|
||||
b := &SliceOrderBook{
|
||||
Bids: PriceVolumeSlice{
|
||||
{Price: number(0.119), Volume: number(100.0)},
|
||||
{Price: number(0.118), Volume: number(100.0)},
|
||||
{Price: number(0.117), Volume: number(100.0)},
|
||||
{Price: number(0.116), Volume: number(100.0)},
|
||||
},
|
||||
Asks: PriceVolumeSlice{
|
||||
{Price: number(0.120), Volume: number(100.0)},
|
||||
{Price: number(0.121), Volume: number(100.0)},
|
||||
{Price: number(0.122), Volume: number(100.0)},
|
||||
},
|
||||
}
|
||||
|
||||
copied := b.CopyDepth(0)
|
||||
assert.Equal(t, 3, len(copied.SideBook(SideTypeSell)))
|
||||
assert.Equal(t, 4, len(copied.SideBook(SideTypeBuy)))
|
||||
}
|
Loading…
Reference in New Issue
Block a user