From a8763a589ebb466b5dcc45db89a7e94ab9f1f0f7 Mon Sep 17 00:00:00 2001 From: Frederic Fortier Date: Wed, 23 Aug 2017 00:09:57 -0400 Subject: [PATCH] Bug fixes --- catalyst/examples/buy_the_dip_live.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/catalyst/examples/buy_the_dip_live.py b/catalyst/examples/buy_the_dip_live.py index 3711b823..ff09a824 100644 --- a/catalyst/examples/buy_the_dip_live.py +++ b/catalyst/examples/buy_the_dip_live.py @@ -67,14 +67,6 @@ def _handle_data(context, data): log.info('skipping bar until all open orders execute') return - if buy_increment is None: - log.info('the rsi is too high to consider buying {}'.format(rsi)) - return - - if price * buy_increment > cash: - log.info('not enough base currency to consider buying') - return - is_buy = False cost_basis = None if context.asset in context.portfolio.positions: @@ -109,6 +101,14 @@ def _handle_data(context, data): is_buy = True if is_buy: + if buy_increment is None: + log.info('the rsi is too high to consider buying {}'.format(rsi)) + return + + if price * buy_increment > cash: + log.info('not enough base currency to consider buying') + return + log.info( 'buying position cheaper than cost basis {} < {}'.format( price,