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

Add weighted averages #306

Merged
merged 8 commits into from
Jul 4, 2023
Merged

Conversation

ZIMkaRU
Copy link
Member

@ZIMkaRU ZIMkaRU commented Jul 3, 2023

This PR adds ability to fetch weighted averages data from the BFX API using v2/auth/r/trades/calc endpoint


Basic changes:

  • makes symbol param required for weighted averages
  • allows only one symbol with params schema
  • reworks WeightedAveragesReport service to be able to work with api data
  • changes test cases for using one symbol

Notes:

  • request/response data structures are the same as it was before
  • If nextPage === true it means that data is not consistent and need to change timeframe. That is, when requesting, we set a limit of 100k and in the api response it returns the number of trade records participating in the calculation, if their number has reached the requested limit, this means that the user may not see the data for the desired period of time and it needs to be reduced. This message should be displayed to the user

Depends on these PRs:

Copy link
Contributor

@ezewer ezewer left a comment

Choose a reason for hiding this comment

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

small comment

@@ -50,6 +63,69 @@ class WeightedAveragesReport {
}
}

async _getWeightedAveragesReportFromApi (args) {
const limit = 100_000
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the lodash?

Copy link
Member Author

Choose a reason for hiding this comment

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

JS shipped a new feature called numeric separator to improve readability on numbers. The underscore _ was introduced in ES2021 as a separator in numbers and we can use it for decimal, binary, hexadecimal, and BigInt numbers

Copy link
Contributor

Choose a reason for hiding this comment

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

interesting

Copy link
Contributor

@ezewer ezewer left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

3 participants