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

Method to_csv

app/outputs.py:108–175  ·  view source on GitHub ↗

Creates the csv 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 CSV message

(self, results, market_pair)

Source from the content-addressed store, hash-verified

106
107
108 def to_csv(self, results, market_pair):
109 """Creates the csv to output to the CLI
110
111 Args:
112 market_pair (str): Market pair that this message relates to.
113 results (dict): The result of the completed analysis to output.
114
115 Returns:
116 str: Completed CSV message
117 """
118
119 logger.warn('WARNING: CSV output is deprecated and will be removed in a future version')
120
121 output = str()
122 for indicator_type in results:
123 for indicator in results[indicator_type]:
124 for i, analysis in enumerate(results[indicator_type][indicator]):
125 value = str()
126
127 if indicator_type == 'crossovers':
128 key_signal = '{}_{}'.format(
129 analysis['config']['key_signal'],
130 analysis['config']['key_indicator_index']
131 )
132
133 key_value = analysis['result'].iloc[-1][key_signal]
134
135 crossed_signal = '{}_{}'.format(
136 analysis['config']['crossed_signal'],
137 analysis['config']['crossed_indicator_index']
138 )
139
140 crossed_value = analysis['result'].iloc[-1][crossed_signal]
141
142 if isinstance(key_value, float):
143 key_value = format(key_value, '.8f')
144
145 if isinstance(crossed_value, float):
146 crossed_value = format(crossed_value, '.8f')
147
148 value = '/'.join([key_value, crossed_value])
149 else:
150 for signal in analysis['config']['signal']:
151 value = analysis['result'].iloc[-1][signal]
152 if isinstance(value, float):
153 value = format(value, '.8f')
154
155 is_hot = str()
156 if 'is_hot' in analysis['result'].iloc[-1]:
157 is_hot = str(analysis['result'].iloc[-1]['is_hot'])
158
159 is_cold = str()
160 if 'is_cold' in analysis['result'].iloc[-1]:
161 is_cold = str(analysis['result'].iloc[-1]['is_cold'])
162
163 new_output = ','.join([
164 market_pair,
165 indicator_type,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected