mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add 1m kline window protection
This commit is contained in:
parent
35bb5bda06
commit
c089e9a1b5
|
@ -173,6 +173,17 @@ func (k *KLineWindow) Add(line KLine) {
|
||||||
*k = append(*k, line)
|
*k = append(*k, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k KLineWindow) Take(size int) KLineWindow {
|
||||||
|
return k[:size]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k KLineWindow) Tail(size int) KLineWindow {
|
||||||
|
if len(k) <= size {
|
||||||
|
return k[:]
|
||||||
|
}
|
||||||
|
return k[len(k) - size:]
|
||||||
|
}
|
||||||
|
|
||||||
func (k *KLineWindow) Truncate(size int) {
|
func (k *KLineWindow) Truncate(size int) {
|
||||||
if len(*k) <= size {
|
if len(*k) <= size {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user