Default analyzer which gives users basic trading information.
| 15 | from outputs import Output |
| 16 | |
| 17 | class Behaviour(): |
| 18 | """Default analyzer which gives users basic trading information. |
| 19 | """ |
| 20 | |
| 21 | def __init__(self, config, exchange_interface, notifier): |
| 22 | """Initializes DefaultBehaviour class. |
| 23 | |
| 24 | Args: |
| 25 | indicator_conf (dict): A dictionary of configuration for this analyzer. |
| 26 | exchange_interface (ExchangeInterface): Instance of the ExchangeInterface class for |
| 27 | making exchange queries. |
| 28 | notifier (Notifier): Instance of the notifier class for informing a user when a |
| 29 | threshold has been crossed. |
| 30 | """ |
| 31 | |
| 32 | self.logger = structlog.get_logger() |
| 33 | self.indicator_conf = config.indicators |
| 34 | self.informant_conf = config.informants |
| 35 | self.crossover_conf = config.crossovers |
| 36 | self.exchange_interface = exchange_interface |
| 37 | self.strategy_analyzer = StrategyAnalyzer() |
| 38 | self.notifier = notifier |
| 39 | |
| 40 | output_interface = Output() |
| 41 | self.output = output_interface.dispatcher |
| 42 | |
| 43 | |
| 44 | def run(self, market_pairs, output_mode): |
| 45 | """The analyzer entrypoint |
| 46 | |
| 47 | Args: |
| 48 | market_pairs (list): List of symbol pairs to operate on, if empty get all pairs. |
| 49 | output_mode (str): Which console output mode to use. |
| 50 | """ |
| 51 | |
| 52 | self.logger.info("Starting default analyzer...") |
| 53 | |
| 54 | if market_pairs: |
| 55 | self.logger.info("Found configured markets: %s", market_pairs) |
| 56 | else: |
| 57 | self.logger.info("No configured markets, using all available on exchange.") |
| 58 | |
| 59 | market_data = self.exchange_interface.get_exchange_markets(markets=market_pairs) |
| 60 | |
| 61 | self.logger.info("Using the following exchange(s): %s", list(market_data.keys())) |
| 62 | |
| 63 | new_result = self._test_strategies(market_data, output_mode) |
| 64 | |
| 65 | self.notifier.notify_all(new_result) |
| 66 | |
| 67 | |
| 68 | def _test_strategies(self, market_data, output_mode): |
| 69 | """Test the strategies and perform notifications as required |
| 70 | |
| 71 | Args: |
| 72 | market_data (dict): A dictionary containing the market data of the symbols to analyze. |
| 73 | output_mode (str): Which console output mode to use. |
| 74 | """ |