(self, exchange, provided_symbol=None)
| 502 | return symbol |
| 503 | |
| 504 | def test_exchange(self, exchange, provided_symbol=None): |
| 505 | spot_symbols = None |
| 506 | swap_symbols = None |
| 507 | if provided_symbol is not None: |
| 508 | market = exchange.market(provided_symbol) |
| 509 | if market['spot']: |
| 510 | spot_symbols = [provided_symbol] |
| 511 | else: |
| 512 | swap_symbols = [provided_symbol] |
| 513 | else: |
| 514 | if exchange.has['spot']: |
| 515 | primary_symbol = self.get_valid_symbol(exchange, True) |
| 516 | if primary_symbol is not None: |
| 517 | secondary_symbol = primary_symbol.replace('BTC', 'ETH') # this should work any exchange |
| 518 | spot_symbols = [primary_symbol, secondary_symbol] |
| 519 | if exchange.has['swap']: |
| 520 | primary_symbol = self.get_valid_symbol(exchange, False) |
| 521 | # some exchanges advertise has['swap']=true via describe() but |
| 522 | # the live market list contains no swap entries (e.g. bequant |
| 523 | # inherits hitbtc swap support but exposes only spot pairs). |
| 524 | # getValidSymbol returns undefined in that case — skip swap |
| 525 | # tests rather than crashing on `undefined.replace(...)`. |
| 526 | if primary_symbol is not None: |
| 527 | secondary_symbol = primary_symbol.replace('BTC', 'ETH') # this should work any exchange |
| 528 | swap_symbols = [primary_symbol, secondary_symbol] |
| 529 | if spot_symbols is not None: |
| 530 | dump('[INFO:MAIN] Selected SPOT SYMBOL:', exchange.json(spot_symbols)) |
| 531 | if swap_symbols is not None: |
| 532 | dump('[INFO:MAIN] Selected SWAP SYMBOL:', exchange.json(swap_symbols)) |
| 533 | if not self.private_test_only: |
| 534 | # note, spot & swap tests should run sequentially, because of conflicting `exchange.options['defaultType']` setting |
| 535 | if exchange.has['spot'] and spot_symbols is not None: |
| 536 | if self.info: |
| 537 | dump('[INFO] ### SPOT TESTS ###') |
| 538 | exchange.options['defaultType'] = 'spot' |
| 539 | self.run_public_tests(exchange, spot_symbols) |
| 540 | if exchange.has['swap'] and swap_symbols is not None: |
| 541 | if self.info: |
| 542 | dump('[INFO] ### SWAP TESTS ###') |
| 543 | exchange.options['defaultType'] = 'swap' |
| 544 | self.run_public_tests(exchange, swap_symbols) |
| 545 | if self.private_test or self.private_test_only: |
| 546 | if exchange.has['spot'] and spot_symbols is not None: |
| 547 | exchange.options['defaultType'] = 'spot' |
| 548 | self.run_private_tests(exchange, spot_symbols) |
| 549 | if exchange.has['swap'] and swap_symbols is not None: |
| 550 | exchange.options['defaultType'] = 'swap' |
| 551 | self.run_private_tests(exchange, swap_symbols) |
| 552 | return True |
| 553 | |
| 554 | def run_private_tests(self, exchange, symbol): |
| 555 | if not exchange.check_required_credentials(False): |
no test coverage detected