- get_signal to return both SELL and BUY signal

- _process modified so that we do not sell if we would buy afterwards
- execute_sell modified so that that min_roi_reached is not executed if we would buy afterwards

Veuillez saisir le message de validation pour vos modifications. Les lignes
This commit is contained in:
toto
2018-01-16 20:22:15 +01:00
parent 5a82d99482
commit 12ffbf5047
4 changed files with 71 additions and 63 deletions

View File

@@ -280,36 +280,36 @@ def analyze_ticker(ticker_history: List[Dict]) -> DataFrame:
return dataframe
def get_signal(pair: str, signal: SignalType) -> bool:
def get_signal(pair: str) -> (bool, bool):
"""
Calculates current signal based several technical analysis indicators
:param pair: pair in format BTC_ANT or BTC-ANT
:return: True if pair is good for buying, False otherwise
:return: (True, False) if pair is good for buying and not for selling
"""
ticker_hist = get_ticker_history(pair)
if not ticker_hist:
logger.warning('Empty ticker history for pair %s', pair)
return False
return (False, False)
try:
dataframe = analyze_ticker(ticker_hist)
except ValueError as ex:
logger.warning('Unable to analyze ticker for pair %s: %s', pair, str(ex))
return False
return (False, False)
except Exception as ex:
logger.exception('Unexpected error when analyzing ticker for pair %s: %s', pair, str(ex))
return False
return (False, False)
if dataframe.empty:
return False
return (False, False)
latest = dataframe.iloc[-1]
# Check if dataframe is out of date
signal_date = arrow.get(latest['date'])
if signal_date < arrow.now() - timedelta(minutes=10):
return False
return (False, False)
result = latest[signal.value] == 1
logger.debug('%s_trigger: %s (pair=%s, signal=%s)', signal.value, latest['date'], pair, result)
return result
(buy, sell) = latest[SignalType.BUY] == 1, latest[SignalType.SELL] == 1
logger.debug('%trigger: %s (pair=%s, buy=%s sell=%s)', latest['date'], pair, buy, sell)
return (buy, sell)