Merge branch 'develop' into stoploss_market
This commit is contained in:
@@ -63,8 +63,7 @@ class FreqtradeBot:
|
||||
|
||||
self.exchange = ExchangeResolver.load_exchange(self.config['exchange']['name'], self.config)
|
||||
|
||||
persistence.init(self.config.get('db_url', None),
|
||||
clean_open_orders=self.config.get('dry_run', False))
|
||||
persistence.init(self.config.get('db_url', None), clean_open_orders=self.config['dry_run'])
|
||||
|
||||
self.wallets = Wallets(self.config, self.exchange)
|
||||
|
||||
@@ -219,7 +218,7 @@ class FreqtradeBot:
|
||||
|
||||
return trades_created
|
||||
|
||||
def get_target_bid(self, pair: str, tick: Dict = None) -> float:
|
||||
def get_buy_rate(self, pair: str, tick: Dict = None) -> float:
|
||||
"""
|
||||
Calculates bid target between current ask price and last price
|
||||
:return: float: Price
|
||||
@@ -436,7 +435,7 @@ class FreqtradeBot:
|
||||
buy_limit_requested = price
|
||||
else:
|
||||
# Calculate price
|
||||
buy_limit_requested = self.get_target_bid(pair)
|
||||
buy_limit_requested = self.get_buy_rate(pair)
|
||||
|
||||
min_stake_amount = self._get_min_pair_stake_amount(pair, buy_limit_requested)
|
||||
if min_stake_amount is not None and min_stake_amount > stake_amount:
|
||||
@@ -926,7 +925,7 @@ class FreqtradeBot:
|
||||
|
||||
# if stoploss is on exchange and we are on dry_run mode,
|
||||
# we consider the sell price stop price
|
||||
if self.config.get('dry_run', False) and sell_type == 'stoploss' \
|
||||
if self.config['dry_run'] and sell_type == 'stoploss' \
|
||||
and self.strategy.order_types['stoploss_on_exchange']:
|
||||
limit = trade.stop_loss
|
||||
|
||||
|
@@ -70,7 +70,7 @@ def generate_text_table_sell_reason(data: Dict[str, Dict], results: DataFrame) -
|
||||
for reason, count in results['sell_reason'].value_counts().iteritems():
|
||||
result = results.loc[results['sell_reason'] == reason]
|
||||
profit = len(result[result['profit_abs'] >= 0])
|
||||
loss = len(result[results['profit_abs'] < 0])
|
||||
loss = len(result[result['profit_abs'] < 0])
|
||||
profit_mean = round(result['profit_percent'].mean() * 100.0, 2)
|
||||
tabular_data.append([reason.value, count, profit, loss, profit_mean])
|
||||
return tabulate(tabular_data, headers=headers, tablefmt="pipe")
|
||||
|
@@ -88,7 +88,7 @@ class RPC:
|
||||
"""
|
||||
config = self._freqtrade.config
|
||||
val = {
|
||||
'dry_run': config.get('dry_run', False),
|
||||
'dry_run': config['dry_run'],
|
||||
'stake_currency': config['stake_currency'],
|
||||
'stake_amount': config['stake_amount'],
|
||||
'minimal_roi': config['minimal_roi'].copy(),
|
||||
@@ -337,7 +337,7 @@ class RPC:
|
||||
'stake': stake_currency,
|
||||
})
|
||||
if total == 0.0:
|
||||
if self._freqtrade.config.get('dry_run', False):
|
||||
if self._freqtrade.config['dry_run']:
|
||||
raise RPCException('Running in Dry Run, balances are not available.')
|
||||
else:
|
||||
raise RPCException('All balances are zero.')
|
||||
@@ -351,7 +351,7 @@ class RPC:
|
||||
'symbol': symbol,
|
||||
'value': value,
|
||||
'stake': stake_currency,
|
||||
'note': 'Simulated balances' if self._freqtrade.config.get('dry_run', False) else ''
|
||||
'note': 'Simulated balances' if self._freqtrade.config['dry_run'] else ''
|
||||
}
|
||||
|
||||
def _rpc_start(self) -> Dict[str, str]:
|
||||
|
@@ -62,7 +62,7 @@ class RPCManager:
|
||||
logger.error(f"Message type {msg['type']} not implemented by handler {mod.name}.")
|
||||
|
||||
def startup_messages(self, config, pairlist) -> None:
|
||||
if config.get('dry_run', False):
|
||||
if config['dry_run']:
|
||||
self.send_msg({
|
||||
'type': RPCMessageType.WARNING_NOTIFICATION,
|
||||
'status': 'Dry run is enabled. All trades are simulated.'
|
||||
|
@@ -389,9 +389,11 @@ class IStrategy(ABC):
|
||||
trade.adjust_stop_loss(high or current_rate, stop_loss_value)
|
||||
|
||||
# evaluate if the stoploss was hit if stoploss is not on exchange
|
||||
# in Dry-Run, this handles stoploss logic as well, as the logic will not be different to
|
||||
# regular stoploss handling.
|
||||
if ((self.stoploss is not None) and
|
||||
(trade.stop_loss >= current_rate) and
|
||||
(not self.order_types.get('stoploss_on_exchange'))):
|
||||
(not self.order_types.get('stoploss_on_exchange') or self.config['dry_run'])):
|
||||
|
||||
sell_type = SellType.STOP_LOSS
|
||||
|
||||
|
@@ -27,7 +27,8 @@ class SampleHyperOptLoss(IHyperOptLoss):
|
||||
Defines the default loss function for hyperopt
|
||||
This is intended to give you some inspiration for your own loss function.
|
||||
|
||||
The Function needs to return a number (float) - which becomes for better backtest results.
|
||||
The Function needs to return a number (float) - which becomes smaller for better backtest
|
||||
results.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
|
Reference in New Issue
Block a user