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

multi: market overview and price feed #1232

Merged
merged 5 commits into from
Oct 19, 2021
Merged

Conversation

buck54321
Copy link
Member

Resolves #941

Add new price_feed subscription. The response to the subscription request contains the spot prices for all known markets. Subscribers will then receive an update to the spot price for every market at the end of every epoch.

server/market

BookRouter handles the subscriptions. The spot price is passed by Market as part of the sigDataEpochReport. It was already being generated by (*DataAPI).ReportEpoch, but we were discarding it.

dex/candles

(*Cache).Delta method updated to ignore leading and trailing zeros. Zeros occur when the book is empty.

client/core

Subscribe to the price feed right after fetching configuration, including after reconnect. Populate the new Market.Spot field. Send updates as notifications.

front-end

Display 24-hour percent change and current rate in the list on the left side of the markets view.

@buck54321 buck54321 changed the title Market overview multi: market overview and price feed Oct 15, 2021
Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tests well.

Will leave it up for a day for others.

server/market/bookrouter.go Show resolved Hide resolved
client/core/notification.go Outdated Show resolved Hide resolved
client/core/bookie.go Show resolved Hide resolved
}
case 'spots': {
const xc = this.user.exchanges[note.host]
for (const [mktName, spot] of Object.entries(note.spots)) xc.markets[mktName].spot = spot
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another place this can come in handy is when showing lot sizes during registration. For display purposes only, especially if they are paying their fees in a market's quote asset, we could show them a conversion based on the current price without needing to subscribe to the market order book.

@buck54321
Copy link
Member Author

If anyone else looking at this on the simnet harness, I'll note that testing is a pain because we interpret our 24 hour change from the 5-minute candles, so even if you put some action on the books immediately, it can take 5 minutes before you see a non-zero change.

Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. My review items are resolved. Leaving open for other reviews for a day or two longer.

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When clicking on a market when looking at candles, I am no longer able to interact with the candles ui.

image

@buck54321
Copy link
Member Author

When clicking on a market when looking at candles, I am no longer able to interact with the candles ui.

image

Fixed in #1238

@chappjc chappjc merged commit bb05332 into decred:master Oct 19, 2021
@chappjc chappjc added this to the 0.4 milestone Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api: need a spot price subscription
3 participants