forked from PeetCrypto/freqtrade-stuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BreakEven.py
67 lines (50 loc) · 2.17 KB
/
BreakEven.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame
# --------------------------------
class BreakEven(IStrategy):
"""
author@: lenik
Sometimes I want to close the bot ASAP, but not have the positions floating around.
I can "/stopbuy" and wait for the positions to get closed by the bot rules, which is
waiting for some profit, etc -- this usually takes too long...
What I would prefer is to close everything that is over 0% profit to avoid the losses.
Here's a simple strategy with empty buy/sell signals and "minimal_roi = { 0 : 0 }" that
sells everything already at profit and wait until the positions at loss will come to break
even point (or the small profit you provide in ROI table).
You may restart the bot with the new strategy as a command-line parameter.
Another way would be to specify the original strategy in the config file, then change to
this one and simply "/reload_config" from the Telegram bot.
"""
# This attribute will be overridden if the config file contains "minimal_roi"
minimal_roi = {
"0": 0.01, # at least 1% at first
"10": 0 # after 10min, everything goes
}
# This is more radical version that sells everything above the profit level
# minimal_roi = {
# "0": 0
# }
# And this is basically "/forcesell all", that sells no matter what profit
# minimal_roi = {
# "0": -1
# }
# Optimal stoploss designed for the strategy
stoploss = -0.05
# Optimal timeframe for the strategy
timeframe = '5m'
# don't generate any buy or sell signals, everything is handled by ROI and stop_loss
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
return dataframe
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
),
'buy'] = 0
return dataframe
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
),
'sell'] = 0
return dataframe