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

Trade Aggregations endpoint #96

Merged
merged 9 commits into from
Jul 26, 2024
Merged

Trade Aggregations endpoint #96

merged 9 commits into from
Jul 26, 2024

Conversation

kevin-pease
Copy link
Contributor

@kevin-pease kevin-pease commented Jul 24, 2024

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Adds the trade aggregations endpoint. Fixes #55.

πŸ’₯ Does this PR introduce a breaking change?

No.

πŸ“ Links to relevant issues/docs

Note: the offset field is mentioned in the documentation, but isn't present in the Laboratory. See:
https://developers.stellar.org/docs/data/horizon/api-reference/aggregations/trade-aggregations/list

πŸ€” Checklist before submitting

  • All projects build
  • Follows style guide lines
  • Relevant documentation was updated
  • Rebased onto current main

@kevin-pease kevin-pease changed the title 55 trade aggregations Trade Aggregations endpoint Jul 24, 2024
Copy link
Collaborator

@tluijken tluijken left a comment

Choose a reason for hiding this comment

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

Graag ook nog even rebasen op de laatste develop. Ik heb main weer naar develop gemerged t.b.v. de release.

Comment on lines 324 to 354
match &self.base_asset.0 {
AssetType::Native => {
asset_parameters.push(format!("base_asset_type=native"));
}
AssetType::Alphanumeric4(asset) => {
asset_parameters.push(format!("base_asset_type=credit_alphanum4"));
asset_parameters.push(format!("&base_asset_code={}", asset.asset_code));
asset_parameters.push(format!("&base_asset_issuer={}", asset.asset_issuer));
}
AssetType::Alphanumeric12(asset) => {
asset_parameters.push(format!("base_asset_type=credit_alphanum12"));
asset_parameters.push(format!("&base_asset_code={}", asset.asset_code));
asset_parameters.push(format!("&base_asset_issuer={}", asset.asset_issuer));
}
}

match &self.counter_asset.0 {
AssetType::Native => {
asset_parameters.push(format!("&counter_asset_type=native"));
}
AssetType::Alphanumeric4(asset) => {
asset_parameters.push(format!("&counter_asset_type=credit_alphanum4"));
asset_parameters.push(format!("&counter_asset_code={}", asset.asset_code));
asset_parameters.push(format!("&counter_asset_issuer={}", asset.asset_issuer));
}
AssetType::Alphanumeric12(asset) => {
asset_parameters.push(format!("&counter_asset_type=credit_alphanum12"));
asset_parameters.push(format!("&counter_asset_code={}", asset.asset_code));
asset_parameters.push(format!("&counter_asset_issuer={}", asset.asset_issuer));
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Deze constructie heb ik eerder gezien. Er zit veel duplicate code bij.
Kun je m in lijn met deze implementatie brengen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Klopt, deze komt elders ook voor. Ik dacht dat we hier een aparte issue voor hadden aangemaakt (zodat ik dit in de maintenance-fase kan oppakken) maar deze staat er nog niet bij. Zal ik 'm nu meenemen, of in een nieuwe feature branch? Dan zou ik gelijk die andere implementatie kunnen refactoren.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ik zou m gelijk nu meepakken.

/// // Use with HorizonClient::get_trade_aggregations
/// ```
///
#[derive(Clone, Debug, PartialEq, Default)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kunnen we hier de Pagination derive gebruiken? Dan hoef je ook niet de set_limit, set_order te implementeren. Dat regelt de derive voor je.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dat heb ik inderdaad overwogen, alleen ontbreekt cursor in deze request. Deze zou dan toegevoegd moeten worden, zonder dat deze gebruikt wordt. Is dat wenselijk?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interessant, want hoe indexed deze paginering nu zonder cursor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dat kan ik nergens terugvinden in de documentatie. Misschien was een limiet en sorteervolgorde voldoende bij dit endpoint.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ik snap m, het gaat met name om start en end tijd, icm met de resolution.
In dat geval zou ik zeggen, laat m zoals ie nu is. De implementatie werkt anders dan de andere paginatie functies. DRY is een fabel ;-)

@tluijken tluijken merged commit 5bf8241 into develop Jul 26, 2024
2 checks passed
@tluijken tluijken deleted the 55-trade-aggregations branch July 26, 2024 10:20
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.

Implement Trade Aggregations endpoint
2 participants