How to use report_message method in Slash

Best Python code snippet using slash

base.py

Source:base.py Github

copy

Full Screen

1import os2import sys3sys.path.append(os.path.abspath('messages'))4import ast5import grpc6import time7import threading8import datetime9import json10from testing_data_pb2 import TestingData11from optimization_report_pb2 import OptimizationReport12def address_parser(file):13 with open(file) as json_file:14 parsed = json.loads(json_file.read())15 return parsed['meta_client']['address']16def convertsion_report_to_message(report):17 report_message = OptimizationReport()18 # Assigning each value of the backtest report message19 # to its counterpart20 if report.profit:21 report_message.profit.value = report.profit22 if report.profit_factor:23 report_message.profit_factor.value = report.profit_factor24 if report.expected_payoff:25 report_message.expected_payoff.value = report.expected_payoff26 if report.max_drawdown:27 report_message.max_drawdown.value = report.max_drawdown28 if report.max_drawdown_rate:29 report_message.max_drawdown_rate.value = report.max_drawdown_rate30 if report.relative_drawdown:31 report_message.relative_drawdown.value = report.relative_drawdown32 if report.relative_drawdown_rate:33 report_message.relative_drawdown_rate.value = report.relative_drawdown_rate34 if report.abs_drawdown:35 report_message.abs_drawdown.value = report.abs_drawdown36 if report.abs_drawdown_rate:37 report_message.abs_drawdown_rate.value = report.abs_drawdown_rate38 if report.gross_profit:39 report_message.gross_profit.value = report.gross_profit40 if report.gross_loss:41 report_message.gross_loss.value = report.gross_loss42 if report.total_trades:43 report_message.total_trades.value = report.total_trades44 if report.largest_loss_trade:45 report_message.largest_loss_trade.value = report.largest_loss_trade46 if report.largest_profit_trade:47 report_message.largest_profit_trade.value = report.largest_profit_trade48 if report.average_loss_trade:49 report_message.average_loss_trade.value = report.average_loss_trade50 if report.average_profit_trade:51 report_message.average_profit_trade.value = report.average_profit_trade52 if report.modeling_quality_percentage:53 report_message.modeling_quality_percentage.value = report.modeling_quality_percentage54 if report.max_consecutive_loss:55 report_message.max_consecutive_loss.value = report.max_consecutive_loss56 if report.max_consecutive_loss_count:57 report_message.max_consecutive_loss_count.value = report.max_consecutive_loss_count58 if report.max_consecutive_losses_count:59 report_message.max_consecutive_losses_count.value = report.max_consecutive_losses_count60 if report.max_consecutive_losses_loss:61 report_message.max_consecutive_losses_loss.value = report.max_consecutive_losses_loss62 if report.max_consecutive_profit:63 report_message.max_consecutive_profit.value = report.max_consecutive_profit64 if report.max_consecutive_profit_count:65 report_message.max_consecutive_profit_count.value = report.max_consecutive_profit_count66 if report.max_consecutive_wins_count:67 report_message.max_consecutive_wins_count.value = report.max_consecutive_wins_count68 if report.max_consecutive_wins_profit:69 report_message.max_consecutive_wins_profit.value = report.max_consecutive_wins_profit70 if report.profit_trades:71 report_message.profit_trades.value = report.profit_trades72 if report.profit_trades_rate:73 report_message.profit_trades_rate.value = report.profit_trades_rate74 if report.loss_trades:75 report_message.loss_trades.value = report.loss_trades76 if report.loss_trades_rate:77 report_message.loss_trades_rate.value = report.loss_trades_rate78 if report.ave_consecutive_wins:79 report_message.ave_consecutive_wins.value = report.ave_consecutive_wins80 if report.ave_consecutive_losses:81 report_message.ave_consecutive_losses.value = report.ave_consecutive_losses82 if report.short_positions:83 report_message.short_positions.value = report.short_positions84 if report.short_positions_rate:85 report_message.short_positions_rate.value = report.short_positions_rate86 if report.long_positions:87 report_message.long_positions.value = report.long_positions88 if report.long_positions_rate:89 report_message.long_positions_rate.value = report.long_positions_rate90 # Return the message91 print(report_message)92 return report_message93def convertsion_report_from_message(report_message):94 report = BacktestReport()95 # Assigning each value of the backtest report object96 # to its message counterpart97 if report_message.profit.value.value:98 report.profit = report_message.profit.value99 if report_message.profit_factor.value:100 report.profit_factor = report_message.profit_factor.value101 if report_message.expected_payoff.value:102 report.expected_payoff = report_message.expected_payoff.value103 if report_message.max_drawdown.value:104 report.max_drawdown = report_message.max_drawdown.value105 if report_message.max_drawdown_rate.value:106 report.max_drawdown_rate = report_message.max_drawdown_rate.value107 if report_message.relative_drawdown.value:108 report.relative_drawdown = report_message.relative_drawdown.value109 if report_message.relative_drawdown_rate.value:110 report.relative_drawdown_rate = report_message.relative_drawdown_rate.value111 if report_message.abs_drawdown.value:112 report.abs_drawdown = report_message.abs_drawdown.value113 if report_message.abs_drawdown_rate.value:114 report.abs_drawdown_rate = report_message.abs_drawdown_rate.value115 if report_message.gross_profit.value:116 report.gross_profit = report_message.gross_profit.value117 if report_message.gross_loss.value:118 report.gross_loss = report_message.gross_loss.value119 if report_message.total_trades.value:120 report.total_trades = report_message.total_trades.value121 if report_message.largest_loss_trade.value:122 report.largest_loss_trade = report_message.largest_loss_trade.value123 if report_message.largest_profit_trade.value:124 report.largest_profit_trade = report_message.largest_profit_trade.value125 if report_message.average_loss_trade.value:126 report.average_loss_trade = report_message.average_loss_trade.value127 if report_message.average_profit_trade.value:128 report.average_profit_trade = report_message.average_profit_trade.value129 if report_message.modeling_quality_percentage.value:130 report.modeling_quality_percentage = report_message.modeling_quality_percentage.value131 if report_message.max_consecutive_loss.value:132 report.max_consecutive_loss = report_message.max_consecutive_loss.value133 if report_message.max_consecutive_loss_count.value:134 report.max_consecutive_loss_count = report_message.max_consecutive_loss_count.value135 if report_message.max_consecutive_losses_count.value:136 report.max_consecutive_losses_count = report_message.max_consecutive_losses_count.value137 if report_message.max_consecutive_losses_loss.value:138 report.max_consecutive_losses_loss = report_message.max_consecutive_losses_loss.value139 if report_message.max_consecutive_profit.value:140 report.max_consecutive_profit = report_message.max_consecutive_profit.value141 if report_message.max_consecutive_profit_count.value:142 report.max_consecutive_profit_count = report_message.max_consecutive_profit_count.value143 if report_message.max_consecutive_wins_count.value:144 report.max_consecutive_wins_count = report_message.max_consecutive_wins_count.value145 if report_message.max_consecutive_wins_profit.value:146 report.max_consecutive_wins_profit = report_message.max_consecutive_wins_profit.value147 if report_message.profit_trades.value:148 report.profit_trades = report_message.profit_trades.value149 if report_message.profit_trades_rate.value:150 report.profit_trades_rate = report_message.profit_trades_rate.value151 if report_message.loss_trades.value:152 report.loss_trades = report_message.loss_trades.value153 if report_message.loss_trades_rate.value:154 report.loss_trades_rate = report_message.loss_trades_rate.value155 if report_message.ave_consecutive_wins.value:156 report.ave_consecutive_wins = report_message.ave_consecutive_wins.value157 if report_message.ave_consecutive_losses.value:158 report.ave_consecutive_losses = report_message.ave_consecutive_losses.value159 if report_message.short_positions.value:160 report.short_positions = report_message.short_positions.value161 if report_message.short_positions_rate.value:162 report.short_positions_rate = report_message.short_positions_rate.value163 if report_message.long_positions.value:164 report.long_positions = report_message.long_positions.value165 if report_message.long_positions.value:166 report.long_positions_rate = report_message.long_positions_rate.value167 # Return the report168 print(report)...

Full Screen

Full Screen

order_4_download_multi_images.py

Source:order_4_download_multi_images.py Github

copy

Full Screen

1from task_inventory.order_1_to_30.order_3_donwload_image_with_url import DownloadImageWithUrl2""" Order 4: Donwload multi images, and get the schedule.3If crawl a website, we can crawl many image url and save them to database.4When download those images, should know the schedule.5"""6class DownloadMultiImages(object):7 @staticmethod8 def download(images, save_path, report_func=None):9 report_message = {10 'success': 0,11 'error': 0,12 'total': len(images)13 }14 for img in images:15 try:16 DownloadImageWithUrl.donwload(img.get('url'), save_path, img.get('name'))17 report_message['success'] = report_message['success'] + 118 except IOError:19 report_message['error'] = report_message['error'] + 120 if report_func:21 report_func(report_message)22# base_url = 'http://img.hb.aicdn.com/576fe24099dd9481d52ebeb503b0e17cd95183d5341e6-VUYSZv_fw658'23# image_save_path = '/Users/Fernando/Develop/test'24#25# download_images = list()26# for i in range(0, 1000):27# download_image = dict()28# download_image['name'] = f'img_{str(i)}.jpg'29# download_image['url'] = base_url30# download_images.append(download_image)31#32#33# def report(report_info):34# print(report_info)35#...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful