diff --git a/catalyst/data/bundles/poloniex.py b/catalyst/data/bundles/poloniex.py index 4dcdf7bc..ad224492 100644 --- a/catalyst/data/bundles/poloniex.py +++ b/catalyst/data/bundles/poloniex.py @@ -90,6 +90,8 @@ class PoloniexBundle(BaseCryptoPricingBundle): start_date, end_date, frequency): + # TODO: replace this with direct exchange call + # The end date and frequency should be used to calculate the number of bars raw = pd.read_json( self._format_data_url( api_key, @@ -153,6 +155,7 @@ class PoloniexBundle(BaseCryptoPricingBundle): return self._format_polo_query(query_params) def _format_polo_query(self, query_params): + # TODO: got against the exchange object return 'https://poloniex.com/public?{query}'.format( query=urlencode(query_params), ) diff --git a/catalyst/examples/arbitrage_with_interface.py b/catalyst/examples/arbitrage_with_interface.py index 7ee9bf86..01baefa9 100644 --- a/catalyst/examples/arbitrage_with_interface.py +++ b/catalyst/examples/arbitrage_with_interface.py @@ -30,7 +30,7 @@ def initialize(context): # the exchange information. This allow all other operations using # the TradingPair to target the correct exchange. context.trading_pairs[context.buying_exchange] = \ - symbol(context.trading_pair_symbol, context.buying_exchange.name) + symbol('neo_eth', context.buying_exchange.name) context.trading_pairs[context.selling_exchange] = \ symbol(context.trading_pair_symbol, context.selling_exchange.name) diff --git a/catalyst/examples/buy_low_sell_high.py b/catalyst/examples/buy_low_sell_high.py index e1459ee6..feadf49b 100644 --- a/catalyst/examples/buy_low_sell_high.py +++ b/catalyst/examples/buy_low_sell_high.py @@ -38,6 +38,8 @@ def initialize(context): context.retry_update_portfolio = 10 context.retry_order = 5 + context.swallow_errors = True + context.errors = [] pass @@ -49,6 +51,7 @@ def _handle_data(context, data): bar_count=20, frequency='15m' ) + rsi = talib.RSI(prices.values, timeperiod=14)[-1] log.info('got rsi: {}'.format(rsi)) @@ -135,11 +138,11 @@ def _handle_data(context, data): def handle_data(context, data): log.info('handling bar {}'.format(data.current_dt)) - # try: - _handle_data(context, data) - # except Exception as e: - # log.warn('aborting the bar on error {}'.format(e)) - # context.errors.append(e) + try: + _handle_data(context, data) + except Exception as e: + log.warn('aborting the bar on error {}'.format(e)) + context.errors.append(e) log.info('completed bar {}, total execution errors {}'.format( data.current_dt, diff --git a/catalyst/exchange/algorithm_exchange.py b/catalyst/exchange/algorithm_exchange.py index 88128091..f0193b12 100644 --- a/catalyst/exchange/algorithm_exchange.py +++ b/catalyst/exchange/algorithm_exchange.py @@ -544,6 +544,7 @@ class ExchangeTradingAlgorithm(TradingAlgorithm): :param amount: :return: """ + # TODO: is this good enough? Victor has a better solution. return amount @api_method diff --git a/catalyst/exchange/bitfinex/bitfinex.py b/catalyst/exchange/bitfinex/bitfinex.py index 6d0fb09f..a72b6167 100644 --- a/catalyst/exchange/bitfinex/bitfinex.py +++ b/catalyst/exchange/bitfinex/bitfinex.py @@ -224,7 +224,8 @@ class Bitfinex(Exchange): # TODO: fetch account data and keep in cache return None - def get_candles(self, data_frequency, assets, bar_count=None): + def get_candles(self, data_frequency, assets, bar_count=None, + start_date=None): """ Retrieve OHLVC candles from Bitfinex @@ -239,7 +240,6 @@ class Bitfinex(Exchange): '1M' """ - # TODO: use BcolzMinuteBarReader to read from cache freq_match = re.match(r'([0-9].*)(m|h|d)', data_frequency, re.M | re.I) if freq_match: number = int(freq_match.group(1)) diff --git a/catalyst/exchange/bitfinex/symbols.json b/catalyst/exchange/bitfinex/symbols.json index 2134bd9f..bd6951d1 100644 --- a/catalyst/exchange/bitfinex/symbols.json +++ b/catalyst/exchange/bitfinex/symbols.json @@ -1,7 +1,8 @@ { "neobtc": { "symbol": "neo_btc", - "start_date": "2017-09-07" + "start_date": "2017-09-07", + "precision":5 }, "neousd": { "symbol": "neo_usd", diff --git a/catalyst/exchange/bittrex/bittrex.py b/catalyst/exchange/bittrex/bittrex.py index 87b1c437..3593e89c 100644 --- a/catalyst/exchange/bittrex/bittrex.py +++ b/catalyst/exchange/bittrex/bittrex.py @@ -208,7 +208,7 @@ class Bittrex(Exchange): error=status['message'] ) - def get_candles(self, data_frequency, assets, bar_count=None): + def get_candles(self, data_frequency, assets, bar_count=None, start_date=None): """ Supported Intervals ------------------- diff --git a/catalyst/exchange/data_portal_exchange.py b/catalyst/exchange/data_portal_exchange.py index b1d91f56..b2214962 100644 --- a/catalyst/exchange/data_portal_exchange.py +++ b/catalyst/exchange/data_portal_exchange.py @@ -70,6 +70,7 @@ class DataPortalExchange(DataPortal): df_list.append(df) + # Merging the values values of each exchange return pd.concat(df_list) else: diff --git a/catalyst/exchange/exchange.py b/catalyst/exchange/exchange.py index 7aaff3fc..56bf786f 100644 --- a/catalyst/exchange/exchange.py +++ b/catalyst/exchange/exchange.py @@ -323,6 +323,7 @@ class Exchange: ) try: + #TODO: use victor's modified branch using int64 self.minute_writer.write_sid( sid=asset.sid, df=df @@ -592,7 +593,8 @@ class Exchange: pass @abstractmethod - def get_candles(self, data_frequency, assets, bar_count=None): + def get_candles(self, data_frequency, assets, bar_count=None, + start_date=None): """ Retrieve OHLCV candles for the given assets @@ -601,6 +603,7 @@ class Exchange: :param end_dt: :param bar_count: :param limit: + :param start_date: :return: """ pass diff --git a/catalyst/exchange/live_graph_clock.py b/catalyst/exchange/live_graph_clock.py index be3b80a8..ce3aa7df 100644 --- a/catalyst/exchange/live_graph_clock.py +++ b/catalyst/exchange/live_graph_clock.py @@ -27,8 +27,6 @@ from catalyst.exchange.exchange_errors import \ log = Logger('LiveGraphClock') -style.use('dark_background') - fmt = mdates.DateFormatter('%Y-%m-%d %H:%M') @@ -60,6 +58,8 @@ class LiveGraphClock(object): def __init__(self, sessions, context, time_skew=pd.Timedelta('0s')): + style.use('dark_background') + self.sessions = sessions self.time_skew = time_skew self._last_emit = None diff --git a/catalyst/utils/run_algo.py b/catalyst/utils/run_algo.py index 793c8919..46b87845 100644 --- a/catalyst/utils/run_algo.py +++ b/catalyst/utils/run_algo.py @@ -152,12 +152,16 @@ def _run(handle_data, exchange_name = exchange start = pd.Timestamp.utcnow() - end = start + timedelta(minutes=1439) + + # TODO: fix the end data. + end = start + timedelta(hours=8760) + exchange_list = [x.strip().lower() for x in exchange.split(',')] exchanges = dict() for exchange_name in exchange_list: + # Looking for the portfolio from the cache first portfolio = get_algo_object( algo_name=algo_namespace, key='portfolio_{}'.format(exchange_name), @@ -169,6 +173,7 @@ def _run(handle_data, start_date=pd.Timestamp.utcnow() ) + # This corresponds to the json file containing api token info exchange_auth = get_exchange_auth(exchange_name) if exchange_name == 'bitfinex': exchanges[exchange_name] = Bitfinex( @@ -352,7 +357,7 @@ def _run(handle_data, TradingAlgorithmClass = ( partial(ExchangeTradingAlgorithm, exchanges=exchanges, algo_namespace=algo_namespace, live_graph=live_graph) - if live and exchanges else TradingAlgorithm) + if live and exchanges else TradingAlgorithm) # TODO: backtest trading algo class perf = TradingAlgorithmClass( namespace=namespace,