-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindicators.py
50 lines (43 loc) · 1.82 KB
/
indicators.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
from common.data import BotData, Instrument
class BreakDown:
symbols = dict()
def __init__(self, instrument: Instrument, bot: BotData) -> None:
self.symbol = (instrument.symbol, instrument.market)
self.bot = bot
self.name = "BreakDown"
if self.symbol not in BreakDown.symbols:
BreakDown.symbols[self.symbol] = dict()
if bot.timefr not in BreakDown.symbols[self.symbol]:
BreakDown.symbols[self.symbol][bot.timefr] = dict()
self.setup()
self.parameters = BreakDown.symbols[self.symbol][self.bot.timefr][self.bot.name]
def setup(self):
BreakDown.symbols[self.symbol][self.bot.timefr][self.bot.name] = {
"bot_name": self.bot.name,
"symbol": self.symbol,
"up": False,
"dn": False,
"first": 0,
"number": 0,
"trades": 0,
}
def default(self):
self.parameters["first"] = 0
self.parameters["number"] = 0
self.parameters["trades"] = 0
def clean_indicators(bot_name: str, timefr="") -> None:
for symbol in BreakDown.symbols.copy():
if timefr:
if timefr in BreakDown.symbols[symbol]:
if bot_name in BreakDown.symbols[symbol][timefr]:
del BreakDown.symbols[symbol][timefr][bot_name]
if not BreakDown.symbols[symbol][timefr]:
del BreakDown.symbols[symbol][timefr]
else:
for tf in BreakDown.symbols[symbol].copy():
if bot_name in BreakDown.symbols[symbol][tf]:
del BreakDown.symbols[symbol][tf][bot_name]
if not BreakDown.symbols[symbol][tf]:
del BreakDown.symbols[symbol][tf]
if not BreakDown.symbols[symbol]:
del BreakDown.symbols[symbol]