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

Method to_cli

app/outputs.py:25–105  ·  view source on GitHub ↗

Creates the message to output to the CLI Args: market_pair (str): Market pair that this message relates to. results (dict): The result of the completed analysis to output. Returns: str: Completed cli message

(self, results, market_pair)

Source from the content-addressed store, hash-verified

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
67 crossed_signal = '{}_{}'.format(
68 analysis['config']['crossed_signal'],
69 analysis['config']['crossed_indicator_index']
70 )
71
72 crossed_value = analysis['result'].iloc[-1][crossed_signal]
73
74 if isinstance(key_value, float):
75 key_value = format(key_value, '.8f')
76
77 if isinstance(crossed_value, float):
78 crossed_value = format(crossed_value, '.8f')
79
80 formatted_string = '{}/{}'.format(key_value, crossed_value)
81 output += "{}{}: {}{} \t".format(
82 colour_code,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected