rename should_sell to min_roi_reached

This commit is contained in:
Janne Sinivirta 2017-11-16 07:49:06 +02:00 committed by gcarq
parent b9983149ef
commit a963f1820c
2 changed files with 5 additions and 5 deletions

View File

@ -153,9 +153,9 @@ def execute_sell(trade: Trade, limit: float) -> None:
telegram.send_msg(message) telegram.send_msg(message)
def should_sell(trade: Trade, current_rate: float, current_time: datetime) -> bool: def min_roi_reached(trade: Trade, current_rate: float, current_time: datetime) -> bool:
""" """
Based an earlier trade and current price and configuration, decides whether bot should sell Based an earlier trade and current price and ROI configuration, decides whether bot should sell
:return True if bot should sell at current rate :return True if bot should sell at current rate
""" """
current_profit = trade.calc_profit(current_rate) current_profit = trade.calc_profit(current_rate)
@ -183,7 +183,7 @@ def handle_trade(trade: Trade) -> bool:
logger.debug('Handling %s ...', trade) logger.debug('Handling %s ...', trade)
current_rate = exchange.get_ticker(trade.pair)['bid'] current_rate = exchange.get_ticker(trade.pair)['bid']
if should_sell(trade, current_rate, datetime.utcnow()) or get_signal(trade.pair, SignalType.SELL): if min_roi_reached(trade, current_rate, datetime.utcnow()) or get_signal(trade.pair, SignalType.SELL):
execute_sell(trade, current_rate) execute_sell(trade, current_rate)
return True return True
return False return False

View File

@ -9,7 +9,7 @@ from pandas import DataFrame
from freqtrade import exchange from freqtrade import exchange
from freqtrade.analyze import analyze_ticker from freqtrade.analyze import analyze_ticker
from freqtrade.exchange import Bittrex from freqtrade.exchange import Bittrex
from freqtrade.main import should_sell from freqtrade.main import min_roi_reached
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
logging.disable(logging.DEBUG) # disable debug logs that slow backtesting a lot logging.disable(logging.DEBUG) # disable debug logs that slow backtesting a lot
@ -44,7 +44,7 @@ def backtest(backtest_conf, backdata, mocker):
) )
# calculate win/lose forwards from buy point # calculate win/lose forwards from buy point
for row2 in ticker[row.Index:].itertuples(index=True): for row2 in ticker[row.Index:].itertuples(index=True):
if should_sell(trade, row2.close, row2.date) or row2.sell == 1: if min_roi_reached(trade, row2.close, row2.date) or row2.sell == 1:
current_profit = trade.calc_profit(row2.close) current_profit = trade.calc_profit(row2.close)
trades.append((pair, current_profit, row2.Index - row.Index)) trades.append((pair, current_profit, row2.Index - row.Index))