MCPcopy Create free account
hub / github.com/CryptoSignal/Crypto-Signal / Output

Class Output

app/outputs.py:9–201  ·  view source on GitHub ↗

Handles outputting results to the terminal.

Source from the content-addressed store, hash-verified

7
8
9class Output():
10 """ Handles outputting results to the terminal.
11 """
12
13 def __init__(self):
14 """Initializes Output class.
15 """
16
17 self.logger = structlog.get_logger()
18 self.dispatcher = {
19 'cli': self.to_cli,
20 'csv': self.to_csv,
21 'json': self.to_json
22 }
23
24
25 def to_cli(self, results, market_pair):
26 """Creates the message to output to the CLI
27
28 Args:
29 market_pair (str): Market pair that this message relates to.
30 results (dict): The result of the completed analysis to output.
31
32 Returns:
33 str: Completed cli message
34 """
35
36 normal_colour = '\u001b[0m'
37 hot_colour = '\u001b[31m'
38 cold_colour = '\u001b[36m'
39
40 output = "{}:\t\n".format(market_pair)
41 for indicator_type in results:
42 output += '\n{}:\t'.format(indicator_type)
43 for indicator in results[indicator_type]:
44 for i, analysis in enumerate(results[indicator_type][indicator]):
45 if analysis['result'].shape[0] == 0:
46 self.logger.info('No results for %s #%s', indicator, i)
47 continue
48
49 colour_code = normal_colour
50
51 if 'is_hot' in analysis['result'].iloc[-1]:
52 if analysis['result'].iloc[-1]['is_hot']:
53 colour_code = hot_colour
54
55 if 'is_cold' in analysis['result'].iloc[-1]:
56 if analysis['result'].iloc[-1]['is_cold']:
57 colour_code = cold_colour
58
59 if indicator_type == 'crossovers':
60 key_signal = '{}_{}'.format(
61 analysis['config']['key_signal'],
62 analysis['config']['key_indicator_index']
63 )
64
65 key_value = analysis['result'].iloc[-1][key_signal]
66

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected