def run_script(driver): """find the best stop loss value.""" wait = WebDriverWait(driver, 5) driver.get(url) click.strategy_tester() try: click.overview() except NoSuchElementException: time.sleep(1) click.overview() print("Generating Max Profit For Stop Loss.\n") print("Loading script...") for number in range: count = round(number, 2) try: click.settings_button(wait) click.stoploss_input( count, wait) # clicking stop loss input text box and entering number. get.net_value(count, wait) except (StaleElementReferenceException, TimeoutException, NoSuchElementException): print("script has timed out.") break # adding the new value to your strategy. click.settings_button(wait) best_key = find.best_key() click.stoploss_input(best_key, wait) time.sleep(.5) print("\n----------Results----------\n") click.overview() show_me.best_stoploss() click.performance_summary() show_me.total_closed_trades() show_me.win_rate() show_me.net_profit() show_me.max_drawdown() show_me.sharpe_ratio() show_me.win_loss_ratio() show_me.avg_win_trade() show_me.avg_loss_trade() show_me.avg_bars_in_winning_trades()
def run_script(driver): """find the best stop loss value.""" wait = WebDriverWait(driver, 5) driver.get(url) # clicking Strategy Tester tab. click.strategy_tester() print("Generating Max Profit For Stop Loss.\n") print("Loading script...") for number in range: count = round(number, 2) try: # clicking settings button. previous_net_profit = click.settings_button(wait) # clicking stop loss input text box and enter number. click.stoploss_input(count, wait) # extract the net profit percentage. current_net_profit = get.net_value(count, wait) # checking if duplicate Net Profit values. if check.duplicate(count, previous_net_profit, current_net_profit): break except (StaleElementReferenceException, TimeoutException, NoSuchElementException): print("script has timed out.") break # adding the new value to your strategy. click.settings_button(wait) best_key = find.best_key() click.stoploss_input(best_key, wait) time.sleep(.5) print("\n----------Results----------\n") show_me.total_trades() show_me.max_stoploss() show_me.netprofit() show_me.percent_profitable() show_me.max_drawdown() show_me.avg_trade()