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 Bitget as a Source for Rates and Refactor External Market Logic #423

Open
chibie opened this issue Feb 10, 2025 · 1 comment · May be fixed by #425
Open

Add Bitget as a Source for Rates and Refactor External Market Logic #423

chibie opened this issue Feb 10, 2025 · 1 comment · May be fixed by #425

Comments

@chibie
Copy link
Contributor

chibie commented Feb 10, 2025

User Story
As a developer, I want to add Bitget as a source for fetching rates for all supported currencies (e.g., NGN, KES, GHS, etc.), so that we can calculate the median rate from multiple providers (Quidax, Binance, and Bitget) to improve accuracy and reliability.

Acceptance Criteria

  1. GIVEN a supported currency (e.g., NGN, KES, GHS)
    WHEN fetching rates for a token/fiat pair
    THEN the system should fetch rates from Bitget, Binance, and Quidax (if applicable) and calculate the median

  2. GIVEN the currency is NGN
    WHEN fetching rates for USDT/NGN
    THEN the system should fetch rates from Quidax and Bitget

  3. GIVEN the currency is not NGN
    WHEN fetching rates for USDT/
    THEN the system should fetch rates from Binance and Bitget

  4. GIVEN the logic for fetching rates from external providers
    WHEN refactoring the code
    THEN the logic should be moved to /utils/external_markets.go for better organization and reusability

  5. GIVEN the Bitget API is called
    WHEN fetching P2P ads
    THEN the system should fetch the last 20 ads and calculate the median price

Tech Details

  • Add support for the Bitget API to fetch P2P ads.
  • Move the logic for fetching rates from external providers to /utils/external_markets.go.
    • Create utility functions for fetching rates from each provider: Quidax, Binance, and Bitget.
  • Rate Calculation:
    • For USDT/NGN: Fetch rates from Quidax and Bitget, then calculate the median.
    • For other currencies: Fetch rates from Binance and Bitget, then calculate the median.
  • Write tests for the new util functions

Notes/Assumptions

  • The Bitget API is stable and returns data in the expected format.
  • The median rate calculation is sufficient for determining the market rate.
  • The system should handle API failures gracefully and continue with available rates.
@JuViquez
Copy link

May I try my hand at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants