-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathanalysis.py
73 lines (53 loc) · 1.9 KB
/
analysis.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
68
69
70
71
72
73
"""Executes the trading strategies and analyzes the results.
"""
import math
from datetime import datetime
import structlog
import pandas
from talib import abstract
from analyzers.indicators import *
from analyzers.informants import *
from analyzers import *
class StrategyAnalyzer():
"""Contains all the methods required for analyzing strategies.
"""
def __init__(self):
"""Initializes StrategyAnalyzer class """
self.logger = structlog.get_logger()
def indicator_dispatcher(self):
"""Returns a dictionary for dynamic anaylsis selector
Returns:
dictionary: A dictionary of functions to serve as a dynamic analysis selector.
"""
dispatcher = {
'ichimoku': ichimoku.Ichimoku().analyze,
'macd': macd.MACD().analyze,
'rsi': rsi.RSI().analyze,
'momentum': momentum.Momentum().analyze,
'mfi': mfi.MFI().analyze,
'stoch_rsi': stoch_rsi.StochasticRSI().analyze,
'obv': obv.OBV().analyze
}
return dispatcher
def informant_dispatcher(self):
"""Returns a dictionary for dynamic informant selector
Returns:
dictionary: A dictionary of functions to serve as a dynamic informant selector.
"""
dispatcher = {
'sma': sma.SMA().analyze,
'ema': ema.EMA().analyze,
'vwap': vwap.VWAP().analyze,
'bollinger_bands': bollinger_bands.Bollinger().analyze,
'ohlcv': ohlcv.OHLCV().analyze
}
return dispatcher
def crossover_dispatcher(self):
"""Returns a pandas.DataFrame for dynamic crossover selector
Returns:
dictionary: A dictionary of functions to serve as a dynamic crossover selector.
"""
dispatcher = {
'std_crossover': crossover.CrossOver().analyze
}
return dispatcher