Merge pull request #441 from zenixls2/fix/431

fix: #431 for not updating lastPrice if no tade happened
This commit is contained in:
Yo-An Lin 2022-01-22 00:27:54 +08:00 committed by GitHub
commit c6fe3ce155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -405,7 +405,7 @@ func (m *SimplePriceMatching) processKLine(kline types.KLine) {
switch kline.Direction() {
case types.DirectionDown:
if kline.High > kline.Open {
if kline.High >= kline.Open {
m.BuyToPrice(fixedpoint.NewFromFloat(kline.High))
}
@ -417,7 +417,7 @@ func (m *SimplePriceMatching) processKLine(kline types.KLine) {
}
case types.DirectionUp:
if kline.Low < kline.Open {
if kline.Low <= kline.Open {
m.SellToPrice(fixedpoint.NewFromFloat(kline.Low))
}
@ -427,6 +427,10 @@ func (m *SimplePriceMatching) processKLine(kline types.KLine) {
} else {
m.BuyToPrice(fixedpoint.NewFromFloat(kline.Close))
}
default: // no trade up or down
if (m.LastPrice == 0) {
m.BuyToPrice(fixedpoint.NewFromFloat(kline.Close))
}
}
}