diff --git a/catalyst/examples/mean_reversion_simple.py b/catalyst/examples/mean_reversion_simple.py index 0e1c98d7..b3179cdd 100644 --- a/catalyst/examples/mean_reversion_simple.py +++ b/catalyst/examples/mean_reversion_simple.py @@ -38,8 +38,8 @@ def initialize(context): context.base_price = None context.current_day = None - context.RSI_OVERSOLD = 65 - context.RSI_OVERBOUGHT = 82 + context.RSI_OVERSOLD = 30 + context.RSI_OVERBOUGHT = 80 context.CANDLE_SIZE = '5T' context.start_time = time.time() @@ -98,9 +98,10 @@ def handle_data(context, data): # a parameter of the analyze() function for further analysis. record( - volume=(context.market, current['volume']), - price_change=(context.market, price_change), - rsi=(context.market, rsi[-1]), + volume=current['volume'], + price=price, + price_change=price_change, + rsi=rsi[-1], cash=cash ) # We are trying to avoid over-trading by limiting our trades to @@ -108,6 +109,7 @@ def handle_data(context, data): if context.traded_today: return + # TODO: retest with open orders # Since we are using limit orders, some orders may not execute immediately # we wait until all orders are executed before considering more trades. orders = get_open_orders(context.market) diff --git a/catalyst/exchange/bitfinex/bitfinex.py b/catalyst/exchange/bitfinex/bitfinex.py index fa6077ac..591e8486 100644 --- a/catalyst/exchange/bitfinex/bitfinex.py +++ b/catalyst/exchange/bitfinex/bitfinex.py @@ -30,15 +30,17 @@ from catalyst.protocol import Account # Trying to account for REST api instability # https://stackoverflow.com/questions/15431044/can-i-set-max-retries-for-requests-request +from catalyst.utils.deprecate import deprecated + requests.adapters.DEFAULT_RETRIES = 20 BITFINEX_URL = 'https://api.bitfinex.com' - log = Logger('Bitfinex', level=LOG_LEVEL) warning_logger = Logger('AlgoWarning') +@deprecated class Bitfinex(Exchange): def __init__(self, key, secret, base_currency, portfolio=None): self.url = BITFINEX_URL @@ -666,11 +668,11 @@ class Bitfinex(Exchange): """ url = ('{url}/v2/candles/trade:1D:{symbol}/hist?start={start}' '&end={end}').format( - url=self.url, - symbol=symbol_v2, - start=startmonth - 3600 * 24 * 31 * 1000, - end=min(startmonth + 3600 * 24 * 31 * 1000, - int(time.time() * 1000))) + url=self.url, + symbol=symbol_v2, + start=startmonth - 3600 * 24 * 31 * 1000, + end=min(startmonth + 3600 * 24 * 31 * 1000, + int(time.time() * 1000))) try: self.ask_request() diff --git a/catalyst/exchange/bittrex/bittrex.py b/catalyst/exchange/bittrex/bittrex.py index 5835b8e1..3057d501 100644 --- a/catalyst/exchange/bittrex/bittrex.py +++ b/catalyst/exchange/bittrex/bittrex.py @@ -19,12 +19,14 @@ from catalyst.finance.execution import LimitOrder, StopLimitOrder from catalyst.finance.order import Order, ORDER_STATUS # TODO: consider using this: https://github.com/mondeja/bittrex_v2 +from catalyst.utils.deprecate import deprecated log = Logger('Bittrex', level=LOG_LEVEL) URL2 = 'https://bittrex.com/Api/v2.0' +@deprecated class Bittrex(Exchange): def __init__(self, key, secret, base_currency, portfolio=None): self.api = Bittrex_api(key=key, secret=secret) diff --git a/catalyst/exchange/poloniex/poloniex.py b/catalyst/exchange/poloniex/poloniex.py index b29b0e92..49ccbd40 100644 --- a/catalyst/exchange/poloniex/poloniex.py +++ b/catalyst/exchange/poloniex/poloniex.py @@ -28,10 +28,12 @@ from catalyst.exchange.poloniex.poloniex_api import Poloniex_api from catalyst.finance.order import Order, ORDER_STATUS from catalyst.finance.transaction import Transaction from catalyst.protocol import Account +from catalyst.utils.deprecate import deprecated log = Logger('Poloniex', level=LOG_LEVEL) +@deprecated class Poloniex(Exchange): def __init__(self, key, secret, base_currency, portfolio=None): self.api = Poloniex_api(key=key, secret=secret) @@ -292,8 +294,8 @@ class Poloniex(Exchange): """ exchange_symbol = self.get_symbol(asset) - if(isinstance(style, ExchangeLimitOrder) - or isinstance(style, ExchangeStopLimitOrder)): + if (isinstance(style, ExchangeLimitOrder) + or isinstance(style, ExchangeStopLimitOrder)): if isinstance(style, ExchangeStopLimitOrder): log.warn('{} will ignore the stop price'.format(self.name)) diff --git a/tests/exchange/test_bitfinex.py b/tests/exchange/test_bitfinex.py index 1859f38f..4ac4e205 100644 --- a/tests/exchange/test_bitfinex.py +++ b/tests/exchange/test_bitfinex.py @@ -4,10 +4,12 @@ from base import BaseExchangeTestCase from catalyst.exchange.bitfinex.bitfinex import Bitfinex from catalyst.exchange.exchange_utils import get_exchange_auth from catalyst.finance.execution import (LimitOrder) +from catalyst.utils.deprecate import deprecated log = Logger('test_bitfinex') +@deprecated class TestBitfinex(BaseExchangeTestCase): @classmethod def setup(self): diff --git a/tests/exchange/test_bittrex.py b/tests/exchange/test_bittrex.py index 47d54068..d77c67b0 100644 --- a/tests/exchange/test_bittrex.py +++ b/tests/exchange/test_bittrex.py @@ -4,10 +4,12 @@ from catalyst.finance.order import Order from base import BaseExchangeTestCase from logbook import Logger from catalyst.exchange.exchange_utils import get_exchange_auth +from catalyst.utils.deprecate import deprecated log = Logger('test_bittrex') +@deprecated class TestBittrex(BaseExchangeTestCase): @classmethod def setup(self): diff --git a/tests/exchange/test_poloniex.py b/tests/exchange/test_poloniex.py index 62800468..f263e9b0 100644 --- a/tests/exchange/test_poloniex.py +++ b/tests/exchange/test_poloniex.py @@ -4,11 +4,14 @@ from base import BaseExchangeTestCase from logbook import Logger from catalyst.exchange.exchange_utils import get_exchange_auth import pandas as pd + +from catalyst.utils.deprecate import deprecated from test_utils import output_df log = Logger('test_poloniex') +@deprecated class TestPoloniex(BaseExchangeTestCase): @classmethod def setup(self):