added support for the adjusteable stop loss, if we made profit. Implementation based on the cocnept: use positive stop loss, if made profit is > 0
This commit is contained in:
parent
5cf72b5d5f
commit
f8da1bf5a6
@ -4,7 +4,9 @@
|
|||||||
"stake_amount": 0.05,
|
"stake_amount": 0.05,
|
||||||
"fiat_display_currency": "USD",
|
"fiat_display_currency": "USD",
|
||||||
"dry_run": false,
|
"dry_run": false,
|
||||||
"trailing_stop": false,
|
"trailing_stop": {
|
||||||
|
"positive" : 0.01
|
||||||
|
},
|
||||||
"unfilledtimeout": 600,
|
"unfilledtimeout": 600,
|
||||||
"bid_strategy": {
|
"bid_strategy": {
|
||||||
"ask_last_balance": 0.0
|
"ask_last_balance": 0.0
|
||||||
|
@ -203,7 +203,6 @@ class Analyze(object):
|
|||||||
# evaluate if the stoploss was hit
|
# evaluate if the stoploss was hit
|
||||||
if self.strategy.stoploss is not None and trade.stop_loss >= current_rate:
|
if self.strategy.stoploss is not None and trade.stop_loss >= current_rate:
|
||||||
|
|
||||||
# just for debugging
|
|
||||||
if 'trailing_stop' in self.config and self.config['trailing_stop']:
|
if 'trailing_stop' in self.config and self.config['trailing_stop']:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"HIT STOP: current price at {:.6f}, stop loss is {:.6f}, "
|
"HIT STOP: current price at {:.6f}, stop loss is {:.6f}, "
|
||||||
@ -216,7 +215,19 @@ class Analyze(object):
|
|||||||
|
|
||||||
# update the stop loss afterwards, after all by definition it's supposed to be hanging
|
# update the stop loss afterwards, after all by definition it's supposed to be hanging
|
||||||
if 'trailing_stop' in self.config and self.config['trailing_stop']:
|
if 'trailing_stop' in self.config and self.config['trailing_stop']:
|
||||||
trade.adjust_stop_loss(current_rate, self.strategy.stoploss)
|
|
||||||
|
# check if we have a special stop loss for positive condition
|
||||||
|
# and if profit is positive
|
||||||
|
stop_loss_value = self.strategy.stoploss
|
||||||
|
if isinstance(self.config['trailing_stop'], dict) and \
|
||||||
|
'positive' in self.config['trailing_stop'] and \
|
||||||
|
current_profit > 0:
|
||||||
|
|
||||||
|
print("using positive stop loss mode: {} since we have profit {}".format(
|
||||||
|
self.config['trailing_stop']['positive'], current_profit))
|
||||||
|
stop_loss_value = self.config['trailing_stop']['positive']
|
||||||
|
|
||||||
|
trade.adjust_stop_loss(current_rate, stop_loss_value)
|
||||||
|
|
||||||
# Check if time matches and current rate is above threshold
|
# Check if time matches and current rate is above threshold
|
||||||
time_diff = (current_time.timestamp() - trade.open_date.timestamp()) / 60
|
time_diff = (current_time.timestamp() - trade.open_date.timestamp()) / 60
|
||||||
|
@ -141,7 +141,7 @@ class Trade(_DECL_BASE):
|
|||||||
else:
|
else:
|
||||||
logger.debug("keeping current stop loss")
|
logger.debug("keeping current stop loss")
|
||||||
|
|
||||||
print(
|
logger.debug(
|
||||||
"{} - current price {:.8f}, bought at {:.8f} and calculated "
|
"{} - current price {:.8f}, bought at {:.8f} and calculated "
|
||||||
"stop loss is at: {:.8f} initial stop at {:.8f}. trailing stop loss saved us: {:.8f} "
|
"stop loss is at: {:.8f} initial stop at {:.8f}. trailing stop loss saved us: {:.8f} "
|
||||||
"and max observed rate was {:.8f}".format(
|
"and max observed rate was {:.8f}".format(
|
||||||
|
Loading…
Reference in New Issue
Block a user