mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
max: reduce kline parsing cost
This commit is contained in:
parent
f64b0e7a9f
commit
75a2abeeab
|
@ -192,17 +192,19 @@ func parseKLineEvent(val *fastjson.Value) (*KLineEvent, error) {
|
||||||
Timestamp: val.GetInt64("T"),
|
Timestamp: val.GetInt64("T"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
k := val.Get("k")
|
||||||
|
|
||||||
event.KLine = KLine{
|
event.KLine = KLine{
|
||||||
Symbol: string(val.GetStringBytes("k", "M")),
|
Symbol: string(k.GetStringBytes("M")),
|
||||||
Interval: string(val.GetStringBytes("k", "R")),
|
Interval: string(k.GetStringBytes("R")),
|
||||||
StartTime: time.Unix(0, val.GetInt64("k", "ST")*int64(time.Millisecond)),
|
StartTime: time.Unix(0, k.GetInt64("ST")*int64(time.Millisecond)),
|
||||||
EndTime: time.Unix(0, val.GetInt64("k", "ET")*int64(time.Millisecond)),
|
EndTime: time.Unix(0, k.GetInt64("ET")*int64(time.Millisecond)),
|
||||||
Open: fixedpoint.MustNewFromBytes(val.GetStringBytes("k", "O")),
|
Open: fixedpoint.MustNewFromBytes(k.GetStringBytes("O")),
|
||||||
High: fixedpoint.MustNewFromBytes(val.GetStringBytes("k", "H")),
|
High: fixedpoint.MustNewFromBytes(k.GetStringBytes("H")),
|
||||||
Low: fixedpoint.MustNewFromBytes(val.GetStringBytes("k", "L")),
|
Low: fixedpoint.MustNewFromBytes(k.GetStringBytes("L")),
|
||||||
Close: fixedpoint.MustNewFromBytes(val.GetStringBytes("k", "C")),
|
Close: fixedpoint.MustNewFromBytes(k.GetStringBytes("C")),
|
||||||
Volume: fixedpoint.MustNewFromBytes(val.GetStringBytes("k", "v")),
|
Volume: fixedpoint.MustNewFromBytes(k.GetStringBytes("v")),
|
||||||
Closed: val.GetBool("k", "x"),
|
Closed: k.GetBool("x"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &event, nil
|
return &event, nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user