Esempio n. 1
0
def iaa_double_sided_2():
    from d3a.models.const import ConstSettings
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket(sorted_offers=[Offer('id', 2, 2, 'other')],
                              bids=[Bid('bid_id', 10, 10, 'B', 'S')])
    higher_market = FakeMarket([], [])
    owner = FakeArea('owner')
    iaa = TwoSidedPayAsBidAgent(owner=owner, lower_market=lower_market,
                                higher_market=higher_market)
    iaa.event_tick(area=iaa.owner)
    yield iaa
    ConstSettings.IAASettings.MARKET_TYPE = 1
Esempio n. 2
0
def test_iaa_forwards_offers_according_to_percentage(iaa_fee):
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket([], [Bid('id', 1, 1, 'this', 'other')])
    higher_market = FakeMarket([], [Bid('id2', 3, 3, 'child', 'owner')])
    iaa = TwoSidedPayAsBidAgent(owner=FakeArea('owner'),
                                higher_market=higher_market,
                                lower_market=lower_market,
                                transfer_fee_pct=iaa_fee)
    iaa.event_tick(area=iaa.owner)
    assert iaa.higher_market.bid_count == 1
    assert iaa.higher_market.forwarded_bid.price / (1 + (iaa_fee / 100)) == \
        list(iaa.lower_market.bids.values())[-1].price
    ConstSettings.IAASettings.MARKET_TYPE = 1
Esempio n. 3
0
 def create_agent_object(owner, higher_market, lower_market,
                         is_spot_market):
     agent_constructor_arguments = {
         "owner": owner,
         "higher_market": higher_market,
         "lower_market": lower_market,
         "min_offer_age": ConstSettings.IAASettings.MIN_OFFER_AGE
     }
     if is_spot_market:
         if ConstSettings.IAASettings.MARKET_TYPE == 1:
             if ConstSettings.IAASettings.AlternativePricing.PRICING_SCHEME != 0:
                 return OneSidedAlternativePricingAgent(
                     **agent_constructor_arguments)
             else:
                 return OneSidedAgent(**agent_constructor_arguments)
         elif ConstSettings.IAASettings.MARKET_TYPE == 2:
             return TwoSidedPayAsBidAgent(
                 **agent_constructor_arguments,
                 min_bid_age=ConstSettings.IAASettings.MIN_BID_AGE)
         elif ConstSettings.IAASettings.MARKET_TYPE == 3:
             return TwoSidedPayAsClearAgent(
                 **agent_constructor_arguments,
                 min_bid_age=ConstSettings.IAASettings.MIN_BID_AGE)
     else:
         return BalancingAgent(**agent_constructor_arguments)
Esempio n. 4
0
def iaa_double_sided():
    from d3a_interface.constants_limits import ConstSettings
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket(sorted_offers=[Offer('id', 2, 2, 'other', 2)],
                              bids=[Bid('bid_id', 10, 10, 'B', 'S', 10)], transfer_fee_ratio=0.01)
    higher_market = FakeMarket([], [], transfer_fee_ratio=0.01)
    owner = FakeArea('owner')
    iaa = TwoSidedPayAsBidAgent(owner=owner, lower_market=lower_market,
                                higher_market=higher_market)
    iaa.event_tick()
    iaa.owner.current_tick += 2
    iaa.event_tick()
    yield iaa
Esempio n. 5
0
def iaa_bid():
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket([], [Bid('id', 1, 1, 'this', 'other', 1, buyer_origin='id')])
    higher_market = FakeMarket([], [Bid('id2', 1, 1, 'child', 'owner', 1, buyer_origin='id2'),
                                    Bid('id3', 0.5, 1, 'child', 'owner', 1, buyer_origin='id3')])
    owner = FakeArea('owner')

    iaa = TwoSidedPayAsBidAgent(owner=owner,
                                higher_market=higher_market,
                                lower_market=lower_market)
    iaa.event_tick()
    iaa.owner.current_tick = 14
    iaa.event_tick()
    yield iaa
Esempio n. 6
0
def iaa_bid():
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket([], [Bid('id', 1, 1, 'this', 'other')])
    higher_market = FakeMarket([], [Bid('id2', 3, 3, 'child', 'owner'),
                                    Bid('id3', 0.5, 1, 'child', 'owner')])
    owner = FakeArea('owner')
    iaa = TwoSidedPayAsBidAgent(owner=owner,
                                higher_market=higher_market,
                                lower_market=lower_market,
                                transfer_fee_pct=5)
    iaa.event_tick(area=iaa.owner)
    iaa.owner.current_tick = 14
    iaa.event_tick(area=iaa.owner)
    yield iaa
    ConstSettings.IAASettings.MARKET_TYPE = 1
Esempio n. 7
0
def test_iaa_forwards_offers_according_to_constantfee(iaa_fee_const):
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket([], [Bid('id', 15, 1, 'this', 'other', 15)],
                              transfer_fee_const=iaa_fee_const)
    higher_market = FakeMarket([], [Bid('id2', 35, 3, 'child', 'owner', 35)],
                               transfer_fee_const=iaa_fee_const)
    iaa = TwoSidedPayAsBidAgent(owner=FakeArea('owner'),
                                higher_market=higher_market,
                                lower_market=lower_market)
    iaa.event_tick()
    iaa.owner.current_tick = 14
    iaa.event_tick()

    assert iaa.higher_market.bid_count == 1
    bid = list(iaa.lower_market.bids.values())[-1]
    assert iaa.higher_market.forwarded_bid.price == bid.price - iaa_fee_const * bid.energy
Esempio n. 8
0
def test_iaa_forwards_offers_according_to_percentage(iaa_fee):
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket([], [Bid('id', 1, 1, 'this', 'other', 1)],
                              transfer_fee_ratio=iaa_fee)
    higher_market = FakeMarket([], [Bid('id2', 3, 3, 'child', 'owner', 3)],
                               transfer_fee_ratio=iaa_fee)
    iaa = TwoSidedPayAsBidAgent(owner=FakeArea('owner'),
                                higher_market=higher_market,
                                lower_market=lower_market)
    iaa.event_tick()
    iaa.owner.current_tick = 14
    iaa.event_tick()

    assert iaa.higher_market.bid_count == 1
    assert iaa.higher_market.forwarded_bid.price == \
        list(iaa.lower_market.bids.values())[-1].price * (1 - iaa_fee)
def iaa_double_sided():
    from d3a_interface.constants_limits import ConstSettings
    ConstSettings.IAASettings.MARKET_TYPE = 2
    lower_market = FakeMarket(offers=[Offer('id', pendulum.now(), 2, 2, 'other', 2)],
                              bids=[Bid('bid_id', pendulum.now(), 10, 10, 'B', 'S', 10)],
                              transfer_fees=TransferFees(grid_fee_percentage=0.01,
                                                         transfer_fee_const=0))
    higher_market = FakeMarket([], [], transfer_fees=TransferFees(grid_fee_percentage=0.01,
                                                                  transfer_fee_const=0))
    owner = FakeArea('owner')
    iaa = TwoSidedPayAsBidAgent(owner=owner, lower_market=lower_market,
                                higher_market=higher_market)
    iaa.event_tick()
    iaa.owner.current_tick += 2
    iaa.event_tick()
    yield iaa