32 lines
806 B
Go
32 lines
806 B
Go
|
package features
|
||
|
|
||
|
import (
|
||
|
"git.qtrade.icu/coin-quant/exchange"
|
||
|
. "git.qtrade.icu/coin-quant/trademodel"
|
||
|
bfutures "github.com/adshao/go-binance/v2/futures"
|
||
|
)
|
||
|
|
||
|
func processWsCandle(doneC chan struct{}, cb exchange.WatchFn) func(event *bfutures.WsKlineEvent) {
|
||
|
return func(event *bfutures.WsKlineEvent) {
|
||
|
select {
|
||
|
case <-doneC:
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
if event.Kline.IsFinal {
|
||
|
candle := Candle{
|
||
|
ID: 0,
|
||
|
Start: event.Kline.StartTime / 1000,
|
||
|
Open: parseFloat(event.Kline.Open),
|
||
|
High: parseFloat(event.Kline.High),
|
||
|
Low: parseFloat(event.Kline.Low),
|
||
|
Close: parseFloat(event.Kline.Close),
|
||
|
Turnover: parseFloat(event.Kline.QuoteVolume),
|
||
|
Volume: parseFloat(event.Kline.Volume),
|
||
|
Trades: event.Kline.TradeNum,
|
||
|
}
|
||
|
cb(&candle)
|
||
|
}
|
||
|
}
|
||
|
}
|