Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dcrdata/exchanges: use EndRate from dcrdex EpochReportRoute as dcr rate #2007

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions exchanges/exchanges.go
Original file line number Diff line number Diff line change
Expand Up @@ -2419,6 +2419,7 @@ type DecredDEX struct {
reqs map[uint64]func(*msgjson.Message)
cacheMtx sync.RWMutex
candleCaches map[uint64]*candleCache
lastRate float64
seq uint64
stamp int64
cfg *DEXConfig
Expand Down Expand Up @@ -2488,9 +2489,14 @@ func (dcr *DecredDEX) Refresh() {
}
}

// Use mid gap if we are yet to get an epoch report notification.
if dcr.lastRate == 0 {
dcr.lastRate = depth.MidGap()
}

dcr.Update(&ExchangeState{
BaseState: BaseState{
Price: depth.MidGap(),
Price: dcr.lastRate,
Change: change,
Volume: float64(volume) / 1e8,
Stamp: dcr.lastStamp(),
Expand Down Expand Up @@ -2683,6 +2689,9 @@ func (dcr *DecredDEX) processWsMessage(raw []byte) {
if note.Candle.EndStamp == 0 {
return
}

dcr.lastRate = float64(note.Candle.EndRate) / 1e8

candle := &note.Candle
for binSize, cache := range dcr.candles() {
cache.mtx.Lock()
Expand Down Expand Up @@ -2852,7 +2861,7 @@ func (dcr *DecredDEX) setOrderBook(ob *msgjson.OrderBook) {

dcr.Update(&ExchangeState{
BaseState: BaseState{
Price: depth.MidGap(),
Price: dcr.lastRate,
ukane-philemon marked this conversation as resolved.
Show resolved Hide resolved
// Change: priceChange, // With candlesticks
Stamp: dcr.stamp,
},
Expand Down
Loading