Skip to content

Possible bugs on trading and tariff actions #46

@ponseko

Description

@ponseko

Looks like in the current calc_normalized_import_bids, the import bids remain zero if the desired_exports < max_exports. This value is then used to get the gross import, so this seems pretty damaging to trading:

def calc_normalized_import_bids(
self, potential_import_bids_all_regions, gross_outputs, investments
):
normalized_import_bids_all_regions = np.zeros(
(self.num_regions, self.num_regions), dtype=self.float_dtype
)
for region_id in range(self.num_regions):
max_export_rate = self.get_state(
"export_limit_all_regions", region_id=region_id
)
max_exports_from_region_id = self.calc_max_exports(
max_export_rate, gross_outputs[region_id], investments[region_id]
)
desired_exports_from_region_id = np.sum(
potential_import_bids_all_regions[:, region_id]
)
if desired_exports_from_region_id > max_exports_from_region_id:
for exporting_region in range(self.num_regions):
normalized_import_bids_all_regions[exporting_region][region_id] = (
potential_import_bids_all_regions[exporting_region][region_id]
/ desired_exports_from_region_id
* max_exports_from_region_id
)
return normalized_import_bids_all_regions

Furthermore, the import_tariff actions seem to be delayed by a timestep. Both calc_trade_sanctions and calc_welfloss_multiplier, get the action from the prev_state. Is this intentional?

def calc_trade_sanctions(self, gross_imports, save_state=True):
import_tariffs = self.get_prev_state("import_tariffs_all_regions")

def calc_welfloss_multiplier(
self,
gross_outputs,
gross_imports,
net_imports,
welfare_loss_per_unit_tariff=None,
welfare_gain_per_unit_exported=None,
save_state=True,
):
"""Calculate the welfare loss multiplier of exporting region due to being tariffed."""
if not self.apply_welfloss:
return np.ones((self.num_regions), dtype=self.float_dtype)
if welfare_loss_per_unit_tariff is None:
welfare_loss_per_unit_tariff = 0.4 # From Nordhaus 2015
if welfare_gain_per_unit_exported is None:
welfare_gain_per_unit_exported = 0.4
import_tariffs = self.get_prev_state("import_tariffs_all_regions")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions