Skip to content

Commit

Permalink
cleanup & build
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Oct 23, 2017
1 parent a313dce commit b881784
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 52 deletions.
5 changes: 3 additions & 2 deletions build/ccxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -17107,8 +17107,9 @@ public function fetch_tickers ($symbols = null, $params = array ()) {
for ($s = 0; $s < count ($this->symbols); $s++) {
$symbol = $this->symbols[$s];
$market = $this->markets[$symbol];
if (!$market['darkpool'])
$pairs[] = $market['id'];
if ($market['active'])
if (!$market['darkpool'])
$pairs[] = $market['id'];
}
$filter = implode (',', $pairs);
$response = $this->publicGetTicker (array_merge (array (
Expand Down
7 changes: 4 additions & 3 deletions ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -16609,7 +16609,7 @@ var kraken = {
return result;
},

async appendInactiveMarkets (result = []) {
appendInactiveMarkets (result = []) {
let precision = { 'amount': 8, 'price': 8 };
let costLimits = { 'min': 0, 'max': undefined };
let priceLimits = { 'min': Math.pow (10, -precision['price']), 'max': undefined };
Expand Down Expand Up @@ -16680,8 +16680,9 @@ var kraken = {
for (let s = 0; s < this.symbols.length; s++) {
let symbol = this.symbols[s];
let market = this.markets[symbol];
if (!market['darkpool'])
pairs.push (market['id']);
if (market['active'])
if (!market['darkpool'])
pairs.push (market['id']);
}
let filter = pairs.join (',');
let response = await this.publicGetTicker (this.extend ({
Expand Down
7 changes: 4 additions & 3 deletions ccxt/async/exchanges.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions ccxt/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -14967,8 +14967,9 @@ def fetch_tickers(self, symbols=None, params={}):
for s in range(0, len(self.symbols)):
symbol = self.symbols[s]
market = self.markets[symbol]
if not market['darkpool']:
pairs.append(market['id'])
if market['active']:
if not market['darkpool']:
pairs.append(market['id'])
filter = ','.join(pairs)
response = self.publicGetTicker(self.extend({
'pair': filter,
Expand Down
44 changes: 23 additions & 21 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ class Argv(object):
argv = Argv()

parser = argparse.ArgumentParser()

parser.add_argument('--verbose', action='store_true', help='enable verbose output')
parser.add_argument('--nonce', type=int, help='integer')
parser.add_argument('exchange', type=str, help='exchange id in lowercase', nargs='?')
parser.add_argument('symbol', type=str, help='symbol in uppercase', nargs='?')

parser.parse_args(namespace=argv)

exchanges = {}
Expand Down Expand Up @@ -134,31 +136,31 @@ def test_tickers(exchange, symbol):
delay = int(exchange.rateLimit / 1000)
time.sleep(delay)
tickers = None
tickers = exchange.fetch_tickers()
print(green('foo'))
# try:
# # dump(green(exchange.id), 'fetching all tickers at once...')
# tickers = exchange.fetch_tickers()
# print(green('foo'))
# # dump(green(exchange.id), 'fetched all', green(len(list(tickers.keys()))), 'tickers')
# except Exception as e:
# print(str(e), '------------------------------------------')
# dump(green(exchange.id), 'failed to fetch all tickers, fetching multiple tickers at once...')
# tickers = exchange.fetch_tickers([symbol])
# dump(green(exchange.id), 'fetched', green(len(list(tickers.keys()))), 'tickers')
# else:
# test_tickers_async(exchange)
try:
# dump(green(exchange.id), 'fetching all tickers at once...')
tickers = exchange.fetch_tickers()
dump(green(exchange.id), 'fetched all', green(len(list(tickers.keys()))), 'tickers')
except Exception as e:
dump(green(exchange.id), 'failed to fetch all tickers, fetching multiple tickers at once...')
tickers = exchange.fetch_tickers([symbol])
dump(green(exchange.id), 'fetched', green(len(list(tickers.keys()))), 'tickers')

test_tickers_async(exchange)

# ------------------------------------------------------------------------------

def get_active_symbols(exchange):
return [symbol for symbol in exchange.symbols if is_active_symbol (exchange, symbol)]

def is_active_symbol(exchange, symbol):
return ('.' not in symbol) and (('active' not in exchange.markets[symbol]) or (exchange.markets[symbol]['active']))

# def test_tickers_async(exchange):
# dump(green(exchange.id), 'fetching all tickers by simultaneous multiple concurrent requests')
# # Some exchanges not all the symbols can fetch tickers for
# symbols_to_load = [symbol for symbol in exchange.symbols if '.' not in symbol]
# input_coroutines = [exchange.fetchTicker(symbol) for symbol in symbols_to_load]
# tickers = asyncio.gather(*input_coroutines)
# dump(green(exchange.id), 'fetched', green(len(list(tickers))), 'tickers')
def test_tickers_async(exchange):
dump(green(exchange.id), 'fetching all tickers by simultaneous multiple concurrent requests')
symbols_to_load = get_active_symbols(exchange)
input_coroutines = [exchange.fetchTicker(symbol) for symbol in symbols_to_load]
tickers = asyncio.gather(*input_coroutines)
dump(green(exchange.id), 'fetched', green(len(list(tickers))), 'tickers')

# ------------------------------------------------------------------------------

Expand Down
44 changes: 23 additions & 21 deletions test/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class Argv(object):
argv = Argv()

parser = argparse.ArgumentParser()
parser.add_argument('--token_bucket', action='store_true', help='enable token bucket experimental test')
parser.add_argument('--verbose', action='store_true', help='enable verbose output')
parser.add_argument('--nonce', type=int, help='integer')
parser.add_argument('exchange', type=str, help='exchange id in lowercase', nargs='?')
parser.add_argument('symbol', type=str, help='symbol in uppercase', nargs='?')

parser.parse_args(namespace=argv)

exchanges = {}
Expand Down Expand Up @@ -135,31 +137,31 @@ async def test_tickers(exchange, symbol):
delay = int(exchange.rateLimit / 1000)
time.sleep(delay)
tickers = None
tickers = await exchange.fetch_tickers()
print(green('foo'))
# try:
# # dump(green(exchange.id), 'fetching all tickers at once...')
# tickers = await exchange.fetch_tickers()
# print(green('foo'))
# # dump(green(exchange.id), 'fetched all', green(len(list(tickers.keys()))), 'tickers')
# except Exception as e:
# print(str(e), '------------------------------------------')
# dump(green(exchange.id), 'failed to fetch all tickers, fetching multiple tickers at once...')
# tickers = await exchange.fetch_tickers([symbol])
# dump(green(exchange.id), 'fetched', green(len(list(tickers.keys()))), 'tickers')
# else:
# await test_tickers_async(exchange)
try:
# dump(green(exchange.id), 'fetching all tickers at once...')
tickers = await exchange.fetch_tickers()
dump(green(exchange.id), 'fetched all', green(len(list(tickers.keys()))), 'tickers')
except Exception as e:
dump(green(exchange.id), 'failed to fetch all tickers, fetching multiple tickers at once...')
tickers = await exchange.fetch_tickers([symbol])
dump(green(exchange.id), 'fetched', green(len(list(tickers.keys()))), 'tickers')
elif argv.token_bucket:
await test_tickers_async(exchange)

# ------------------------------------------------------------------------------

def get_active_symbols(exchange):
return [symbol for symbol in exchange.symbols if is_active_symbol (exchange, symbol)]

def is_active_symbol(exchange, symbol):
return ('.' not in symbol) and (('active' not in exchange.markets[symbol]) or (exchange.markets[symbol]['active']))

# async def test_tickers_async(exchange):
# dump(green(exchange.id), 'fetching all tickers by simultaneous multiple concurrent requests')
# # Some exchanges not all the symbols can fetch tickers for
# symbols_to_load = [symbol for symbol in exchange.symbols if '.' not in symbol]
# input_coroutines = [exchange.fetchTicker(symbol) for symbol in symbols_to_load]
# tickers = await asyncio.gather(*input_coroutines)
# dump(green(exchange.id), 'fetched', green(len(list(tickers))), 'tickers')
async def test_tickers_async(exchange):
dump(green(exchange.id), 'fetching all tickers by simultaneous multiple concurrent requests')
symbols_to_load = get_active_symbols(exchange)
input_coroutines = [exchange.fetchTicker(symbol) for symbol in symbols_to_load]
tickers = await asyncio.gather(*input_coroutines)
dump(green(exchange.id), 'fetched', green(len(list(tickers))), 'tickers')

# ------------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ function transpilePythonAsyncToSync (oldName, newName) {
return (
line.replace ('asyncio.get_event_loop().run_until_complete(main())', 'main()')
.replace ('import ccxt.async as ccxt', 'import ccxt')
.replace (/.*token\_bucket.*/g, '')
.replace ('async ', '')
.replace ('await ', ''))
})
Expand Down

0 comments on commit b881784

Please sign in to comment.