def export_default_settings_to_json_file(): from d3a.constants import DATE_FORMAT from d3a.d3a_core.util import d3a_path from d3a.d3a_core.util import constsettings_to_dict from d3a_interface.constants_limits import GlobalConfig base_settings = { "sim_duration": f"{GlobalConfig.DURATION_D*24}h", "slot_length": f"{GlobalConfig.SLOT_LENGTH_M}m", "tick_length": f"{GlobalConfig.TICK_LENGTH_S}s", "market_count": GlobalConfig.MARKET_COUNT, "cloud_coverage": GlobalConfig.CLOUD_COVERAGE, "iaa_fee": GlobalConfig.IAA_FEE, "start_date": pendulum.instance(GlobalConfig.start_date).format(DATE_FORMAT), } all_settings = { "basic_settings": base_settings, "advanced_settings": constsettings_to_dict() } settings_filename = os.path.join(d3a_path, "setup", "d3a-settings.json") with open(settings_filename, "w") as settings_file: settings_file.write(json.dumps(all_settings, indent=2))
def export_json_data(self, directory: dir): json_dir = os.path.join(directory, "aggregated_results") mkdir_from_str(json_dir) settings_file = os.path.join(json_dir, "const_settings.json") with open(settings_file, 'w') as outfile: json.dump(constsettings_to_dict(), outfile, indent=2) for key, value in self.endpoint_buffer.generate_json_report().items(): json_file = os.path.join(json_dir, key + ".json") with open(json_file, 'w') as outfile: json.dump(value, outfile, indent=2)
def test_constsettings_to_dict(self): settings_dict = constsettings_to_dict() assert (settings_dict["GeneralSettings"]["DEFAULT_MARKET_MAKER_RATE"] == ConstSettings.GeneralSettings.DEFAULT_MARKET_MAKER_RATE) assert (settings_dict["AreaSettings"]["PERCENTAGE_FEE_LIMIT"] == ConstSettings.AreaSettings.PERCENTAGE_FEE_LIMIT) assert (settings_dict["StorageSettings"]["CAPACITY"] == ConstSettings.StorageSettings.CAPACITY) assert (settings_dict["IAASettings"]["MARKET_TYPE"] == ConstSettings.IAASettings.MARKET_TYPE) assert (settings_dict["IAASettings"]["AlternativePricing"]["COMPARE_PRICING_SCHEMES"] == ConstSettings.IAASettings.AlternativePricing.COMPARE_PRICING_SCHEMES)
def export_default_settings_to_json_file(): from d3a.d3a_core.util import d3a_path from d3a.d3a_core.util import constsettings_to_dict base_settings_str = '{ \n "basic_settings": { \n "duration": "24h", \n ' \ '"slot_length": "60m", \n "tick_length": "60s", \n ' \ '"market_count": 4, \n "cloud_coverage": 0, \n ' \ '"market_maker_rate": 30, \n "iaa_fee": 1 \n },' constsettings_str = json.dumps( {"advanced_settings": constsettings_to_dict()}, indent=2) settings_filename = os.path.join(d3a_path, "setup", "d3a-settings.json") with open(settings_filename, "w") as settings_file: settings_file.write(base_settings_str) settings_file.write(constsettings_str[1::]) # remove leading '{'
def export_json_data(self, directory: dir, area: Area): json_dir = os.path.join(directory, "aggregated_results") mkdir_from_str(json_dir) settings_file = os.path.join(json_dir, "const_settings.json") with open(settings_file, 'w') as outfile: json.dump(constsettings_to_dict(), outfile, indent=2) kpi_file = os.path.join(json_dir, "KPI.json") self.kpi.update_kpis_from_area(area) with open(kpi_file, 'w') as outfile: json.dump(self.kpi.performance_index, outfile, indent=2) trade_file = os.path.join(json_dir, "trade-detail.json") with open(trade_file, 'w') as outfile: json.dump(self.endpoint_buffer.trade_details, outfile, indent=2) for key, value in self.endpoint_buffer.generate_json_report().items(): json_file = os.path.join(json_dir, key + ".json") with open(json_file, 'w') as outfile: json.dump(value, outfile, indent=2)
def before_all(context): context.default_const_settings = constsettings_to_dict() context.config.setup_logging() ConstSettings.GeneralSettings.KEEP_PAST_MARKETS = True
def before_all(context): context.default_const_settings = constsettings_to_dict() context.config.setup_logging()
def before_all(context): context.default_const_settings = constsettings_to_dict() context.config.setup_logging() constants.RETAIN_PAST_MARKET_STRATEGIES_STATE = True if os.environ.get("DISPATCH_EVENTS_BOTTOM_TO_TOP") == "False": d3a.constants.DISPATCH_EVENTS_BOTTOM_TO_TOP = False
def before_all(context): context.default_const_settings = constsettings_to_dict() context.config.setup_logging() ConstSettings.GeneralSettings.KEEP_PAST_MARKETS = True if os.environ.get("DISPATCH_EVENTS_BOTTOM_TO_TOP") == "False": d3a.constants.DISPATCH_EVENTS_BOTTOM_TO_TOP = False
def before_all(context): context.default_const_settings = constsettings_to_dict() context.config.setup_logging() constants.D3A_TEST_RUN = True if os.environ.get("DISPATCH_EVENTS_BOTTOM_TO_TOP") == "False": d3a.constants.DISPATCH_EVENTS_BOTTOM_TO_TOP = False