-
Notifications
You must be signed in to change notification settings - Fork 658
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
Refine parsing candles for dYdX #2148
Conversation
CodSpeed Performance ReportMerging #2148 will degrade performances by 36.48%Comparing Summary
Benchmarks breakdown
|
@@ -98,15 +98,14 @@ def parse_to_bar( | |||
high_price = Price(Decimal(self.high), price_precision) | |||
low_price = Price(Decimal(self.low), price_precision) | |||
close_price = Price(Decimal(self.close), price_precision) | |||
avg_price = Decimal("0.25") * (open_price + high_price + low_price + close_price) | |||
volume = Decimal(self.usdVolume) / avg_price | |||
volume = Quantity(Decimal(self.baseTokenVolume), size_precision) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting choice, because most crypto API's give you both base and quote volumes - but our bar type only has one volume.
After looking around a bit, for spot markets the base volume is common, equities use units of shares, futures is contracts, derivatives markets are often notional value (in quote currency).
I'm still happy to merge this in if you find the base volume more useful in practice on dYdX, or do we want to consider further? I'm thinking a configuration, or per asset class choice - and specify in docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Chris, don't have a preference here. What do the other adapters use?
In develop branch, it is also using base volume by converting from quote to base. So I thought to simplify that. If derivatives markets use notional value, we could do that too but it would be a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making it configurable is indeed preferred I guess. I'll add that then and keep the current default base volume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, looking closer there is that / avg_price
.
I think yet another config option is a nice to have - I'm happy to merge as is for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, feel free to merge if you're happy with the change.
Pull Request
Refine parsing candles for dYdX
Type of change
How has this change been tested?
Unit tests