Esempio n. 1
0
    def to_cryptocompare(self) -> str:
        cryptocompare_str = WORLD_TO_CRYPTOCOMPARE.get(self.identifier,
                                                       self.identifier)
        # There is an asset which should not be queried in cryptocompare
        if cryptocompare_str is None:
            if self.identifier == 'MRS':
                raise UnsupportedAsset(
                    'Marginless is not in cryptocompare. Asking for MRS '
                    'will return MARScoin', )
            else:
                raise RuntimeError(
                    f'Got {self.identifier} as a cryptocompare query but it is '
                    f'documented as returning None and is not handled', )

        return cryptocompare_str
Esempio n. 2
0
    'TSHP',
)


UNSUPPORTED_BINANCE_ASSETS = (
    'ETF',  # ETF is a dead coin given to all ETH holders. Just ignore
    # BTCB, USDSB, BGBP are not yet supported anywhere else
    'BTCB',  # https://www.binance.com/en/support/articles/360029288972
    'USDSB',  # https://www.binance.com/en/support/articles/360029522132
    'BGBP',  # https://www.binance.com/en/support/articles/360030827252
    'TUSDB',  # https://www.binance.com/en/support/articles/360032154071
    '123',  # https://twitter.com/rotkehlchenio/status/1161977327078838272
    '456',  # https://twitter.com/rotkehlchenio/status/1161977327078838272
)

CRYPTOCOMPARE_TO_WORLD = {v: k for k, v in WORLD_TO_CRYPTOCOMPARE.items()}

POLONIEX_TO_WORLD = {v: k for k, v in WORLD_TO_POLONIEX.items()}
BITTREX_TO_WORLD = {v: k for k, v in WORLD_TO_BITTREX.items()}
BINANCE_TO_WORLD = {v: k for k, v in WORLD_TO_BINANCE.items()}

RENAMED_BINANCE_ASSETS = {
    # The old BCC in binance forked into BCHABC and BCHSV
    # but for old trades the canonical chain is ABC (BCH in rotkehlchen)
    'BCC': 'BCH',
    # HCash (HSR) got swapped for Hyperchash (HC)
    # https://support.binance.com/hc/en-us/articles/360012489731-Binance-Supports-Hcash-HSR-Mainnet-Swap-to-HyperCash-HC-
    'HSR': 'HC',
    # Red pulse got swapped for Phoenix
    # https://support.binance.com/hc/en-us/articles/360012507711-Binance-Supports-Red-Pulse-RPX-Token-Swap-to-PHOENIX-PHX-
    'RPX': 'PHX',
Esempio n. 3
0
def process_asset(
    our_data: Dict[str, Dict[str, Any]],
    asset_symbol: str,
    paprika_coins_list: List[Dict[str, Any]],
    paprika: CoinPaprika,
    cmc_list: Optional[List[Dict[str, Any]]],
    cryptocompare_coins_map: Dict[str, Any],
    always_keep_our_time: bool,
) -> Dict[str, Any]:
    """
    Process a single asset symbol. Compare to all external APIs and if there is no
    local data on the symbol query the user on which data to use for each asset attribute.
    """
    token_address = None
    our_asset = our_data[asset_symbol]
    # Coin paprika does not have info on FIAT currencies
    if asset_symbol in FIAT_CURRENCIES:
        return our_data

    found_coin_id = find_paprika_coin_id(asset_symbol, paprika_coins_list)
    if found_coin_id:
        print(f'paprika id: {found_coin_id}')
        paprika_coin_data = paprika.get_coin_by_id(found_coin_id)
        paprika_token_address = get_paprika_data_eth_token_address(
            paprika_data=paprika_coin_data,
            asset_symbol=asset_symbol,
        )
        check_paprika_token_address(
            paprika_token_address=paprika_token_address,
            given_token_address=token_address,
            asset_symbol=asset_symbol,
        )

    else:
        paprika_coin_data = None
    cmc_coin_data = find_cmc_coin_data(asset_symbol, cmc_list)

    our_data = timerange_check(
        asset_symbol=asset_symbol,
        our_asset=our_asset,
        our_data=our_data,
        paprika_data=paprika_coin_data,
        cmc_data=cmc_coin_data,
        always_keep_our_time=always_keep_our_time,
        token_address=token_address,
    )
    our_data = name_check(
        asset_symbol=asset_symbol,
        our_asset=our_asset,
        our_data=our_data,
        paprika_data=paprika_coin_data,
        cmc_data=cmc_coin_data,
    )
    our_data = active_check(
        asset_symbol=asset_symbol,
        our_asset=our_asset,
        our_data=our_data,
        paprika_data=paprika_coin_data,
        cmc_data=cmc_coin_data,
    )
    our_data = typeinfo_check(
        asset_symbol=asset_symbol,
        our_asset=our_asset,
        our_data=our_data,
        paprika_data=paprika_coin_data,
        cmc_data=cmc_coin_data,
    )

    # add the symbol as an asset attribute in the data
    symbol = asset_symbol
    match = re.search('(.*)-\\d+', symbol)
    # If our key is a numbered key, like 'PAI-2', 'PAI-3' e.t.c. use the
    # non suffixed symbol, iow just 'PAI'
    if match:
        symbol = match.group(1)
    our_data[asset_symbol]['symbol'] = symbol

    # Make sure that the asset is also known to cryptocompare
    cryptocompare_symbol = WORLD_TO_CRYPTOCOMPARE.get(asset_symbol,
                                                      asset_symbol)
    cryptocompare_problem = (
        asset_symbol not in KNOWN_TO_MISS_FROM_CRYPTOCOMPARE
        and cryptocompare_symbol not in cryptocompare_coins_map)
    if cryptocompare_problem:
        print(f'Asset {asset_symbol} is not in cryptocompare')
        sys.exit(1)

    return our_data