|
|
|
@ -16,7 +16,6 @@ import random |
|
|
|
|
import shutil |
|
|
|
|
import string |
|
|
|
|
import struct |
|
|
|
|
import urllib.request |
|
|
|
|
import hashlib |
|
|
|
|
import secrets |
|
|
|
|
import datetime as dt |
|
|
|
@ -6397,8 +6396,6 @@ class BasicSwap(BaseApp): |
|
|
|
|
ticker_from = ci_from.chainparams()['ticker'] |
|
|
|
|
ticker_to = ci_to.chainparams()['ticker'] |
|
|
|
|
headers = {'Connection': 'close'} |
|
|
|
|
try: |
|
|
|
|
self.setConnectionParameters() |
|
|
|
|
rv = {} |
|
|
|
|
|
|
|
|
|
if rate_sources.get('coingecko.com', True): |
|
|
|
@ -6406,8 +6403,7 @@ class BasicSwap(BaseApp): |
|
|
|
|
url = 'https://api.coingecko.com/api/v3/simple/price?ids={},{}&vs_currencies=usd,btc'.format(exchange_name_from, exchange_name_to) |
|
|
|
|
self.log.debug(f'lookupRates: {url}') |
|
|
|
|
start = time.time() |
|
|
|
|
req = urllib.request.Request(url, headers=headers) |
|
|
|
|
js = json.loads(urllib.request.urlopen(req, timeout=10).read()) |
|
|
|
|
js = json.loads(self.readURL(url, timeout=10, headers=headers)) |
|
|
|
|
js['time_taken'] = time.time() - start |
|
|
|
|
rate = float(js[exchange_name_from]['usd']) / float(js[exchange_name_to]['usd']) |
|
|
|
|
js['rate_inferred'] = ci_to.format_amount(rate, conv_int=True, r=1) |
|
|
|
@ -6442,8 +6438,7 @@ class BasicSwap(BaseApp): |
|
|
|
|
url = f'{bittrex_api_v3}/markets/{pair}/ticker' |
|
|
|
|
self.log.debug(f'lookupRates: {url}') |
|
|
|
|
start = time.time() |
|
|
|
|
req = urllib.request.Request(url, headers=headers) |
|
|
|
|
js = json.loads(urllib.request.urlopen(req, timeout=10).read()) |
|
|
|
|
js = json.loads(self.readURL(url, timeout=10, headers=headers)) |
|
|
|
|
js['time_taken'] = time.time() - start |
|
|
|
|
js['pair'] = pair |
|
|
|
|
try: |
|
|
|
@ -6460,8 +6455,7 @@ class BasicSwap(BaseApp): |
|
|
|
|
url = f'{bittrex_api_v3}/markets/{pair}/ticker' |
|
|
|
|
self.log.debug(f'lookupRates: {url}') |
|
|
|
|
start = time.time() |
|
|
|
|
req = urllib.request.Request(url, headers=headers) |
|
|
|
|
js = json.loads(urllib.request.urlopen(req, timeout=10).read()) |
|
|
|
|
js = json.loads(self.readURL(url, timeout=10, headers=headers)) |
|
|
|
|
js['time_taken'] = time.time() - start |
|
|
|
|
js['pair'] = pair |
|
|
|
|
js['rate_last'] = js['lastTradeRate'] |
|
|
|
@ -6473,8 +6467,7 @@ class BasicSwap(BaseApp): |
|
|
|
|
url = f'{bittrex_api_v3}/markets/{pair}/ticker' |
|
|
|
|
self.log.debug(f'lookupRates: {url}') |
|
|
|
|
start = time.time() |
|
|
|
|
req = urllib.request.Request(url, headers=headers) |
|
|
|
|
js_from = json.loads(urllib.request.urlopen(req, timeout=10).read()) |
|
|
|
|
js_from = json.loads(self.readURL(url, timeout=10, headers=headers)) |
|
|
|
|
js_from['time_taken'] = time.time() - start |
|
|
|
|
js_from['pair'] = pair |
|
|
|
|
|
|
|
|
@ -6482,8 +6475,7 @@ class BasicSwap(BaseApp): |
|
|
|
|
url = f'{bittrex_api_v3}/markets/{pair}/ticker' |
|
|
|
|
self.log.debug(f'lookupRates: {url}') |
|
|
|
|
start = time.time() |
|
|
|
|
req = urllib.request.Request(url, headers=headers) |
|
|
|
|
js_to = json.loads(urllib.request.urlopen(req, timeout=10).read()) |
|
|
|
|
js_to = json.loads(self.readURL(url, timeout=10, headers=headers)) |
|
|
|
|
js_to['time_taken'] = time.time() - start |
|
|
|
|
js_to['pair'] = pair |
|
|
|
|
|
|
|
|
@ -6543,5 +6535,3 @@ class BasicSwap(BaseApp): |
|
|
|
|
return rv_array |
|
|
|
|
|
|
|
|
|
return rv |
|
|
|
|
finally: |
|
|
|
|
self.popConnectionParameters() |
|
|
|
|