Giter VIP home page Giter VIP logo

bandprotocol-integration-team-assignment's Introduction

Assignment - Band Protocol's Integration Team

About the assignment

Your task is to create a package that is able to get the median prices for each the symbols given while removing any outliers.

Before you get started

Core requirements

The package must be able to do the following features:

  • The main function must accept a list of symbols and return a list of the corresponding prices in USD or an error.
  • Must be able to calculate the median price of each symbol.
  • The code must be able to handle errors for symbols that aren't supported by the exchanges.
  • The code must filter out symbols does not have at least three sources out of the given five.
  • The code must filter out the prices that are outliers. The method for filtering the outliers is up to your discretion.
  • The code must not use the outlier prices during calculations.

Assignment rules

The only allowed imports are those that are built directly into the Python Standard Library, requests, aiohttp, httpx and urllib3.

Expected folder structure

You should design the code similar to how you would design a package. A boilerplate structure will be given in this repository and an example folder structure can be seen below:

...
├── band_assignment
│   ├── handler                 # Contain the API handlers
│   │   ├── __init__.py 
│   │   ├── binance.py          # API handler for Binance
│   │   ├── coingecko.py        # API handler for CoinGecko
│   │   ├── coinmarketcap.py    # API handler for CoinMarketCap
│   │   ├── kraken.py           # API handler for Kraken
│   │   ├── okx.py              # API handler for OKX
│   │   └── wrapper.py          # wrapper function to call all API handlers
│   │ 
│   ├── calculator              # Contains any modules that requires calculations
│   │   ├── __init__.py
│   │   ├── median.py
│   │   ├── outlier.py
│   │   └── ...
│   │ 
│   ├── structs                 # Contains custom structs/errors if any
│   │   ├── __init__.py
│   │   ├── errors              # Contains custom errors if any
│   │   └── ...
│   │
│   └── main.py                 # Contains the main function to run
│
├── tests                       # Contains test scripts
│   ├── conftest.py             # Conftest file [Optional]
│   ├── demo.py                 # Demo script for using the package 
│   ├── test_cases.json         # Contains the test cases
│   └── tests.py                # Unit-tests [Optional]
│    
├── README.md                   # Contains the task instructions
└── report.md                   # Contains the final report

Get familiar with the APIs

The API that are to be used and its corresponding documentations are given below:

Please be aware you will need to create an account for CoinMarketCap in order to get an API key

Core functionality

Handler functions

Example function

def get_exchange_prices(symbols: List[str]) -> List[Optional[float]]:
    # Insert logic here
    return prices

Example results

if the following code is run:

if __name__ == "__main__":
    exchange_prices = get_exchange_prices(["BTC", "ETH", "NOTAREALTOKEN"])

exchange_prices should be returned in a format equivalent to this:

exchange_prices = [23541.0, 1532.32, None]

Calculator functions

Example function

def filter_outliers(prices: List[float]) -> List[float]:
    # Insert logic here
    return filtered_prices


def get_median_price(filtered_prices: List[float]) -> float:
    # Insert logic here
    return median_price

Example results

If the following code is run:

if __name__ == "__main__":
    prices_list = [
        [10.0, 10.1, 9.8, 1000],
        [200.1, 200.1, 200.8, 0.9],
    ]
    median_prices = []
    for prices in prices_list:
        filtered_prices = filter_outliers(prices)
        median_prices.append(get_median_price(filtered_prices))

filtered_prices and median_prices should be in a format equivalent to this:

# Loop 1
filtered_price = [10.0, 10.1, 9.8]
median_prices = [10.0]
# Loop 2 
filtered_price = [200.1, 200.1, 200.8]
median_prices = [10.0, 200.1]

Main function

Example function

def get_prices(symbols: List[str]) -> Dict[str, Optional[float]]:
    # Insert logic here
    return prices

Example results

If the following code is run:

if __name__ == "__main__":
    results = get_prices(["BTC", "ETH", "NOTAREALTOKEN"])

results should be returned in a format equivalent to this:

results = {
    "BTC": 23541.0,
    "ETH": 1532.32,
    "NOTAREALTOKEN": None,
}

Test cases

The test cases can be found under tests/test_cases.json in this repository.

What we expect from you

  1. Think about how the code should be structured, follow PEP 8 guidelines and use type hinting via the typing library.
  2. Consider factors such as API rate limit/weights, coding efficiency and how long your function takes to complete when designing your solution.
  3. Include a demo in the demo.py file that showcases the results from the test cases.
  4. In the README.md, document all the technical decisions and trade-offs you've made, why you made those decisions or trade-offs, the specific outlier rejection method you've used and why you chose that method and any other feature you've left out that you would implement if given more time.

Optional task

For bonus points, you can write a set of unit tests. Make sure to think of the possible edge cases and create a conftest file to simulate the handler functions

Need help?

If you have any doubts, questions or would like to request an extension, feel free to contact us at any time. You can reach us at [email protected] or through posting an issue in this repository.

bandprotocol-integration-team-assignment's People

Contributors

warittornc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.