Skip to content

Commit

Permalink
Document IStrategy.custom_sell.
Browse files Browse the repository at this point in the history
  • Loading branch information
rokups committed Apr 25, 2021
1 parent 1292e08 commit a77337e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/strategy-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ class AwesomeStrategy(IStrategy):

See `custom_stoploss` examples below on how to access the saved dataframe columns

## Custom sell signal

It is possible to define custom sell signals. This is very useful when we need to customize sell conditions for each individual trade.

An example of how we can sell trades that were open longer than 1 day:

``` python
class AwesomeStrategy(IStrategy):
def custom_sell(self, pair: str, trade: Trade, current_time: datetime, current_rate: float,
current_profit: float, **kwargs) -> bool:
time_delta = datetime.datetime.utcnow() - trade.open_date_utc
return time_delta.days >= 1
```

## Custom stoploss

The stoploss price can only ever move upwards - if the stoploss value returned from `custom_stoploss` would result in a lower stoploss price than was previously set, it will be ignored. The traditional `stoploss` value serves as an absolute lower level and will be instated as the initial stoploss.
Expand Down

0 comments on commit a77337e

Please sign in to comment.