Пример #1
0
def test_poly_line_from_tupples():
    demand_curve = create_demand_curve()
    tupples = demand_curve.points
    new_curve = PolyLineFactory.fromTupples(tupples)
    expected_length = len(demand_curve.points)
    actual_length = len(new_curve.points)
    assert actual_length == expected_length
Пример #2
0
def test_poly_line_from_tupples():
    demand_curve = create_demand_curve()
    tupples = demand_curve.points
    new_curve = PolyLineFactory.fromTupples(tupples)
    expected_length = len(demand_curve.points)
    actual_length = len(new_curve.points)
    assert actual_length == expected_length
Пример #3
0
def test_poly_line_combine_demand():
    demand_curve = create_demand_curve()
    curves = [demand_curve, demand_curve]
    combined_curves = PolyLineFactory.combine(curves, 100)
    assert combined_curves.min_x() == 0
    assert combined_curves.max_x() == 2000
    assert combined_curves.min_y() == 0
    assert combined_curves.max_y() == 1000
Пример #4
0
def test_poly_line_combine_supply():
    supply_curve = create_supply_curve()
    curves = [supply_curve, supply_curve]
    combined_curves = PolyLineFactory.combine(curves, 100)
    assert combined_curves.min_x() == 0
    assert combined_curves.max_x() == 2000
    assert combined_curves.min_y() == 0
    assert combined_curves.max_y() == 1000
Пример #5
0
def test_poly_line_combine_demand():
    demand_curve = create_demand_curve()
    curves = [demand_curve, demand_curve]
    combined_curves = PolyLineFactory.combine(curves, 100)
    assert combined_curves.min_x() == 0
    assert combined_curves.max_x() == 2000
    assert combined_curves.min_y() == 0
    assert combined_curves.max_y() == 1000
Пример #6
0
def test_poly_line_combine_supply():
    supply_curve = create_supply_curve()
    curves = [supply_curve, supply_curve]
    combined_curves = PolyLineFactory.combine(curves, 100)
    assert combined_curves.min_x() == 0
    assert combined_curves.max_x() == 2000
    assert combined_curves.min_y() == 0
    assert combined_curves.max_y() == 1000
Пример #7
0
 def match_report_aggregate(self, peer, sender, bus, topic, headers, message):
     timestamp = utils.parse_timestamp_string(message[0])
     market_name = message[1]
     buyer_seller = message[2]
     aggregate_curve_points = message[3]
     decoded_message = "Timestamp: {} Market: {} {} Curve: {}".format(timestamp, market_name, buyer_seller, aggregate_curve_points)
     self.log_event("match_report_aggregate", peer, sender, bus, topic, headers, decoded_message)
     aggregate_curve = PolyLineFactory.fromTupples(aggregate_curve_points)
     self.registrations.report_aggregate(timestamp, market_name, buyer_seller, aggregate_curve)
Пример #8
0
 def accept_offer(self, buyer_seller, identity, market_name, offer):
     _log.info("Offer on Market: {} {} made by {} was accepted.".format(market_name, buyer_seller, identity))
     participant = MarketParticipant(buyer_seller, identity)
     curve = PolyLineFactory.fromTupples(offer)
     self.market_list.make_offer(market_name, participant, curve)
Пример #9
0
 def _aggregate(self, collection):
     curve = PolyLineFactory.combine(collection, self.increment)
     return curve
Пример #10
0
 def accept_offer(self, buyer_seller, identity, market_name, offer):
     _log.info("Offer on Market: {} {} made by {} was accepted.".format(market_name, buyer_seller, identity))
     participant = MarketParticipant(buyer_seller, identity)
     curve = PolyLineFactory.fromTupples(offer)
     self.market_list.make_offer(market_name, participant, curve)
Пример #11
0
 def _aggregate(self, collection):
     curve = PolyLineFactory.combine(collection, self.increment)
     return curve
Пример #12
0
 def _aggregate(self, collection):
     #        curve = PolyLineFactory.combine(collection, self.increment)
     curve = PolyLineFactory.combine_withoutincrement(collection)
     return curve