Skip to content

Fetching

fetch_data_to_dataframe(currency, compare, parameters)

Fetch data from the API and convert it to a pandas dataframe.

Parameters:

Name Type Description Default
currency str

Currency to fetch data for.

required
compare str

Currency to compare to.

required
parameters Dict[str, str]

Dictionary of parameters.

required

Returns:

Type Description
pd.DataFrame

Pandas dataframe containing the data.

Source code in make_us_rich/pipelines/fetching/nodes.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def fetch_data_to_dataframe(
    currency: str, 
    compare: str,
    parameters: Dict[str, str],
) -> pd.DataFrame:
    """
    Fetch data from the API and convert it to a pandas dataframe.

    Parameters
    ----------
    currency: str
        Currency to fetch data for.
    compare: str
        Currency to compare to.
    parameters: Dict[str, str]
        Dictionary of parameters.

    Returns
    -------
    pd.DataFrame
        Pandas dataframe containing the data.
    """
    symbol = f"{currency.upper()}{compare.upper()}"
    client = BinanceClient()
    data = client.get_data(symbol, parameters["interval"], parameters["start_date"])
    return data

Last update: 2022-05-04