diff --git a/catalyst/examples/buy_low_sell_high.py b/catalyst/examples/buy_low_sell_high.py index 51f965b4..7dc95b5b 100644 --- a/catalyst/examples/buy_low_sell_high.py +++ b/catalyst/examples/buy_low_sell_high.py @@ -143,7 +143,7 @@ def analyze(context, stats): if __name__ == '__main__': - live = False + live = True if live: run_algorithm( capital_base=0.001, diff --git a/catalyst/examples/mean_reversion_simple.py b/catalyst/examples/mean_reversion_simple.py index 084411d9..b215f5cf 100644 --- a/catalyst/examples/mean_reversion_simple.py +++ b/catalyst/examples/mean_reversion_simple.py @@ -39,7 +39,7 @@ def initialize(context): context.RSI_OVERSOLD = 55 context.RSI_OVERBOUGHT = 60 - context.CANDLE_SIZE = '5T' + context.CANDLE_SIZE = '15T' context.start_time = time.time() @@ -114,7 +114,7 @@ def handle_data(context, data): # 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) + orders = context.blotter.open_orders if len(orders) > 0: log.info('exiting because orders are open: {}'.format(orders)) return diff --git a/catalyst/exchange/ccxt/ccxt_exchange.py b/catalyst/exchange/ccxt/ccxt_exchange.py index 0d4b3c57..9ac59c6d 100644 --- a/catalyst/exchange/ccxt/ccxt_exchange.py +++ b/catalyst/exchange/ccxt/ccxt_exchange.py @@ -431,18 +431,14 @@ class CCXT(Exchange): bars_to_now = pd.date_range( end_dt, pd.Timestamp.utcnow(), freq=freq ) - if len(bars_to_now) > 1: + # See: https://github.com/ccxt/ccxt/issues/1360 + if len(bars_to_now) > 1 or self.name in ['poloniex']: dt_range = get_periods_range( end_dt=end_dt, periods=bar_count, freq=freq, ) - # with some exchanges, skip the left bound of the range - # since the open range is on the right bound - if self.name in ['poloniex']: - start_dt = dt_range[1] - else: - start_dt = dt_range[0] + start_dt = dt_range[0] since = None if start_dt is not None: @@ -471,6 +467,9 @@ class CCXT(Exchange): close=ohlcv[4], volume=ohlcv[5] )) + candles[asset] = sorted( + candles[asset], key=lambda c: c['last_traded'] + ) if is_single: return six.next(six.itervalues(candles))