stoploss on exchange added as a parameter to order_types

This commit is contained in:
misagh
2018-11-25 17:22:56 +01:00
parent e4744c1ba4
commit 3e29fbb17a
7 changed files with 37 additions and 32 deletions

View File

@@ -32,7 +32,8 @@ class DefaultStrategy(IStrategy):
order_types = {
'buy': 'limit',
'sell': 'limit',
'stoploss': 'limit'
'stoploss': 'limit',
'stoploss_on_exchange': False
}
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:

View File

@@ -68,11 +68,6 @@ class IStrategy(ABC):
# associated stoploss
stoploss: float
# if the stoploss should be on exchange.
# if this is True then a stoploss order will be placed
# immediately after a successful buy order.
stoploss_on_exchange: bool = False
# associated ticker interval
ticker_interval: str
@@ -80,7 +75,8 @@ class IStrategy(ABC):
order_types: Dict = {
'buy': 'limit',
'sell': 'limit',
'stoploss': 'limit'
'stoploss': 'limit',
'stoploss_on_exchange': False
}
# run "populate_indicators" only for new candle
@@ -228,7 +224,7 @@ class IStrategy(ABC):
current_rate = low or rate
current_profit = trade.calc_profit_percent(current_rate)
if self.stoploss_on_exchange:
if self.order_types.get('stoploss_on_exchange'):
stoplossflag = SellCheckTuple(sell_flag=False, sell_type=SellType.NONE)
else:
stoplossflag = self.stop_loss_reached(current_rate=current_rate, trade=trade,