Merge pull request #459 from rybolov/develop
Read .gzip files in testdata/
This commit is contained in:
		| @@ -10,6 +10,7 @@ from freqtrade.analyze import populate_indicators, parse_ticker_dataframe | ||||
|  | ||||
| from freqtrade import misc | ||||
| from user_data.hyperopt_conf import hyperopt_optimize_conf | ||||
| import gzip | ||||
|  | ||||
| logger = logging.getLogger(__name__) | ||||
|  | ||||
| @@ -38,13 +39,19 @@ def load_tickerdata_file(datadir, pair, ticker_interval, | ||||
|         pair=pair, | ||||
|         ticker_interval=ticker_interval, | ||||
|     ) | ||||
|     # The file does not exist we download it | ||||
|     if not os.path.isfile(file): | ||||
|         return None | ||||
|     gzipfile = file + '.gz' | ||||
|  | ||||
|     # Read the file, load the json | ||||
|     # If the file does not exist we download it when None is returned. | ||||
|     # If file exists, read the file, load the json | ||||
|     if os.path.isfile(gzipfile): | ||||
|         with gzip.open(gzipfile) as tickerdata: | ||||
|             pairdata = json.load(tickerdata) | ||||
|     elif os.path.isfile(file): | ||||
|         with open(file) as tickerdata: | ||||
|             pairdata = json.load(tickerdata) | ||||
|     else: | ||||
|         return None | ||||
|  | ||||
|     if timerange: | ||||
|         pairdata = trim_tickerlist(pairdata, timerange) | ||||
|     return pairdata | ||||
|   | ||||
| @@ -202,9 +202,14 @@ def test_download_backtesting_testdata2(mocker): | ||||
|  | ||||
|  | ||||
| def test_load_tickerdata_file(): | ||||
|     # 7 does not exist in either format. | ||||
|     assert not load_tickerdata_file(None, 'BTC_UNITEST', 7) | ||||
|     # 1 exists only as a .json | ||||
|     tickerdata = load_tickerdata_file(None, 'BTC_UNITEST', 1) | ||||
|     assert _BTC_UNITTEST_LENGTH == len(tickerdata) | ||||
|     # 8 .json is empty and will fail if it's loaded. .json.gz is a copy of 1.json | ||||
|     tickerdata = load_tickerdata_file(None, 'BTC_UNITEST', 8) | ||||
|     assert _BTC_UNITTEST_LENGTH == len(tickerdata) | ||||
|  | ||||
|  | ||||
| def test_init(default_conf, mocker): | ||||
|   | ||||
							
								
								
									
										3
									
								
								freqtrade/tests/testdata/BTC_UNITEST-8.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								freqtrade/tests/testdata/BTC_UNITEST-8.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| [ | ||||
|   {"O": 0.00162008, "H": 0.00162008, "L": 0.00162008, "C": 0.00162008, "V": 108.14853839, "T": "2017-11-04T23:02:00", "BV": 0.17520927} | ||||
| ] | ||||
							
								
								
									
										
											BIN
										
									
								
								freqtrade/tests/testdata/BTC_UNITEST-8.json.gz
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								freqtrade/tests/testdata/BTC_UNITEST-8.json.gz
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user