Пример #1
0
def test_pagination(mock_ftx: Ftx):
    """Test pagination in the eth/eur market (public endpoint)"""
    # Try pagination good path
    response = mock_ftx._api_query(
        endpoint='markets/eth/eur/trades',
        limit=3,
        start_time=Timestamp(1617716695),
        end_time=Timestamp(1617724135),
    )

    assert len(response) == 24

    # Try with a page size divisor of the total orders
    response = mock_ftx._api_query(
        endpoint='markets/eth/eur/trades',
        limit=3,
        start_time=Timestamp(1617716695),
        end_time=Timestamp(1617724135),
    )

    assert len(response) == 24

    # Try pagination with same dates. Should return empty list
    response = mock_ftx._api_query(
        endpoint='markets/eth/eur/trades',
        limit=3,
        start_time=Timestamp(1617716695),
        end_time=Timestamp(1617716695),
    )

    assert len(response) == 0
Пример #2
0
def test_ftx_exchange_assets_are_known(mock_ftx: Ftx):

    unknown_assets: Set[str] = set()
    unsupported_assets = set(UNSUPPORTED_FTX_ASSETS)

    def process_currency(currency: Optional[str]):
        """Check if a currency is known for the FTX exchange"""
        if currency is None:
            return
        try:
            if currency not in unknown_assets:
                asset_from_ftx(base_currency)
        except UnsupportedAsset:
            assert base_currency in unsupported_assets
        except UnknownAsset as e:
            test_warnings.warn(
                UserWarning(
                    f'Found unknown asset {e.asset_name} in FTX. '
                    f'Support for it has to be added', ))
            unknown_assets.add(base_currency)

    response = mock_ftx._api_query(endpoint='markets', paginate=False)

    # Extract the unique symbols from the exchange pairs
    for entry in response:
        if entry['type'] == 'future':
            continue

        base_currency = entry.get('baseCurrency', None)
        quote_currency = entry.get('quoteCurrency', None)
        process_currency(base_currency)
        process_currency(quote_currency)