From c98b2f0f4a741bdea72a18976d5094852be5f924 Mon Sep 17 00:00:00 2001 From: Bryant Moscon Date: Fri, 12 Jul 2019 19:03:36 -0400 Subject: [PATCH] Python3 WIP --- gryphon/dashboards/app.py | 2 +- gryphon/dashboards/handlers/admin_base.py | 4 +-- gryphon/dashboards/handlers/ledger.py | 2 +- gryphon/dashboards/handlers/status.py | 2 +- gryphon/dashboards/models/base.py | 2 +- gryphon/dashboards/templates/base.html | 2 +- gryphon/dashboards/util/balances.py | 4 +-- .../auditors/orderbook_auditor.py | 4 +-- .../data_service/exchange_volume_consumer.py | 2 +- gryphon/data_service/migrations/env.py | 2 +- gryphon/data_service/orderbook_consumer.py | 2 +- .../websocket/bitfinex_orderbook_websocket.py | 4 +-- .../websocket/bitstamp_orderbook_websocket.py | 12 ++++---- .../pollers/trades/trades_poller.py | 4 +-- gryphon/data_service/runt.py | 2 +- .../scripts/historical_trade_collector.py | 2 +- gryphon/data_service/trades_consumer.py | 6 ++-- gryphon/execution/app.py | 2 +- gryphon/execution/bots/overwatch.py | 2 +- gryphon/execution/bots/shoebox.py | 2 +- gryphon/execution/console.py | 2 +- gryphon/execution/controllers/balance.py | 2 +- .../controllers/initialize_ledger.py | 2 +- .../controllers/manual_accounting.py | 2 +- .../execution/controllers/run_migrations.py | 2 +- .../harness/exchange_coordinator.pyx | 10 +++---- gryphon/execution/harness/harness.pyx | 3 +- gryphon/execution/lib/auditing.py | 4 +-- gryphon/execution/lib/config.py | 4 +-- gryphon/execution/lib/config_helper.py | 2 +- gryphon/execution/lib/tick_profiling.py | 2 +- gryphon/execution/live_runner.py | 2 +- gryphon/execution/migrations/env.py | 2 +- .../execution/models/backtesting/result.py | 2 +- gryphon/execution/scripts/ledger_export.py | 2 +- gryphon/execution/scripts/reset_balance.py | 2 +- gryphon/execution/strategies/base.pyx | 2 +- .../builtin/fundamental_value/v1.py | 2 +- .../builtin/fundamental_value/v2.py | 2 +- .../builtin/fundamental_value/v3.py | 2 +- gryphon/lib/analysis/legacy/price_diff.py | 2 +- gryphon/lib/arbitrage.py | 2 +- gryphon/lib/bitcoinwisdom.py | 2 +- gryphon/lib/configuration.py | 12 ++++---- gryphon/lib/debugging/bitstamp_cert_error.py | 4 +-- gryphon/lib/exchange/bitfinex_btc_usd.py | 10 +++---- gryphon/lib/exchange/bitstamp_btc_usd.py | 18 ++++++------ gryphon/lib/exchange/coinbase_btc_usd.py | 4 +-- gryphon/lib/exchange/exchange_order.pyx | 2 +- gryphon/lib/exchange/exchange_trade.pyx | 2 +- gryphon/lib/exchange/gemini_btc_usd.py | 8 +++--- gryphon/lib/exchange/itbit_btc_usd.py | 2 +- gryphon/lib/exchange/kraken_btc_eur.py | 28 +++++++++---------- gryphon/lib/exchange/okcoin_btc_usd.py | 2 +- gryphon/lib/exchange/quadriga_btc_cad.py | 12 ++++---- gryphon/lib/hackernewsie.py | 2 +- gryphon/lib/models/atlaszero/base.py | 2 +- gryphon/lib/models/atlaszero/metric.py | 2 +- gryphon/lib/models/base.pyx | 2 +- gryphon/lib/models/datum.py | 6 ++-- gryphon/lib/models/emeraldhavoc/base.py | 2 +- .../models/emeraldhavoc/exchange_volume.py | 4 +-- gryphon/lib/models/emeraldhavoc/orderbook.pyx | 4 +-- gryphon/lib/models/emeraldhavoc/trade.py | 8 +++--- gryphon/lib/models/event.py | 6 ++-- gryphon/lib/models/exchange.pyx | 10 +++---- gryphon/lib/models/liability.py | 8 +++--- gryphon/lib/models/market_data.py | 2 +- gryphon/lib/models/order.pyx | 6 ++-- gryphon/lib/models/orderbook_snapshot.py | 4 +-- gryphon/lib/models/ticker.py | 6 ++-- gryphon/lib/models/trade.pyx | 4 +-- gryphon/lib/models/transaction.py | 4 +-- gryphon/lib/money.py | 2 +- gryphon/lib/scripts/bitstamp_auth_test.py | 2 +- .../scripts/test_fast_revenue_fees_profit.py | 2 +- gryphon/lib/twistedbitcoinwisdom.py | 2 +- .../exchange_coordinator/auth_methods.py | 2 +- .../exchange_coordinator/bitstamp.py | 2 +- .../exchange_coordinator/kraken.py | 2 +- .../exchange_coordinator/public_methods.py | 2 +- .../exchange_wrappers/auth_methods.py | 2 +- .../exchange_wrappers/bitstamp_auth.py | 2 +- .../exchange_wrappers/bitstamp_live_orders.py | 2 +- .../exchange_wrappers/coinbase_auth.py | 2 +- .../exchange_wrappers/coinbase_live_orders.py | 2 +- .../exchange_wrappers/gemini_auth.py | 2 +- .../exchange_wrappers/gemini_live_orders.py | 2 +- .../exchange_wrappers/itbit_auth.py | 2 +- .../exchange_wrappers/itbit_live_orders.py | 2 +- .../exchange_wrappers/kraken_auth.py | 2 +- .../exchange_wrappers/kraken_live_orders.py | 2 +- .../exchange_wrappers/live_orders.py | 2 +- .../exchange_wrappers/quadriga_auth.py | 2 +- .../exchange_wrappers/quadriga_live_orders.py | 2 +- gryphon/tests/extra/libraries/sharpe_test.py | 2 +- gryphon/tests/logic/auditing/auditing_test.py | 2 +- .../tests/logic/configuration/base_test.py | 12 ++++---- .../configuration/bitstamp_bch_btc_test.py | 2 +- .../configuration/bitstamp_bch_eur_test.py | 2 +- .../configuration/bitstamp_bch_usd_test.py | 2 +- .../configuration/bitstamp_btc_eur_test.py | 2 +- .../configuration/bitstamp_eth_btc_test.py | 2 +- .../configuration/bitstamp_eth_eur_test.py | 2 +- .../configuration/bitstamp_eth_usd_test.py | 2 +- .../logic/configuration/bitstamp_test.py | 2 +- .../logic/configuration/coinbase_test.py | 2 +- gryphon/tests/logic/configuration/exchange.py | 2 +- .../configuration/execution_config_test.py | 6 ++-- .../configuration/gemini_eth_btc_test.py | 2 +- .../configuration/gemini_eth_usd_test.py | 2 +- .../tests/logic/configuration/gemini_test.py | 2 +- .../tests/logic/configuration/itbit_test.py | 2 +- .../logic/configuration/kraken_cad_test.py | 2 +- .../tests/logic/configuration/kraken_test.py | 2 +- .../logic/configuration/kraken_usd_test.py | 2 +- .../logic/configuration/quadriga_test.py | 2 +- .../configuration/strategy_config_test.py | 2 +- .../logic/exchange_wrappers/bitstamp_test.py | 2 +- .../tests/logic/exchange_wrappers/coinbase.py | 2 +- .../logic/exchange_wrappers/gemini_test.py | 2 +- .../tests/logic/exchange_wrappers/itbit.py | 2 +- .../tests/logic/exchange_wrappers/kraken.py | 2 +- .../logic/exchange_wrappers/public_methods.py | 2 +- .../tests/logic/exchange_wrappers/quadriga.py | 2 +- .../tests/logic/libraries/arbitrage_test.py | 2 +- .../logic/libraries/close_options_test.py | 2 +- .../logic/libraries/market_making_test.py | 2 +- .../tests/logic/libraries/midpoint_test.py | 2 +- gryphon/tests/logic/libraries/money_test.py | 2 +- .../logic/libraries/order_sliding_test.py | 2 +- .../libraries/orderbook_strength_test.py | 2 +- gryphon/tests/logic/libraries/revenue_test.py | 2 +- .../logic/libraries/volume_available_test.py | 2 +- gryphon/tests/logic/models/balance_test.py | 2 +- gryphon/tests/logic/models/liability_test.py | 2 +- gryphon/tests/logic/models/order_test.py | 2 +- gryphon/tests/logic/models/trade_test.py | 2 +- .../tests/logic/models/transaction_test.py | 2 +- gryphon/tests/logic/strategies/multi_test.py | 2 +- gryphon/tests/runtests.py | 2 +- requirements/gryphon+gds.txt | 11 +++----- requirements/gryphon-base.txt | 11 +++----- setup.py | 9 ++---- 144 files changed, 239 insertions(+), 251 deletions(-) diff --git a/gryphon/dashboards/app.py b/gryphon/dashboards/app.py index 6c3f1c1..66f1bb1 100755 --- a/gryphon/dashboards/app.py +++ b/gryphon/dashboards/app.py @@ -13,7 +13,7 @@ from gryphon.lib import environment environment.load_environment_variables() -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() from gryphon.dashboards.routes import url_patterns diff --git a/gryphon/dashboards/handlers/admin_base.py b/gryphon/dashboards/handlers/admin_base.py index 83d2056..14c1c52 100755 --- a/gryphon/dashboards/handlers/admin_base.py +++ b/gryphon/dashboards/handlers/admin_base.py @@ -27,7 +27,7 @@ def write_error(self, status_code, **kwargs): exc_info = kwargs.get('exc_info') error_readout = [ - unicode(line, 'utf8') for line in traceback.format_exception(*exc_info) + str(line, 'utf8') for line in traceback.format_exception(*exc_info) ] logger.critical(u''.join(error_readout)) @@ -47,7 +47,7 @@ def get_current_user(self): def get_secure_cookie(self, name, include_name=True, value=None): cookie_value = super(AdminBaseHandler, self).get_secure_cookie(name) - return unicode(cookie_value or '', 'utf8') + return str(cookie_value or '', 'utf8') def show_error_message(self, message): self.set_secure_cookie('error_message', message) diff --git a/gryphon/dashboards/handlers/ledger.py b/gryphon/dashboards/handlers/ledger.py index 59cfe5c..7e67118 100755 --- a/gryphon/dashboards/handlers/ledger.py +++ b/gryphon/dashboards/handlers/ledger.py @@ -261,7 +261,7 @@ def table_entries_from_transaction(self, transaction): entry['date'] = date entry['details'] = ''.join([ '%s:%s ' % (k, v) - for k, v in transaction.transaction_details.iteritems() + for k, v in transaction.transaction_details.items() if k in ['external_transaction_id', 'notes'] and v not in ['xxx'] ]) diff --git a/gryphon/dashboards/handlers/status.py b/gryphon/dashboards/handlers/status.py index 9a620af..90b175a 100755 --- a/gryphon/dashboards/handlers/status.py +++ b/gryphon/dashboards/handlers/status.py @@ -140,7 +140,7 @@ def get_system_balances(self, exchanges): system_balance += e.exchange_account_db_object(self.trading_db).balance total_fiat = sum([ - balance.to("USD") for currency, balance in system_balance.iteritems() + balance.to("USD") for currency, balance in system_balance.items() if currency not in Money.CRYPTO_CURRENCIES ]) diff --git a/gryphon/dashboards/models/base.py b/gryphon/dashboards/models/base.py index 3d30076..b8283a9 100755 --- a/gryphon/dashboards/models/base.py +++ b/gryphon/dashboards/models/base.py @@ -5,7 +5,7 @@ metadata = Base.metadata def unicode_string(self): - return unicode(self).encode('utf-8') + return str(self).encode('utf-8') Base.__str__ == unicode_string diff --git a/gryphon/dashboards/templates/base.html b/gryphon/dashboards/templates/base.html index 6a9f2e7..0834c3f 100755 --- a/gryphon/dashboards/templates/base.html +++ b/gryphon/dashboards/templates/base.html @@ -170,7 +170,7 @@
Custom Strategies
  • {% if len(args['exchanges']) > 0 %} - {% for key, name in args['exchanges'].iteritems() %} + {% for key, name in args['exchanges'].items() %}
  • {% set url = "/ledger/%s" % key %} {{ name }} diff --git a/gryphon/dashboards/util/balances.py b/gryphon/dashboards/util/balances.py index 38fc9e9..ba4a579 100755 --- a/gryphon/dashboards/util/balances.py +++ b/gryphon/dashboards/util/balances.py @@ -34,7 +34,7 @@ def get_balance_time_series_from_audits(audits): continue # convert to Money objects - for currency, balance_str in balance_data.iteritems(): + for currency, balance_str in balance_data.items(): balance_data[currency] = Money.loads(balance_str) balance = Balance(balance_data) @@ -103,7 +103,7 @@ def get_drift_from_audits(audits): if 'drift' in audit.data: data = json.loads(audit.data) - for currency, str_amount in data['drift'].iteritems(): + for currency, str_amount in data['drift'].items(): drift_by_currency += Money.loads(str_amount) return drift_by_currency diff --git a/gryphon/data_service/auditors/orderbook_auditor.py b/gryphon/data_service/auditors/orderbook_auditor.py index 2852622..9737494 100755 --- a/gryphon/data_service/auditors/orderbook_auditor.py +++ b/gryphon/data_service/auditors/orderbook_auditor.py @@ -242,7 +242,7 @@ def audit_orderbook(self, orderbook, orderbook_timestamp): if not our_orderbooks: log.msg('No orderbooks to audit against') - for key, value in fundamental_values.iteritems(): + for key, value in fundamental_values.items(): log.msg( '------ Fundamental Value Closeness:%.6f, DBfv:%s, HTTPfv:%s' % ( key, @@ -250,7 +250,7 @@ def audit_orderbook(self, orderbook, orderbook_timestamp): value['http_fundamental_value'] )) - for key, value in change_dict.iteritems(): + for key, value in change_dict.items(): log.msg('------ Change Count: %s' % key) log.msg( diff --git a/gryphon/data_service/exchange_volume_consumer.py b/gryphon/data_service/exchange_volume_consumer.py index 8644fc7..177eab7 100755 --- a/gryphon/data_service/exchange_volume_consumer.py +++ b/gryphon/data_service/exchange_volume_consumer.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import json import os diff --git a/gryphon/data_service/migrations/env.py b/gryphon/data_service/migrations/env.py index 6838420..9f85288 100755 --- a/gryphon/data_service/migrations/env.py +++ b/gryphon/data_service/migrations/env.py @@ -1,5 +1,5 @@ from __future__ import with_statement -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from logging.config import fileConfig from alembic import context diff --git a/gryphon/data_service/orderbook_consumer.py b/gryphon/data_service/orderbook_consumer.py index c563a9c..c6d4638 100755 --- a/gryphon/data_service/orderbook_consumer.py +++ b/gryphon/data_service/orderbook_consumer.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import json import os import subprocess diff --git a/gryphon/data_service/pollers/orderbook/websocket/bitfinex_orderbook_websocket.py b/gryphon/data_service/pollers/orderbook/websocket/bitfinex_orderbook_websocket.py index 736b8f2..4525c61 100755 --- a/gryphon/data_service/pollers/orderbook/websocket/bitfinex_orderbook_websocket.py +++ b/gryphon/data_service/pollers/orderbook/websocket/bitfinex_orderbook_websocket.py @@ -130,11 +130,11 @@ def get_orderbook_to_publish(self): bids = [] asks = [] - for price, volume in sorted(self.bids_dict.iteritems(), reverse=True): + for price, volume in sorted(self.bids_dict.items(), reverse=True): if volume > 0: bids.append([str(price), str(volume), '']) - for price, volume in sorted(self.asks_dict.iteritems()): + for price, volume in sorted(self.asks_dict.items()): if volume > 0: asks.append([str(price), str(volume), '']) diff --git a/gryphon/data_service/pollers/orderbook/websocket/bitstamp_orderbook_websocket.py b/gryphon/data_service/pollers/orderbook/websocket/bitstamp_orderbook_websocket.py index 8935921..c4da754 100755 --- a/gryphon/data_service/pollers/orderbook/websocket/bitstamp_orderbook_websocket.py +++ b/gryphon/data_service/pollers/orderbook/websocket/bitstamp_orderbook_websocket.py @@ -211,26 +211,26 @@ def apply_change_to_orderbook(self, change): # Remove the 0 volumes from the orderbook. self.orderbook['bids'].update(bids_changes) - for k, v in self.orderbook['bids'].iteritems(): + for k, v in self.orderbook['bids'].items(): if v == "0": self.orderbook['bids'].pop(k) # Re-sort the bids. self.orderbook['bids'] = OrderedDict(sorted( - self.orderbook['bids'].iteritems(), + self.orderbook['bids'].items(), key=lambda (k, v): float(k), reverse=True, )) self.orderbook['asks'].update(asks_changes) - for k, v in self.orderbook['asks'].iteritems(): + for k, v in self.orderbook['asks'].items(): if v == "0": self.orderbook['asks'].pop(k) # Re-sort the asks. self.orderbook['asks'] = OrderedDict( - sorted(self.orderbook['asks'].iteritems(), key=lambda (k, v): float(k)), + sorted(self.orderbook['asks'].items(), key=lambda (k, v): float(k)), ) def parse_orders(self, orders): @@ -247,7 +247,7 @@ def get_orderbook_to_publish(self): price_key_orderbook = self.orderbook return { - 'bids': [[k, v, ''] for k, v in price_key_orderbook['bids'].iteritems()], - 'asks': [[k, v, ''] for k, v in price_key_orderbook['asks'].iteritems()], + 'bids': [[k, v, ''] for k, v in price_key_orderbook['bids'].items()], + 'asks': [[k, v, ''] for k, v in price_key_orderbook['asks'].items()], } diff --git a/gryphon/data_service/pollers/trades/trades_poller.py b/gryphon/data_service/pollers/trades/trades_poller.py index 0a802de..bb2ce9b 100755 --- a/gryphon/data_service/pollers/trades/trades_poller.py +++ b/gryphon/data_service/pollers/trades/trades_poller.py @@ -50,9 +50,9 @@ def parse_response(self, resp_obj): for trade in trades: if trade['trade_id'] > self.most_recent_trade_id: trade['price_currency'] = trade['price'].currency - trade['price'] = unicode(trade['price'].amount) + trade['price'] = str(trade['price'].amount) trade['volume_currency'] = trade['volume'].currency - trade['volume'] = unicode(trade['volume'].amount) + trade['volume'] = str(trade['volume'].amount) trade['timestamp'] = int(trade['timestamp']) trade_string = json.dumps(trade, ensure_ascii=False) self.producer.publish_message(trade_string) diff --git a/gryphon/data_service/runt.py b/gryphon/data_service/runt.py index 53ec662..b6af499 100755 --- a/gryphon/data_service/runt.py +++ b/gryphon/data_service/runt.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import logging import logging.handlers import os diff --git a/gryphon/data_service/scripts/historical_trade_collector.py b/gryphon/data_service/scripts/historical_trade_collector.py index 8c93789..4fa6b73 100755 --- a/gryphon/data_service/scripts/historical_trade_collector.py +++ b/gryphon/data_service/scripts/historical_trade_collector.py @@ -1,7 +1,7 @@ import csv from datetime import timedelta import gzip -import StringIO +from io import StringIO from delorean import epoch import requests diff --git a/gryphon/data_service/trades_consumer.py b/gryphon/data_service/trades_consumer.py index 0f2f99b..015a1a4 100755 --- a/gryphon/data_service/trades_consumer.py +++ b/gryphon/data_service/trades_consumer.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import json import os @@ -27,9 +27,9 @@ def trades_consumer_function(message, db): t = Trade( price=Money(trade_json['price'], price_currency), volume=Money(trade_json['volume'], volume_currency), - exchange=unicode(trade_json['exchange']), + exchange=str(trade_json['exchange']), timestamp=timestamp, - exchange_trade_id=unicode(trade_json['trade_id']), + exchange_trade_id=str(trade_json['trade_id']), ) db.add(t) diff --git a/gryphon/execution/app.py b/gryphon/execution/app.py index f0faa36..bcb20c2 100755 --- a/gryphon/execution/app.py +++ b/gryphon/execution/app.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import importlib import logging diff --git a/gryphon/execution/bots/overwatch.py b/gryphon/execution/bots/overwatch.py index ab6912a..6d00863 100755 --- a/gryphon/execution/bots/overwatch.py +++ b/gryphon/execution/bots/overwatch.py @@ -220,7 +220,7 @@ def check_spreads_are_normal(db): sanity = True - for exchange_name, fv in native_fvs.iteritems(): + for exchange_name, fv in native_fvs.items(): if abs(fv - current_core_fv) > INTER_EXCHANGE_SPREAD_THRESHOLD: sanity = False break diff --git a/gryphon/execution/bots/shoebox.py b/gryphon/execution/bots/shoebox.py index 0c89cc0..6fb70c7 100755 --- a/gryphon/execution/bots/shoebox.py +++ b/gryphon/execution/bots/shoebox.py @@ -301,7 +301,7 @@ def manual_btc_withdrawals(db): logger.info('Running manual BTC withdrawals') - for name, target in MANUAL_BTC_EXCHANGES.iteritems(): + for name, target in MANUAL_BTC_EXCHANGES.items(): exchange_db = exchange_factory.make_exchange_data_from_key(name, db) if exchange_db.balance['BTC'] > target: withdrawal_amount = exchange_db.balance['BTC'] - target diff --git a/gryphon/execution/console.py b/gryphon/execution/console.py index 9ab2e7b..7999695 100755 --- a/gryphon/execution/console.py +++ b/gryphon/execution/console.py @@ -14,7 +14,7 @@ strategy config files. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from datetime import datetime, timedelta import logging diff --git a/gryphon/execution/controllers/balance.py b/gryphon/execution/controllers/balance.py index 1365c5a..3517516 100755 --- a/gryphon/execution/controllers/balance.py +++ b/gryphon/execution/controllers/balance.py @@ -50,7 +50,7 @@ def get_db_balances(exchanges): def format_balances(exchange_balances, db_balances): output_string = u"\n{0:15} : {1:15} | {2:15} || {3:15} | {4:15}\n".format("Balances", "FIAT", "BTC", "dbFIAT", "dbBTC") - for name, balance in sorted(exchange_balances.iteritems()): + for name, balance in sorted(exchange_balances.items()): db_balance = db_balances[name] chunk = u"{0:15} : {1:15} | {2:15.8f} || {3:15} | {4:15.8f}\n".format( name, diff --git a/gryphon/execution/controllers/initialize_ledger.py b/gryphon/execution/controllers/initialize_ledger.py index 029a8d0..162c1db 100755 --- a/gryphon/execution/controllers/initialize_ledger.py +++ b/gryphon/execution/controllers/initialize_ledger.py @@ -16,7 +16,7 @@ [--execute] """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os diff --git a/gryphon/execution/controllers/manual_accounting.py b/gryphon/execution/controllers/manual_accounting.py index 6d4bfb7..e71c664 100755 --- a/gryphon/execution/controllers/manual_accounting.py +++ b/gryphon/execution/controllers/manual_accounting.py @@ -91,7 +91,7 @@ def manual_accounting(exchange_name, order_id, actor, execute=False): old_balance = exchange_data.balance[exchange.volume_currency] - for currency_code, position in position_change.iteritems(): + for currency_code, position in position_change.items(): exchange_data.position[currency_code] += position exchange_data.balance[currency_code] += position diff --git a/gryphon/execution/controllers/run_migrations.py b/gryphon/execution/controllers/run_migrations.py index 8697b31..7b6bb8b 100755 --- a/gryphon/execution/controllers/run_migrations.py +++ b/gryphon/execution/controllers/run_migrations.py @@ -6,7 +6,7 @@ gryphon-exec run-migrations [GDS | TRADING | DASHBOARD] [--execute] """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import logging import os diff --git a/gryphon/execution/harness/exchange_coordinator.pyx b/gryphon/execution/harness/exchange_coordinator.pyx index e36071c..16e6630 100755 --- a/gryphon/execution/harness/exchange_coordinator.pyx +++ b/gryphon/execution/harness/exchange_coordinator.pyx @@ -13,9 +13,7 @@ it makes sure that our database does not get out of sync with our our account wi exchange. """ -import pyximport; pyximport.install() - -from sets import Set +import pyximport; pyximport.install(language_level=3) from cdecimal import Decimal, ROUND_UP, ROUND_DOWN from delorean import Delorean @@ -81,9 +79,9 @@ class ExchangeCoordinator(object): @tick_profile def _get_current_orders(self, exchange_open_orders): db_open_orders = self._get_db_open_orders() - db_open_order_ids = Set([o.exchange_order_id for o in db_open_orders]) + db_open_order_ids = set([o.exchange_order_id for o in db_open_orders]) - exchange_open_order_ids = Set([o['id'] for o in exchange_open_orders]) + exchange_open_order_ids = set([o['id'] for o in exchange_open_orders]) eaten_order_ids = db_open_order_ids - exchange_open_order_ids current_order_ids = db_open_order_ids & exchange_open_order_ids @@ -226,7 +224,7 @@ class ExchangeCoordinator(object): """ Formerly harness:update_position. """ - for currency_code, position in position_change.iteritems(): + for currency_code, position in position_change.items(): self.exchange_account.position[currency_code] += position self.exchange_account.balance[currency_code] += position diff --git a/gryphon/execution/harness/harness.pyx b/gryphon/execution/harness/harness.pyx index e0d88e0..8cd7776 100755 --- a/gryphon/execution/harness/harness.pyx +++ b/gryphon/execution/harness/harness.pyx @@ -11,7 +11,6 @@ backtesting. For this, you can write another harness (so long as it conforms to interface), and reimplement the interface functions in a different way. """ -from sets import Set import termcolor as tc import time @@ -227,7 +226,7 @@ class Harness(ConfigurableObject): This function simply attaches the date and colours to a log message, and then dispatches to the appropriate logger function. """ - timestamp = unicode(Delorean().datetime.strftime('%d/%m/%y %H:%M:%S %Z')) + timestamp = str(Delorean().datetime.strftime('%d/%m/%y %H:%M:%S %Z')) result_string = u'[%s] (%s) %s' % ( self.strategy.name if self.strategy else 'HARNESS_SETUP', diff --git a/gryphon/execution/lib/auditing.py b/gryphon/execution/lib/auditing.py index 1e5a9dd..3f1571e 100755 --- a/gryphon/execution/lib/auditing.py +++ b/gryphon/execution/lib/auditing.py @@ -150,7 +150,7 @@ def order_audit(db, exchange, skip_recent=0, tolerance=Decimal('0')): failed_order_data = [] - for exchange_order_id, exchange_volume_filled in audit_data.iteritems(): + for exchange_order_id, exchange_volume_filled in audit_data.items(): try: db_volume_filled = db_order_hash[exchange_order_id] @@ -287,7 +287,7 @@ def balance_equality(balance_a, balance_b): are fixing it here with the intention of a later fix to the core lib. """ - currencies = set(balance_a.keys() + balance_b.keys()) + currencies = set(list(balance_a.keys()) + list(balance_b.keys())) for currency in currencies: if currency in balance_a and currency in balance_b: diff --git a/gryphon/execution/lib/config.py b/gryphon/execution/lib/config.py index ffb1d2e..a2f0f21 100755 --- a/gryphon/execution/lib/config.py +++ b/gryphon/execution/lib/config.py @@ -1,4 +1,4 @@ -import ConfigParser +import configparser from gryphon.lib.logger import get_logger @@ -8,7 +8,7 @@ def get_config_var(filepath, section, key): print filepath - config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() config.read(filepath) section_dict = dict(config.items('live')) diff --git a/gryphon/execution/lib/config_helper.py b/gryphon/execution/lib/config_helper.py index 4da43d2..abdcc3f 100755 --- a/gryphon/execution/lib/config_helper.py +++ b/gryphon/execution/lib/config_helper.py @@ -14,7 +14,7 @@ 3) At no point is there a any guarantee a setting is in the configuration object. """ -import ConfigParser +import configparser import argparse from cdecimal import Decimal, InvalidOperation diff --git a/gryphon/execution/lib/tick_profiling.py b/gryphon/execution/lib/tick_profiling.py index 9595fa7..968fb70 100755 --- a/gryphon/execution/lib/tick_profiling.py +++ b/gryphon/execution/lib/tick_profiling.py @@ -21,7 +21,7 @@ def record_tick_data(tick_start, strategy_name): def record_tick_block_data(algo, tick_count, strategy_name): - for function_name, profile_times in tick_profile_data.iteritems(): + for function_name, profile_times in tick_profile_data.items(): datum_name = datum_name_for_function_block(strategy_name, function_name) for block_time in profile_times: diff --git a/gryphon/execution/live_runner.py b/gryphon/execution/live_runner.py index 78e448d..b320a80 100755 --- a/gryphon/execution/live_runner.py +++ b/gryphon/execution/live_runner.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from cdecimal import Decimal import inspect import os diff --git a/gryphon/execution/migrations/env.py b/gryphon/execution/migrations/env.py index 1f2c073..e292077 100755 --- a/gryphon/execution/migrations/env.py +++ b/gryphon/execution/migrations/env.py @@ -1,5 +1,5 @@ from __future__ import with_statement -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from alembic import context from sqlalchemy import engine_from_config, pool, create_engine from logging.config import fileConfig diff --git a/gryphon/execution/models/backtesting/result.py b/gryphon/execution/models/backtesting/result.py index f9bee4c..cc43586 100755 --- a/gryphon/execution/models/backtesting/result.py +++ b/gryphon/execution/models/backtesting/result.py @@ -27,7 +27,7 @@ class Result(Base): trades = relationship('ResultTrade', cascade="all,delete-orphan", backref='result') def __init__(self, usd, btc, trading_volume, algorithm, batch, ticks): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() self.algorithm = algorithm self.batch = batch diff --git a/gryphon/execution/scripts/ledger_export.py b/gryphon/execution/scripts/ledger_export.py index edf29bc..f99e690 100755 --- a/gryphon/execution/scripts/ledger_export.py +++ b/gryphon/execution/scripts/ledger_export.py @@ -182,7 +182,7 @@ def table_entries_from_transaction(transaction): entry['date'] = date entry['details'] = ''.join([ '%s:%s ' % (k, v) - for k, v in transaction.transaction_details.iteritems() + for k, v in transaction.transaction_details.items() if k in ['external_transaction_id', 'notes'] and v not in ['xxx'] ]) diff --git a/gryphon/execution/scripts/reset_balance.py b/gryphon/execution/scripts/reset_balance.py index 1c005aa..f9dcb82 100755 --- a/gryphon/execution/scripts/reset_balance.py +++ b/gryphon/execution/scripts/reset_balance.py @@ -16,7 +16,7 @@ account database object. It's really just a cache. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import sys diff --git a/gryphon/execution/strategies/base.pyx b/gryphon/execution/strategies/base.pyx index ab1d3ec..6f1d69e 100755 --- a/gryphon/execution/strategies/base.pyx +++ b/gryphon/execution/strategies/base.pyx @@ -1,4 +1,4 @@ -import ConfigParser +import configparser from delorean import Delorean import pickle import random diff --git a/gryphon/execution/strategies/builtin/fundamental_value/v1.py b/gryphon/execution/strategies/builtin/fundamental_value/v1.py index 76c1ab9..17c9baa 100755 --- a/gryphon/execution/strategies/builtin/fundamental_value/v1.py +++ b/gryphon/execution/strategies/builtin/fundamental_value/v1.py @@ -30,7 +30,7 @@ def calculate(algo, fundamental_value_balance_map): # Determine which exchanges should participate in the bid and which in the ask # and sum them up appropriately. - for exchange_name, exchange in fundamental_value_balance_map.iteritems(): + for exchange_name, exchange in fundamental_value_balance_map.items(): # You may sell if you have enough bitcoin to place an order and don't have # too much fiat. if (exchange[algo.volume_currency.lower()] > buffer_value and diff --git a/gryphon/execution/strategies/builtin/fundamental_value/v2.py b/gryphon/execution/strategies/builtin/fundamental_value/v2.py index 1526dff..6c8e433 100755 --- a/gryphon/execution/strategies/builtin/fundamental_value/v2.py +++ b/gryphon/execution/strategies/builtin/fundamental_value/v2.py @@ -20,7 +20,7 @@ def calculate(algo, fundamental_value_balance_map): participating_exchanges = [] - for exchange_name, exchange in fundamental_value_balance_map.iteritems(): + for exchange_name, exchange in fundamental_value_balance_map.items(): # If you have bitcoin and are below your maximum fiat, you can sell. can_sell = ( exchange[algo.volume_currency.lower()] > buffer_value and diff --git a/gryphon/execution/strategies/builtin/fundamental_value/v3.py b/gryphon/execution/strategies/builtin/fundamental_value/v3.py index e8b7004..334d8b4 100755 --- a/gryphon/execution/strategies/builtin/fundamental_value/v3.py +++ b/gryphon/execution/strategies/builtin/fundamental_value/v3.py @@ -34,7 +34,7 @@ def calculate(algo, fundamental_value_balance_map): # Determine which exchanges should participate in the bid and which in the ask # and sum them up appropriately. - for exchange_name, exchange in fundamental_value_balance_map.iteritems(): + for exchange_name, exchange in fundamental_value_balance_map.items(): # You may sell if you have enough bitcoin to place an order and don't have # too much fiat. exchange_weight = conf.fv_v3_weights[algo.volume_currency][exchange_name] diff --git a/gryphon/lib/analysis/legacy/price_diff.py b/gryphon/lib/analysis/legacy/price_diff.py index 3851505..b01f138 100755 --- a/gryphon/lib/analysis/legacy/price_diff.py +++ b/gryphon/lib/analysis/legacy/price_diff.py @@ -79,7 +79,7 @@ def price_diff_compare(fund_vals, fund_val_timestamps, alt_fund_vals, alt_fund_v diffs = {} current_alt = 0 current_fund = 0 - for ts, val in timeline.iteritems(): + for ts, val in timeline.items(): if 'alt' in val: current_alt = val['alt'] if 'fund' in val: diff --git a/gryphon/lib/arbitrage.py b/gryphon/lib/arbitrage.py index cd5aaf9..d7e82fb 100755 --- a/gryphon/lib/arbitrage.py +++ b/gryphon/lib/arbitrage.py @@ -61,7 +61,7 @@ def price_currency(self): def profit(self): return self.revenue - self.fees - def __nonzero__(self): + def __bool__(self): """ A cross is falsy if there is no overlap volume. """ diff --git a/gryphon/lib/bitcoinwisdom.py b/gryphon/lib/bitcoinwisdom.py index dc2271a..ce776d9 100755 --- a/gryphon/lib/bitcoinwisdom.py +++ b/gryphon/lib/bitcoinwisdom.py @@ -83,7 +83,7 @@ def volume_in_period(self, start_date, end_date): step=self.determine_step(start_date, end_date), ) - for k,v in periods.iteritems(): + for k,v in periods.items(): t=Delorean(k, 'UTC').datetime vol=v if t >= start_date and t < end_date: diff --git a/gryphon/lib/configuration.py b/gryphon/lib/configuration.py index c3547f4..6ea4615 100755 --- a/gryphon/lib/configuration.py +++ b/gryphon/lib/configuration.py @@ -4,8 +4,8 @@ import argparse from collections import defaultdict -import ConfigParser -import StringIO +import configparser +from io import StringIO from cdecimal import Decimal, InvalidOperation @@ -19,7 +19,7 @@ def read_config_from_file(config_filename): Section titles of the form [x:y] are parsed into sub-dictionaries under the key x. """ - parser = ConfigParser.RawConfigParser() + parser = configparser.RawConfigParser() parser.read(config_filename) configuration = parse_sections(parser) @@ -31,8 +31,8 @@ def _get_parser_for_string_config(string_config): """ This should only be used for unit testing. """ - buf = StringIO.StringIO(string_config) - parser = ConfigParser.ConfigParser() + buf = StringIO(string_config) + parser = configparser.ConfigParser() parser.readfp(buf) return parser @@ -112,6 +112,6 @@ def dict_update_override(dicta, dictb): iii) does override a valid value in a with a valid value from b """ dicta.update( - {k: v for k, v in dictb.iteritems() if v or (k not in dicta)} + {k: v for k, v in dictb.items() if v or (k not in dicta)} ) diff --git a/gryphon/lib/debugging/bitstamp_cert_error.py b/gryphon/lib/debugging/bitstamp_cert_error.py index 7b28087..fb09abf 100755 --- a/gryphon/lib/debugging/bitstamp_cert_error.py +++ b/gryphon/lib/debugging/bitstamp_cert_error.py @@ -70,7 +70,7 @@ def requests_dot_post(): print '---' print "Trying requests.post" - nonce = unicode(int(round(time.time() * 1000))) + nonce = str(int(round(time.time() * 1000))) message = nonce + CLIENT_ID + API_KEY sig = hmac.new(SECRET, msg=message, digestmod=hashlib.sha256).hexdigest().upper() @@ -105,7 +105,7 @@ def session_post(session=None, clear_cookies=None): print "Clearing the session's cookies" session.cookies.clear() - nonce = unicode(int(round(time.time() * 1000))) + nonce = str(int(round(time.time() * 1000))) message = nonce + CLIENT_ID + API_KEY sig = hmac.new(SECRET, msg=message, digestmod=hashlib.sha256).hexdigest().upper() diff --git a/gryphon/lib/exchange/bitfinex_btc_usd.py b/gryphon/lib/exchange/bitfinex_btc_usd.py index 4c5f148..5b3ccbc 100755 --- a/gryphon/lib/exchange/bitfinex_btc_usd.py +++ b/gryphon/lib/exchange/bitfinex_btc_usd.py @@ -90,13 +90,13 @@ def trades_for_orders_req(self): return self.all_trades_req() def trades_for_orders_resp(self, req, order_ids): - order_ids = [unicode(o) for o in order_ids] + order_ids = [str(o) for o in order_ids] trades = self.all_trades_resp(req) matching_trades = {} for trade in trades: - oid = unicode(trade['order_id']) + oid = str(trade['order_id']) if oid in order_ids: if not oid in matching_trades: matching_trades[oid] = [] @@ -262,7 +262,7 @@ def multi_order_details_req(self): return self.trades_for_orders_req() def multi_order_details_resp(self, req, order_ids): - order_ids = [unicode(o) for o in order_ids] + order_ids = [str(o) for o in order_ids] multi_trades = self.trades_for_orders_resp(req, order_ids) data = {} @@ -294,7 +294,7 @@ def multi_order_details_resp(self, req, order_ids): our_trades.append({ 'time': int(float(t['timestamp'])), - 'trade_id': unicode(t['tid']), + 'trade_id': str(t['tid']), 'fee': fee, 'btc': btc_amount, 'fiat': usd_amount, @@ -328,7 +328,7 @@ def cancel_order_resp(self, req): return {'success': True} def withdraw_crypto_req(self, address, volume): - if not isinstance(address, basestring): + if not isinstance(address, str): raise TypeError('Withdrawal address must be a string') if not isinstance(volume, Money) or volume.currency != 'BTC': diff --git a/gryphon/lib/exchange/bitstamp_btc_usd.py b/gryphon/lib/exchange/bitstamp_btc_usd.py index 5dc8484..c3341ac 100755 --- a/gryphon/lib/exchange/bitstamp_btc_usd.py +++ b/gryphon/lib/exchange/bitstamp_btc_usd.py @@ -111,9 +111,9 @@ def get_ticker_resp(self, req): } def order_is_open(self, order_id): - order_id = unicode(order_id) + order_id = str(order_id) open_orders = self.open_orders() - matching_orders = [o for o in open_orders if unicode(o.get('id')) == order_id] + matching_orders = [o for o in open_orders if str(o.get('id')) == order_id] is_open = len(matching_orders) > 0 return is_open @@ -154,13 +154,13 @@ def trades_for_orders_req(self): return self.all_trades_req() def trades_for_orders_resp(self, req, order_ids): - order_ids = [unicode(o) for o in order_ids] + order_ids = [str(o) for o in order_ids] trades = self.all_trades_resp(req) matching_trades = {} for trade in trades: - oid = unicode(trade['order_id']) + oid = str(trade['order_id']) if oid in order_ids: if oid not in matching_trades: @@ -194,7 +194,7 @@ def auth_request(self, req_method, url, request_args): payload = request_args['data'] = {} # TODO: fix nonce collisions - nonce = unicode(int(round(time.time() * 1000))) + nonce = str(int(round(time.time() * 1000))) message = nonce + self.client_id + self.api_key sig = hmac.new( @@ -289,7 +289,7 @@ def place_order_resp(self, req): response = self.resp(req) try: - return {'success': True, 'order_id': unicode(response['id'])} + return {'success': True, 'order_id': str(response['id'])} except KeyError: raise exceptions.ExchangeAPIErrorException( self, @@ -339,7 +339,7 @@ def get_multi_order_details_req(self): return self.trades_for_orders_req() def get_multi_order_details_resp(self, req, order_ids): - order_ids = [unicode(o) for o in order_ids] + order_ids = [str(o) for o in order_ids] multi_trades = self.trades_for_orders_resp(req, order_ids) data = {} @@ -377,7 +377,7 @@ def get_multi_order_details_resp(self, req, order_ids): our_trades.append({ 'time': int(parse(t['datetime']).epoch), - 'trade_id': unicode(t['id']), + 'trade_id': str(t['id']), 'fee': fee, vol_currency_key: volume_currency_amount, 'fiat': price_currency_amount, @@ -410,7 +410,7 @@ def cancel_order_resp(self, req): return {'success': True} def withdraw_crypto_req(self, address, volume): - if not isinstance(address, basestring): + if not isinstance(address, str): raise TypeError('Withdrawal address must be a string') if (not isinstance(volume, Money) diff --git a/gryphon/lib/exchange/coinbase_btc_usd.py b/gryphon/lib/exchange/coinbase_btc_usd.py index dd5b44f..c78c06e 100755 --- a/gryphon/lib/exchange/coinbase_btc_usd.py +++ b/gryphon/lib/exchange/coinbase_btc_usd.py @@ -298,7 +298,7 @@ def auth_request(self, req_method, url, request_args): self.load_creds() req_method = req_method.upper() - timestamp = unicode(int(round(time.time()))) + timestamp = str(int(round(time.time()))) # This has already been dumped to json by req(). body = request_args['data'] @@ -538,7 +538,7 @@ def cancel_order_resp(self, req): raise exceptions.CancelOrderNotFoundError() def withdraw_crypto(self, address, volume): - if not isinstance(address, basestring): + if not isinstance(address, str): raise TypeError('Withdrawal address must be a string') if not isinstance(volume, Money) or volume.currency != 'BTC': diff --git a/gryphon/lib/exchange/exchange_order.pyx b/gryphon/lib/exchange/exchange_order.pyx index 829ab8d..d5c1bdd 100755 --- a/gryphon/lib/exchange/exchange_order.pyx +++ b/gryphon/lib/exchange/exchange_order.pyx @@ -29,7 +29,7 @@ class Order(object): (self.type, self.exchange.name, self.volume, self.price, self.status, self.order_id)) def __repr__(self): - return "<" + unicode(self) + ">" + return "<" + str(self) + ">" def __eq__(self, other): return (self.order_id == other.order_id and diff --git a/gryphon/lib/exchange/exchange_trade.pyx b/gryphon/lib/exchange/exchange_trade.pyx index 89bec25..4e9b951 100755 --- a/gryphon/lib/exchange/exchange_trade.pyx +++ b/gryphon/lib/exchange/exchange_trade.pyx @@ -18,7 +18,7 @@ class Trade(object): (self.volume, self.price, self.bid.order_id, self.ask.order_id)) def __repr__(self): - return "<" + unicode(self) + ">" + return "<" + str(self) + ">" @property def trade_type(self): diff --git a/gryphon/lib/exchange/gemini_btc_usd.py b/gryphon/lib/exchange/gemini_btc_usd.py index e3ba828..2231693 100755 --- a/gryphon/lib/exchange/gemini_btc_usd.py +++ b/gryphon/lib/exchange/gemini_btc_usd.py @@ -146,13 +146,13 @@ def trades_for_orders_req(self): return self.all_trades_req() def trades_for_orders_resp(self, req, order_ids): - order_ids = [unicode(o) for o in order_ids] + order_ids = [str(o) for o in order_ids] trades = self.all_trades_resp(req) matching_trades = {} for trade in trades: - oid = unicode(trade['order_id']) + oid = str(trade['order_id']) if oid in order_ids: if not oid in matching_trades: @@ -270,7 +270,7 @@ def get_multi_order_details_req(self): return self.trades_for_orders_req() def get_multi_order_details_resp(self, req, order_ids): - order_ids = [unicode(o) for o in order_ids] + order_ids = [str(o) for o in order_ids] multi_trades = self.trades_for_orders_resp(req, order_ids) data = {} @@ -296,7 +296,7 @@ def get_multi_order_details_resp(self, req, order_ids): our_trades.append({ 'time': int(float(t['timestamp'])), - 'trade_id': unicode(t['tid']), + 'trade_id': str(t['tid']), 'fee': fee, self.volume_currency.lower(): volume_amount, 'fiat': price_currency_amount, diff --git a/gryphon/lib/exchange/itbit_btc_usd.py b/gryphon/lib/exchange/itbit_btc_usd.py index 4634c99..027ffaa 100755 --- a/gryphon/lib/exchange/itbit_btc_usd.py +++ b/gryphon/lib/exchange/itbit_btc_usd.py @@ -438,7 +438,7 @@ def cancel_order_resp(self, req): return {'success': True} def withdraw_crypto_req(self, address, volume): - if not isinstance(address, basestring): + if not isinstance(address, str): raise TypeError('Withdrawal address must be a string') if not isinstance(volume, Money) or volume.currency != self.volume_currency: diff --git a/gryphon/lib/exchange/kraken_btc_eur.py b/gryphon/lib/exchange/kraken_btc_eur.py index 5437039..ef2eda3 100755 --- a/gryphon/lib/exchange/kraken_btc_eur.py +++ b/gryphon/lib/exchange/kraken_btc_eur.py @@ -147,7 +147,7 @@ def get_trades_info_from_ledger(self, trade_ids, order_open_timestamp, order_clo 'fiat_fee': Money(0, self.currency), } - for ledger_id, entry in entries.iteritems(): + for ledger_id, entry in entries.items(): trade_id = entry['refid'] if trade_id not in trade_ids: @@ -263,7 +263,7 @@ def closed_orders_resp(self, req): count = int(response['count']) closed_orders = [] - for order_id, raw_order in response['closed'].iteritems(): + for order_id, raw_order in response['closed'].items(): raw_order['order_id'] = order_id closed_orders.append(raw_order) @@ -288,7 +288,7 @@ def auth_request(self, req_method, url, request_args): endpoint = url.replace(self.base_url, '') endpoint = '/0' + endpoint - nonce = unicode(int(round(time.time() * 1000))) + nonce = str(int(round(time.time() * 1000))) try: payload = request_args['data'] @@ -374,8 +374,8 @@ def place_order_req(self, mode, volume, price, order_type=order_types.LIMIT_ORDE 'pair': self.pair, 'type': mode, 'ordertype': 'limit', - 'price': unicode(price.amount), - 'volume': unicode(volume.amount), + 'price': str(price.amount), + 'volume': str(volume.amount), } except AttributeError: @@ -387,7 +387,7 @@ def place_order_resp(self, req): response = self.resp(req) try: - return {'success': True, 'order_id': unicode(response['txid'][0])} + return {'success': True, 'order_id': str(response['txid'][0])} except KeyError: raise exceptions.ExchangeAPIErrorException( self, @@ -405,7 +405,7 @@ def get_open_orders_resp(self, req): try: raw_open_orders = response['open'] - for order_id, raw_order in raw_open_orders.iteritems(): + for order_id, raw_order in raw_open_orders.items(): if raw_order['status'] == 'open': mode = self._order_mode_to_const(raw_order['descr']['type']) volume = Money(raw_order['vol'], 'BTC') @@ -443,7 +443,7 @@ def get_multi_order_details(self, order_ids): return self.get_multi_order_details_resp(req, order_ids) def get_multi_order_details_req(self, order_ids): - order_ids = [unicode(o) for o in order_ids] + order_ids = [str(o) for o in order_ids] payload = { 'trades': True, @@ -482,7 +482,7 @@ def get_multi_order_details_resp(self, req, order_ids): closetm, ) - for t_id, t in trades.iteritems(): + for t_id, t in trades.items(): fiat = abs(t['fiat']) btc = abs(t['btc']) @@ -504,7 +504,7 @@ def get_multi_order_details_resp(self, req, order_ids): our_trades.append({ 'time': int(t['time']), - 'trade_id': unicode(t_id), + 'trade_id': str(t_id), 'fee': fee, 'btc': btc, 'fiat': fiat, @@ -522,7 +522,7 @@ def get_multi_order_details_resp(self, req, order_ids): def cancel_order_req(self, order_id): payload = { - 'txid': unicode(order_id), + 'txid': str(order_id), } return self.req('post', '/private/CancelOrder', data=payload) @@ -539,7 +539,7 @@ def cancel_order_resp(self, req): ) def withdraw_crypto_req(self, address, volume): - if not isinstance(address, basestring): + if not isinstance(address, str): raise TypeError('Withdrawal address must be a string') if self.volume_currency != 'BTC': @@ -554,12 +554,12 @@ def withdraw_crypto_req(self, address, volume): # find the corresponding exchange name, which we then pass to Kraken. deposit_addresses = { name: addr - for name, addr in os.environ.iteritems() if '_DEPOSIT_ADDRESS' in name + for name, addr in os.environ.items() if '_DEPOSIT_ADDRESS' in name } address_to_name_map = { addr: name.replace('_DEPOSIT_ADDRESS', '') - for name, addr in deposit_addresses.iteritems() + for name, addr in deposit_addresses.items() } try: diff --git a/gryphon/lib/exchange/okcoin_btc_usd.py b/gryphon/lib/exchange/okcoin_btc_usd.py index 63afabd..40a5768 100755 --- a/gryphon/lib/exchange/okcoin_btc_usd.py +++ b/gryphon/lib/exchange/okcoin_btc_usd.py @@ -480,7 +480,7 @@ def cancel_order_resp(self, req): return {'success': True} def withdraw_crypto_req(self, address, volume): - if not isinstance(address, basestring): + if not isinstance(address, str): raise TypeError('Withdrawal address must be a string') if not isinstance(volume, Money) or volume.currency != self.volume_currency: diff --git a/gryphon/lib/exchange/quadriga_btc_cad.py b/gryphon/lib/exchange/quadriga_btc_cad.py index 54ee2c6..0c05dcf 100755 --- a/gryphon/lib/exchange/quadriga_btc_cad.py +++ b/gryphon/lib/exchange/quadriga_btc_cad.py @@ -141,8 +141,8 @@ def trades(self): trades.append({ 'time': self._datetime_to_timestamp(raw_transaction['datetime']), - 'trade_id': unicode(raw_transaction['id']), - 'order_id': unicode(raw_transaction['order_id']), + 'trade_id': str(raw_transaction['id']), + 'order_id': str(raw_transaction['order_id']), 'btc': btc, 'fiat': fiat, 'fee': fee, @@ -177,7 +177,7 @@ def auth_request(self, req_method, url, request_args): except KeyError: payload = request_args['data'] = {} - nonce = unicode(int(round(time.time() * 1000))) + nonce = str(int(round(time.time() * 1000))) message= nonce + self.api_key + self.client_id sig = hmac.new( @@ -230,7 +230,7 @@ def place_order_resp(self, req): response = self.resp(req) try: - return {'success': True, 'order_id': unicode(response['id'])} + return {'success': True, 'order_id': str(response['id'])} except KeyError: raise exceptions.ExchangeAPIErrorException( self, @@ -265,7 +265,7 @@ def get_order_details(self, order_id): def get_order_details_req(self, order_id): payload = { - 'id': unicode(order_id), + 'id': str(order_id), } return self.req('post', '/lookup_order', data=payload) @@ -333,7 +333,7 @@ def cancel_order_resp(self, req): return {'success': True} def withdraw_crypto_req(self, address, volume): - if not isinstance(address, basestring): + if not isinstance(address, str): raise TypeError('Withdrawal address must be a string') if not isinstance(volume, Money) or volume.currency != self.volume_currency: diff --git a/gryphon/lib/hackernewsie.py b/gryphon/lib/hackernewsie.py index 666600c..c6cf29c 100755 --- a/gryphon/lib/hackernewsie.py +++ b/gryphon/lib/hackernewsie.py @@ -27,7 +27,7 @@ def get_hn_breaking_news(keywords={'bitcoin': 3, 'bitstamp': 0}): one_day_ago = Delorean().last_day(1).epoch - for keyword, upvote_threshold in keywords.iteritems(): + for keyword, upvote_threshold in keywords.items(): # We quote the keywords so they don't match things that are close # Prompted by Bitcoin matching Ditchin (https://news.ycombinator.com/item?id=10850368) keyword = '"%s"' % keyword diff --git a/gryphon/lib/models/atlaszero/base.py b/gryphon/lib/models/atlaszero/base.py index 6b768cf..6feb715 100755 --- a/gryphon/lib/models/atlaszero/base.py +++ b/gryphon/lib/models/atlaszero/base.py @@ -11,7 +11,7 @@ def unicode_string(self): - return unicode(self).encode('utf-8') + return str(self).encode('utf-8') AtlasZeroBase.__str__ == unicode_string diff --git a/gryphon/lib/models/atlaszero/metric.py b/gryphon/lib/models/atlaszero/metric.py index ddddb30..8eabb83 100755 --- a/gryphon/lib/models/atlaszero/metric.py +++ b/gryphon/lib/models/atlaszero/metric.py @@ -34,7 +34,7 @@ def __init__(self, metric_type, value, timestamp): self.value = value def __unicode__(self): - return unicode(repr(self)) + return str(repr(self)) def __repr__(self): d = { diff --git a/gryphon/lib/models/base.pyx b/gryphon/lib/models/base.pyx index 3d30076..b8283a9 100755 --- a/gryphon/lib/models/base.pyx +++ b/gryphon/lib/models/base.pyx @@ -5,7 +5,7 @@ Base = declarative_base() metadata = Base.metadata def unicode_string(self): - return unicode(self).encode('utf-8') + return str(self).encode('utf-8') Base.__str__ == unicode_string diff --git a/gryphon/lib/models/datum.py b/gryphon/lib/models/datum.py index 34b6c72..905294c 100755 --- a/gryphon/lib/models/datum.py +++ b/gryphon/lib/models/datum.py @@ -31,17 +31,17 @@ def __init__(self, datum_type, numeric_value=None, string_value=None, meta_data= self.datum_type = datum_type self.numeric_value = numeric_value self.string_value = string_value - self.unique_id = u'dat_%s' % unicode(uuid.uuid4().hex) + self.unique_id = u'dat_%s' % str(uuid.uuid4().hex) self.meta_data = json.dumps(meta_data) self.order = order def __unicode__(self): - return unicode(repr(self)) + return str(repr(self)) def __repr__(self): d = { 'datum_type': self.datum_type, - 'time_created': unicode(self.time_created), + 'time_created': str(self.time_created), 'meta_data': json.loads(self.meta_data), } if self.numeric_value: diff --git a/gryphon/lib/models/emeraldhavoc/base.py b/gryphon/lib/models/emeraldhavoc/base.py index 179153b..9cba10f 100755 --- a/gryphon/lib/models/emeraldhavoc/base.py +++ b/gryphon/lib/models/emeraldhavoc/base.py @@ -10,7 +10,7 @@ metadata = EmeraldHavocBase.metadata def unicode_string(self): - return unicode(self).encode('utf-8') + return str(self).encode('utf-8') EmeraldHavocBase.__str__ == unicode_string diff --git a/gryphon/lib/models/emeraldhavoc/exchange_volume.py b/gryphon/lib/models/emeraldhavoc/exchange_volume.py index 613ffc5..cd61feb 100755 --- a/gryphon/lib/models/emeraldhavoc/exchange_volume.py +++ b/gryphon/lib/models/emeraldhavoc/exchange_volume.py @@ -23,7 +23,7 @@ class ExchangeVolume(EmeraldHavocBase): _exchange_volume = Column('exchange_volume', Numeric(precision=20, scale=10)) def __init__(self, exchange_volume, exchange, timestamp): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() self.timestamp = timestamp self.exchange_volume = exchange_volume @@ -39,7 +39,7 @@ def __repr__(self): def to_json(self): return json.dumps({ 'exchange_volume_id': self.exchange_volume_id, - 'time_created': unicode(self.time_created), + 'time_created': str(self.time_created), 'unique_id': self.unique_id, 'exchange': self.exchange, 'exchange_volume': self.exchange_volume diff --git a/gryphon/lib/models/emeraldhavoc/orderbook.pyx b/gryphon/lib/models/emeraldhavoc/orderbook.pyx index 2a2b83d..0496c0d 100755 --- a/gryphon/lib/models/emeraldhavoc/orderbook.pyx +++ b/gryphon/lib/models/emeraldhavoc/orderbook.pyx @@ -28,7 +28,7 @@ class Orderbook(EmeraldHavocBase): _asks = Column('asks', UnicodeText(length=2**31)) def __init__(self, exchange, orderbook, timestamp=None): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() self.timestamp = timestamp self.bids = orderbook['bids'] @@ -57,7 +57,7 @@ class Orderbook(EmeraldHavocBase): def to_json(self): return json.dumps({ 'trade_id':self.trade_id, - 'time_created':unicode(self.time_created), + 'time_created':str(self.time_created), 'unique_id':self.unique_id, 'exchange':self.exchange, 'bids':self.bids, diff --git a/gryphon/lib/models/emeraldhavoc/trade.py b/gryphon/lib/models/emeraldhavoc/trade.py index 2f29947..99c6893 100755 --- a/gryphon/lib/models/emeraldhavoc/trade.py +++ b/gryphon/lib/models/emeraldhavoc/trade.py @@ -39,7 +39,7 @@ class Trade(EmeraldHavocBase): ) def __init__(self, price, volume, exchange, timestamp, exchange_trade_id, source='EXCHANGE'): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() self.timestamp = timestamp self.price = price @@ -58,7 +58,7 @@ def __repr__(self): def to_json(self): return json.dumps({ 'trade_id':self.trade_id, - 'timestamp':unicode(self.timestamp), + 'timestamp':str(self.timestamp), 'unique_id':self.unique_id, 'exchange':self.exchange, 'price':self.price, @@ -72,7 +72,7 @@ def volume(self): @volume.setter def volume(self, value): self._volume = value.amount - self._volume_currency = unicode(value.currency) + self._volume_currency = str(value.currency) @property def price(self): @@ -81,4 +81,4 @@ def price(self): @price.setter def price(self, value): self._price = value.amount - self._price_currency = unicode(value.currency) + self._price_currency = str(value.currency) diff --git a/gryphon/lib/models/event.py b/gryphon/lib/models/event.py index 18a30ff..0df6cdb 100755 --- a/gryphon/lib/models/event.py +++ b/gryphon/lib/models/event.py @@ -27,18 +27,18 @@ def __init__(self, event_type, exchange_name, data): self.time_created = datetime.utcnow() self.event_type = event_type self.exchange_name = exchange_name - self.unique_id = u'evt_%s' % unicode(uuid.uuid4().hex) + self.unique_id = u'evt_%s' % str(uuid.uuid4().hex) self.data = json.dumps(data) def __unicode__(self): - return unicode(repr(self)) + return str(repr(self)) def __repr__(self): return json.dumps({ 'event_type':self.event_type, 'exchange':self.exchange_name, 'data': json.loads(self.data), - 'time_created': unicode(self.time_created), + 'time_created': str(self.time_created), }, ensure_ascii=False) diff --git a/gryphon/lib/models/exchange.pyx b/gryphon/lib/models/exchange.pyx index 979c7a3..d0a369e 100755 --- a/gryphon/lib/models/exchange.pyx +++ b/gryphon/lib/models/exchange.pyx @@ -102,11 +102,11 @@ class Balance(MutableDict): # Make a deep copy of self. copy.deepcopy() is 4x slower than this # because we know the exact structure and don't have to watch for recursions result = self.__class__() - for currency, m in self.iteritems(): + for currency, m in self.items(): result[currency] = Money(m.amount, m.currency) if isinstance(other, Balance): - all_currencies = list(set(self.keys() + other.keys())) + all_currencies = list(set(list(self.keys()) + list(other.keys()))) for c in all_currencies: result[c] += other[c] elif isinstance(other, Money): @@ -117,7 +117,7 @@ class Balance(MutableDict): def __neg__(self): result = self.__class__() - for currency, balance in self.iteritems(): + for currency, balance in self.items(): result[currency] = -balance return result @@ -138,7 +138,7 @@ class Balance(MutableDict): def total_usd_value(self, date=None): total_usd_value = Money(0, 'USD') - for currency, balance in self.iteritems(): + for currency, balance in self.items(): total_usd_value += balance.to('USD', date=date) return total_usd_value @@ -168,7 +168,7 @@ class Exchange(Base): transactions = relationship('Transaction', cascade='all,delete-orphan', backref='exchange', lazy='dynamic') def __init__(self, name): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.name = name self.position = Position() self.target = Target() diff --git a/gryphon/lib/models/liability.py b/gryphon/lib/models/liability.py index 46494cd..9ccafe2 100755 --- a/gryphon/lib/models/liability.py +++ b/gryphon/lib/models/liability.py @@ -55,7 +55,7 @@ class Liability(Base): _details = Column('details', UnicodeText(length=2**31)) def __init__(self, amount, liability_type, entity_name, time_started=None, time_repayed=None, details=None): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() self.amount = amount @@ -81,12 +81,12 @@ def to_json(self): return json.dumps({ 'liability_id': self.liability_id, 'unique_id': self.unique_id, - 'time_created': unicode(self.time_created), + 'time_created': str(self.time_created), 'amount': self.amount, 'liability_type': self.liability_type, 'entity_name': self.entity_name, - 'time_started': unicode(self.time_started), - 'time_repayed': unicode(self.time_repayed), + 'time_started': str(self.time_started), + 'time_repayed': str(self.time_repayed), 'details': self.details, }, ensure_ascii=False) diff --git a/gryphon/lib/models/market_data.py b/gryphon/lib/models/market_data.py index bde06ab..eca9a98 100755 --- a/gryphon/lib/models/market_data.py +++ b/gryphon/lib/models/market_data.py @@ -66,7 +66,7 @@ def __init__(self, timestamp, exchange, price, currency, volume, entry_type, tic self.ticker_symbol = ticker_symbol def __str__(self): - return unicode(self) + return str(self) def __unicode__(self): return '%s,%s,%s,%s,%s,%s,%s' % ( diff --git a/gryphon/lib/models/order.pyx b/gryphon/lib/models/order.pyx index 6032529..040aff2 100755 --- a/gryphon/lib/models/order.pyx +++ b/gryphon/lib/models/order.pyx @@ -56,7 +56,7 @@ class Order(Base, BasicOrder): def __init__(self, actor, mode, volume, price, exchange, exchange_order_id): self.status = self.OPEN - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() assert actor and price and volume and exchange and mode @@ -80,8 +80,8 @@ class Order(Base, BasicOrder): 'order_id':self.order_id, 'unique_id':self.unique_id, 'exchange_order_id':self.exchange_order_id, - 'time_created':unicode(self.time_created), - 'time_executed':unicode(self.time_executed), + 'time_created':str(self.time_created), + 'time_executed':str(self.time_executed), 'exchange':self.exchange.name, 'status':self.status, 'order_type': self.order_type, diff --git a/gryphon/lib/models/orderbook_snapshot.py b/gryphon/lib/models/orderbook_snapshot.py index 3cf607a..d15608a 100755 --- a/gryphon/lib/models/orderbook_snapshot.py +++ b/gryphon/lib/models/orderbook_snapshot.py @@ -17,7 +17,7 @@ class OrderbookSnapshot(Base): time_retrieved = Column(DateTime, nullable=False) def __init__(self, data, time_retrieved): - self.unique_id = u'ord_%s' % unicode(uuid.uuid4().hex) + self.unique_id = u'ord_%s' % str(uuid.uuid4().hex) self.time_retrieved = time_retrieved self.data = data @@ -27,5 +27,5 @@ def __unicode__(self): def __repr__(self): return json.dumps({ 'data': self.data, - 'time_retrieved': unicode(self.time_retrieved), + 'time_retrieved': str(self.time_retrieved), }, ensure_ascii=False) diff --git a/gryphon/lib/models/ticker.py b/gryphon/lib/models/ticker.py index cd303d7..129e6e9 100755 --- a/gryphon/lib/models/ticker.py +++ b/gryphon/lib/models/ticker.py @@ -23,15 +23,15 @@ class Ticker(Base): def __init__(self, exchange, data): self.time_retrieved = datetime.utcnow() self.exchange = exchange - self.unique_id = u'tkr_%s' % unicode(uuid.uuid4().hex) + self.unique_id = u'tkr_%s' % str(uuid.uuid4().hex) self.data = json.dumps(data) def __unicode__(self): - return unicode(repr(self)) + return str(repr(self)) def __repr__(self): return json.dumps({ 'exchange':self.exchange, 'data': self.data, - 'time_retrieved': unicode(self.time_retrieved), + 'time_retrieved': str(self.time_retrieved), }, ensure_ascii=False) diff --git a/gryphon/lib/models/trade.pyx b/gryphon/lib/models/trade.pyx index 3c29b07..7c55471 100755 --- a/gryphon/lib/models/trade.pyx +++ b/gryphon/lib/models/trade.pyx @@ -54,7 +54,7 @@ class Trade(Base): order_id = Column(Integer, ForeignKey('order.order_id')) def __init__(self, trade_type, price, fee, volume, exchange_trade_id, order, meta_data={}): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() self.trade_type = trade_type self.price = price @@ -75,7 +75,7 @@ class Trade(Base): return json.dumps({ 'trade_id':self.trade_id, 'trade_type':self.trade_type, - 'time_created':unicode(self.time_created), + 'time_created':str(self.time_created), 'unique_id':self.unique_id, 'exchange_trade_id':self.exchange_trade_id, 'order_id':self.order_id, diff --git a/gryphon/lib/models/transaction.py b/gryphon/lib/models/transaction.py index c6a5109..f96b773 100755 --- a/gryphon/lib/models/transaction.py +++ b/gryphon/lib/models/transaction.py @@ -62,7 +62,7 @@ class Transaction(Base): fee_buyback_transaction = relationship("Transaction", remote_side=[transaction_id], backref='fee_buyback_transactions') def __init__(self, transaction_type, transaction_status, amount, exchange, transaction_details, fee=None): - self.unique_id = unicode(uuid.uuid4().hex) + self.unique_id = str(uuid.uuid4().hex) self.time_created = datetime.utcnow() self.transaction_type = transaction_type self.transaction_status = transaction_status @@ -84,7 +84,7 @@ def to_json(self): 'transaction_id':self.transaction_id, 'transaction_type':self.transaction_type, 'transaction_status':self.transaction_status, - 'time_created':unicode(self.time_created), + 'time_created':str(self.time_created), 'unique_id':self.unique_id, 'exchange':self.exchange.name, 'amount':self.amount, diff --git a/gryphon/lib/money.py b/gryphon/lib/money.py index 65ff3a8..3677333 100755 --- a/gryphon/lib/money.py +++ b/gryphon/lib/money.py @@ -16,7 +16,7 @@ class Money(super_money.Money): CURRENCIES = FIAT_CURRENCIES + CRYPTO_CURRENCIES def __init__(self, amount="0", currency=None): - if isinstance(amount, basestring): + if isinstance(amount, str): amount = amount.replace(",", "") try: diff --git a/gryphon/lib/scripts/bitstamp_auth_test.py b/gryphon/lib/scripts/bitstamp_auth_test.py index 90dfb84..db6fe53 100755 --- a/gryphon/lib/scripts/bitstamp_auth_test.py +++ b/gryphon/lib/scripts/bitstamp_auth_test.py @@ -24,7 +24,7 @@ def construct_payload(): - nonce = unicode(int(round(time.time() * 1000))) + nonce = str(int(round(time.time() * 1000))) message = nonce + CLIENT_ID + API_KEY sig = hmac.new(SECRET, msg=message, digestmod=hashlib.sha256).hexdigest().upper() diff --git a/gryphon/lib/scripts/test_fast_revenue_fees_profit.py b/gryphon/lib/scripts/test_fast_revenue_fees_profit.py index 5308c41..64b5b67 100755 --- a/gryphon/lib/scripts/test_fast_revenue_fees_profit.py +++ b/gryphon/lib/scripts/test_fast_revenue_fees_profit.py @@ -3,7 +3,7 @@ random period and checks their results are the same. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from cdecimal import * from datetime import datetime, timedelta diff --git a/gryphon/lib/twistedbitcoinwisdom.py b/gryphon/lib/twistedbitcoinwisdom.py index d95eb76..b7d0b3a 100755 --- a/gryphon/lib/twistedbitcoinwisdom.py +++ b/gryphon/lib/twistedbitcoinwisdom.py @@ -19,7 +19,7 @@ def volume_in_period(self, start_date, end_date): from twisted.internet import defer total_volume = Money(0, 'BTC') periods = yield self.period(step=self.determine_step(start_date, end_date)) - for k,v in periods.iteritems(): + for k,v in periods.items(): t=Delorean(k, 'UTC').datetime vol=v if t >= start_date and t < end_date: diff --git a/gryphon/tests/environment/exchange_coordinator/auth_methods.py b/gryphon/tests/environment/exchange_coordinator/auth_methods.py index d638ed2..7fcc2c8 100644 --- a/gryphon/tests/environment/exchange_coordinator/auth_methods.py +++ b/gryphon/tests/environment/exchange_coordinator/auth_methods.py @@ -2,7 +2,7 @@ Test an exchange's authenticated endpoints that don't make any modifying calls. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import logging diff --git a/gryphon/tests/environment/exchange_coordinator/bitstamp.py b/gryphon/tests/environment/exchange_coordinator/bitstamp.py index c2c2054..c0c26da 100644 --- a/gryphon/tests/environment/exchange_coordinator/bitstamp.py +++ b/gryphon/tests/environment/exchange_coordinator/bitstamp.py @@ -1,6 +1,6 @@ """ """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import time import unittest diff --git a/gryphon/tests/environment/exchange_coordinator/kraken.py b/gryphon/tests/environment/exchange_coordinator/kraken.py index e5a69d0..5590412 100644 --- a/gryphon/tests/environment/exchange_coordinator/kraken.py +++ b/gryphon/tests/environment/exchange_coordinator/kraken.py @@ -1,6 +1,6 @@ """ """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os from gryphon.lib.exchange.kraken_btc_eur import KrakenBTCEURExchange diff --git a/gryphon/tests/environment/exchange_coordinator/public_methods.py b/gryphon/tests/environment/exchange_coordinator/public_methods.py index 08e9f78..a9e188a 100644 --- a/gryphon/tests/environment/exchange_coordinator/public_methods.py +++ b/gryphon/tests/environment/exchange_coordinator/public_methods.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import logging import os diff --git a/gryphon/tests/environment/exchange_wrappers/auth_methods.py b/gryphon/tests/environment/exchange_wrappers/auth_methods.py index d638ed2..7fcc2c8 100644 --- a/gryphon/tests/environment/exchange_wrappers/auth_methods.py +++ b/gryphon/tests/environment/exchange_wrappers/auth_methods.py @@ -2,7 +2,7 @@ Test an exchange's authenticated endpoints that don't make any modifying calls. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import logging diff --git a/gryphon/tests/environment/exchange_wrappers/bitstamp_auth.py b/gryphon/tests/environment/exchange_wrappers/bitstamp_auth.py index 9bde17f..939ffac 100644 --- a/gryphon/tests/environment/exchange_wrappers/bitstamp_auth.py +++ b/gryphon/tests/environment/exchange_wrappers/bitstamp_auth.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.bitstamp_btc_usd import BitstampBTCUSDExchange from gryphon.tests.exceptional.exchange_wrappers.auth_methods import ExchangeAuthMethodsTests diff --git a/gryphon/tests/environment/exchange_wrappers/bitstamp_live_orders.py b/gryphon/tests/environment/exchange_wrappers/bitstamp_live_orders.py index 66e5b43..87e1de5 100644 --- a/gryphon/tests/environment/exchange_wrappers/bitstamp_live_orders.py +++ b/gryphon/tests/environment/exchange_wrappers/bitstamp_live_orders.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.bitstamp_btc_usd import BitstampBTCUSDExchange from gryphon.tests.exceptional.exchange_wrappers.live_orders import LiveOrdersTest diff --git a/gryphon/tests/environment/exchange_wrappers/coinbase_auth.py b/gryphon/tests/environment/exchange_wrappers/coinbase_auth.py index 38605ca..ea0a159 100644 --- a/gryphon/tests/environment/exchange_wrappers/coinbase_auth.py +++ b/gryphon/tests/environment/exchange_wrappers/coinbase_auth.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.coinbase_btc_usd import CoinbaseBTCUSDExchange from gryphon.tests.environment.exchange_wrappers.auth_methods import ExchangeAuthMethodsTests diff --git a/gryphon/tests/environment/exchange_wrappers/coinbase_live_orders.py b/gryphon/tests/environment/exchange_wrappers/coinbase_live_orders.py index 320f6aa..b585cb2 100644 --- a/gryphon/tests/environment/exchange_wrappers/coinbase_live_orders.py +++ b/gryphon/tests/environment/exchange_wrappers/coinbase_live_orders.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.coinbase_btc_usd import CoinbaseBTCUSDExchange from gryphon.tests.environment.exchange_wrappers.live_orders import LiveOrdersTest diff --git a/gryphon/tests/environment/exchange_wrappers/gemini_auth.py b/gryphon/tests/environment/exchange_wrappers/gemini_auth.py index b2d95b3..afe31dd 100644 --- a/gryphon/tests/environment/exchange_wrappers/gemini_auth.py +++ b/gryphon/tests/environment/exchange_wrappers/gemini_auth.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.gemini_btc_usd import GeminiBTCUSDExchange from gryphon.tests.exceptional.exchange_wrappers.auth_methods import ExchangeAuthMethodsTests diff --git a/gryphon/tests/environment/exchange_wrappers/gemini_live_orders.py b/gryphon/tests/environment/exchange_wrappers/gemini_live_orders.py index 23d814c..ad01159 100644 --- a/gryphon/tests/environment/exchange_wrappers/gemini_live_orders.py +++ b/gryphon/tests/environment/exchange_wrappers/gemini_live_orders.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.gemini_btc_usd import GeminiBTCUSDExchange from gryphon.tests.exceptional.exchange_wrappers.live_orders import LiveOrdersTest diff --git a/gryphon/tests/environment/exchange_wrappers/itbit_auth.py b/gryphon/tests/environment/exchange_wrappers/itbit_auth.py index 1e1a3ee..ad69fb1 100644 --- a/gryphon/tests/environment/exchange_wrappers/itbit_auth.py +++ b/gryphon/tests/environment/exchange_wrappers/itbit_auth.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.itbit_btc_usd import ItbitBTCUSDExchange from gryphon.tests.exceptional.exchange_wrappers.auth_methods import ExchangeAuthMethodsTests diff --git a/gryphon/tests/environment/exchange_wrappers/itbit_live_orders.py b/gryphon/tests/environment/exchange_wrappers/itbit_live_orders.py index 6ef1d3e..92f20e9 100644 --- a/gryphon/tests/environment/exchange_wrappers/itbit_live_orders.py +++ b/gryphon/tests/environment/exchange_wrappers/itbit_live_orders.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.itbit_btc_usd import ItbitBTCUSDExchange from gryphon.tests.exceptional.exchange_wrappers.live_orders import LiveOrdersTest diff --git a/gryphon/tests/environment/exchange_wrappers/kraken_auth.py b/gryphon/tests/environment/exchange_wrappers/kraken_auth.py index 18424e3..ae702ab 100644 --- a/gryphon/tests/environment/exchange_wrappers/kraken_auth.py +++ b/gryphon/tests/environment/exchange_wrappers/kraken_auth.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.kraken_btc_eur import KrakenBTCEURExchange from gryphon.tests.exceptional.exchange_wrappers.auth_methods import ExchangeAuthMethodsTests diff --git a/gryphon/tests/environment/exchange_wrappers/kraken_live_orders.py b/gryphon/tests/environment/exchange_wrappers/kraken_live_orders.py index 3b77e02..0d9edb4 100644 --- a/gryphon/tests/environment/exchange_wrappers/kraken_live_orders.py +++ b/gryphon/tests/environment/exchange_wrappers/kraken_live_orders.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.kraken_btc_eur import KrakenBTCEURExchange from gryphon.tests.exceptional.exchange_wrappers.live_orders import LiveOrdersTest diff --git a/gryphon/tests/environment/exchange_wrappers/live_orders.py b/gryphon/tests/environment/exchange_wrappers/live_orders.py index a2d01b3..4e24536 100644 --- a/gryphon/tests/environment/exchange_wrappers/live_orders.py +++ b/gryphon/tests/environment/exchange_wrappers/live_orders.py @@ -2,7 +2,7 @@ Tests authenticated and order-placing endpoints. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import logging diff --git a/gryphon/tests/environment/exchange_wrappers/quadriga_auth.py b/gryphon/tests/environment/exchange_wrappers/quadriga_auth.py index c3e5624..ad9e2d6 100644 --- a/gryphon/tests/environment/exchange_wrappers/quadriga_auth.py +++ b/gryphon/tests/environment/exchange_wrappers/quadriga_auth.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.quadriga_btc_cad import QuadrigaBTCCADExchange from gryphon.tests.exceptional.exchange_wrappers.auth_methods import ExchangeAuthMethodsTests diff --git a/gryphon/tests/environment/exchange_wrappers/quadriga_live_orders.py b/gryphon/tests/environment/exchange_wrappers/quadriga_live_orders.py index 1a619d5..df6242f 100644 --- a/gryphon/tests/environment/exchange_wrappers/quadriga_live_orders.py +++ b/gryphon/tests/environment/exchange_wrappers/quadriga_live_orders.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.quadriga_btc_cad import QuadrigaBTCCADExchange from gryphon.tests.exceptional.exchange_wrappers.live_orders import LiveOrdersTest diff --git a/gryphon/tests/extra/libraries/sharpe_test.py b/gryphon/tests/extra/libraries/sharpe_test.py index 7ab1232..7c403b8 100644 --- a/gryphon/tests/extra/libraries/sharpe_test.py +++ b/gryphon/tests/extra/libraries/sharpe_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import datetime diff --git a/gryphon/tests/logic/auditing/auditing_test.py b/gryphon/tests/logic/auditing/auditing_test.py index 965af64..a855714 100644 --- a/gryphon/tests/logic/auditing/auditing_test.py +++ b/gryphon/tests/logic/auditing/auditing_test.py @@ -2,7 +2,7 @@ Tests for gryphon.execution.auditing. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import unittest diff --git a/gryphon/tests/logic/configuration/base_test.py b/gryphon/tests/logic/configuration/base_test.py index 8d41e04..96fd7bd 100644 --- a/gryphon/tests/logic/configuration/base_test.py +++ b/gryphon/tests/logic/configuration/base_test.py @@ -2,7 +2,7 @@ Tests for the gryphon.lib configuration library. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest import mock import sure @@ -170,7 +170,7 @@ def test_parse_sections_trivial(self): parsed = configuration.parse_sections(parser) len(parsed.keys()).should.equal(1) - parsed.keys().should.equal(['strategy']) + list(parsed.keys()).should.equal(['strategy']) parsed['strategy'].should.equal({'midpoint': Decimal('0.001')}) def test_parse_sections_simple(self): @@ -179,7 +179,7 @@ def test_parse_sections_simple(self): parsed = configuration.parse_sections(parser) len(parsed.keys()).should.equal(1) - parsed.keys().should.equal(['strategy']) + list(parsed.keys()).should.equal(['strategy']) parsed['strategy']['midpoint'].should.equal(Decimal('0.001')) parsed['strategy']['quote_depth'].should.equal(Money('20', 'BTC')) parsed['strategy']['use_gds'].should.equal(True) @@ -191,7 +191,7 @@ def test_parse_sections_multi_section(self): parsed = configuration.parse_sections(parser) len(parsed.keys()).should.equal(2) - parsed.keys().should.equal(['platform', 'strategy']) + list(parsed.keys()).should.equal(['platform', 'strategy']) parsed['strategy']['tick_sleep'].should.equal(Decimal('1')) parsed['platform']['audit'].should.equal(False) @@ -201,11 +201,11 @@ def test_parse_sections_subsection(self): parsed = configuration.parse_sections(parser) len(parsed.keys()).should.equal(2) - parsed.keys().should.equal(['platform', 'strategy']) + list(parsed.keys()).should.equal(['platform', 'strategy']) parsed['strategy']['tick_sleep'].should.equal(Decimal('1')) parsed['platform']['audit'].should.equal(False) - parsed['strategy']['midpoint_weights'].keys().should.equal([ + list(parsed['strategy']['midpoint_weights'].keys()).should.equal([ 'coinbase_btc_usd', 'bitstamp_btc_usd', ]) diff --git a/gryphon/tests/logic/configuration/bitstamp_bch_btc_test.py b/gryphon/tests/logic/configuration/bitstamp_bch_btc_test.py index 1663dec..d53b37c 100644 --- a/gryphon/tests/logic/configuration/bitstamp_bch_btc_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_bch_btc_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/bitstamp_bch_eur_test.py b/gryphon/tests/logic/configuration/bitstamp_bch_eur_test.py index 90bf535..1103e7b 100644 --- a/gryphon/tests/logic/configuration/bitstamp_bch_eur_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_bch_eur_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/bitstamp_bch_usd_test.py b/gryphon/tests/logic/configuration/bitstamp_bch_usd_test.py index 246cfa8..09d8db2 100644 --- a/gryphon/tests/logic/configuration/bitstamp_bch_usd_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_bch_usd_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/bitstamp_btc_eur_test.py b/gryphon/tests/logic/configuration/bitstamp_btc_eur_test.py index cb7e991..5656c76 100644 --- a/gryphon/tests/logic/configuration/bitstamp_btc_eur_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_btc_eur_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/bitstamp_eth_btc_test.py b/gryphon/tests/logic/configuration/bitstamp_eth_btc_test.py index 026e439..7e419f6 100644 --- a/gryphon/tests/logic/configuration/bitstamp_eth_btc_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_eth_btc_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/bitstamp_eth_eur_test.py b/gryphon/tests/logic/configuration/bitstamp_eth_eur_test.py index bb7966a..54ddcc1 100644 --- a/gryphon/tests/logic/configuration/bitstamp_eth_eur_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_eth_eur_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/bitstamp_eth_usd_test.py b/gryphon/tests/logic/configuration/bitstamp_eth_usd_test.py index a67d373..6f9fbf0 100644 --- a/gryphon/tests/logic/configuration/bitstamp_eth_usd_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_eth_usd_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/bitstamp_test.py b/gryphon/tests/logic/configuration/bitstamp_test.py index 0b61eb3..13682e9 100644 --- a/gryphon/tests/logic/configuration/bitstamp_test.py +++ b/gryphon/tests/logic/configuration/bitstamp_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/coinbase_test.py b/gryphon/tests/logic/configuration/coinbase_test.py index af44d91..3cf250f 100644 --- a/gryphon/tests/logic/configuration/coinbase_test.py +++ b/gryphon/tests/logic/configuration/coinbase_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/exchange.py b/gryphon/tests/logic/configuration/exchange.py index a5ddaec..4a0c18d 100644 --- a/gryphon/tests/logic/configuration/exchange.py +++ b/gryphon/tests/logic/configuration/exchange.py @@ -1,7 +1,7 @@ """ Just a few exercises for our configuration library. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import time diff --git a/gryphon/tests/logic/configuration/execution_config_test.py b/gryphon/tests/logic/configuration/execution_config_test.py index 6df4fc1..14cb925 100644 --- a/gryphon/tests/logic/configuration/execution_config_test.py +++ b/gryphon/tests/logic/configuration/execution_config_test.py @@ -2,7 +2,7 @@ Just a few exercises for the execution configuration helper library. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import time import unittest @@ -81,7 +81,7 @@ def test_parse_extra_args(self): parsed = config_helper.parse_extra_strategy_args(extra_args) assert len(parsed.keys()) == 1 - assert parsed.keys()[0] == 'spread' + assert list(parsed.keys())[0] == 'spread' assert parsed['spread'] == Decimal('0.01') def test_parse_extra_args_boolean(self): @@ -90,7 +90,7 @@ def test_parse_extra_args_boolean(self): parsed = config_helper.parse_extra_strategy_args(extra_args) assert len(parsed.keys()) == 1 - assert parsed.keys()[0] == 'market_order' + assert list(parsed.keys())[0] == 'market_order' assert parsed['market_order'] == True def test_parse_extra_args_complex(self): diff --git a/gryphon/tests/logic/configuration/gemini_eth_btc_test.py b/gryphon/tests/logic/configuration/gemini_eth_btc_test.py index 9041dfa..0b8e34c 100644 --- a/gryphon/tests/logic/configuration/gemini_eth_btc_test.py +++ b/gryphon/tests/logic/configuration/gemini_eth_btc_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/gemini_eth_usd_test.py b/gryphon/tests/logic/configuration/gemini_eth_usd_test.py index 53bc15f..886ecbf 100644 --- a/gryphon/tests/logic/configuration/gemini_eth_usd_test.py +++ b/gryphon/tests/logic/configuration/gemini_eth_usd_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/gemini_test.py b/gryphon/tests/logic/configuration/gemini_test.py index c14bc89..b00107c 100644 --- a/gryphon/tests/logic/configuration/gemini_test.py +++ b/gryphon/tests/logic/configuration/gemini_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/itbit_test.py b/gryphon/tests/logic/configuration/itbit_test.py index 210c176..4e63d52 100644 --- a/gryphon/tests/logic/configuration/itbit_test.py +++ b/gryphon/tests/logic/configuration/itbit_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/kraken_cad_test.py b/gryphon/tests/logic/configuration/kraken_cad_test.py index a5fa029..6f85227 100644 --- a/gryphon/tests/logic/configuration/kraken_cad_test.py +++ b/gryphon/tests/logic/configuration/kraken_cad_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/kraken_test.py b/gryphon/tests/logic/configuration/kraken_test.py index 8f1dc56..8703793 100644 --- a/gryphon/tests/logic/configuration/kraken_test.py +++ b/gryphon/tests/logic/configuration/kraken_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/kraken_usd_test.py b/gryphon/tests/logic/configuration/kraken_usd_test.py index 5210c66..c381455 100644 --- a/gryphon/tests/logic/configuration/kraken_usd_test.py +++ b/gryphon/tests/logic/configuration/kraken_usd_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/quadriga_test.py b/gryphon/tests/logic/configuration/quadriga_test.py index c9c4aea..41dcceb 100644 --- a/gryphon/tests/logic/configuration/quadriga_test.py +++ b/gryphon/tests/logic/configuration/quadriga_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/configuration/strategy_config_test.py b/gryphon/tests/logic/configuration/strategy_config_test.py index 129ec8f..a34f866 100644 --- a/gryphon/tests/logic/configuration/strategy_config_test.py +++ b/gryphon/tests/logic/configuration/strategy_config_test.py @@ -1,7 +1,7 @@ """ Just a few exercises for our configuration library. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest import mock diff --git a/gryphon/tests/logic/exchange_wrappers/bitstamp_test.py b/gryphon/tests/logic/exchange_wrappers/bitstamp_test.py index 360bcd1..251ce88 100644 --- a/gryphon/tests/logic/exchange_wrappers/bitstamp_test.py +++ b/gryphon/tests/logic/exchange_wrappers/bitstamp_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.bitstamp_btc_usd import BitstampBTCUSDExchange from gryphon.tests.logic.exchange_wrappers.public_methods import ExchangePublicMethodsTests diff --git a/gryphon/tests/logic/exchange_wrappers/coinbase.py b/gryphon/tests/logic/exchange_wrappers/coinbase.py index 6eba85d..a1293a5 100644 --- a/gryphon/tests/logic/exchange_wrappers/coinbase.py +++ b/gryphon/tests/logic/exchange_wrappers/coinbase.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.coinbase_btc_usd import CoinbaseBTCUSDExchange from gryphon.tests.logic.exchange_wrappers.public_methods import ExchangePublicMethodsTests diff --git a/gryphon/tests/logic/exchange_wrappers/gemini_test.py b/gryphon/tests/logic/exchange_wrappers/gemini_test.py index b5a5206..a3f3991 100644 --- a/gryphon/tests/logic/exchange_wrappers/gemini_test.py +++ b/gryphon/tests/logic/exchange_wrappers/gemini_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.gemini_btc_usd import GeminiBTCUSDExchange from gryphon.tests.logic.exchange_wrappers.public_methods import ExchangePublicMethodsTests diff --git a/gryphon/tests/logic/exchange_wrappers/itbit.py b/gryphon/tests/logic/exchange_wrappers/itbit.py index 6eb8f1f..a0e34d6 100644 --- a/gryphon/tests/logic/exchange_wrappers/itbit.py +++ b/gryphon/tests/logic/exchange_wrappers/itbit.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.itbit_btc_usd import ItbitBTCUSDExchange from gryphon.tests.logic.exchange_wrappers.public_methods import ExchangePublicMethodsTests diff --git a/gryphon/tests/logic/exchange_wrappers/kraken.py b/gryphon/tests/logic/exchange_wrappers/kraken.py index 5c39057..364b6c5 100644 --- a/gryphon/tests/logic/exchange_wrappers/kraken.py +++ b/gryphon/tests/logic/exchange_wrappers/kraken.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.kraken_btc_eur import KrakenBTCEURExchange from gryphon.tests.logic.exchange_wrappers.public_methods import ExchangePublicMethodsTests diff --git a/gryphon/tests/logic/exchange_wrappers/public_methods.py b/gryphon/tests/logic/exchange_wrappers/public_methods.py index 08e9f78..a9e188a 100644 --- a/gryphon/tests/logic/exchange_wrappers/public_methods.py +++ b/gryphon/tests/logic/exchange_wrappers/public_methods.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import logging import os diff --git a/gryphon/tests/logic/exchange_wrappers/quadriga.py b/gryphon/tests/logic/exchange_wrappers/quadriga.py index b0a6bd7..0d3d6c3 100644 --- a/gryphon/tests/logic/exchange_wrappers/quadriga.py +++ b/gryphon/tests/logic/exchange_wrappers/quadriga.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) from gryphon.lib.exchange.quadriga_btc_cad import QuadrigaBTCCADExchange from gryphon.tests.logic.exchange_wrappers.public_methods import ExchangePublicMethodsTests diff --git a/gryphon/tests/logic/libraries/arbitrage_test.py b/gryphon/tests/logic/libraries/arbitrage_test.py index f4835bb..12c352a 100644 --- a/gryphon/tests/logic/libraries/arbitrage_test.py +++ b/gryphon/tests/logic/libraries/arbitrage_test.py @@ -8,7 +8,7 @@ we can test e.g. detecting arbitrage between USD and CAD priced orderbooks. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import unittest diff --git a/gryphon/tests/logic/libraries/close_options_test.py b/gryphon/tests/logic/libraries/close_options_test.py index 3941d3b..82d31d1 100644 --- a/gryphon/tests/logic/libraries/close_options_test.py +++ b/gryphon/tests/logic/libraries/close_options_test.py @@ -2,7 +2,7 @@ Unit tests for gryphon.lib.gryphonfury.close_options """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import mock diff --git a/gryphon/tests/logic/libraries/market_making_test.py b/gryphon/tests/logic/libraries/market_making_test.py index 4c6312e..fb848f0 100644 --- a/gryphon/tests/logic/libraries/market_making_test.py +++ b/gryphon/tests/logic/libraries/market_making_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import unittest diff --git a/gryphon/tests/logic/libraries/midpoint_test.py b/gryphon/tests/logic/libraries/midpoint_test.py index 5320e11..fadefc9 100644 --- a/gryphon/tests/logic/libraries/midpoint_test.py +++ b/gryphon/tests/logic/libraries/midpoint_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import unittest diff --git a/gryphon/tests/logic/libraries/money_test.py b/gryphon/tests/logic/libraries/money_test.py index c5a11b2..206832b 100644 --- a/gryphon/tests/logic/libraries/money_test.py +++ b/gryphon/tests/logic/libraries/money_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import os diff --git a/gryphon/tests/logic/libraries/order_sliding_test.py b/gryphon/tests/logic/libraries/order_sliding_test.py index b1ba817..f7e40ab 100644 --- a/gryphon/tests/logic/libraries/order_sliding_test.py +++ b/gryphon/tests/logic/libraries/order_sliding_test.py @@ -6,7 +6,7 @@ not guaranteed that our fee levels on a given exchange won't change. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import unittest diff --git a/gryphon/tests/logic/libraries/orderbook_strength_test.py b/gryphon/tests/logic/libraries/orderbook_strength_test.py index af5d3e0..f45b591 100644 --- a/gryphon/tests/logic/libraries/orderbook_strength_test.py +++ b/gryphon/tests/logic/libraries/orderbook_strength_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import unittest diff --git a/gryphon/tests/logic/libraries/revenue_test.py b/gryphon/tests/logic/libraries/revenue_test.py index d2f48f4..61ad959 100644 --- a/gryphon/tests/logic/libraries/revenue_test.py +++ b/gryphon/tests/logic/libraries/revenue_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() from decimal import Decimal diff --git a/gryphon/tests/logic/libraries/volume_available_test.py b/gryphon/tests/logic/libraries/volume_available_test.py index af7d418..dd060d8 100644 --- a/gryphon/tests/logic/libraries/volume_available_test.py +++ b/gryphon/tests/logic/libraries/volume_available_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/logic/models/balance_test.py b/gryphon/tests/logic/models/balance_test.py index ec11cb9..86c3661 100644 --- a/gryphon/tests/logic/models/balance_test.py +++ b/gryphon/tests/logic/models/balance_test.py @@ -2,7 +2,7 @@ This file tests the Balance class, which also tests for us the Position and Target classes, since they are just clones of Balance. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest import sure diff --git a/gryphon/tests/logic/models/liability_test.py b/gryphon/tests/logic/models/liability_test.py index 5c66b37..ebd0862 100644 --- a/gryphon/tests/logic/models/liability_test.py +++ b/gryphon/tests/logic/models/liability_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import os diff --git a/gryphon/tests/logic/models/order_test.py b/gryphon/tests/logic/models/order_test.py index ead2182..ab49395 100644 --- a/gryphon/tests/logic/models/order_test.py +++ b/gryphon/tests/logic/models/order_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import unittest diff --git a/gryphon/tests/logic/models/trade_test.py b/gryphon/tests/logic/models/trade_test.py index f76e8d4..fee5327 100644 --- a/gryphon/tests/logic/models/trade_test.py +++ b/gryphon/tests/logic/models/trade_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import gryphon.lib; gryphon.lib.prepare() import os diff --git a/gryphon/tests/logic/models/transaction_test.py b/gryphon/tests/logic/models/transaction_test.py index 4e5e2e7..1de6b52 100644 --- a/gryphon/tests/logic/models/transaction_test.py +++ b/gryphon/tests/logic/models/transaction_test.py @@ -1,4 +1,4 @@ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import os import unittest diff --git a/gryphon/tests/logic/strategies/multi_test.py b/gryphon/tests/logic/strategies/multi_test.py index b715cc3..23d403f 100644 --- a/gryphon/tests/logic/strategies/multi_test.py +++ b/gryphon/tests/logic/strategies/multi_test.py @@ -2,7 +2,7 @@ Some simple tests for the Multiexchange Linear Market Making strategy. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import unittest diff --git a/gryphon/tests/runtests.py b/gryphon/tests/runtests.py index 7d0c0aa..f1af389 100755 --- a/gryphon/tests/runtests.py +++ b/gryphon/tests/runtests.py @@ -3,7 +3,7 @@ point. """ -import pyximport; pyximport.install() +import pyximport; pyximport.install(language_level=3) import logging import os diff --git a/requirements/gryphon+gds.txt b/requirements/gryphon+gds.txt index a02e7ac..19da121 100755 --- a/requirements/gryphon+gds.txt +++ b/requirements/gryphon+gds.txt @@ -8,7 +8,7 @@ Automat==0.7.0 Babel==2.6.0 backports.shutil-get-terminal-size==1.0.0 cement==2.10.12 -certifi==2018.4.16 +certifi cffi==1.11.5 chardet==3.0.4 coinbase==1.0.4 @@ -16,11 +16,9 @@ colorama==0.4.1 constantly==15.1.0 contextlib2==0.5.5 cryptography==2.4.2 -Cython==0.20.1 +Cython==0.29.12 decorator==4.3.0 Delorean==1.0.0 -enum34==1.1.6 -futures==3.2.0 gryphon-cdecimal==2.3 gryphon-money==1.2.1 gryphon-pusherclient==0.2.1 @@ -31,12 +29,11 @@ incremental==17.5.0 ipaddress==1.0.22 ipython==5.7.0 ipython-genutils==0.2.0 -line-profiler==2.1.2 Mako==1.0.7 MarkupSafe==1.0 mock==1.0.1 more-itertools==4.3.0 -MySQL-python==1.2.5 +mysqlclient nose==1.3.7 pathlib2==2.3.2 pexpect==4.6.0 @@ -65,7 +62,7 @@ service-identity==18.1.0 simplegeneric==0.8.1 six==1.11.0 SQLAlchemy==1.2.14 -sure==1.2.9 +sure==1.4.11 termcolor==1.1.0 termstyle==0.1.11 traitlets==4.3.2 diff --git a/requirements/gryphon-base.txt b/requirements/gryphon-base.txt index 3b50821..a48c346 100755 --- a/requirements/gryphon-base.txt +++ b/requirements/gryphon-base.txt @@ -3,16 +3,14 @@ appnope==0.1.0 Babel==2.6.0 backports.shutil-get-terminal-size==1.0.0 cement==2.10.12 -certifi==2018.4.16 +certifi chardet==3.0.4 coinbase==1.0.4 colorama==0.4.1 contextlib2==0.5.5 -Cython==0.20.1 +Cython==0.29.12 decorator==4.3.0 Delorean==1.0.0 -enum34==1.1.6 -futures==3.2.0 gryphon-cdecimal==2.3 gryphon-money==1.2.1 gryphon-pusherclient==0.2.1 @@ -20,12 +18,11 @@ humanize==0.5.1 idna==2.7 ipython==5.7.0 ipython-genutils==0.2.0 -line-profiler==2.1.2 Mako==1.0.7 MarkupSafe==1.0 mock==1.0.1 more-itertools==4.3.0 -MySQL-python==1.2.5 +mysqlclient nose==1.3.7 pathlib2==2.3.2 pexpect==4.6.0 @@ -48,7 +45,7 @@ scandir==1.7 simplegeneric==0.8.1 six==1.11.0 SQLAlchemy==1.2.14 -sure==1.2.9 +sure==1.4.11 termcolor==1.1.0 termstyle==0.1.11 traitlets==4.3.2 diff --git a/setup.py b/setup.py index f17aadc..8d3cc84 100755 --- a/setup.py +++ b/setup.py @@ -54,27 +54,24 @@ def run(self): 'Babel==2.6.0', 'backports.shutil-get-terminal-size==1.0.0', 'cement==2.10.12', - 'certifi==2018.4.16', + 'certifi', 'chardet==3.0.4', 'coinbase==1.0.4', 'contextlib2==0.5.5', - 'Cython==0.20.1', + 'Cython==0.29.12', 'decorator==4.3.0', 'Delorean>=1.0.0,<2', - 'enum34==1.1.6', - 'futures==3.2.0', 'gryphon-cdecimal==2.3', 'gryphon-money', # Our fork of Python Money. 'gryphon-pusherclient', # Our duplicate of PythonPusherClient. 'idna==2.7', 'ipython==5.7.0', 'ipython-genutils==0.2.0', - 'line-profiler==2.1.2', 'Mako==1.0.7', 'MarkupSafe==1.0', 'mock==1.0.1', 'more-itertools>=4.2.0,<5', - 'MySQL-python==1.2.5', + 'mysqlclient', 'nose==1.3.7', 'pathlib2==2.3.2', 'pexpect==4.6.0',