def _balancing_trade(self, offer, target_energy): trade = None buyer = make_ba_name(self.owner) \ if make_ba_name(self.owner) != offer.seller \ else f"{self.owner.name} Reserve" if abs(offer.energy) <= abs(target_energy): trade = self.lower_market.accept_offer(offer_or_id=offer, buyer=buyer, energy=offer.energy) elif abs(offer.energy) >= abs(target_energy): trade = self.lower_market.accept_offer(offer_or_id=offer, buyer=buyer, energy=target_energy) return trade
def __init__(self, owner, higher_market, lower_market, min_offer_age=ConstSettings.IAASettings.MIN_OFFER_AGE): self.balancing_spot_trade_ratio = owner.balancing_spot_trade_ratio super().__init__(owner=owner, higher_market=higher_market, lower_market=lower_market, min_offer_age=min_offer_age, engine_type=BalancingEngine) self.name = make_ba_name(self.owner)
def __init__(self, owner, higher_market, lower_market, transfer_fee_pct=1, min_offer_age=1): self.balancing_spot_trade_ratio = owner.balancing_spot_trade_ratio super().__init__(owner=owner, higher_market=higher_market, lower_market=lower_market, transfer_fee_pct=transfer_fee_pct, min_offer_age=min_offer_age, engine_type=BalancingEngine) self.name = make_ba_name(self.owner)
def number_of_balancing_trades(context, area, b_trade_nr, s_trade_nr): b_trade_nr = int(b_trade_nr) s_trade_nr = int(s_trade_nr) area_object = next( filter(lambda x: x.name == area, context.simulation.area.children)) for market in area_object.past_balancing_markets: if len(market.trades) == 0: continue reduced_trades = reduce( lambda acc, t: acc + 1 if t.buyer == make_ba_name(area_object) else acc, market.trades, 0) assert b_trade_nr == reduced_trades assert len(area_object._markets.past_markets[ market.time_slot].trades) == s_trade_nr
def __init__(self, owner, higher_market, lower_market, min_offer_age=ConstSettings.IAASettings.MIN_OFFER_AGE): self.balancing_spot_trade_ratio = owner.balancing_spot_trade_ratio self.engines = [ BalancingEngine('High -> Low', higher_market, lower_market, min_offer_age, self), BalancingEngine('Low -> High', lower_market, higher_market, min_offer_age, self), ] super().__init__(owner=owner, higher_market=higher_market, lower_market=lower_market, min_offer_age=min_offer_age, do_create_engine=False) self.name = make_ba_name(self.owner)