@@ -264,34 +264,60 @@ def export_optimizer(self, file_type: str):
264
264
else :
265
265
create_popup (self , 'No table rows found because optimizer has not been run yet.' )
266
266
267
- def validate_optimizer (self , combos : dict ):
267
+ def validate_optimizer_or_backtest (self , caller ):
268
268
"""
269
- Validate optimizer to ensure it is correctly setup.
269
+ Validate optimizer/backtester to ensure it is correctly setup.
270
270
:return: False if not validated and true if validated.
271
271
"""
272
- if not self .validate_ticker (OPTIMIZER ):
272
+ config = self .configuration
273
+ noun = 'optimizer' if caller == OPTIMIZER else 'backtester'
274
+
275
+ if not self .validate_ticker (caller ):
273
276
return False
274
277
275
- if self . configuration . optimizer_backtest_dict [OPTIMIZER ]['data' ] is None :
276
- create_popup (self , "No data setup yet for optimizer . Please configure them in settings first." )
278
+ if config . optimizer_backtest_dict [caller ]['data' ] is None :
279
+ create_popup (self , f "No data setup yet for { noun } . Please download or import data in settings first." )
277
280
return False
278
281
279
- if self .configuration .get_optimizer_settings ()['strategies' ] == {}:
280
- create_popup (self , "No strategies found. Make sure you have some strategies for optimization." )
282
+ selected_symbol = self .interfaceDictionary [caller ]['configuration' ]['ticker' ].text ()
283
+ download_symbol = config .optimizer_backtest_dict [caller ]['dataType' ]
284
+
285
+ if selected_symbol != download_symbol and download_symbol .lower () != 'imported' :
286
+ create_popup (self , f"{ noun .capitalize ()} symbol ({ selected_symbol } ) does not match downloaded symbol "
287
+ f"({ download_symbol } ). Change your ticker to ({ download_symbol } ) "
288
+ f"or download ({ selected_symbol } ) data to get rid of this error." )
281
289
return False
282
290
283
- if not self .check_combos (combos ['strategies' ]):
284
- create_popup (self , "Please configure your strategies correctly." )
291
+ selected_interval = self .interfaceDictionary [caller ]['configuration' ]['interval' ].currentText ().lower ()
292
+ download_interval = config .optimizer_backtest_dict [caller ]['dataInterval' ].lower ()
293
+
294
+ if selected_interval != download_interval and download_symbol .lower () != 'imported' :
295
+ create_popup (self , f"{ noun .capitalize ()} interval ({ selected_interval } ) does not match downloaded interval "
296
+ f"({ download_interval } ). Change your data interval to ({ download_interval } ) "
297
+ f"or download ({ selected_interval } ) data to get rid of this error." )
285
298
return False
286
299
300
+ if download_symbol .lower () == 'imported' :
301
+ # TODO: Add verification for imports.
302
+ create_popup (self , "You are using imported data. Please ensure they logically work correctly with your "
303
+ "inputs. Algobot currently does not support imported data verification." )
304
+
287
305
return True
288
306
289
307
def initiate_optimizer (self ):
290
308
"""
291
309
Main function to begin optimization.
292
310
"""
311
+ if not self .validate_optimizer_or_backtest (caller = OPTIMIZER ):
312
+ return
313
+
293
314
combos = self .configuration .get_optimizer_settings ()
294
- if not self .validate_optimizer (combos = combos ):
315
+ if combos ['strategies' ] == {}:
316
+ create_popup (self , "No strategies found. Make sure you have some strategies for optimization." )
317
+ return
318
+
319
+ if not self .check_combos (combos ['strategies' ]):
320
+ create_popup (self , "Please configure your strategies correctly." )
295
321
return
296
322
297
323
self .threads [OPTIMIZER ] = optimizerThread .OptimizerThread (gui = self , logger = self .logger , combos = combos )
@@ -322,11 +348,7 @@ def initiate_backtest(self):
322
348
"""
323
349
Initiates backtest based on settings configured. If there is no data configured, prompts user to configure data.
324
350
"""
325
- if not self .validate_ticker (BACKTEST ):
326
- return
327
-
328
- if self .configuration .optimizer_backtest_dict [BACKTEST ]['data' ] is None :
329
- create_popup (self , "No data setup yet for backtesting. Please configure them in settings first." )
351
+ if not self .validate_optimizer_or_backtest (caller = BACKTEST ):
330
352
return
331
353
332
354
if not self .check_strategies (BACKTEST ):
@@ -500,7 +522,8 @@ def validate_ticker(self, caller: int):
500
522
create_popup (self , "Please specify a ticker. No ticker found." )
501
523
return False
502
524
if selected_ticker not in self .tickers :
503
- create_popup (self , "Invalid ticker specified. Please check your settings and configure it correctly." )
525
+ create_popup (self , f'Invalid ticker "{ selected_ticker } " provided. If it is valid, '
526
+ f'then try updating your tickers in the configuration settings.' )
504
527
return False
505
528
return True
506
529
0 commit comments