add 1m kline window protection

This commit is contained in:
c9s 2020-06-10 13:53:31 +08:00
parent 35bb5bda06
commit c089e9a1b5

View File

@ -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