def test_transformation(self): """ Test the data gets transformed and written properly.""" # Pick the path and transform the data. in_file = common.get_raw_data("USD_CHF") out_file = self.tmp_file transformer.transform(in_file, out_file, 10000) # Read the file and check the numbers. results = [] with open(self.tmp_file, 'r') as csv_handle: reader = csv.reader(csv_handle, delimiter=' ') for row in reader: results.append(row) # Make sure it's working properly. self.assertTrue(len(results) > 2800) self.assertEqual(len(results[0]), 8) self.assertEqual(results[0][0], '155.0') self.assertEqual(results[10][1], '-28.0') self.assertEqual(results[28][2], '-83.0') self.assertEqual(results[236][3], '3.0') self.assertEqual(results[387][4], '59.0') self.assertEqual(results[822][5], '-142.4') self.assertEqual(results[1298][6], '-8.1') self.assertEqual(results[2150][7], '-39.6') return
def main(): """ Main in transforming data for strategy Euler.""" for instrument in common.ALL_PAIRS: # Gather necessary data. in_file = common.get_raw_data(instrument) out_file = util.get_clean_data(instrument) pip_factor = common.get_pip_factor(instrument) # Transform. transform(in_file, out_file, pip_factor) return
def __init__(self, instrument): """ Initialize the strategy class Euler. Args: instrument: string. The currency pair. e.g. 'EUR_USD'. Returns: void. """ super(Euler, self).__init__(instrument) # Initialize learner and model. self.learner = Learner(instrument) self.model = None # Read in the raw data file for testing. test_file = common.get_raw_data(instrument) self.test_data = transformer.read_raw_file(test_file) return